2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-11 22:06:16 +00:00
|
|
|
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
#include "mozilla/dom/XMLDocument.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsParserCIID.h"
|
2012-03-22 14:42:42 +00:00
|
|
|
#include "nsCharsetSource.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIXMLContentSink.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2000-06-17 01:46:58 +00:00
|
|
|
#include "nsIContent.h"
|
1999-11-19 07:35:27 +00:00
|
|
|
#include "nsIContentViewerContainer.h"
|
|
|
|
#include "nsIContentViewer.h"
|
2000-03-11 00:28:44 +00:00
|
|
|
#include "nsIDocShell.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsHTMLParts.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-11-11 22:06:16 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2001-02-03 01:16:20 +00:00
|
|
|
#include "nsIBaseWindow.h"
|
2003-04-02 21:44:39 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2000-06-17 01:46:58 +00:00
|
|
|
#include "nsIDOMDocumentType.h"
|
1999-07-16 11:14:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-09-03 22:48:20 +00:00
|
|
|
#include "nsXPIDLString.h"
|
2001-05-11 21:05:08 +00:00
|
|
|
#include "nsIHttpChannel.h"
|
2001-04-30 23:35:09 +00:00
|
|
|
#include "nsIURI.h"
|
1999-09-03 22:48:20 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2000-05-01 06:58:53 +00:00
|
|
|
#include "nsNetUtil.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2003-10-21 22:11:49 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2000-09-20 23:38:28 +00:00
|
|
|
#include "nsIPrincipal.h"
|
2001-02-19 12:55:42 +00:00
|
|
|
#include "nsLayoutCID.h"
|
2013-04-09 15:29:44 +00:00
|
|
|
#include "mozilla/dom/Attr.h"
|
2001-02-21 20:38:08 +00:00
|
|
|
#include "nsCExternalHandlerService.h"
|
|
|
|
#include "nsMimeTypes.h"
|
2014-03-17 06:56:53 +00:00
|
|
|
#include "mozilla/EventListenerManager.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 16:46:42 +00:00
|
|
|
#include "nsContentUtils.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2004-04-13 03:21:50 +00:00
|
|
|
#include "nsJSUtils.h"
|
2002-05-15 18:55:21 +00:00
|
|
|
#include "nsCRT.h"
|
2002-06-14 23:54:18 +00:00
|
|
|
#include "nsIAuthPrompt.h"
|
2004-06-25 12:26:02 +00:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2010-03-02 19:40:14 +00:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2006-09-05 10:22:54 +00:00
|
|
|
#include "nsNodeUtils.h"
|
2008-04-09 00:38:12 +00:00
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include "nsIScriptError.h"
|
2008-09-20 18:55:04 +00:00
|
|
|
#include "nsIHTMLDocument.h"
|
2013-09-25 11:21:22 +00:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2014-03-18 04:48:21 +00:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2013-06-26 14:59:45 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-03-26 15:31:54 +00:00
|
|
|
#include "mozilla/dom/XMLDocumentBinding.h"
|
2014-06-03 15:38:37 +00:00
|
|
|
#include "mozilla/dom/DocumentBinding.h"
|
1999-01-19 23:07:33 +00:00
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
1999-01-19 23:07:33 +00:00
|
|
|
// ==================================================================
|
|
|
|
// =
|
|
|
|
// ==================================================================
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2000-02-23 01:48:22 +00:00
|
|
|
|
2003-03-05 15:08:41 +00:00
|
|
|
nsresult
|
2000-05-01 06:58:53 +00:00
|
|
|
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
2002-03-23 22:46:13 +00:00
|
|
|
const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
2000-05-01 06:58:53 +00:00
|
|
|
nsIDOMDocumentType* aDoctype,
|
2006-02-20 18:57:32 +00:00
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
nsIURI* aBaseURI,
|
2007-10-01 10:02:32 +00:00
|
|
|
nsIPrincipal* aPrincipal,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aLoadedAsData,
|
2013-04-04 09:32:29 +00:00
|
|
|
nsIGlobalObject* aEventObject,
|
2011-11-16 07:38:51 +00:00
|
|
|
DocumentFlavor aFlavor)
|
2000-05-01 06:58:53 +00:00
|
|
|
{
|
2006-02-20 18:57:32 +00: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.
|
|
|
|
|
2000-06-17 01:46:58 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aInstancePtrResult = nullptr;
|
2000-06-21 00:53:26 +00:00
|
|
|
|
2008-09-20 18:55:04 +00:00
|
|
|
nsCOMPtr<nsIDocument> d;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHTML = false;
|
|
|
|
bool isXHTML = false;
|
2011-11-16 07:38:51 +00:00
|
|
|
if (aFlavor == DocumentFlavorSVG) {
|
2011-10-13 10:50:05 +00:00
|
|
|
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
2011-11-16 07:38:51 +00:00
|
|
|
} else if (aFlavor == DocumentFlavorHTML) {
|
|
|
|
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
|
|
|
isHTML = true;
|
2014-06-03 15:38:37 +00:00
|
|
|
} else if (aFlavor == DocumentFlavorPlain) {
|
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d), aLoadedAsData, true);
|
2011-10-13 10:50:05 +00:00
|
|
|
} else if (aDoctype) {
|
2014-06-03 15:38:37 +00:00
|
|
|
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
2010-09-21 09:17:18 +00:00
|
|
|
nsAutoString publicId, name;
|
2008-09-20 18:55:04 +00:00
|
|
|
aDoctype->GetPublicId(publicId);
|
2010-09-21 09:17:18 +00:00
|
|
|
if (publicId.IsEmpty()) {
|
|
|
|
aDoctype->GetName(name);
|
|
|
|
}
|
|
|
|
if (name.EqualsLiteral("html") ||
|
|
|
|
publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") ||
|
2008-09-20 18:55:04 +00: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 14:59:28 +00:00
|
|
|
isHTML = true;
|
2008-09-20 18:55:04 +00: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 14:59:28 +00:00
|
|
|
isHTML = true;
|
|
|
|
isXHTML = true;
|
2008-09-20 18:55:04 +00: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 15:38:37 +00:00
|
|
|
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
2008-09-20 18:55:04 +00:00
|
|
|
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
|
|
|
}
|
2002-01-25 06:37:35 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-04-04 09:32:29 +00:00
|
|
|
if (nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aEventObject)) {
|
|
|
|
d->SetScriptHandlingObject(sgo);
|
|
|
|
} else if (aEventObject){
|
|
|
|
d->SetScopeObject(aEventObject);
|
|
|
|
}
|
|
|
|
|
2008-09-20 18:55:04 +00:00
|
|
|
if (isHTML) {
|
|
|
|
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(d);
|
|
|
|
NS_ASSERTION(htmlDoc, "HTML Document doesn't implement nsIHTMLDocument?");
|
|
|
|
htmlDoc->SetCompatibilityMode(eCompatibility_FullStandards);
|
|
|
|
htmlDoc->SetIsXHTML(isXHTML);
|
|
|
|
}
|
|
|
|
nsDocument* doc = static_cast<nsDocument*>(d.get());
|
2007-10-01 10:02:32 +00:00
|
|
|
doc->SetLoadedAsData(aLoadedAsData);
|
2006-05-31 17:57:14 +00:00
|
|
|
doc->nsDocument::SetDocumentURI(aDocumentURI);
|
2006-02-20 18:57:32 +00:00
|
|
|
// Must set the principal first, since SetBaseURI checks it.
|
|
|
|
doc->SetPrincipal(aPrincipal);
|
2004-01-09 23:54:21 +00:00
|
|
|
doc->SetBaseURI(aBaseURI);
|
2000-06-17 01:46:58 +00:00
|
|
|
|
2008-09-20 18:55:04 +00:00
|
|
|
// XMLDocuments and documents "created in memory" get to be UTF-8 by default,
|
|
|
|
// unlike the legacy HTML mess
|
2008-08-28 12:56:45 +00:00
|
|
|
doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
|
|
|
|
|
2000-06-17 01:46:58 +00:00
|
|
|
if (aDoctype) {
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
2001-01-23 07:42:20 +00:00
|
|
|
rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-06-17 01:46:58 +00:00
|
|
|
}
|
|
|
|
|
2002-01-24 02:03:19 +00:00
|
|
|
if (!aQualifiedName.IsEmpty()) {
|
2000-06-17 01:46:58 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> root;
|
2001-01-23 07:42:20 +00:00
|
|
|
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName,
|
|
|
|
getter_AddRefs(root));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
|
|
|
|
|
|
|
rv = doc->AppendChild(root, getter_AddRefs(tmpNode));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-06-17 01:46:58 +00:00
|
|
|
}
|
|
|
|
|
2001-01-23 07:42:20 +00:00
|
|
|
*aInstancePtrResult = doc;
|
|
|
|
NS_ADDREF(*aInstancePtrResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-01 06:58:53 +00:00
|
|
|
}
|
|
|
|
|
2003-03-05 15:08:41 +00:00
|
|
|
nsresult
|
2014-06-03 15:38:37 +00:00
|
|
|
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
|
|
|
|
bool aIsPlainDocument)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2013-07-27 09:12:38 +00:00
|
|
|
nsRefPtr<XMLDocument> doc = new XMLDocument();
|
2002-01-25 06:37:35 +00:00
|
|
|
|
|
|
|
nsresult rv = doc->Init();
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2013-07-27 09:12:38 +00:00
|
|
|
*aInstancePtrResult = nullptr;
|
|
|
|
return rv;
|
2002-01-25 06:37:35 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 16:18:57 +00:00
|
|
|
doc->SetLoadedAsData(aLoadedAsData);
|
2014-06-03 15:38:37 +00:00
|
|
|
doc->mIsPlainDocument = aIsPlainDocument;
|
2013-07-27 09:12:38 +00:00
|
|
|
doc.forget(aInstancePtrResult);
|
2002-01-25 06:37:35 +00:00
|
|
|
|
2013-07-27 09:12:38 +00:00
|
|
|
return NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2011-11-03 20:39:08 +00:00
|
|
|
nsresult
|
|
|
|
NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
nsIURI* aBaseURI,
|
|
|
|
nsIPrincipal* aPrincipal)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_NewDOMDocument(aInstancePtrResult,
|
|
|
|
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_LITERAL_STRING("bindings"), nullptr,
|
2011-11-03 20:39:08 +00:00
|
|
|
aDocumentURI, aBaseURI, aPrincipal, false,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, DocumentFlavorLegacyGuess);
|
2011-11-03 20:39:08 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);
|
|
|
|
nsDocument* doc = static_cast<nsDocument*>(idoc.get());
|
|
|
|
doc->SetLoadedAsInteractiveData(true);
|
|
|
|
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
XMLDocument::XMLDocument(const char* aContentType)
|
2006-04-21 01:24:44 +00:00
|
|
|
: nsDocument(aContentType),
|
2011-10-17 14:59:28 +00:00
|
|
|
mAsync(true)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2003-03-26 07:41:30 +00:00
|
|
|
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
|
|
|
// bother initializing members to 0.
|
2014-05-24 19:28:48 +00:00
|
|
|
|
|
|
|
mType = eGenericXML;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::~XMLDocument()
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2003-03-21 19:22:52 +00:00
|
|
|
// XXX We rather crash than hang
|
2011-10-17 14:59:28 +00:00
|
|
|
mLoopingForSyncLoad = false;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
// QueryInterface implementation for XMLDocument
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(XMLDocument, nsDocument, nsIDOMXMLDocument)
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2003-03-26 07:41:30 +00:00
|
|
|
nsresult
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::Init()
|
2003-03-26 07:41:30 +00:00
|
|
|
{
|
|
|
|
nsresult rv = nsDocument::Init();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-10-22 06:09:48 +00:00
|
|
|
void
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2003-10-22 06:09:48 +00:00
|
|
|
nsDocument::Reset(aChannel, aLoadGroup);
|
1999-01-06 00:32:41 +00:00
|
|
|
}
|
|
|
|
|
2005-04-28 16:57:24 +00:00
|
|
|
void
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|
|
|
nsIPrincipal* aPrincipal)
|
2005-04-28 16:57:24 +00:00
|
|
|
{
|
2005-06-01 01:15:23 +00:00
|
|
|
if (mChannelIsPending) {
|
2005-04-28 16:57:24 +00:00
|
|
|
StopDocumentLoad();
|
2005-06-01 01:15:23 +00:00
|
|
|
mChannel->Cancel(NS_BINDING_ABORTED);
|
2012-09-11 18:00:37 +00:00
|
|
|
mChannelIsPending = false;
|
2005-04-28 16:57:24 +00:00
|
|
|
}
|
2008-01-25 21:49:11 +00:00
|
|
|
|
2006-11-22 18:27:54 +00:00
|
|
|
nsDocument::ResetToURI(aURI, aLoadGroup, aPrincipal);
|
2005-04-28 16:57:24 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 19:22:52 +00:00
|
|
|
NS_IMETHODIMP
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::GetAsync(bool *aAsync)
|
2003-03-21 19:22:52 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAsync);
|
|
|
|
*aAsync = mAsync;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::SetAsync(bool aAsync)
|
2003-03-21 19:22:52 +00:00
|
|
|
{
|
|
|
|
mAsync = aAsync;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-01 06:58:53 +00:00
|
|
|
NS_IMETHODIMP
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::Load(const nsAString& aUrl, bool *aReturn)
|
2013-03-26 15:31:54 +00:00
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
*aReturn = Load(aUrl, rv);
|
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
|
2000-05-01 06:58:53 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasHadScriptObject = true;
|
2011-03-24 11:37:32 +00:00
|
|
|
nsIScriptGlobalObject* scriptObject =
|
|
|
|
GetScriptHandlingObject(hasHadScriptObject);
|
2013-03-26 15:31:54 +00:00
|
|
|
if (!scriptObject && hasHadScriptObject) {
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return false;
|
|
|
|
}
|
2011-03-24 11:37:32 +00:00
|
|
|
|
2013-11-11 21:12:18 +00:00
|
|
|
WarnOnceAbout(nsIDocument::eUseOfDOM3LoadMethod);
|
2010-04-13 01:59:00 +00:00
|
|
|
|
2014-08-19 19:02:06 +00:00
|
|
|
nsCOMPtr<nsIDocument> callingDoc = GetEntryDocument();
|
2014-08-29 23:56:28 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
|
|
|
|
|
|
|
|
// The callingDoc's Principal and doc's Principal should be the same
|
2014-10-20 19:43:41 +00:00
|
|
|
if (callingDoc && (callingDoc->NodePrincipal() != principal)) {
|
2014-08-29 23:56:28 +00:00
|
|
|
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
|
|
|
NS_LITERAL_CSTRING("DOM"),
|
|
|
|
callingDoc,
|
|
|
|
nsContentUtils::eDOM_PROPERTIES,
|
|
|
|
"XMLDocumentLoadPrincipalMismatch");
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
nsIURI *baseURI = mDocumentURI;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString charset;
|
2003-07-28 23:12:46 +00:00
|
|
|
|
2008-01-25 21:49:11 +00:00
|
|
|
if (callingDoc) {
|
2010-04-19 15:40:15 +00:00
|
|
|
baseURI = callingDoc->GetDocBaseURI();
|
2008-01-25 21:49:11 +00:00
|
|
|
charset = callingDoc->GetDocumentCharacterSet();
|
2003-07-28 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new URI
|
2004-02-19 23:10:47 +00:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI);
|
2003-07-28 23:12:46 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-07-28 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 00:38:12 +00:00
|
|
|
// Check to see whether the current document is allowed to load this URI.
|
|
|
|
// It's important to use the current document's principal for this check so
|
|
|
|
// that we don't end up in a case where code with elevated privileges is
|
|
|
|
// calling us and changing the principal of this document.
|
2004-02-19 23:10:47 +00:00
|
|
|
|
2008-02-27 03:45:29 +00:00
|
|
|
// Enforce same-origin even for chrome loaders to avoid someone accidentally
|
|
|
|
// using a document that content has a reference to and turn that into a
|
|
|
|
// chrome document.
|
2010-03-02 19:40:14 +00:00
|
|
|
if (!nsContentUtils::IsSystemPrincipal(principal)) {
|
2012-08-20 18:34:33 +00:00
|
|
|
rv = principal->CheckMayLoad(uri, false, false);
|
2013-03-26 15:31:54 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-02 19:40:14 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
2010-03-02 19:40:14 +00:00
|
|
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
|
|
|
|
uri,
|
|
|
|
principal,
|
|
|
|
callingDoc ? callingDoc.get() :
|
|
|
|
static_cast<nsIDocument*>(this),
|
|
|
|
NS_LITERAL_CSTRING("application/xml"),
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr,
|
2010-03-02 19:40:14 +00:00
|
|
|
&shouldLoad,
|
|
|
|
nsContentUtils::GetContentPolicy(),
|
|
|
|
nsContentUtils::GetSecurityManager());
|
2013-03-26 15:31:54 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-02 19:40:14 +00:00
|
|
|
if (NS_CP_REJECTED(shouldLoad)) {
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(NS_ERROR_CONTENT_BLOCKED);
|
|
|
|
return false;
|
2010-03-02 19:40:14 +00:00
|
|
|
}
|
2008-01-25 21:49:11 +00:00
|
|
|
} else {
|
|
|
|
// We're called from chrome, check to make sure the URI we're
|
|
|
|
// about to load is also chrome.
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isChrome = false;
|
2008-01-25 21:49:11 +00:00
|
|
|
if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) {
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString spec;
|
2008-04-09 00:38:12 +00:00
|
|
|
if (mDocumentURI)
|
|
|
|
mDocumentURI->GetSpec(spec);
|
|
|
|
|
|
|
|
nsAutoString error;
|
|
|
|
error.AssignLiteral("Cross site loading using document.load is no "
|
|
|
|
"longer supported. Use XMLHttpRequest instead.");
|
2011-12-21 21:51:29 +00:00
|
|
|
nsCOMPtr<nsIScriptError> errorObject =
|
2008-04-09 00:38:12 +00:00
|
|
|
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
|
2013-03-26 15:31:54 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-20 16:21:58 +00:00
|
|
|
|
2012-09-09 23:29:12 +00:00
|
|
|
rv = errorObject->InitWithWindowID(error,
|
|
|
|
NS_ConvertUTF8toUTF16(spec),
|
|
|
|
EmptyString(),
|
|
|
|
0, 0, nsIScriptError::warningFlag,
|
2010-12-20 16:21:58 +00:00
|
|
|
"DOM",
|
|
|
|
callingDoc ?
|
2011-08-24 20:44:35 +00:00
|
|
|
callingDoc->InnerWindowID() :
|
|
|
|
this->InnerWindowID());
|
2010-12-20 16:21:58 +00:00
|
|
|
|
2013-03-26 15:31:54 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-09 00:38:12 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIConsoleService> consoleService =
|
|
|
|
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
2011-12-21 21:51:29 +00:00
|
|
|
if (consoleService) {
|
|
|
|
consoleService->LogMessage(errorObject);
|
2008-04-09 00:38:12 +00:00
|
|
|
}
|
|
|
|
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
|
|
|
return false;
|
2008-01-25 21:49:11 +00:00
|
|
|
}
|
2003-07-28 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-01-25 21:49:11 +00:00
|
|
|
// Partial Reset, need to restore principal for security reasons and
|
|
|
|
// event listener manager so that load listeners etc. will
|
|
|
|
// remain. This should be done before the security check is done to
|
|
|
|
// ensure that the document is reset even if the new document can't
|
|
|
|
// be loaded. Note that we need to hold a strong ref to |principal|
|
|
|
|
// here, because ResetToURI will null out our node principal before
|
|
|
|
// setting the new one.
|
2014-03-17 06:56:53 +00:00
|
|
|
nsRefPtr<EventListenerManager> elm(mListenerManager);
|
2012-07-30 14:20:58 +00:00
|
|
|
mListenerManager = nullptr;
|
2003-07-28 23:12:46 +00:00
|
|
|
|
2008-01-25 21:49:11 +00:00
|
|
|
// When we are called from JS we can find the load group for the page,
|
|
|
|
// and add ourselves to it. This way any pending requests
|
|
|
|
// will be automatically aborted if the user leaves the page.
|
2003-07-28 23:12:46 +00:00
|
|
|
|
2008-01-25 21:49:11 +00:00
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
|
|
|
if (callingDoc) {
|
|
|
|
loadGroup = callingDoc->GetDocumentLoadGroup();
|
2003-07-28 23:12:46 +00:00
|
|
|
}
|
2002-06-14 23:54:18 +00:00
|
|
|
|
2008-01-25 21:49:11 +00:00
|
|
|
ResetToURI(uri, loadGroup, principal);
|
|
|
|
|
|
|
|
mListenerManager = elm;
|
2002-08-13 18:41:16 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
// Create a channel
|
2008-11-26 01:50:04 +00:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req = nsContentUtils::GetSameOriginChecker();
|
2013-03-26 15:31:54 +00:00
|
|
|
if (!req) {
|
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return false;
|
|
|
|
}
|
2003-04-02 21:44:39 +00:00
|
|
|
|
2004-02-19 23:10:47 +00:00
|
|
|
nsCOMPtr<nsIChannel> channel;
|
2003-04-02 21:44:39 +00:00
|
|
|
// nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active,
|
|
|
|
// which in turn keeps STOP button from becoming active
|
2014-09-22 11:49:12 +00:00
|
|
|
rv = NS_NewChannel(getter_AddRefs(channel),
|
|
|
|
uri,
|
|
|
|
callingDoc ? callingDoc.get() :
|
|
|
|
static_cast<nsIDocument*>(this),
|
|
|
|
nsILoadInfo::SEC_NORMAL,
|
|
|
|
nsIContentPolicy::TYPE_XMLHTTPREQUEST,
|
|
|
|
loadGroup,
|
|
|
|
req,
|
2003-04-02 21:44:39 +00:00
|
|
|
nsIRequest::LOAD_BACKGROUND);
|
2014-09-22 11:49:12 +00:00
|
|
|
|
2003-07-28 23:12:46 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-07-28 23:12:46 +00:00
|
|
|
}
|
2000-05-01 06:58:53 +00:00
|
|
|
|
2012-04-17 06:41:49 +00:00
|
|
|
// StartDocumentLoad asserts that readyState is uninitialized, so
|
|
|
|
// uninitialize it. SetReadyStateInternal make this transition invisible to
|
|
|
|
// Web content. But before doing that, assert that the current readyState
|
|
|
|
// is complete as it should be after the call to ResetToURI() above.
|
|
|
|
MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE,
|
|
|
|
"Bad readyState");
|
|
|
|
SetReadyStateInternal(nsIDocument::READYSTATE_UNINITIALIZED);
|
|
|
|
|
2000-05-01 06:58:53 +00:00
|
|
|
// Prepare for loading the XML document "into oneself"
|
|
|
|
nsCOMPtr<nsIStreamListener> listener;
|
|
|
|
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
2012-07-30 14:20:58 +00:00
|
|
|
loadGroup, nullptr,
|
2000-05-01 06:58:53 +00:00
|
|
|
getter_AddRefs(listener),
|
2011-10-17 14:59:28 +00:00
|
|
|
false))) {
|
2013-03-20 16:22:26 +00:00
|
|
|
NS_ERROR("XMLDocument::Load: Failed to start the document load.");
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2000-05-01 06:58:53 +00:00
|
|
|
}
|
|
|
|
|
2005-04-28 16:57:24 +00:00
|
|
|
// After this point, if we error out of this method we should clear
|
2005-06-01 01:15:23 +00:00
|
|
|
// mChannelIsPending.
|
2005-04-28 16:57:24 +00:00
|
|
|
|
2000-05-01 06:58:53 +00:00
|
|
|
// Start an asynchronous read of the XML document
|
2012-07-30 14:20:58 +00:00
|
|
|
rv = channel->AsyncOpen(listener, nullptr);
|
2003-03-21 19:22:52 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mChannelIsPending = false;
|
2013-03-26 15:31:54 +00:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-03-21 19:22:52 +00:00
|
|
|
}
|
2000-05-01 06:58:53 +00:00
|
|
|
|
2003-03-21 19:22:52 +00:00
|
|
|
if (!mAsync) {
|
2006-05-10 17:30:15 +00:00
|
|
|
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
2003-03-21 19:22:52 +00:00
|
|
|
|
2012-03-31 16:30:13 +00:00
|
|
|
nsAutoSyncOperation sync(this);
|
2011-10-17 14:59:28 +00:00
|
|
|
mLoopingForSyncLoad = true;
|
2003-03-21 19:22:52 +00:00
|
|
|
while (mLoopingForSyncLoad) {
|
2006-05-10 17:30:15 +00:00
|
|
|
if (!NS_ProcessNextEvent(thread))
|
|
|
|
break;
|
2003-03-21 19:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We set return to true unless there was a parsing error
|
2013-03-26 15:31:54 +00:00
|
|
|
Element* rootElement = GetRootElement();
|
|
|
|
if (!rootElement) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rootElement->LocalName().EqualsLiteral("parsererror")) {
|
|
|
|
nsAutoString ns;
|
|
|
|
rootElement->GetNamespaceURI(ns);
|
|
|
|
if (ns.EqualsLiteral("http://www.mozilla.org/newlayout/xml/parsererror.xml")) {
|
|
|
|
return false;
|
2003-03-21 19:22:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-26 15:31:54 +00:00
|
|
|
return true;
|
2000-05-01 06:58:53 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
nsresult
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::StartDocumentLoad(const char* aCommand,
|
|
|
|
nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener **aDocListener,
|
|
|
|
bool aReset,
|
|
|
|
nsIContentSink* aSink)
|
1999-01-06 00:32:41 +00:00
|
|
|
{
|
1999-07-16 11:14:36 +00:00
|
|
|
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
1999-07-20 08:46:33 +00:00
|
|
|
aChannel, aLoadGroup,
|
1999-01-06 00:32:41 +00:00
|
|
|
aContainer,
|
2001-11-02 01:53:13 +00:00
|
|
|
aDocListener, aReset, aSink);
|
2001-05-15 03:42:33 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-01-06 00:32:41 +00:00
|
|
|
|
2007-07-27 02:49:18 +00:00
|
|
|
if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mLoadedAsInteractiveData = true;
|
2007-07-27 02:49:18 +00:00
|
|
|
aCommand = kLoadAsData; // XBL, for example, needs scripts and styles
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t charsetSource = kCharsetFromDocTypeDefault;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8"));
|
2012-07-30 14:20:58 +00:00
|
|
|
TryChannelCharset(aChannel, charsetSource, charset, nullptr);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
1999-07-16 11:14:36 +00:00
|
|
|
nsCOMPtr<nsIURI> aUrl;
|
|
|
|
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-03 22:48:20 +00:00
|
|
|
|
2001-03-10 21:02:12 +00:00
|
|
|
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2005-04-28 16:57:24 +00:00
|
|
|
mParser = do_CreateInstance(kCParserCID, &rv);
|
2003-01-14 22:32:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-05-15 03:42:33 +00:00
|
|
|
|
2001-11-02 01:53:13 +00:00
|
|
|
nsCOMPtr<nsIXMLContentSink> sink;
|
2000-08-30 00:35:43 +00:00
|
|
|
|
2003-01-14 22:32:18 +00:00
|
|
|
if (aSink) {
|
|
|
|
sink = do_QueryInterface(aSink);
|
2001-05-15 03:42:33 +00:00
|
|
|
}
|
2001-11-02 01:53:13 +00:00
|
|
|
else {
|
2003-04-03 18:57:33 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
2003-01-14 22:32:18 +00:00
|
|
|
if (aContainer) {
|
2003-04-03 18:57:33 +00:00
|
|
|
docShell = do_QueryInterface(aContainer);
|
|
|
|
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
2003-01-14 22:32:18 +00:00
|
|
|
}
|
2003-04-03 18:57:33 +00:00
|
|
|
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell,
|
2003-01-14 22:32:18 +00:00
|
|
|
aChannel);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-11-02 01:53:13 +00:00
|
|
|
}
|
|
|
|
|
2003-01-14 22:32:18 +00:00
|
|
|
// Set the parser as the stream listener for the document loader...
|
2005-04-28 16:57:24 +00:00
|
|
|
rv = CallQueryInterface(mParser, aDocListener);
|
2003-01-14 22:32:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-05-15 03:42:33 +00:00
|
|
|
|
2005-06-01 01:15:23 +00:00
|
|
|
NS_ASSERTION(mChannel, "How can we not have a channel here?");
|
2011-10-17 14:59:28 +00:00
|
|
|
mChannelIsPending = true;
|
2005-06-01 01:15:23 +00:00
|
|
|
|
2003-01-14 22:32:18 +00:00
|
|
|
SetDocumentCharacterSet(charset);
|
2005-04-28 16:57:24 +00:00
|
|
|
mParser->SetDocumentCharset(charset, charsetSource);
|
|
|
|
mParser->SetCommand(aCommand);
|
|
|
|
mParser->SetContentSink(sink);
|
2012-07-30 14:20:58 +00:00
|
|
|
mParser->Parse(aUrl, nullptr, (void *)this);
|
1998-11-11 22:06:16 +00:00
|
|
|
|
2003-01-14 22:32:18 +00:00
|
|
|
return NS_OK;
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:09:48 +00:00
|
|
|
void
|
2013-03-20 16:22:26 +00:00
|
|
|
XMLDocument::EndLoad()
|
1998-11-11 22:06:16 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
mChannelIsPending = false;
|
|
|
|
mLoopingForSyncLoad = false;
|
2003-03-21 19:22:52 +00:00
|
|
|
|
2009-01-26 09:53:20 +00:00
|
|
|
mSynchronousDOMContentLoaded = (mLoadedAsData || mLoadedAsInteractiveData);
|
2008-07-19 15:20:22 +00:00
|
|
|
nsDocument::EndLoad();
|
2009-01-26 09:53:20 +00:00
|
|
|
if (mSynchronousDOMContentLoaded) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mSynchronousDOMContentLoaded = false;
|
2009-01-09 17:12:09 +00:00
|
|
|
nsDocument::SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
2005-04-28 23:48:28 +00:00
|
|
|
// Generate a document load event for the case when an XML
|
|
|
|
// document was loaded as pure data without any presentation
|
|
|
|
// attached to it.
|
2013-10-02 03:46:04 +00:00
|
|
|
WidgetEvent event(true, NS_LOAD);
|
2014-03-18 04:48:21 +00:00
|
|
|
EventDispatcher::Dispatch(static_cast<nsIDocument*>(this), nullptr, &event);
|
2013-09-30 23:20:23 +00:00
|
|
|
}
|
1998-11-11 22:06:16 +00:00
|
|
|
}
|
2013-09-30 23:20:23 +00:00
|
|
|
|
2012-02-01 21:58:01 +00:00
|
|
|
/* virtual */ void
|
2013-09-30 23:20:23 +00:00
|
|
|
XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
2012-02-01 21:58:01 +00:00
|
|
|
{
|
2013-09-30 23:20:23 +00:00
|
|
|
nsDocument::DocAddSizeOfExcludingThis(aWindowSizes);
|
2012-02-01 21:58:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-02 22:39:46 +00:00
|
|
|
// nsIDOMDocument interface
|
|
|
|
|
2006-09-05 10:22:54 +00:00
|
|
|
nsresult
|
2014-06-20 02:01:40 +00:00
|
|
|
XMLDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
|
2006-09-05 10:22:54 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
|
|
|
|
"Can't import this document into another document!");
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
nsRefPtr<XMLDocument> clone = new XMLDocument();
|
2008-09-18 11:15:47 +00:00
|
|
|
nsresult rv = CloneDocHelper(clone);
|
2006-09-05 10:22:54 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
// State from XMLDocument
|
2008-09-18 11:15:47 +00:00
|
|
|
clone->mAsync = mAsync;
|
2014-06-03 15:38:37 +00:00
|
|
|
clone->mIsPlainDocument = mIsPlainDocument;
|
2008-09-18 11:15:47 +00:00
|
|
|
|
|
|
|
return CallQueryInterface(clone.get(), aResult);
|
2006-09-05 10:22:54 +00:00
|
|
|
}
|
2013-03-20 16:22:26 +00:00
|
|
|
|
2013-03-26 15:31:54 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
XMLDocument::WrapNode(JSContext *aCx)
|
2013-03-26 15:31:54 +00:00
|
|
|
{
|
2014-06-03 15:38:37 +00:00
|
|
|
if (mIsPlainDocument) {
|
|
|
|
return DocumentBinding::Wrap(aCx, this);
|
|
|
|
}
|
|
|
|
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return XMLDocumentBinding::Wrap(aCx, this);
|
2013-03-26 15:31:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 16:22:26 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|