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 nsresult
Clone(dom::NodeInfo
* aNodeInfo
, nsINode
** aResult
) const final
;
37 nsresult
CopyInnerTo(GeneratedImageContent
* aDest
) {
38 nsresult rv
= nsGenericHTMLElement::CopyInnerTo(aDest
);
39 NS_ENSURE_SUCCESS(rv
, rv
);
40 aDest
->mIndex
= mIndex
;
44 // Is this an image created from 'list-style-image'?
45 bool IsForListStyleImageMarker() const { return Index() == uint32_t(-1); }
47 // @note we use -1 for images created from 'list-style-image'
48 uint32_t Index() const { return mIndex
; }
50 // Notify this image failed to load.
51 void NotifyLoadFailed() { SetStates(ElementState::BROKEN
, true); }
54 JSObject
* WrapNode(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) final
;
57 virtual ~GeneratedImageContent() = default;
61 } // namespace mozilla::dom
63 #endif // dom_base_GeneratedImageContent_h