1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef dom_base_GeneratedImageContent_h
8 #define dom_base_GeneratedImageContent_h
10 /* A content node that keeps track of an index in the parent's `content`
11 * property value, used for url() values in the content of a ::before or ::after
14 #include "mozilla/dom/HTMLElementBinding.h"
15 #include "mozilla/dom/NameSpaceConstants.h"
16 #include "mozilla/dom/NodeInfo.h"
17 #include "nsGenericHTMLElement.h"
19 namespace mozilla::dom
{
21 class GeneratedImageContent final
: public nsGenericHTMLElement
{
23 static already_AddRefed
<GeneratedImageContent
> Create(Document
&,
24 uint32_t aContentIndex
);
25 // An image created from 'list-style-image' for a ::marker pseudo.
26 static already_AddRefed
<GeneratedImageContent
> CreateForListStyleImage(
29 explicit GeneratedImageContent(already_AddRefed
<dom::NodeInfo
>&& aNodeInfo
)
30 : nsGenericHTMLElement(std::move(aNodeInfo
)) {
31 MOZ_ASSERT(IsInNamespace(kNameSpaceID_XHTML
),
32 "Someone messed up our nodeinfo");
35 ElementState
IntrinsicState() const override
{
36 ElementState state
= nsGenericHTMLElement::IntrinsicState();
38 state
|= ElementState::BROKEN
;
42 nsresult
Clone(dom::NodeInfo
* aNodeInfo
, nsINode
** aResult
) const final
;
44 nsresult
CopyInnerTo(GeneratedImageContent
* aDest
) {
45 nsresult rv
= nsGenericHTMLElement::CopyInnerTo(aDest
);
46 NS_ENSURE_SUCCESS(rv
, rv
);
47 aDest
->mIndex
= mIndex
;
51 // Is this an image created from 'list-style-image'?
52 bool IsForListStyleImageMarker() const { return Index() == uint32_t(-1); }
54 // @note we use -1 for images created from 'list-style-image'
55 uint32_t Index() const { return mIndex
; }
57 // Notify this image failed to load.
58 void NotifyLoadFailed() {
64 JSObject
* WrapNode(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) final
;
67 virtual ~GeneratedImageContent() = default;
72 } // namespace mozilla::dom
74 #endif // dom_base_GeneratedImageContent_h