2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-11-12 01:06:16 +03:00
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
#include "mozilla/dom/XMLDocument.h"
|
1998-11-12 01:06:16 +03:00
|
|
|
#include "nsParserCIID.h"
|
2012-03-22 18:42:42 +04:00
|
|
|
#include "nsCharsetSource.h"
|
1998-11-12 01:06:16 +03:00
|
|
|
#include "nsIXMLContentSink.h"
|
2017-02-14 18:11:00 +03:00
|
|
|
#include "nsPresContext.h"
|
2000-06-17 05:46:58 +04:00
|
|
|
#include "nsIContent.h"
|
2000-03-11 03:28:44 +03:00
|
|
|
#include "nsIDocShell.h"
|
1998-11-12 01:06:16 +03:00
|
|
|
#include "nsHTMLParts.h"
|
1999-07-16 15:14:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2017-08-17 08:29:03 +03:00
|
|
|
#include "nsString.h"
|
2001-05-01 03:35:09 +04:00
|
|
|
#include "nsIURI.h"
|
2000-05-01 10:58:53 +04:00
|
|
|
#include "nsNetUtil.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2000-09-21 03:38:28 +04:00
|
|
|
#include "nsIPrincipal.h"
|
2001-02-19 15:55:42 +03:00
|
|
|
#include "nsLayoutCID.h"
|
2013-04-09 19:29:44 +04:00
|
|
|
#include "mozilla/dom/Attr.h"
|
2001-02-21 23:38:08 +03:00
|
|
|
#include "nsCExternalHandlerService.h"
|
|
|
|
#include "nsMimeTypes.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#include "nsContentUtils.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2004-04-13 07:21:50 +04:00
|
|
|
#include "nsJSUtils.h"
|
2002-05-15 22:55:21 +04:00
|
|
|
#include "nsCRT.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2010-03-02 22:40:14 +03:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2008-04-09 04:38:12 +04:00
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include "nsIScriptError.h"
|
2019-06-04 20:27:41 +03:00
|
|
|
#include "nsHTMLDocument.h"
|
2013-09-25 15:21:22 +04:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2019-03-30 23:18:33 +03:00
|
|
|
#include "mozilla/Encoding.h"
|
2018-03-13 23:24:01 +03:00
|
|
|
#include "mozilla/dom/DocumentType.h"
|
2013-06-26 18:59:45 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2020-03-17 17:52:37 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
2013-03-26 19:31:54 +04:00
|
|
|
#include "mozilla/dom/XMLDocumentBinding.h"
|
2014-06-03 19:38:37 +04:00
|
|
|
#include "mozilla/dom/DocumentBinding.h"
|
1999-01-20 02:07:33 +03:00
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
1999-01-20 02:07:33 +03:00
|
|
|
// ==================================================================
|
|
|
|
// =
|
|
|
|
// ==================================================================
|
1998-11-12 01:06:16 +03:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult NS_NewDOMDocument(Document** aInstancePtrResult,
|
2017-02-14 18:11:00 +03:00
|
|
|
const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
2018-03-13 23:24:01 +03:00
|
|
|
DocumentType* aDoctype, nsIURI* aDocumentURI,
|
2007-10-01 14:02:32 +04:00
|
|
|
nsIURI* aBaseURI, nsIPrincipal* aPrincipal,
|
2013-04-04 13:32:29 +04:00
|
|
|
bool aLoadedAsData, nsIGlobalObject* aEventObject,
|
2018-02-25 19:28:14 +03:00
|
|
|
DocumentFlavor aFlavor) {
|
2006-02-20 21:57:32 +03:00
|
|
|
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
|
|
|
|
// since at least one caller (XMLHttpRequest) doesn't have decent args to
|
|
|
|
// pass in.
|
2017-02-14 18:11:00 +03:00
|
|
|
|
2000-06-17 05:46:58 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aInstancePtrResult = nullptr;
|
2000-06-21 04:53:26 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> d;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHTML = false;
|
|
|
|
bool isXHTML = false;
|
2011-11-16 11:38:51 +04:00
|
|
|
if (aFlavor == DocumentFlavorSVG) {
|
2011-10-13 14:50:05 +04:00
|
|
|
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
2011-11-16 11:38:51 +04:00
|
|
|
} else if (aFlavor == DocumentFlavorHTML) {
|
|
|
|
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
|
|
|
isHTML = true;
|
2020-01-16 18:41:18 +03:00
|
|
|
} else if (aFlavor == DocumentFlavorXML) {
|
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
2014-06-03 19:38:37 +04:00
|
|
|
} else if (aFlavor == DocumentFlavorPlain) {
|
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aLoadedAsData, true);
|
2011-10-13 14:50:05 +04:00
|
|
|
} else if (aDoctype) {
|
2014-06-03 19:38:37 +04:00
|
|
|
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
2010-09-21 13:17:18 +04:00
|
|
|
nsAutoString publicId, name;
|
2008-09-20 22:55:04 +04:00
|
|
|
aDoctype->GetPublicId(publicId);
|
2010-09-21 13:17:18 +04:00
|
|
|
if (publicId.IsEmpty()) {
|
|
|
|
aDoctype->GetName(name);
|
|
|
|
}
|
|
|
|
if (name.EqualsLiteral("html") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") ||
|
2008-09-20 22:55:04 +04:00
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Frameset//EN") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Transitional//EN") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0//EN") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Frameset//EN") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Transitional//EN")) {
|
|
|
|
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
2011-10-17 18:59:28 +04:00
|
|
|
isHTML = true;
|
2008-09-20 22:55:04 +04:00
|
|
|
} else if (publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Strict//EN") ||
|
|
|
|
publicId.EqualsLiteral(
|
|
|
|
"-//W3C//DTD XHTML 1.0 Transitional//EN") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Frameset//EN")) {
|
|
|
|
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
2011-10-17 18:59:28 +04:00
|
|
|
isHTML = true;
|
|
|
|
isXHTML = true;
|
2008-09-20 22:55:04 +04:00
|
|
|
} else if (publicId.EqualsLiteral("-//W3C//DTD SVG 1.1//EN")) {
|
|
|
|
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
|
|
|
}
|
|
|
|
// XXX Add support for XUL documents.
|
|
|
|
else {
|
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-03 19:38:37 +04:00
|
|
|
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
2008-09-20 22:55:04 +04:00
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
|
|
|
}
|
2002-01-25 09:37:35 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-09-20 22:55:04 +04:00
|
|
|
if (isHTML) {
|
2019-05-28 02:03:03 +03:00
|
|
|
d->SetCompatibilityMode(eCompatibility_FullStandards);
|
2019-06-04 20:27:41 +03:00
|
|
|
d->AsHTMLDocument()->SetIsXHTML(isXHTML);
|
2008-09-20 22:55:04 +04:00
|
|
|
}
|
2018-12-31 17:10:19 +03:00
|
|
|
d->SetLoadedAsData(aLoadedAsData);
|
|
|
|
d->SetDocumentURI(aDocumentURI);
|
2006-02-20 21:57:32 +03:00
|
|
|
// Must set the principal first, since SetBaseURI checks it.
|
2019-04-12 08:31:32 +03:00
|
|
|
d->SetPrincipals(aPrincipal, aPrincipal);
|
2018-12-31 17:10:19 +03:00
|
|
|
d->SetBaseURI(aBaseURI);
|
2000-06-17 05:46:58 +04:00
|
|
|
|
2016-10-07 21:59:59 +03:00
|
|
|
// We need to set the script handling object after we set the principal such
|
|
|
|
// that the doc group is assigned correctly.
|
|
|
|
if (nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aEventObject)) {
|
|
|
|
d->SetScriptHandlingObject(sgo);
|
|
|
|
} else if (aEventObject) {
|
|
|
|
d->SetScopeObject(aEventObject);
|
|
|
|
}
|
|
|
|
|
2008-09-20 22:55:04 +04:00
|
|
|
// XMLDocuments and documents "created in memory" get to be UTF-8 by default,
|
|
|
|
// unlike the legacy HTML mess
|
2018-12-31 17:10:19 +03:00
|
|
|
d->SetDocumentCharacterSet(UTF_8_ENCODING);
|
2017-02-14 18:11:00 +03:00
|
|
|
|
2000-06-17 05:46:58 +04:00
|
|
|
if (aDoctype) {
|
2016-11-19 00:38:29 +03:00
|
|
|
ErrorResult result;
|
2018-03-13 23:24:01 +03:00
|
|
|
d->AppendChild(*aDoctype, result);
|
2017-09-13 20:34:55 +03:00
|
|
|
// Need to WouldReportJSException() if our callee can throw a JS
|
|
|
|
// exception (which it can) and we're neither propagating the
|
|
|
|
// error out nor unconditionally suppressing it.
|
|
|
|
result.WouldReportJSException();
|
2016-11-19 00:38:29 +03:00
|
|
|
if (NS_WARN_IF(result.Failed())) {
|
|
|
|
return result.StealNSResult();
|
|
|
|
}
|
2000-06-17 05:46:58 +04:00
|
|
|
}
|
2017-02-14 18:11:00 +03:00
|
|
|
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aQualifiedName.IsEmpty()) {
|
2016-11-19 00:38:29 +03:00
|
|
|
ErrorResult result;
|
2017-02-14 19:07:00 +03:00
|
|
|
ElementCreationOptionsOrString options;
|
|
|
|
options.SetAsString();
|
|
|
|
|
2016-11-19 00:38:29 +03:00
|
|
|
nsCOMPtr<Element> root =
|
2018-12-31 17:10:19 +03:00
|
|
|
d->CreateElementNS(aNamespaceURI, aQualifiedName, options, result);
|
2016-11-19 00:38:29 +03:00
|
|
|
if (NS_WARN_IF(result.Failed())) {
|
|
|
|
return result.StealNSResult();
|
|
|
|
}
|
2001-01-23 10:42:20 +03:00
|
|
|
|
2016-11-19 00:38:29 +03:00
|
|
|
d->AppendChild(*root, result);
|
2017-09-13 20:34:55 +03:00
|
|
|
// Need to WouldReportJSException() if our callee can throw a JS
|
|
|
|
// exception (which it can) and we're neither propagating the
|
|
|
|
// error out nor unconditionally suppressing it.
|
|
|
|
result.WouldReportJSException();
|
2016-11-19 00:38:29 +03:00
|
|
|
if (NS_WARN_IF(result.Failed())) {
|
|
|
|
return result.StealNSResult();
|
|
|
|
}
|
2000-06-17 05:46:58 +04:00
|
|
|
}
|
|
|
|
|
2018-05-11 20:46:15 +03:00
|
|
|
d.forget(aInstancePtrResult);
|
2001-01-23 10:42:20 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-01 10:58:53 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult NS_NewXMLDocument(Document** aInstancePtrResult, bool aLoadedAsData,
|
2014-06-03 19:38:37 +04:00
|
|
|
bool aIsPlainDocument) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<XMLDocument> doc = new XMLDocument();
|
2002-01-25 09:37:35 +03:00
|
|
|
|
|
|
|
nsresult rv = doc->Init();
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2013-07-27 13:12:38 +04:00
|
|
|
*aInstancePtrResult = nullptr;
|
|
|
|
return rv;
|
2002-01-25 09:37:35 +03:00
|
|
|
}
|
|
|
|
|
2012-11-21 20:18:57 +04:00
|
|
|
doc->SetLoadedAsData(aLoadedAsData);
|
2014-06-03 19:38:37 +04:00
|
|
|
doc->mIsPlainDocument = aIsPlainDocument;
|
2013-07-27 13:12:38 +04:00
|
|
|
doc.forget(aInstancePtrResult);
|
2002-01-25 09:37:35 +03:00
|
|
|
|
2013-07-27 13:12:38 +04:00
|
|
|
return NS_OK;
|
1998-11-12 01:06:16 +03:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
XMLDocument::XMLDocument(const char* aContentType)
|
2019-01-02 16:05:23 +03:00
|
|
|
: Document(aContentType),
|
2017-01-24 19:10:39 +03:00
|
|
|
mChannelIsPending(false),
|
|
|
|
mIsPlainDocument(false),
|
|
|
|
mSuppressParserErrorElement(false),
|
|
|
|
mSuppressParserErrorConsoleMessages(false) {
|
2014-05-24 23:28:48 +04:00
|
|
|
mType = eGenericXML;
|
1998-11-12 01:06:16 +03:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
nsresult XMLDocument::Init() {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult rv = Document::Init();
|
2003-03-26 10:41:30 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
void XMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document::Reset(aChannel, aLoadGroup);
|
1999-01-06 03:32:41 +03:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
void XMLDocument::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
|
2019-04-12 08:31:32 +03:00
|
|
|
nsIPrincipal* aPrincipal,
|
|
|
|
nsIPrincipal* aStoragePrincipal) {
|
2005-06-01 05:15:23 +04:00
|
|
|
if (mChannelIsPending) {
|
2005-04-28 20:57:24 +04:00
|
|
|
StopDocumentLoad();
|
2005-06-01 05:15:23 +04:00
|
|
|
mChannel->Cancel(NS_BINDING_ABORTED);
|
2012-09-11 22:00:37 +04:00
|
|
|
mChannelIsPending = false;
|
2005-04-28 20:57:24 +04:00
|
|
|
}
|
2008-01-26 00:49:11 +03:00
|
|
|
|
2019-04-12 08:31:32 +03:00
|
|
|
Document::ResetToURI(aURI, aLoadGroup, aPrincipal, aStoragePrincipal);
|
2005-04-28 20:57:24 +04:00
|
|
|
}
|
|
|
|
|
2016-08-29 23:30:36 +03:00
|
|
|
void XMLDocument::SetSuppressParserErrorElement(bool aSuppress) {
|
|
|
|
mSuppressParserErrorElement = aSuppress;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XMLDocument::SuppressParserErrorElement() {
|
|
|
|
return mSuppressParserErrorElement;
|
|
|
|
}
|
|
|
|
|
2016-09-21 20:48:05 +03:00
|
|
|
void XMLDocument::SetSuppressParserErrorConsoleMessages(bool aSuppress) {
|
|
|
|
mSuppressParserErrorConsoleMessages = aSuppress;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XMLDocument::SuppressParserErrorConsoleMessages() {
|
|
|
|
return mSuppressParserErrorConsoleMessages;
|
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
nsresult XMLDocument::StartDocumentLoad(const char* aCommand,
|
|
|
|
nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener** aDocListener,
|
|
|
|
bool aReset, nsIContentSink* aSink) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult rv = Document::StartDocumentLoad(
|
2001-11-02 04:53:13 +03:00
|
|
|
aCommand, aChannel, aLoadGroup, aContainer, aDocListener, aReset, aSink);
|
2001-05-15 07:42:33 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-01-06 03:32:41 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t charsetSource = kCharsetFromDocTypeDefault;
|
2017-06-18 14:37:50 +03:00
|
|
|
NotNull<const Encoding*> encoding = UTF_8_ENCODING;
|
|
|
|
TryChannelCharset(aChannel, charsetSource, encoding, nullptr);
|
1998-11-12 01:06:16 +03:00
|
|
|
|
1999-07-16 15:14:36 +04:00
|
|
|
nsCOMPtr<nsIURI> aUrl;
|
|
|
|
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-04 02:48:20 +04:00
|
|
|
|
2001-03-11 00:02:12 +03:00
|
|
|
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
1998-11-12 01:06:16 +03:00
|
|
|
|
2005-04-28 20:57:24 +04:00
|
|
|
mParser = do_CreateInstance(kCParserCID, &rv);
|
2003-01-15 01:32:18 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-05-15 07:42:33 +04:00
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
nsCOMPtr<nsIXMLContentSink> sink;
|
2017-02-14 18:11:00 +03:00
|
|
|
|
2003-01-15 01:32:18 +03:00
|
|
|
if (aSink) {
|
|
|
|
sink = do_QueryInterface(aSink);
|
2001-11-02 04:53:13 +03:00
|
|
|
} else {
|
2003-04-03 22:57:33 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
2003-01-15 01:32:18 +03:00
|
|
|
if (aContainer) {
|
2003-04-03 22:57:33 +04:00
|
|
|
docShell = do_QueryInterface(aContainer);
|
|
|
|
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
2003-01-15 01:32:18 +03:00
|
|
|
}
|
2003-04-03 22:57:33 +04:00
|
|
|
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell,
|
2003-01-15 01:32:18 +03:00
|
|
|
aChannel);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-11-02 04:53:13 +03:00
|
|
|
}
|
|
|
|
|
2003-01-15 01:32:18 +03:00
|
|
|
// Set the parser as the stream listener for the document loader...
|
2005-04-28 20:57:24 +04:00
|
|
|
rv = CallQueryInterface(mParser, aDocListener);
|
2003-01-15 01:32:18 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-05-15 07:42:33 +04:00
|
|
|
|
2005-06-01 05:15:23 +04:00
|
|
|
NS_ASSERTION(mChannel, "How can we not have a channel here?");
|
2011-10-17 18:59:28 +04:00
|
|
|
mChannelIsPending = true;
|
2017-02-14 18:11:00 +03:00
|
|
|
|
2017-06-18 14:37:50 +03:00
|
|
|
SetDocumentCharacterSet(encoding);
|
|
|
|
mParser->SetDocumentCharset(encoding, charsetSource);
|
2005-04-28 20:57:24 +04:00
|
|
|
mParser->SetCommand(aCommand);
|
|
|
|
mParser->SetContentSink(sink);
|
2012-07-30 18:20:58 +04:00
|
|
|
mParser->Parse(aUrl, nullptr, (void*)this);
|
1998-11-12 01:06:16 +03:00
|
|
|
|
2003-01-15 01:32:18 +03:00
|
|
|
return NS_OK;
|
1998-11-12 01:06:16 +03:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
void XMLDocument::EndLoad() {
|
2011-10-17 18:59:28 +04:00
|
|
|
mChannelIsPending = false;
|
2003-03-21 22:22:52 +03:00
|
|
|
|
2020-02-24 20:46:04 +03:00
|
|
|
mSynchronousDOMContentLoaded = mLoadedAsData;
|
2019-01-02 16:05:23 +03:00
|
|
|
Document::EndLoad();
|
2009-01-26 12:53:20 +03:00
|
|
|
if (mSynchronousDOMContentLoaded) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mSynchronousDOMContentLoaded = false;
|
2019-01-02 16:05:23 +03:00
|
|
|
Document::SetReadyStateInternal(Document::READYSTATE_COMPLETE);
|
2005-04-29 03:48:28 +04:00
|
|
|
// Generate a document load event for the case when an XML
|
|
|
|
// document was loaded as pure data without any presentation
|
|
|
|
// attached to it.
|
2015-09-02 09:07:59 +03:00
|
|
|
WidgetEvent event(true, eLoad);
|
2018-12-26 05:32:55 +03:00
|
|
|
EventDispatcher::Dispatch(ToSupports(this), nullptr, &event);
|
2013-10-01 03:20:23 +04:00
|
|
|
}
|
1998-11-12 01:06:16 +03:00
|
|
|
}
|
2013-10-01 03:20:23 +04:00
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* virtual */
|
|
|
|
void XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document::DocAddSizeOfExcludingThis(aWindowSizes);
|
2012-02-02 01:58:01 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
// Document interface
|
2004-03-03 01:39:46 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult XMLDocument::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const {
|
2006-09-05 14:22:54 +04:00
|
|
|
NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
|
|
|
|
"Can't import this document into another document!");
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<XMLDocument> clone = new XMLDocument();
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult rv = CloneDocHelper(clone);
|
2006-09-05 14:22:54 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
// State from XMLDocument
|
2014-06-03 19:38:37 +04:00
|
|
|
clone->mIsPlainDocument = mIsPlainDocument;
|
2008-09-18 15:15:47 +04:00
|
|
|
|
2018-09-27 17:59:55 +03:00
|
|
|
clone.forget(aResult);
|
|
|
|
return NS_OK;
|
2006-09-05 14:22:54 +04:00
|
|
|
}
|
2013-03-20 20:22:26 +04:00
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* XMLDocument::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2014-06-03 19:38:37 +04:00
|
|
|
if (mIsPlainDocument) {
|
2018-11-29 02:24:53 +03:00
|
|
|
return Document_Binding::Wrap(aCx, this, aGivenProto);
|
2018-09-25 20:35:07 +03:00
|
|
|
}
|
2018-11-29 02:24:53 +03:00
|
|
|
|
|
|
|
return XMLDocument_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-26 19:31:54 +04:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|