GeneratedImageContent.cpp (1557B)
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/. */ 6 7 #include "mozilla/dom/GeneratedImageContent.h" 8 9 #include "mozilla/dom/Document.h" 10 #include "mozilla/dom/HTMLElementBinding.h" 11 #include "mozilla/dom/NameSpaceConstants.h" 12 #include "nsContentCreatorFunctions.h" 13 #include "nsGkAtoms.h" 14 #include "nsNodeInfoManager.h" 15 16 namespace mozilla::dom { 17 18 NS_IMPL_ELEMENT_CLONE(GeneratedImageContent); 19 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); 25 26 auto* nim = nodeInfo->NodeInfoManager(); 27 RefPtr<GeneratedImageContent> image = 28 new (nim) GeneratedImageContent(nodeInfo.forget()); 29 image->mIndex = aContentIndex; 30 return image.forget(); 31 } 32 33 already_AddRefed<GeneratedImageContent> 34 GeneratedImageContent::CreateForListStyleImage(Document& aDocument) { 35 return Create(aDocument, uint32_t(-1)); 36 } 37 38 JSObject* GeneratedImageContent::WrapNode(JSContext* aCx, 39 JS::Handle<JSObject*> aGivenProto) { 40 return dom::HTMLElement_Binding::Wrap(aCx, this, aGivenProto); 41 } 42 43 } // namespace mozilla::dom