michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: #include "mozilla/dom/XMLDocument.h" michael@0: #include "nsParserCIID.h" michael@0: #include "nsCharsetSource.h" michael@0: #include "nsIXMLContentSink.h" michael@0: #include "nsPresContext.h" michael@0: #include "nsIContent.h" michael@0: #include "nsIContentViewerContainer.h" michael@0: #include "nsIContentViewer.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIMarkupDocumentViewer.h" michael@0: #include "nsHTMLParts.h" michael@0: #include "nsIComponentManager.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsIBaseWindow.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsIDOMDocumentType.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsXPIDLString.h" michael@0: #include "nsIHttpChannel.h" michael@0: #include "nsIURI.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsNetUtil.h" michael@0: #include "nsError.h" michael@0: #include "nsIScriptSecurityManager.h" michael@0: #include "nsIPrincipal.h" michael@0: #include "nsLayoutCID.h" michael@0: #include "mozilla/dom/Attr.h" michael@0: #include "nsCExternalHandlerService.h" michael@0: #include "nsMimeTypes.h" michael@0: #include "mozilla/EventListenerManager.h" michael@0: #include "nsContentUtils.h" michael@0: #include "nsThreadUtils.h" michael@0: #include "nsJSUtils.h" michael@0: #include "nsCRT.h" michael@0: #include "nsIAuthPrompt.h" michael@0: #include "nsContentCreatorFunctions.h" michael@0: #include "nsContentPolicyUtils.h" michael@0: #include "nsIDOMUserDataHandler.h" michael@0: #include "nsNodeUtils.h" michael@0: #include "nsIConsoleService.h" michael@0: #include "nsIScriptError.h" michael@0: #include "nsIHTMLDocument.h" michael@0: #include "mozilla/BasicEvents.h" michael@0: #include "mozilla/EventDispatcher.h" michael@0: #include "mozilla/dom/Element.h" michael@0: #include "mozilla/dom/XMLDocumentBinding.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::dom; michael@0: michael@0: // ================================================================== michael@0: // = michael@0: // ================================================================== michael@0: michael@0: michael@0: nsresult michael@0: NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult, michael@0: const nsAString& aNamespaceURI, michael@0: const nsAString& aQualifiedName, michael@0: nsIDOMDocumentType* aDoctype, michael@0: nsIURI* aDocumentURI, michael@0: nsIURI* aBaseURI, michael@0: nsIPrincipal* aPrincipal, michael@0: bool aLoadedAsData, michael@0: nsIGlobalObject* aEventObject, michael@0: DocumentFlavor aFlavor) michael@0: { michael@0: // Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null, michael@0: // since at least one caller (XMLHttpRequest) doesn't have decent args to michael@0: // pass in. michael@0: michael@0: nsresult rv; michael@0: michael@0: *aInstancePtrResult = nullptr; michael@0: michael@0: nsCOMPtr d; michael@0: bool isHTML = false; michael@0: bool isXHTML = false; michael@0: if (aFlavor == DocumentFlavorSVG) { michael@0: rv = NS_NewSVGDocument(getter_AddRefs(d)); michael@0: } else if (aFlavor == DocumentFlavorHTML) { michael@0: rv = NS_NewHTMLDocument(getter_AddRefs(d)); michael@0: isHTML = true; michael@0: } else if (aDoctype) { michael@0: nsAutoString publicId, name; michael@0: aDoctype->GetPublicId(publicId); michael@0: if (publicId.IsEmpty()) { michael@0: aDoctype->GetName(name); michael@0: } michael@0: if (name.EqualsLiteral("html") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Frameset//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Transitional//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.0//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Frameset//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Transitional//EN")) { michael@0: rv = NS_NewHTMLDocument(getter_AddRefs(d)); michael@0: isHTML = true; michael@0: } else if (publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Strict//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Transitional//EN") || michael@0: publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Frameset//EN")) { michael@0: rv = NS_NewHTMLDocument(getter_AddRefs(d)); michael@0: isHTML = true; michael@0: isXHTML = true; michael@0: } michael@0: else if (publicId.EqualsLiteral("-//W3C//DTD SVG 1.1//EN")) { michael@0: rv = NS_NewSVGDocument(getter_AddRefs(d)); michael@0: } michael@0: // XXX Add support for XUL documents. michael@0: else { michael@0: rv = NS_NewXMLDocument(getter_AddRefs(d)); michael@0: } michael@0: } else { michael@0: rv = NS_NewXMLDocument(getter_AddRefs(d)); michael@0: } michael@0: michael@0: if (NS_FAILED(rv)) { michael@0: return rv; michael@0: } michael@0: michael@0: if (nsCOMPtr sgo = do_QueryInterface(aEventObject)) { michael@0: d->SetScriptHandlingObject(sgo); michael@0: } else if (aEventObject){ michael@0: d->SetScopeObject(aEventObject); michael@0: } michael@0: michael@0: if (isHTML) { michael@0: nsCOMPtr htmlDoc = do_QueryInterface(d); michael@0: NS_ASSERTION(htmlDoc, "HTML Document doesn't implement nsIHTMLDocument?"); michael@0: htmlDoc->SetCompatibilityMode(eCompatibility_FullStandards); michael@0: htmlDoc->SetIsXHTML(isXHTML); michael@0: } michael@0: nsDocument* doc = static_cast(d.get()); michael@0: doc->SetLoadedAsData(aLoadedAsData); michael@0: doc->nsDocument::SetDocumentURI(aDocumentURI); michael@0: // Must set the principal first, since SetBaseURI checks it. michael@0: doc->SetPrincipal(aPrincipal); michael@0: doc->SetBaseURI(aBaseURI); michael@0: michael@0: // XMLDocuments and documents "created in memory" get to be UTF-8 by default, michael@0: // unlike the legacy HTML mess michael@0: doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8")); michael@0: michael@0: if (aDoctype) { michael@0: nsCOMPtr tmpNode; michael@0: rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode)); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: } michael@0: michael@0: if (!aQualifiedName.IsEmpty()) { michael@0: nsCOMPtr root; michael@0: rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName, michael@0: getter_AddRefs(root)); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: nsCOMPtr tmpNode; michael@0: michael@0: rv = doc->AppendChild(root, getter_AddRefs(tmpNode)); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: } michael@0: michael@0: *aInstancePtrResult = doc; michael@0: NS_ADDREF(*aInstancePtrResult); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData) michael@0: { michael@0: nsRefPtr doc = new XMLDocument(); michael@0: michael@0: nsresult rv = doc->Init(); michael@0: michael@0: if (NS_FAILED(rv)) { michael@0: *aInstancePtrResult = nullptr; michael@0: return rv; michael@0: } michael@0: michael@0: doc->SetLoadedAsData(aLoadedAsData); michael@0: doc.forget(aInstancePtrResult); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult, michael@0: nsIURI* aDocumentURI, michael@0: nsIURI* aBaseURI, michael@0: nsIPrincipal* aPrincipal) michael@0: { michael@0: nsresult rv = NS_NewDOMDocument(aInstancePtrResult, michael@0: NS_LITERAL_STRING("http://www.mozilla.org/xbl"), michael@0: NS_LITERAL_STRING("bindings"), nullptr, michael@0: aDocumentURI, aBaseURI, aPrincipal, false, michael@0: nullptr, DocumentFlavorLegacyGuess); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: nsCOMPtr idoc = do_QueryInterface(*aInstancePtrResult); michael@0: nsDocument* doc = static_cast(idoc.get()); michael@0: doc->SetLoadedAsInteractiveData(true); michael@0: doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: XMLDocument::XMLDocument(const char* aContentType) michael@0: : nsDocument(aContentType), michael@0: mAsync(true) michael@0: { michael@0: // NOTE! nsDocument::operator new() zeroes out all members, so don't michael@0: // bother initializing members to 0. michael@0: } michael@0: michael@0: XMLDocument::~XMLDocument() michael@0: { michael@0: // XXX We rather crash than hang michael@0: mLoopingForSyncLoad = false; michael@0: } michael@0: michael@0: // QueryInterface implementation for XMLDocument michael@0: NS_IMPL_ISUPPORTS_INHERITED(XMLDocument, nsDocument, nsIDOMXMLDocument) michael@0: michael@0: nsresult michael@0: XMLDocument::Init() michael@0: { michael@0: nsresult rv = nsDocument::Init(); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: void michael@0: XMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) michael@0: { michael@0: nsDocument::Reset(aChannel, aLoadGroup); michael@0: } michael@0: michael@0: void michael@0: XMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, michael@0: nsIPrincipal* aPrincipal) michael@0: { michael@0: if (mChannelIsPending) { michael@0: StopDocumentLoad(); michael@0: mChannel->Cancel(NS_BINDING_ABORTED); michael@0: mChannelIsPending = false; michael@0: } michael@0: michael@0: nsDocument::ResetToURI(aURI, aLoadGroup, aPrincipal); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: XMLDocument::GetAsync(bool *aAsync) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aAsync); michael@0: *aAsync = mAsync; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: XMLDocument::SetAsync(bool aAsync) michael@0: { michael@0: mAsync = aAsync; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: XMLDocument::Load(const nsAString& aUrl, bool *aReturn) michael@0: { michael@0: ErrorResult rv; michael@0: *aReturn = Load(aUrl, rv); michael@0: return rv.ErrorCode(); michael@0: } michael@0: michael@0: bool michael@0: XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv) michael@0: { michael@0: bool hasHadScriptObject = true; michael@0: nsIScriptGlobalObject* scriptObject = michael@0: GetScriptHandlingObject(hasHadScriptObject); michael@0: if (!scriptObject && hasHadScriptObject) { michael@0: aRv.Throw(NS_ERROR_UNEXPECTED); michael@0: return false; michael@0: } michael@0: michael@0: WarnOnceAbout(nsIDocument::eUseOfDOM3LoadMethod); michael@0: michael@0: nsCOMPtr callingDoc = nsContentUtils::GetDocumentFromContext(); michael@0: michael@0: nsIURI *baseURI = mDocumentURI; michael@0: nsAutoCString charset; michael@0: michael@0: if (callingDoc) { michael@0: baseURI = callingDoc->GetDocBaseURI(); michael@0: charset = callingDoc->GetDocumentCharacterSet(); michael@0: } michael@0: michael@0: // Create a new URI michael@0: nsCOMPtr uri; michael@0: nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI); michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: // Check to see whether the current document is allowed to load this URI. michael@0: // It's important to use the current document's principal for this check so michael@0: // that we don't end up in a case where code with elevated privileges is michael@0: // calling us and changing the principal of this document. michael@0: michael@0: // Enforce same-origin even for chrome loaders to avoid someone accidentally michael@0: // using a document that content has a reference to and turn that into a michael@0: // chrome document. michael@0: nsCOMPtr principal = NodePrincipal(); michael@0: if (!nsContentUtils::IsSystemPrincipal(principal)) { michael@0: rv = principal->CheckMayLoad(uri, false, false); michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: int16_t shouldLoad = nsIContentPolicy::ACCEPT; michael@0: rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST, michael@0: uri, michael@0: principal, michael@0: callingDoc ? callingDoc.get() : michael@0: static_cast(this), michael@0: NS_LITERAL_CSTRING("application/xml"), michael@0: nullptr, michael@0: &shouldLoad, michael@0: nsContentUtils::GetContentPolicy(), michael@0: nsContentUtils::GetSecurityManager()); michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: if (NS_CP_REJECTED(shouldLoad)) { michael@0: aRv.Throw(NS_ERROR_CONTENT_BLOCKED); michael@0: return false; michael@0: } michael@0: } else { michael@0: // We're called from chrome, check to make sure the URI we're michael@0: // about to load is also chrome. michael@0: michael@0: bool isChrome = false; michael@0: if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) { michael@0: nsAutoCString spec; michael@0: if (mDocumentURI) michael@0: mDocumentURI->GetSpec(spec); michael@0: michael@0: nsAutoString error; michael@0: error.AssignLiteral("Cross site loading using document.load is no " michael@0: "longer supported. Use XMLHttpRequest instead."); michael@0: nsCOMPtr errorObject = michael@0: do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv); michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: rv = errorObject->InitWithWindowID(error, michael@0: NS_ConvertUTF8toUTF16(spec), michael@0: EmptyString(), michael@0: 0, 0, nsIScriptError::warningFlag, michael@0: "DOM", michael@0: callingDoc ? michael@0: callingDoc->InnerWindowID() : michael@0: this->InnerWindowID()); michael@0: michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: nsCOMPtr consoleService = michael@0: do_GetService(NS_CONSOLESERVICE_CONTRACTID); michael@0: if (consoleService) { michael@0: consoleService->LogMessage(errorObject); michael@0: } michael@0: michael@0: aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); michael@0: return false; michael@0: } michael@0: } michael@0: michael@0: // Partial Reset, need to restore principal for security reasons and michael@0: // event listener manager so that load listeners etc. will michael@0: // remain. This should be done before the security check is done to michael@0: // ensure that the document is reset even if the new document can't michael@0: // be loaded. Note that we need to hold a strong ref to |principal| michael@0: // here, because ResetToURI will null out our node principal before michael@0: // setting the new one. michael@0: nsRefPtr elm(mListenerManager); michael@0: mListenerManager = nullptr; michael@0: michael@0: // When we are called from JS we can find the load group for the page, michael@0: // and add ourselves to it. This way any pending requests michael@0: // will be automatically aborted if the user leaves the page. michael@0: michael@0: nsCOMPtr loadGroup; michael@0: if (callingDoc) { michael@0: loadGroup = callingDoc->GetDocumentLoadGroup(); michael@0: } michael@0: michael@0: ResetToURI(uri, loadGroup, principal); michael@0: michael@0: mListenerManager = elm; michael@0: michael@0: // Create a channel michael@0: nsCOMPtr req = nsContentUtils::GetSameOriginChecker(); michael@0: if (!req) { michael@0: aRv.Throw(NS_ERROR_OUT_OF_MEMORY); michael@0: return false; michael@0: } michael@0: michael@0: nsCOMPtr channel; michael@0: // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, michael@0: // which in turn keeps STOP button from becoming active michael@0: rv = NS_NewChannel(getter_AddRefs(channel), uri, nullptr, loadGroup, req, michael@0: nsIRequest::LOAD_BACKGROUND); michael@0: if (NS_FAILED(rv)) { michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: // StartDocumentLoad asserts that readyState is uninitialized, so michael@0: // uninitialize it. SetReadyStateInternal make this transition invisible to michael@0: // Web content. But before doing that, assert that the current readyState michael@0: // is complete as it should be after the call to ResetToURI() above. michael@0: MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE, michael@0: "Bad readyState"); michael@0: SetReadyStateInternal(nsIDocument::READYSTATE_UNINITIALIZED); michael@0: michael@0: // Prepare for loading the XML document "into oneself" michael@0: nsCOMPtr listener; michael@0: if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel, michael@0: loadGroup, nullptr, michael@0: getter_AddRefs(listener), michael@0: false))) { michael@0: NS_ERROR("XMLDocument::Load: Failed to start the document load."); michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: // After this point, if we error out of this method we should clear michael@0: // mChannelIsPending. michael@0: michael@0: // Start an asynchronous read of the XML document michael@0: rv = channel->AsyncOpen(listener, nullptr); michael@0: if (NS_FAILED(rv)) { michael@0: mChannelIsPending = false; michael@0: aRv.Throw(rv); michael@0: return false; michael@0: } michael@0: michael@0: if (!mAsync) { michael@0: nsCOMPtr thread = do_GetCurrentThread(); michael@0: michael@0: nsAutoSyncOperation sync(this); michael@0: mLoopingForSyncLoad = true; michael@0: while (mLoopingForSyncLoad) { michael@0: if (!NS_ProcessNextEvent(thread)) michael@0: break; michael@0: } michael@0: michael@0: // We set return to true unless there was a parsing error michael@0: Element* rootElement = GetRootElement(); michael@0: if (!rootElement) { michael@0: return false; michael@0: } michael@0: michael@0: if (rootElement->LocalName().EqualsLiteral("parsererror")) { michael@0: nsAutoString ns; michael@0: rootElement->GetNamespaceURI(ns); michael@0: if (ns.EqualsLiteral("http://www.mozilla.org/newlayout/xml/parsererror.xml")) { michael@0: return false; michael@0: } michael@0: } michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: nsresult michael@0: XMLDocument::StartDocumentLoad(const char* aCommand, michael@0: nsIChannel* aChannel, michael@0: nsILoadGroup* aLoadGroup, michael@0: nsISupports* aContainer, michael@0: nsIStreamListener **aDocListener, michael@0: bool aReset, michael@0: nsIContentSink* aSink) michael@0: { michael@0: nsresult rv = nsDocument::StartDocumentLoad(aCommand, michael@0: aChannel, aLoadGroup, michael@0: aContainer, michael@0: aDocListener, aReset, aSink); michael@0: if (NS_FAILED(rv)) return rv; michael@0: michael@0: if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) { michael@0: mLoadedAsInteractiveData = true; michael@0: aCommand = kLoadAsData; // XBL, for example, needs scripts and styles michael@0: } michael@0: michael@0: michael@0: int32_t charsetSource = kCharsetFromDocTypeDefault; michael@0: nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8")); michael@0: TryChannelCharset(aChannel, charsetSource, charset, nullptr); michael@0: michael@0: nsCOMPtr aUrl; michael@0: rv = aChannel->GetURI(getter_AddRefs(aUrl)); michael@0: if (NS_FAILED(rv)) return rv; michael@0: michael@0: static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); michael@0: michael@0: mParser = do_CreateInstance(kCParserCID, &rv); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: nsCOMPtr sink; michael@0: michael@0: if (aSink) { michael@0: sink = do_QueryInterface(aSink); michael@0: } michael@0: else { michael@0: nsCOMPtr docShell; michael@0: if (aContainer) { michael@0: docShell = do_QueryInterface(aContainer); michael@0: NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE); michael@0: } michael@0: rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell, michael@0: aChannel); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: } michael@0: michael@0: // Set the parser as the stream listener for the document loader... michael@0: rv = CallQueryInterface(mParser, aDocListener); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: NS_ASSERTION(mChannel, "How can we not have a channel here?"); michael@0: mChannelIsPending = true; michael@0: michael@0: SetDocumentCharacterSet(charset); michael@0: mParser->SetDocumentCharset(charset, charsetSource); michael@0: mParser->SetCommand(aCommand); michael@0: mParser->SetContentSink(sink); michael@0: mParser->Parse(aUrl, nullptr, (void *)this); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: void michael@0: XMLDocument::EndLoad() michael@0: { michael@0: mChannelIsPending = false; michael@0: mLoopingForSyncLoad = false; michael@0: michael@0: mSynchronousDOMContentLoaded = (mLoadedAsData || mLoadedAsInteractiveData); michael@0: nsDocument::EndLoad(); michael@0: if (mSynchronousDOMContentLoaded) { michael@0: mSynchronousDOMContentLoaded = false; michael@0: nsDocument::SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE); michael@0: // Generate a document load event for the case when an XML michael@0: // document was loaded as pure data without any presentation michael@0: // attached to it. michael@0: WidgetEvent event(true, NS_LOAD); michael@0: EventDispatcher::Dispatch(static_cast(this), nullptr, &event); michael@0: } michael@0: } michael@0: michael@0: /* virtual */ void michael@0: XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const michael@0: { michael@0: nsDocument::DocAddSizeOfExcludingThis(aWindowSizes); michael@0: } michael@0: michael@0: // nsIDOMDocument interface michael@0: michael@0: nsresult michael@0: XMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const michael@0: { michael@0: NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager, michael@0: "Can't import this document into another document!"); michael@0: michael@0: nsRefPtr clone = new XMLDocument(); michael@0: nsresult rv = CloneDocHelper(clone); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: // State from XMLDocument michael@0: clone->mAsync = mAsync; michael@0: michael@0: return CallQueryInterface(clone.get(), aResult); michael@0: } michael@0: michael@0: JSObject* michael@0: XMLDocument::WrapNode(JSContext *aCx) michael@0: { michael@0: return XMLDocumentBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla