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"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2000-06-17 05:46:58 +04:00
|
|
|
#include "nsIContent.h"
|
1999-11-19 10:35:27 +03:00
|
|
|
#include "nsIContentViewerContainer.h"
|
|
|
|
#include "nsIContentViewer.h"
|
2000-03-11 03:28:44 +03:00
|
|
|
#include "nsIDocShell.h"
|
1998-11-12 01:06:16 +03:00
|
|
|
#include "nsHTMLParts.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-11-12 01:06:16 +03:00
|
|
|
#include "nsIDOMElement.h"
|
2001-02-03 04:16:20 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
2003-04-03 01:44:39 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2000-06-17 05:46:58 +04:00
|
|
|
#include "nsIDOMDocumentType.h"
|
1999-07-16 15:14:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-09-04 02:48:20 +04:00
|
|
|
#include "nsXPIDLString.h"
|
2015-08-12 07:30:36 +03:00
|
|
|
#include "nsIHttpChannelInternal.h"
|
2001-05-01 03:35:09 +04:00
|
|
|
#include "nsIURI.h"
|
1999-09-04 02:48:20 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2000-05-01 10:58:53 +04:00
|
|
|
#include "nsNetUtil.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2003-10-22 02:11:49 +04:00
|
|
|
#include "nsIScriptSecurityManager.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"
|
2014-03-17 10:56:53 +04: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 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"
|
2002-06-15 03:54:18 +04:00
|
|
|
#include "nsIAuthPrompt.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2010-03-02 22:40:14 +03:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2006-09-05 14:22:54 +04:00
|
|
|
#include "nsNodeUtils.h"
|
2008-04-09 04:38:12 +04:00
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include "nsIScriptError.h"
|
2008-09-20 22:55:04 +04:00
|
|
|
#include "nsIHTMLDocument.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"
|
2013-06-26 18:59:45 +04:00
|
|
|
#include "mozilla/dom/Element.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
|
|
|
|
2000-02-23 04:48:22 +03:00
|
|
|
|
2003-03-05 18:08:41 +03:00
|
|
|
nsresult
|
2000-05-01 10:58:53 +04:00
|
|
|
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
2002-03-24 01:46:13 +03:00
|
|
|
const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
2000-05-01 10:58:53 +04:00
|
|
|
nsIDOMDocumentType* aDoctype,
|
2006-02-20 21:57:32 +03:00
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
nsIURI* aBaseURI,
|
2007-10-01 14:02:32 +04:00
|
|
|
nsIPrincipal* aPrincipal,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aLoadedAsData,
|
2013-04-04 13:32:29 +04:00
|
|
|
nsIGlobalObject* aEventObject,
|
2011-11-16 11:38:51 +04:00
|
|
|
DocumentFlavor aFlavor)
|
2000-05-01 10:58:53 +04:00
|
|
|
{
|
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.
|
|
|
|
|
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
|
|
|
|
2008-09-20 22:55:04 +04:00
|
|
|
nsCOMPtr<nsIDocument> 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;
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-04 13:32:29 +04:00
|
|
|
if (nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aEventObject)) {
|
|
|
|
d->SetScriptHandlingObject(sgo);
|
|
|
|
} else if (aEventObject){
|
|
|
|
d->SetScopeObject(aEventObject);
|
|
|
|
}
|
|
|
|
|
2008-09-20 22:55:04 +04: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 14:02:32 +04:00
|
|
|
doc->SetLoadedAsData(aLoadedAsData);
|
2006-05-31 21:57:14 +04:00
|
|
|
doc->nsDocument::SetDocumentURI(aDocumentURI);
|
2006-02-20 21:57:32 +03:00
|
|
|
// Must set the principal first, since SetBaseURI checks it.
|
|
|
|
doc->SetPrincipal(aPrincipal);
|
2004-01-10 02:54:21 +03:00
|
|
|
doc->SetBaseURI(aBaseURI);
|
2000-06-17 05:46:58 +04:00
|
|
|
|
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
|
2008-08-28 16:56:45 +04:00
|
|
|
doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
|
|
|
|
|
2000-06-17 05:46:58 +04:00
|
|
|
if (aDoctype) {
|
|
|
|
nsCOMPtr<nsIDOMNode> tmpNode;
|
2001-01-23 10:42:20 +03:00
|
|
|
rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-06-17 05:46:58 +04:00
|
|
|
}
|
|
|
|
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aQualifiedName.IsEmpty()) {
|
2000-06-17 05:46:58 +04:00
|
|
|
nsCOMPtr<nsIDOMElement> root;
|
2001-01-23 10:42:20 +03: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 05:46:58 +04:00
|
|
|
}
|
|
|
|
|
2001-01-23 10:42:20 +03:00
|
|
|
*aInstancePtrResult = doc;
|
|
|
|
NS_ADDREF(*aInstancePtrResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-01 10:58:53 +04:00
|
|
|
}
|
|
|
|
|
2003-03-05 18:08:41 +03:00
|
|
|
nsresult
|
2014-06-03 19:38:37 +04:00
|
|
|
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
|
|
|
|
bool aIsPlainDocument)
|
1998-11-12 01:06:16 +03:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2011-11-04 00:39:08 +04: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 18:20:58 +04:00
|
|
|
NS_LITERAL_STRING("bindings"), nullptr,
|
2011-11-04 00:39:08 +04:00
|
|
|
aDocumentURI, aBaseURI, aPrincipal, false,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, DocumentFlavorLegacyGuess);
|
2011-11-04 00:39:08 +04: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 20:22:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
XMLDocument::XMLDocument(const char* aContentType)
|
2006-04-21 05:24:44 +04:00
|
|
|
: nsDocument(aContentType),
|
2011-10-17 18:59:28 +04:00
|
|
|
mAsync(true)
|
1998-11-12 01:06:16 +03:00
|
|
|
{
|
2003-03-26 10:41:30 +03:00
|
|
|
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
|
|
|
// bother initializing members to 0.
|
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
|
|
|
XMLDocument::~XMLDocument()
|
1998-11-12 01:06:16 +03:00
|
|
|
{
|
2003-03-21 22:22:52 +03:00
|
|
|
// XXX We rather crash than hang
|
2011-10-17 18:59:28 +04:00
|
|
|
mLoopingForSyncLoad = false;
|
1998-11-12 01:06:16 +03:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
// QueryInterface implementation for XMLDocument
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(XMLDocument, nsDocument, nsIDOMXMLDocument)
|
1998-11-12 01:06:16 +03:00
|
|
|
|
2003-03-26 10:41:30 +03:00
|
|
|
nsresult
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::Init()
|
2003-03-26 10:41:30 +03:00
|
|
|
{
|
|
|
|
nsresult rv = nsDocument::Init();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
void
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
1998-11-12 01:06:16 +03:00
|
|
|
{
|
2003-10-22 10:09:48 +04:00
|
|
|
nsDocument::Reset(aChannel, aLoadGroup);
|
1999-01-06 03:32:41 +03:00
|
|
|
}
|
|
|
|
|
2005-04-28 20:57:24 +04:00
|
|
|
void
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|
|
|
nsIPrincipal* aPrincipal)
|
2005-04-28 20:57:24 +04:00
|
|
|
{
|
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
|
|
|
|
2006-11-22 21:27:54 +03:00
|
|
|
nsDocument::ResetToURI(aURI, aLoadGroup, aPrincipal);
|
2005-04-28 20:57:24 +04:00
|
|
|
}
|
|
|
|
|
2003-03-21 22:22:52 +03:00
|
|
|
NS_IMETHODIMP
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::GetAsync(bool *aAsync)
|
2003-03-21 22:22:52 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAsync);
|
|
|
|
*aAsync = mAsync;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::SetAsync(bool aAsync)
|
2003-03-21 22:22:52 +03:00
|
|
|
{
|
|
|
|
mAsync = aAsync;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-01 10:58:53 +04:00
|
|
|
NS_IMETHODIMP
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::Load(const nsAString& aUrl, bool *aReturn)
|
2013-03-26 19:31:54 +04:00
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
*aReturn = Load(aUrl, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2013-03-26 19:31:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
|
2000-05-01 10:58:53 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasHadScriptObject = true;
|
2011-03-24 14:37:32 +03:00
|
|
|
nsIScriptGlobalObject* scriptObject =
|
|
|
|
GetScriptHandlingObject(hasHadScriptObject);
|
2013-03-26 19:31:54 +04:00
|
|
|
if (!scriptObject && hasHadScriptObject) {
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return false;
|
|
|
|
}
|
2011-03-24 14:37:32 +03:00
|
|
|
|
2013-11-12 01:12:18 +04:00
|
|
|
WarnOnceAbout(nsIDocument::eUseOfDOM3LoadMethod);
|
2010-04-13 05:59:00 +04:00
|
|
|
|
2014-08-19 23:02:06 +04:00
|
|
|
nsCOMPtr<nsIDocument> callingDoc = GetEntryDocument();
|
2014-08-30 03:56:28 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
|
|
|
|
|
|
|
|
// The callingDoc's Principal and doc's Principal should be the same
|
2014-10-20 23:43:41 +04:00
|
|
|
if (callingDoc && (callingDoc->NodePrincipal() != principal)) {
|
2014-08-30 03:56:28 +04:00
|
|
|
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
|
|
|
|
NS_LITERAL_CSTRING("DOM"),
|
|
|
|
callingDoc,
|
|
|
|
nsContentUtils::eDOM_PROPERTIES,
|
|
|
|
"XMLDocumentLoadPrincipalMismatch");
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
nsIURI *baseURI = mDocumentURI;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString charset;
|
2003-07-29 03:12:46 +04:00
|
|
|
|
2008-01-26 00:49:11 +03:00
|
|
|
if (callingDoc) {
|
2010-04-19 19:40:15 +04:00
|
|
|
baseURI = callingDoc->GetDocBaseURI();
|
2008-01-26 00:49:11 +03:00
|
|
|
charset = callingDoc->GetDocumentCharacterSet();
|
2003-07-29 03:12:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new URI
|
2004-02-20 02:10:47 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl, charset.get(), baseURI);
|
2003-07-29 03:12:46 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-03-26 19:31:54 +04:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-07-29 03:12:46 +04:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:19:08 +03:00
|
|
|
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
2008-01-26 00:49:11 +03:00
|
|
|
// We're called from chrome, check to make sure the URI we're
|
|
|
|
// about to load is also chrome.
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isChrome = false;
|
2008-01-26 00:49:11 +03:00
|
|
|
if (NS_FAILED(uri->SchemeIs("chrome", &isChrome)) || !isChrome) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2008-04-09 04:38:12 +04: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-22 01:51:29 +04:00
|
|
|
nsCOMPtr<nsIScriptError> errorObject =
|
2008-04-09 04:38:12 +04:00
|
|
|
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
|
2013-03-26 19:31:54 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-20 19:21:58 +03:00
|
|
|
|
2012-09-10 03:29:12 +04:00
|
|
|
rv = errorObject->InitWithWindowID(error,
|
|
|
|
NS_ConvertUTF8toUTF16(spec),
|
|
|
|
EmptyString(),
|
|
|
|
0, 0, nsIScriptError::warningFlag,
|
2010-12-20 19:21:58 +03:00
|
|
|
"DOM",
|
|
|
|
callingDoc ?
|
2011-08-25 00:44:35 +04:00
|
|
|
callingDoc->InnerWindowID() :
|
|
|
|
this->InnerWindowID());
|
2010-12-20 19:21:58 +03:00
|
|
|
|
2013-03-26 19:31:54 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-09 04:38:12 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIConsoleService> consoleService =
|
|
|
|
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
2011-12-22 01:51:29 +04:00
|
|
|
if (consoleService) {
|
|
|
|
consoleService->LogMessage(errorObject);
|
2008-04-09 04:38:12 +04:00
|
|
|
}
|
|
|
|
|
2013-03-26 19:31:54 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
|
|
|
return false;
|
2008-01-26 00:49:11 +03:00
|
|
|
}
|
2003-07-29 03:12:46 +04:00
|
|
|
}
|
|
|
|
|
2008-01-26 00:49:11 +03: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.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<EventListenerManager> elm(mListenerManager);
|
2012-07-30 18:20:58 +04:00
|
|
|
mListenerManager = nullptr;
|
2003-07-29 03:12:46 +04:00
|
|
|
|
2008-01-26 00:49:11 +03: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-29 03:12:46 +04:00
|
|
|
|
2008-01-26 00:49:11 +03:00
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
|
|
|
if (callingDoc) {
|
|
|
|
loadGroup = callingDoc->GetDocumentLoadGroup();
|
2003-07-29 03:12:46 +04:00
|
|
|
}
|
2002-06-15 03:54:18 +04:00
|
|
|
|
2008-01-26 00:49:11 +03:00
|
|
|
ResetToURI(uri, loadGroup, principal);
|
|
|
|
|
|
|
|
mListenerManager = elm;
|
2002-08-13 22:41:16 +04:00
|
|
|
|
2000-09-21 03:38:28 +04:00
|
|
|
// Create a channel
|
2015-01-26 20:28:15 +03:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req = nsContentUtils::SameOriginChecker();
|
2003-04-03 01:44:39 +04:00
|
|
|
|
2004-02-20 02:10:47 +03:00
|
|
|
nsCOMPtr<nsIChannel> channel;
|
2003-04-03 01:44:39 +04:00
|
|
|
// nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active,
|
|
|
|
// which in turn keeps STOP button from becoming active
|
2014-09-22 15:49:12 +04:00
|
|
|
rv = NS_NewChannel(getter_AddRefs(channel),
|
|
|
|
uri,
|
|
|
|
callingDoc ? callingDoc.get() :
|
|
|
|
static_cast<nsIDocument*>(this),
|
2015-08-10 20:19:08 +03:00
|
|
|
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
2015-08-06 21:17:24 +03:00
|
|
|
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
|
2014-09-22 15:49:12 +04:00
|
|
|
loadGroup,
|
|
|
|
req,
|
2003-04-03 01:44:39 +04:00
|
|
|
nsIRequest::LOAD_BACKGROUND);
|
2014-09-22 15:49:12 +04:00
|
|
|
|
2003-07-29 03:12:46 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-03-26 19:31:54 +04:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-07-29 03:12:46 +04:00
|
|
|
}
|
2000-05-01 10:58:53 +04:00
|
|
|
|
2015-08-12 07:30:36 +03:00
|
|
|
// TODO Bug 1189945: Remove nsIChannel CorsMode flag and set Request.mode
|
|
|
|
// based on nsILoadInfo securityFlags instead. This block will be removed
|
|
|
|
// when Request.mode set correctly.
|
|
|
|
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(channel);
|
|
|
|
if (httpChannel) {
|
|
|
|
httpChannel->SetCorsMode(nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN);
|
|
|
|
}
|
|
|
|
|
2012-04-17 10:41:49 +04: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 10:58:53 +04:00
|
|
|
// Prepare for loading the XML document "into oneself"
|
|
|
|
nsCOMPtr<nsIStreamListener> listener;
|
|
|
|
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
2012-07-30 18:20:58 +04:00
|
|
|
loadGroup, nullptr,
|
2000-05-01 10:58:53 +04:00
|
|
|
getter_AddRefs(listener),
|
2011-10-17 18:59:28 +04:00
|
|
|
false))) {
|
2013-03-20 20:22:26 +04:00
|
|
|
NS_ERROR("XMLDocument::Load: Failed to start the document load.");
|
2013-03-26 19:31:54 +04:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2000-05-01 10:58:53 +04:00
|
|
|
}
|
|
|
|
|
2005-04-28 20:57:24 +04:00
|
|
|
// After this point, if we error out of this method we should clear
|
2005-06-01 05:15:23 +04:00
|
|
|
// mChannelIsPending.
|
2005-04-28 20:57:24 +04:00
|
|
|
|
2000-05-01 10:58:53 +04:00
|
|
|
// Start an asynchronous read of the XML document
|
2015-08-10 20:19:08 +03:00
|
|
|
rv = channel->AsyncOpen2(listener);
|
2003-03-21 22:22:52 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mChannelIsPending = false;
|
2013-03-26 19:31:54 +04:00
|
|
|
aRv.Throw(rv);
|
|
|
|
return false;
|
2003-03-21 22:22:52 +03:00
|
|
|
}
|
2000-05-01 10:58:53 +04:00
|
|
|
|
2003-03-21 22:22:52 +03:00
|
|
|
if (!mAsync) {
|
2006-05-10 21:30:15 +04:00
|
|
|
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
2003-03-21 22:22:52 +03:00
|
|
|
|
2012-03-31 20:30:13 +04:00
|
|
|
nsAutoSyncOperation sync(this);
|
2011-10-17 18:59:28 +04:00
|
|
|
mLoopingForSyncLoad = true;
|
2003-03-21 22:22:52 +03:00
|
|
|
while (mLoopingForSyncLoad) {
|
2006-05-10 21:30:15 +04:00
|
|
|
if (!NS_ProcessNextEvent(thread))
|
|
|
|
break;
|
2003-03-21 22:22:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// We set return to true unless there was a parsing error
|
2013-03-26 19:31:54 +04: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 22:22:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-26 19:31:54 +04:00
|
|
|
return true;
|
2000-05-01 10:58:53 +04:00
|
|
|
}
|
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
nsresult
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::StartDocumentLoad(const char* aCommand,
|
|
|
|
nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener **aDocListener,
|
|
|
|
bool aReset,
|
|
|
|
nsIContentSink* aSink)
|
1999-01-06 03:32:41 +03:00
|
|
|
{
|
1999-07-16 15:14:36 +04:00
|
|
|
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
1999-07-20 12:46:33 +04:00
|
|
|
aChannel, aLoadGroup,
|
1999-01-06 03:32:41 +03:00
|
|
|
aContainer,
|
2001-11-02 04:53:13 +03:00
|
|
|
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
|
|
|
|
2007-07-27 06:49:18 +04:00
|
|
|
if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mLoadedAsInteractiveData = true;
|
2007-07-27 06:49:18 +04:00
|
|
|
aCommand = kLoadAsData; // XBL, for example, needs scripts and styles
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t charsetSource = kCharsetFromDocTypeDefault;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString charset(NS_LITERAL_CSTRING("UTF-8"));
|
2012-07-30 18:20:58 +04:00
|
|
|
TryChannelCharset(aChannel, charsetSource, charset, 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;
|
2000-08-30 04:35:43 +04:00
|
|
|
|
2003-01-15 01:32:18 +03:00
|
|
|
if (aSink) {
|
|
|
|
sink = do_QueryInterface(aSink);
|
2001-05-15 07:42:33 +04:00
|
|
|
}
|
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;
|
2005-06-01 05:15:23 +04:00
|
|
|
|
2003-01-15 01:32:18 +03:00
|
|
|
SetDocumentCharacterSet(charset);
|
2005-04-28 20:57:24 +04:00
|
|
|
mParser->SetDocumentCharset(charset, charsetSource);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
void
|
2013-03-20 20:22:26 +04:00
|
|
|
XMLDocument::EndLoad()
|
1998-11-12 01:06:16 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mChannelIsPending = false;
|
|
|
|
mLoopingForSyncLoad = false;
|
2003-03-21 22:22:52 +03:00
|
|
|
|
2009-01-26 12:53:20 +03:00
|
|
|
mSynchronousDOMContentLoaded = (mLoadedAsData || mLoadedAsInteractiveData);
|
2008-07-19 19:20:22 +04:00
|
|
|
nsDocument::EndLoad();
|
2009-01-26 12:53:20 +03:00
|
|
|
if (mSynchronousDOMContentLoaded) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mSynchronousDOMContentLoaded = false;
|
2009-01-09 20:12:09 +03:00
|
|
|
nsDocument::SetReadyStateInternal(nsIDocument::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);
|
2014-03-18 08:48:21 +04:00
|
|
|
EventDispatcher::Dispatch(static_cast<nsIDocument*>(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
|
|
|
|
2012-02-02 01:58:01 +04:00
|
|
|
/* virtual */ void
|
2013-10-01 03:20:23 +04:00
|
|
|
XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
2012-02-02 01:58:01 +04:00
|
|
|
{
|
2013-10-01 03:20:23 +04:00
|
|
|
nsDocument::DocAddSizeOfExcludingThis(aWindowSizes);
|
2012-02-02 01:58:01 +04:00
|
|
|
}
|
|
|
|
|
2004-03-03 01:39:46 +03:00
|
|
|
// nsIDOMDocument interface
|
|
|
|
|
2006-09-05 14:22:54 +04:00
|
|
|
nsresult
|
2014-06-20 06:01:40 +04:00
|
|
|
XMLDocument::Clone(mozilla::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();
|
2008-09-18 15:15:47 +04: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
|
2008-09-18 15:15:47 +04:00
|
|
|
clone->mAsync = mAsync;
|
2014-06-03 19:38:37 +04:00
|
|
|
clone->mIsPlainDocument = mIsPlainDocument;
|
2008-09-18 15:15:47 +04:00
|
|
|
|
|
|
|
return CallQueryInterface(clone.get(), aResult);
|
2006-09-05 14:22:54 +04:00
|
|
|
}
|
2013-03-20 20:22:26 +04:00
|
|
|
|
2013-03-26 19:31:54 +04:00
|
|
|
JSObject*
|
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
|
|
|
XMLDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-03-26 19:31:54 +04:00
|
|
|
{
|
2014-06-03 19:38:37 +04:00
|
|
|
if (mIsPlainDocument) {
|
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
|
|
|
return DocumentBinding::Wrap(aCx, this, aGivenProto);
|
2014-06-03 19:38:37 +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
|
|
|
return XMLDocumentBinding::Wrap(aCx, this, aGivenProto);
|
2013-03-26 19:31:54 +04:00
|
|
|
}
|
|
|
|
|
2013-03-20 20:22:26 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|