SVGDocument.cpp (1857B)
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/SVGDocument.h" 8 9 #include "SVGElement.h" 10 #include "mozilla/StyleSheet.h" 11 #include "mozilla/StyleSheetInlines.h" 12 #include "mozilla/css/Loader.h" 13 #include "mozilla/dom/Element.h" 14 #include "nsLiteralString.h" 15 #include "nsNetUtil.h" 16 #include "nsServiceManagerUtils.h" 17 #include "nsString.h" 18 19 using namespace mozilla::css; 20 using namespace mozilla::dom; 21 22 namespace mozilla::dom { 23 24 //---------------------------------------------------------------------- 25 // Implementation 26 27 nsresult SVGDocument::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const { 28 NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager, 29 "Can't import this document into another document!"); 30 31 // TODO: Disable styling when not needed 32 RefPtr<SVGDocument> clone = new SVGDocument(LoadedAsData::AsData); 33 nsresult rv = CloneDocHelper(clone.get()); 34 NS_ENSURE_SUCCESS(rv, rv); 35 36 clone.forget(aResult); 37 return NS_OK; 38 } 39 40 } // namespace mozilla::dom 41 42 //////////////////////////////////////////////////////////////////////// 43 // Exported creation functions 44 45 nsresult NS_NewSVGDocument(Document** aInstancePtrResult, 46 nsIPrincipal* aPrincipal, 47 nsIPrincipal* aPartitionedPrincipal, 48 mozilla::dom::LoadedAsData aLoadedAsData) { 49 RefPtr<SVGDocument> doc = new SVGDocument(aLoadedAsData); 50 51 nsresult rv = doc->Init(aPrincipal, aPartitionedPrincipal); 52 if (NS_FAILED(rv)) { 53 return rv; 54 } 55 56 doc.forget(aInstancePtrResult); 57 return rv; 58 }