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 #include "mozilla/dom/GeneratedImageContent.h"
9 #include "nsContentCreatorFunctions.h"
10 #include "nsGkAtoms.h"
11 #include "mozilla/dom/Document.h"
12 #include "nsNodeInfoManager.h"
13 #include "mozilla/dom/HTMLElementBinding.h"
14 #include "mozilla/dom/NameSpaceConstants.h"
16 namespace mozilla::dom
{
18 NS_IMPL_ELEMENT_CLONE(GeneratedImageContent
);
20 already_AddRefed
<GeneratedImageContent
> GeneratedImageContent::Create(
21 Document
& aDocument
, uint32_t aContentIndex
) {
22 RefPtr
<dom::NodeInfo
> nodeInfo
= aDocument
.NodeInfoManager()->GetNodeInfo(
23 nsGkAtoms::mozgeneratedcontentimage
, nullptr, kNameSpaceID_XHTML
,
24 nsINode::ELEMENT_NODE
);
26 auto* nim
= nodeInfo
->NodeInfoManager();
27 RefPtr
<GeneratedImageContent
> image
=
28 new (nim
) GeneratedImageContent(nodeInfo
.forget());
29 image
->mIndex
= aContentIndex
;
30 return image
.forget();
33 already_AddRefed
<GeneratedImageContent
>
34 GeneratedImageContent::CreateForListStyleImage(Document
& aDocument
) {
35 return Create(aDocument
, uint32_t(-1));
38 JSObject
* GeneratedImageContent::WrapNode(JSContext
* aCx
,
39 JS::Handle
<JSObject
*> aGivenProto
) {
40 return dom::HTMLElement_Binding::Wrap(aCx
, this, aGivenProto
);
43 } // namespace mozilla::dom