Fix for bug 337704 (Clean up files moved from xmlextras). r/sr=bz.

This commit is contained in:
peterv%propagandism.org 2006-06-15 20:30:44 +00:00
Родитель 8af6b7c427
Коммит 898dda321e
23 изменённых файлов: 316 добавлений и 505 удалений

Просмотреть файл

@ -93,6 +93,8 @@ struct JSRuntime;
class nsIXTFService;
#endif
extern const char kLoadAsData[];
class nsContentUtils
{
public:
@ -872,6 +874,30 @@ public:
const nsAString& aFragment,
nsIDOMDocumentFragment** aReturn);
/**
* Creates a new XML document, setting the document's container to be the
* docshell of whatever script is on the JSContext stack.
*
* @param aNamespaceURI Namespace for the root element to create and insert in
* the document. Only used if aQualifiedName is not
* empty.
* @param aQualifiedName Qualified name for the root element to create and
* insert in the document. If empty no root element will
* be created.
* @param aDoctype Doctype node to insert in the document.
* @param aDocumentURI URI of the document. Must not be null.
* @param aBaseURI Base URI of the document. Must not be null.
* @param aPrincipal Prinicpal of the document. Must not be null.
* @param aResult [out] The document that was created.
*/
static nsresult CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIDOMDocument** aResult);
private:
static nsresult doReparentContentWrapper(nsIContent *aChild,
JSContext *cx,

Просмотреть файл

@ -73,7 +73,8 @@ interface nsIDOMParser : nsISupports {
* @returns The DOM document created as a result of parsing the
* string
*/
nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf, in PRUint32 bufLen, in string contentType);
nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf,
in PRUint32 bufLen, in string contentType);
/**
* The byte stream passed in is parsed into a DOM document.

Просмотреть файл

@ -61,7 +61,7 @@ interface nsIChannel;
* a document.
*/
[scriptable, uuid(96a13c30-695a-492c-918b-04ae3edb4e4c)]
[scriptable, uuid(2ae03836-0704-45c9-a545-4169548c0669)]
interface nsISyncLoadDOMService : nsISupports
{
/**
@ -90,14 +90,4 @@ interface nsISyncLoadDOMService : nsISupports
*/
nsIDOMDocument loadLocalDocument(in nsIChannel aChannel,
in nsIURI aLoaderURI);
/**
* Synchronously load the xbl-document from the specified channel. The channel
* must be possible to open synchronously.
*
* @param aChannel The channel to load the document from.
*
* @returns The document loaded from the URI.
*/
nsIDOMDocument loadLocalXBLDocument(in nsIChannel aChannel);
};

Просмотреть файл

@ -159,6 +159,7 @@ INCLUDES += \
-I$(srcdir)/../../../layout/generic \
-I$(srcdir)/../../../layout/style \
-I$(srcdir)/../../../dom/src/base \
-I$(srcdir)/../../xml/document/src \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -141,6 +141,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsIScriptError.h"
#include "nsIConsoleService.h"
const char kLoadAsData[] = "loadAsData";
static const char kJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
@ -3373,3 +3375,32 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
return NS_OK;
}
/* static */
nsresult
nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype,
nsIURI* aDocumentURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIDOMDocument** aResult)
{
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal);
NS_ENSURE_SUCCESS(rv, rv);
nsIDocShell *docShell = GetDocShellFromCaller();
if (docShell) {
nsCOMPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
nsCOMPtr<nsISupports> container = presContext->GetContainer();
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
if (document) {
document->SetContainer(container);
}
}
}
return NS_OK;
}

Просмотреть файл

@ -45,8 +45,6 @@
#include "nsContentUtils.h" // for NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO
#include "nsIDOMDocument.h"
static const char kLoadAsData[] = "loadAsData";
nsresult
NS_NewDOMBuilder(nsIDOMDOMBuilder** aResult,
PRUint16 aMode,

Просмотреть файл

@ -43,19 +43,10 @@
#include "nsIInputStream.h"
#include "nsNetUtil.h"
#include "nsStringStream.h"
#include "nsIXPConnect.h"
#include "nsIServiceManager.h"
#include "nsLayoutCID.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIDOMWindow.h"
#include "nsIPrivateDOMImplementation.h"
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMClassInfo.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
@ -67,10 +58,6 @@
#include "nsContentUtils.h"
#include "nsDOMJSUtils.h"
static const char* kLoadAsData = "loadAsData";
static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
// nsIDOMEventListener
nsresult
nsDOMParser::HandleEvent(nsIDOMEvent* aEvent)
@ -202,51 +189,27 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
nsresult rv;
nsCOMPtr<nsIBufferedInputStream> bufferedStream;
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(stream)) {
bufferedStream = do_CreateInstance(NS_BUFFEREDINPUTSTREAM_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = bufferedStream->Init(stream, 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), stream,
4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = bufferedStream;
}
nsCOMPtr<nsIPrincipal> principal;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (secMan) {
secMan->GetSubjectPrincipal(getter_AddRefs(principal));
}
// Try to find a base URI for the document we're creating.
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIXPCNativeCallContext> cc;
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
if(NS_SUCCEEDED(rv)) {
rv = xpc->GetCurrentNativeCallContext(getter_AddRefs(cc));
}
if (NS_SUCCEEDED(rv) && cc) {
JSContext* cx;
rv = cc->GetJSContext(&cx);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsIScriptContext *scriptContext = GetScriptContextFromJSContext(cx);
if (scriptContext) {
nsCOMPtr<nsIDOMWindow> window =
do_QueryInterface(scriptContext->GetGlobalObject());
if (window) {
nsCOMPtr<nsIDOMDocument> domdoc;
window->GetDocument(getter_AddRefs(domdoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
if (doc) {
baseURI = doc->GetBaseURI();
}
}
}
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(nsContentUtils::GetDocumentFromContext());
if (doc) {
baseURI = doc->GetBaseURI();
}
if (!baseURI) {
@ -262,28 +225,15 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
}
}
// Get and initialize a DOMImplementation
nsCOMPtr<nsIDOMDOMImplementation> implementation(do_CreateInstance(kIDOMDOMImplementationCID, &rv));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
if (baseURI) {
nsCOMPtr<nsIPrivateDOMImplementation> privImpl(do_QueryInterface(implementation));
if (privImpl) {
// XXXbz Is this really right? Why are we setting the documentURI to
// baseURI? But note that's what the StartDocumentLoad() below would do
// if we let it reset. In any case, this is odd, since the caller can
// set baseURI to anything it feels like, pretty much.
privImpl->Init(baseURI, baseURI, principal);
}
}
// Create an empty document from it
// XXXbz Is this really right? Why are we setting the documentURI to
// baseURI? But note that's what the StartDocumentLoad() below would do
// if we let it reset. In any case, this is odd, since the caller can
// set baseURI to anything it feels like, pretty much.
nsCOMPtr<nsIDOMDocument> domDocument;
rv = implementation->CreateDocument(EmptyString(),
EmptyString(),
nsnull,
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
baseURI, baseURI, principal,
getter_AddRefs(domDocument));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
NS_ENSURE_SUCCESS(rv, rv);
// Register as a load listener on the document
nsCOMPtr<nsIDOMEventReceiver> target(do_QueryInterface(domDocument));
@ -296,7 +246,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
rv = target->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMEventListener*,
proxy),
NS_GET_IID(nsIDOMLoadListener));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
NS_ENSURE_SUCCESS(rv, rv);
}
// Create a fake channel

Просмотреть файл

@ -43,16 +43,12 @@
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDocumentEncoder.h"
#include "nsIComponentManager.h"
#include "nsIContentSerializer.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsContentCID.h"
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsIURI.h"
#include "nsContentUtils.h"
#include "nsDOMError.h"
nsDOMSerializer::nsDOMSerializer()
{
@ -126,53 +122,6 @@ SetUpEncoder(nsIDOMNode *aRoot, const nsACString& aCharset,
return rv;
}
static nsresult
CheckSameOrigin(nsIDOMNode *aRoot)
{
// Make sure that the caller has permission to access the root
// Be sure to QI to nsINode to make sure we're passed a native
// object.
nsCOMPtr<nsINode> node(do_QueryInterface(aRoot));
if (NS_UNLIKELY(!node)) {
// We got a non-native object.
return NS_ERROR_INVALID_POINTER;
}
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRBool ubrEnabled = PR_FALSE;
rv = secMan->IsCapabilityEnabled("UniversalBrowserRead", &ubrEnabled);
NS_ENSURE_SUCCESS(rv, rv);
if (ubrEnabled) {
// UniversalBrowserRead is enabled (or we're not called from
// script), permit access.
return NS_OK;
}
nsCOMPtr<nsIPrincipal> subject;
rv = secMan->GetSubjectPrincipal(getter_AddRefs(subject));
NS_ENSURE_SUCCESS(rv, rv);
// XXXbz can we happen to not have a subject principal here?
// nsScriptSecurityManager::IsCapabilityEnabled doesn't actually use
// GetSubjectPrincipal, so not sure...
// In any case, no subject principal means access is allowed.
if (subject) {
// Check if the caller is from the same origin that the root is from.
return secMan->CheckSameOriginPrincipal(subject, node->NodePrincipal());
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMSerializer::SerializeToString(nsIDOMNode *aRoot, nsAString& _retval)
{
@ -180,12 +129,12 @@ nsDOMSerializer::SerializeToString(nsIDOMNode *aRoot, nsAString& _retval)
_retval.Truncate();
nsresult rv = CheckSameOrigin(aRoot);
if (NS_FAILED(rv))
return rv;
if (!nsContentUtils::CanCallerAccess(aRoot)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIDocumentEncoder> encoder;
rv = SetUpEncoder(aRoot, EmptyCString(), getter_AddRefs(encoder));
nsresult rv = SetUpEncoder(aRoot, EmptyCString(), getter_AddRefs(encoder));
if (NS_FAILED(rv))
return rv;
@ -202,12 +151,12 @@ nsDOMSerializer::SerializeToStream(nsIDOMNode *aRoot,
// The charset arg can be null, in which case we get the document's
// charset and use that when serializing.
nsresult rv = CheckSameOrigin(aRoot);
if (NS_FAILED(rv))
return rv;
if (!nsContentUtils::CanCallerAccess(aRoot)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIDocumentEncoder> encoder;
rv = SetUpEncoder(aRoot, aCharset, getter_AddRefs(encoder));
nsresult rv = SetUpEncoder(aRoot, aCharset, getter_AddRefs(encoder));
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -614,23 +614,9 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
}
}
rv = NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI, mPrincipal);
nsIDocShell *docShell = nsContentUtils::GetDocShellFromCaller();
if (docShell) {
nsCOMPtr<nsPresContext> presContext;
docShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
nsCOMPtr<nsISupports> container = presContext->GetContainer();
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aReturn);
if (document) {
document->SetContainer(container);
}
}
}
return rv;
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI, mPrincipal,
aReturn);
}
NS_IMETHODIMP

Просмотреть файл

@ -40,62 +40,26 @@
* A service that provides methods for synchronously loading a DOM in various ways.
*/
#include "nsSyncLoadService.h"
#include "nsCOMPtr.h"
#include "nsIChannel.h"
#include "nsIDOMLoadListener.h"
#include "nsIChannelEventSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIScriptContext.h"
#include "nsISyncLoadDOMService.h"
#include "nsString.h"
#include "nsWeakReference.h"
#include "jsapi.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIDOMEventReceiver.h"
#include "nsIJSContextStack.h"
#include "nsIPrivateDOMImplementation.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"
#include "nsContentCID.h"
#include "nsContentUtils.h"
#include "nsThreadUtils.h"
#include "nsNetUtil.h"
#include "nsIHttpChannel.h"
#include "nsIScriptLoader.h"
#include "nsIScriptLoaderObserver.h"
#include "nsIXMLContentSink.h"
#include "nsIContent.h"
#include "nsAutoPtr.h"
#include "nsLoadListenerProxy.h"
static const char kLoadAsData[] = "loadAsData";
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
// This is ugly, but nsXBLContentSink.h isn't exported
nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,
nsIURI* aURL,
nsISupports* aContainer);
class nsSyncLoadService : public nsISyncLoadDOMService
{
public:
nsSyncLoadService();
virtual ~nsSyncLoadService();
NS_DECL_ISUPPORTS
NS_DECL_NSISYNCLOADDOMSERVICE
static
nsresult PushSyncStreamToListener(nsIInputStream* aIn,
nsIStreamListener* aListener,
nsIChannel* aChannel);
};
#include "nsStreamUtils.h"
/**
* This class manages loading a single XML document
@ -107,7 +71,6 @@ class nsSyncLoader : public nsIDOMLoadListener,
public nsSupportsWeakReference
{
public:
nsSyncLoader();
virtual ~nsSyncLoader();
NS_DECL_ISUPPORTS
@ -116,8 +79,7 @@ public:
PRBool aChannelIsSync, PRBool aForceToXML,
nsIDOMDocument** aResult);
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
NS_DECL_NSIDOMEVENTLISTENER;
// nsIDOMLoadListener
NS_IMETHOD Load(nsIDOMEvent* aEvent);
@ -130,7 +92,7 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
protected:
private:
nsresult PushAsyncStream(nsIStreamListener* aListener);
nsresult PushSyncStream(nsIStreamListener* aListener);
@ -186,10 +148,6 @@ nsForceXMLListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
return mListener->OnStopRequest(aRequest, aContext, aStatusCode);
}
nsSyncLoader::nsSyncLoader()
{
}
nsSyncLoader::~nsSyncLoader()
{
if (mLoading && mChannel) {
@ -220,6 +178,9 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"),
PR_FALSE);
if (aLoaderURI) {
http->SetReferrer(aLoaderURI);
}
}
if (aLoaderURI) {
@ -244,7 +205,8 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
NS_ENSURE_SUCCESS(rv, rv);
// Create document
nsCOMPtr<nsIDocument> document = do_CreateInstance(kXMLDocumentCID, &rv);
nsCOMPtr<nsIDocument> document;
rv = NS_NewXMLDocument(getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
// Start the document load. Do this before we attach the load listener
@ -434,122 +396,96 @@ nsSyncLoader::GetInterface(const nsIID & aIID,
return QueryInterface(aIID, aResult);
}
nsSyncLoadService::nsSyncLoadService()
{
}
nsSyncLoadService::~nsSyncLoadService()
{
}
NS_IMPL_ISUPPORTS1(nsSyncLoadService,
nsISyncLoadDOMService)
static nsresult
LoadFromChannel(nsIChannel* aChannel, nsIURI *aLoaderURI, PRBool aChannelIsSync,
PRBool aForceToXML, nsIDOMDocument** aResult)
{
nsRefPtr<nsSyncLoader> loader = new nsSyncLoader();
if (!loader) {
return NS_ERROR_OUT_OF_MEMORY;
}
return loader->LoadDocument(aChannel, aLoaderURI, aChannelIsSync,
aForceToXML, aResult);
}
NS_IMETHODIMP
nsSyncLoadService::LoadDocument(nsIChannel* aChannel, nsIURI* aLoaderURI,
nsIDOMDocument** aResult)
{
nsRefPtr<nsSyncLoader> loader = new nsSyncLoader();
NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY);
return loader->LoadDocument(aChannel, aLoaderURI, PR_FALSE, PR_FALSE,
aResult);
return LoadFromChannel(aChannel, aLoaderURI, PR_FALSE, PR_FALSE, aResult);
}
NS_IMETHODIMP
nsSyncLoadService::LoadDocumentAsXML(nsIChannel* aChannel, nsIURI* aLoaderURI,
nsIDOMDocument** aResult)
{
nsRefPtr<nsSyncLoader> loader = new nsSyncLoader();
NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY);
return loader->LoadDocument(aChannel, aLoaderURI, PR_FALSE, PR_TRUE,
aResult);
return LoadFromChannel(aChannel, aLoaderURI, PR_FALSE, PR_TRUE, aResult);
}
nsresult
NS_IMETHODIMP
nsSyncLoadService::LoadLocalDocument(nsIChannel* aChannel, nsIURI* aLoaderURI,
nsIDOMDocument** _retval)
nsIDOMDocument** aResult)
{
nsSyncLoader* loader = new nsSyncLoader();
NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(loader);
nsresult rv = loader->LoadDocument(aChannel, aLoaderURI, PR_TRUE, PR_TRUE,
_retval);
NS_RELEASE(loader);
return rv;
return LoadFromChannel(aChannel, aLoaderURI, PR_TRUE, PR_TRUE, aResult);
}
/* static */
nsresult
nsSyncLoadService::LoadLocalXBLDocument(nsIChannel* aChannel,
nsIDOMDocument** _retval)
nsSyncLoadService::LoadDocument(nsIURI *aURI, nsIURI *aLoaderURI,
nsILoadGroup *aLoadGroup, PRBool aForceToXML,
nsIDOMDocument** aResult)
{
*_retval = nsnull;
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannel(getter_AddRefs(channel), aURI, nsnull,
aLoadGroup);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> in;
nsresult rv = aChannel->Open(getter_AddRefs(in));
if (NS_FAILED(rv)) {
return rv;
if (!aForceToXML) {
channel->SetContentType(NS_LITERAL_CSTRING("text/xml"));
}
// Get uri and loadgroup
nsCOMPtr<nsIURI> docURI;
rv = aChannel->GetURI(getter_AddRefs(docURI));
NS_ENSURE_SUCCESS(rv, rv);
PRBool isChrome = PR_FALSE, isResource = PR_FALSE;
PRBool isSync = (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
isChrome) ||
(NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) &&
isResource);
nsCOMPtr<nsILoadGroup> loadGroup;
rv = aChannel->GetLoadGroup(getter_AddRefs(loadGroup));
NS_ENSURE_SUCCESS(rv, rv);
// Create document and contentsink and set them up.
nsCOMPtr<nsIDocument> doc = do_CreateInstance(kXMLDocumentCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXMLContentSink> xblSink;
rv = NS_NewXBLContentSink(getter_AddRefs(xblSink), doc, docURI, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStreamListener> listener;
rv = doc->StartDocumentLoad("loadAsInteractiveData",
aChannel,
loadGroup,
nsnull,
getter_AddRefs(listener),
PR_TRUE,
xblSink);
NS_ENSURE_SUCCESS(rv, rv);
rv = PushSyncStreamToListener(in, listener, aChannel);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(doc, _retval);
return LoadFromChannel(channel, aLoaderURI, isSync, aForceToXML, aResult);
}
// static
/* static */
nsresult
nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
nsIStreamListener* aListener,
nsIChannel* aChannel)
{
// Set up buffering stream
nsresult rv;
nsCOMPtr<nsIInputStream> bufferedStream;
nsresult rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
aIn, 4096);
NS_ENSURE_SUCCESS(rv, rv);
if (!NS_InputStreamIsBuffered(aIn)) {
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), aIn,
4096);
NS_ENSURE_SUCCESS(rv, rv);
aIn = bufferedStream;
}
// Load
aListener->OnStartRequest(aChannel, nsnull);
PRUint32 sourceOffset = 0;
while (1) {
PRUint32 readCount = 0;
rv = bufferedStream->Available(&readCount);
rv = aIn->Available(&readCount);
if (NS_FAILED(rv) || !readCount) {
break;
}
rv = aListener->OnDataAvailable(aChannel, nsnull, bufferedStream,
sourceOffset, readCount);
rv = aListener->OnDataAvailable(aChannel, nsnull, aIn, sourceOffset,
readCount);
if (NS_FAILED(rv)) {
break;
}
@ -560,12 +496,3 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
return rv;
}
nsresult
NS_NewSyncLoadDOMService(nsISyncLoadDOMService** aResult)
{
*aResult = new nsSyncLoadService();
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult);
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Peter Van der Beken.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Van der Beken <peterv@propagandism.org>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* A service that provides methods for synchronously loading a DOM in various ways.
*/
#ifndef nsSyncLoadService_h__
#define nsSyncLoadService_h__
#include "nsISyncLoadDOMService.h"
class nsIInputStream;
class nsILoadGroup;
class nsIStreamListener;
class nsSyncLoadService : public nsISyncLoadDOMService
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISYNCLOADDOMSERVICE
/**
* Synchronously load the document from the specified URI.
*
* @param aURI URI to load the document from.
* @param aLoaderURI URI of loading document. For security checks and
* referrer header. May be null if no security checks
* should be done.
* @param aLoadGroup The loadgroup to use for loading the document.
* @param aForceToXML Whether to parse the document as XML, regardless of
* content type.
* @param aResult [out] The document loaded from the URI.
*/
static nsresult LoadDocument(nsIURI *aURI, nsIURI *aLoaderURI,
nsILoadGroup *aLoadGroup, PRBool aForceToXML,
nsIDOMDocument** aResult);
/**
* Read input stream aIn in chunks and deliver synchronously to aListener.
*
* @param aIn The stream to be read.
* @param aListener The listener that will receive
* OnStartRequest/OnDataAvailable/OnStopRequest
* notifications.
* @param aChannel The channel that aIn was opened from.
*/
static nsresult PushSyncStreamToListener(nsIInputStream* aIn,
nsIStreamListener* aListener,
nsIChannel* aChannel);
};
#endif // nsSyncLoadService_h__

Просмотреть файл

@ -38,15 +38,10 @@
#include "nsXMLHttpRequest.h"
#include "nsISimpleEnumerator.h"
#include "nsIXPConnect.h"
#include "nsIUnicodeEncoder.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsLayoutCID.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIPrivateDOMImplementation.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "nsIURI.h"
#include "nsILoadGroup.h"
#include "nsNetUtil.h"
@ -82,8 +77,7 @@
#include "nsDOMJSUtils.h"
#include "nsCOMArray.h"
#include "nsDOMClassInfo.h"
static const char* kLoadAsData = "loadAsData";
#include "nsIScriptableUConv.h"
#define LOAD_STR "load"
#define ERROR_STR "error"
@ -92,7 +86,6 @@ static const char* kLoadAsData = "loadAsData";
#define READYSTATE_STR "readystatechange"
// CIDs
static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
// State
#define XML_HTTP_REQUEST_UNINITIALIZED (1 << 0) // 0
@ -1059,8 +1052,8 @@ nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url)
nsAutoString user, password;
nsCOMPtr<nsIXPCNativeCallContext> cc;
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
if(NS_SUCCEEDED(rv)) {
nsIXPConnect *xpc = nsContentUtils::XPConnect();
if (xpc) {
rv = xpc->GetCurrentNativeCallContext(getter_AddRefs(cc));
}
@ -1081,9 +1074,10 @@ nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url)
rv = NS_NewURI(getter_AddRefs(targetURI), url, nsnull, GetBaseURI());
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (!secMan) {
return NS_ERROR_FAILURE;
}
rv = secMan->CheckConnect(cx, targetURI, "XMLHttpRequest","open");
if (NS_FAILED(rv))
@ -1135,69 +1129,6 @@ nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url)
return OpenRequest(method, url, async, user, password);
}
nsresult
nsXMLHttpRequest::GetStreamForWString(const PRUnichar* aStr,
PRInt32 aLength,
nsIInputStream** aStream)
{
nsresult rv;
nsCOMPtr<nsIUnicodeEncoder> encoder;
char* postData;
// We want to encode the string as utf-8, so get the right encoder
nsCOMPtr<nsICharsetConverterManager> charsetConv =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
rv = charsetConv->GetUnicodeEncoderRaw("UTF-8",
getter_AddRefs(encoder));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
// Convert to utf-8
PRInt32 charLength;
const PRUnichar* unicodeBuf = aStr;
PRInt32 unicodeLength = aLength;
rv = encoder->GetMaxLength(unicodeBuf, unicodeLength, &charLength);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
// Allocate extra space for the null-terminator
postData = (char*)nsMemory::Alloc(charLength + 1);
if (!postData) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = encoder->Convert(unicodeBuf,
&unicodeLength, postData, &charLength);
if (NS_FAILED(rv)) {
nsMemory::Free(postData);
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
if (!httpChannel) {
nsMemory::Free(postData);
return NS_ERROR_FAILURE;
}
// Null-terminate
postData[charLength] = '\0';
nsCOMPtr<nsIStringInputStream> inputStream(do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
if (NS_SUCCEEDED(rv)) {
rv = inputStream->AdoptData(postData, charLength);
if (NS_SUCCEEDED(rv)) {
return CallQueryInterface(inputStream, aStream);
}
}
// If we got here then something went wrong before the stream
// adopted the buffer.
nsMemory::Free(postData);
return NS_ERROR_FAILURE;
}
/*
* "Copy" from a stream.
*/
@ -1289,37 +1220,25 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
mState |= XML_HTTP_REQUEST_PARSEBODY;
ChangeState(XML_HTTP_REQUEST_LOADED);
nsresult rv;
// Get and initialize a DOMImplementation
nsCOMPtr<nsIDOMDOMImplementation> implementation =
do_CreateInstance(kIDOMDOMImplementationCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrivateDOMImplementation> privImpl =
do_QueryInterface(implementation);
if (privImpl) {
// XXXbz this is probably all wrong when not called from JS... and possibly
// even then! Fixing that requires giving XMLHttpRequest some principals
// when inited. Until then, cases when we don't actually parse the
// document will give our mDocument he wrong principal. I'm just not sure
// how wrong it can get... Shouldn't be too bad as long as mScriptContext
// is sane, I guess.
nsCOMPtr<nsIDocument> doc = GetDocumentFromScriptContext(mScriptContext);
nsIURI* uri = GetBaseURI();
nsIPrincipal* principal = nsnull;
if (doc) {
principal = doc->NodePrincipal();
}
privImpl->Init(uri, uri, principal);
// XXXbz this is probably all wrong when not called from JS... and possibly
// even then! Fixing that requires giving XMLHttpRequest some principals
// when inited. Until then, cases when we don't actually parse the
// document will give our mDocument he wrong principal. I'm just not sure
// how wrong it can get... Shouldn't be too bad as long as mScriptContext
// is sane, I guess.
nsCOMPtr<nsIDocument> doc = GetDocumentFromScriptContext(mScriptContext);
nsIURI* uri = GetBaseURI();
nsIPrincipal* principal = nsnull;
if (doc) {
principal = doc->NodePrincipal();
}
// Create an empty document from it
const nsAString& emptyStr = EmptyString();
rv = implementation->CreateDocument(emptyStr,
emptyStr,
nsnull,
getter_AddRefs(mDocument));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsresult rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, uri,
uri, principal,
getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
// Reset responseBody
mResponseBody.Truncate();
@ -1614,11 +1533,16 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
if (serial) {
// Convert to a byte stream
rv = GetStreamForWString(serial.get(),
nsCRT::strlen(serial.get()),
getter_AddRefs(postDataStream));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIScriptableUnicodeConverter> converter =
do_CreateInstance("@mozilla.org/intl/scriptableunicodeconverter", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = converter->SetCharset("UTF-8");
NS_ENSURE_SUCCESS(rv, rv);
rv = converter->ConvertToInputStream(serial,
getter_AddRefs(postDataStream));
NS_ENSURE_SUCCESS(rv, rv);
}
if (postDataStream) {
@ -1742,10 +1666,10 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
// Prevent modification to certain HTTP headers (see bug 302263), unless
// the executing script has UniversalBrowserWrite permission.
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secMan)
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (!secMan) {
return NS_ERROR_FAILURE;
}
PRBool privileged;
nsresult rv = secMan->IsCapabilityEnabled("UniversalBrowserWrite",
@ -1976,10 +1900,10 @@ nsXMLHttpRequest::OnChannelRedirect(nsIChannel *aOldChannel,
if (!cx)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (!secMan) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIURI> newURI;
rv = aNewChannel->GetURI(getter_AddRefs(newURI)); // The redirected URI

Просмотреть файл

@ -122,9 +122,6 @@ public:
protected:
typedef nsMarkedJSFunctionHolder<nsIDOMEventListener> ListenerHolder;
nsresult GetStreamForWString(const PRUnichar* aStr,
PRInt32 aLength,
nsIInputStream** aStream);
nsresult DetectCharset(nsACString& aCharset);
nsresult ConvertBodyToText(nsAString& aOutBuffer);
static NS_METHOD StreamReaderFunc(nsIInputStream* in,

Просмотреть файл

@ -169,7 +169,6 @@ protected:
nsXBLProtoImplField* mField;
};
// This is also declared in nsSyncLoadService.cpp
nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,

Просмотреть файл

@ -74,7 +74,7 @@
#include "nsXULAtoms.h"
#include "nsCRT.h"
#include "nsContentUtils.h"
#include "nsISyncLoadDOMService.h"
#include "nsSyncLoadService.h"
#include "nsIDOM3Node.h"
#include "nsContentPolicyUtils.h"
@ -90,9 +90,6 @@
#include "nsIDOMLoadListener.h"
#include "nsIDOMEventGroup.h"
// Static IIDs/CIDs. Try to minimize these.
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
static PRBool IsChromeOrResourceURI(nsIURI* aURI)
{
PRBool isChrome = PR_FALSE;
@ -1149,32 +1146,31 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
if (IsChromeOrResourceURI(aDocumentURI))
aForceSyncLoad = PR_TRUE;
if(!aForceSyncLoad) {
// Create the XML document
nsCOMPtr<nsIDocument> doc = do_CreateInstance(kXMLDocumentCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Create document and contentsink and set them up.
nsCOMPtr<nsIDocument> doc;
rv = NS_NewXMLDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), aDocumentURI, nsnull, loadGroup);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIXMLContentSink> xblSink;
rv = NS_NewXBLContentSink(getter_AddRefs(xblSink), doc, aDocumentURI, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStreamListener> listener;
nsCOMPtr<nsIXMLContentSink> xblSink;
NS_NewXBLContentSink(getter_AddRefs(xblSink), doc, aDocumentURI, nsnull);
if (!xblSink)
return NS_ERROR_FAILURE;
// Open channel
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), aDocumentURI, nsnull, loadGroup);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv = doc->StartDocumentLoad("loadAsInteractiveData",
channel,
loadGroup,
nsnull,
getter_AddRefs(listener),
PR_TRUE,
xblSink))) {
NS_ERROR("Failure to init XBL doc prior to load.");
return rv;
}
nsCOMPtr<nsIStreamListener> listener;
rv = doc->StartDocumentLoad("loadAsInteractiveData",
channel,
loadGroup,
nsnull,
getter_AddRefs(listener),
PR_TRUE,
xblSink);
NS_ENSURE_SUCCESS(rv, rv);
if (!aForceSyncLoad) {
// We can be asynchronous
nsXBLStreamListener* xblListener = new nsXBLStreamListener(this, listener, aBoundDocument, doc);
NS_ENSURE_TRUE(xblListener,NS_ERROR_OUT_OF_MEMORY);
@ -1204,24 +1200,16 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
}
// Now do a blocking synchronous parse of the file.
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsISyncLoadDOMService> loader =
do_GetService("@mozilla.org/content/syncload-dom-service;1", &rv);
nsCOMPtr<nsIInputStream> in;
rv = channel->Open(getter_AddRefs(in));
NS_ENSURE_SUCCESS(rv, rv);
// Open channel
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), aDocumentURI, nsnull, loadGroup);
rv = nsSyncLoadService::PushSyncStreamToListener(in, listener, channel);
NS_ENSURE_SUCCESS(rv, rv);
rv = loader->LoadLocalXBLDocument(channel, getter_AddRefs(domDoc));
if (rv == NS_ERROR_FILE_NOT_FOUND) {
return NS_OK;
}
NS_ENSURE_SUCCESS(rv, rv);
doc.swap(*aResult);
return CallQueryInterface(domDoc, aResult);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -105,10 +105,6 @@
#define kXSLType "text/xsl"
static const char kLoadAsData[] = "loadAsData";
// XXX Open Issues:
// 1) what's not allowed - We need to figure out which HTML tags
// (prefixed with a HTML namespace qualifier) are explicitly not

Просмотреть файл

@ -95,8 +95,6 @@
// XXX The XML world depends on the html atoms
#include "nsHTMLAtoms.h"
static const char kLoadAsData[] = "loadAsData";
// ==================================================================
// =

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsIBindingManager.h"
#include "nsIObserver.h"
#include "nsIXSLTProcessor.h"
#include "nsISyncLoadDOMService.h"
#include "nsSyncLoadService.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
@ -126,15 +126,9 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument)
NS_LITERAL_CSTRING("chrome://global/content/xml/XMLPrettyPrint.xsl"));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), xslUri, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> xslDocument;
nsCOMPtr<nsISyncLoadDOMService> loader =
do_GetService("@mozilla.org/content/syncload-dom-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = loader->LoadLocalDocument(channel, nsnull, getter_AddRefs(xslDocument));
rv = nsSyncLoadService::LoadDocument(xslUri, nsnull, nsnull, PR_TRUE,
getter_AddRefs(xslDocument));
NS_ENSURE_SUCCESS(rv, rv);
// Transform the document

Просмотреть файл

@ -94,4 +94,5 @@ INCLUDES += \
-I$(srcdir) \
-I$(srcdir)/../xpath \
-I$(srcdir)/../xslt \
-I$(srcdir)/../../../base/src \
$(NULL)

Просмотреть файл

@ -43,7 +43,7 @@
#ifndef TX_EXE
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsISyncLoadDOMService.h"
#include "nsSyncLoadService.h"
#include "nsNetUtil.h"
#else
#include "expat_config.h"
@ -101,24 +101,12 @@ txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
nsIURI *loaderUri = loaderDocument->GetDocumentURI();
NS_ENSURE_TRUE(loaderUri, NS_ERROR_FAILURE);
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), documentURI, nsnull,
loadGroup);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel);
if (http) {
http->SetReferrer(loaderUri);
}
nsCOMPtr<nsISyncLoadDOMService> loader =
do_GetService("@mozilla.org/content/syncload-dom-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Raw pointer, we want the resulting txXPathNode to hold a reference to
// the document.
nsIDOMDocument* theDocument = nsnull;
rv = loader->LoadDocumentAsXML(channel, loaderUri, &theDocument);
rv = nsSyncLoadService::LoadDocument(documentURI, loaderUri, loadGroup,
PR_TRUE, &theDocument);
if (NS_FAILED(rv)) {
aErrMsg.Append(NS_LITERAL_STRING("Document load of ") +
aHref + NS_LITERAL_STRING(" failed."));

Просмотреть файл

@ -130,6 +130,7 @@ INCLUDES += \
-I$(srcdir)/../base \
-I$(srcdir)/../xml \
-I$(srcdir)/../xpath \
-I$(srcdir)/../../../base/src \
$(NULL)
ifdef MOZ_XSLT_STANDALONE

Просмотреть файл

@ -53,7 +53,7 @@
#include "nsIScriptSecurityManager.h"
#include "nsContentPolicyUtils.h"
#include "nsIStreamConverterService.h"
#include "nsISyncLoadDOMService.h"
#include "nsSyncLoadService.h"
#include "nsIURI.h"
#include "nsIPrincipal.h"
#include "nsIWindowWatcher.h"
@ -68,7 +68,6 @@
#include "txXMLUtils.h"
#include "nsAttrName.h"
static const char kLoadAsData[] = "loadAsData";
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
static void
@ -703,9 +702,6 @@ public:
protected:
nsAutoRefCnt mRefCnt;
private:
nsCOMPtr<nsISyncLoadDOMService> mLoadService;
};
txSyncCompileObserver::txSyncCompileObserver()
@ -749,29 +745,11 @@ txSyncCompileObserver::loadURI(const nsAString& aUri,
rv = CheckLoadURI(uri, referrerUri, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
if (!mLoadService) {
mLoadService =
do_GetService("@mozilla.org/content/syncload-dom-service;1");
NS_ENSURE_TRUE(mLoadService, NS_ERROR_OUT_OF_MEMORY);
}
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), uri);
NS_ENSURE_SUCCESS(rv, rv);
// This is probably called by js, a loadGroup for the channel doesn't
// make sense.
channel->SetContentType(NS_LITERAL_CSTRING("text/xml"));
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) {
httpChannel->SetReferrer(referrerUri);
}
nsCOMPtr<nsIDOMDocument> document;
rv = mLoadService->LoadDocument(channel, referrerUri,
getter_AddRefs(document));
rv = nsSyncLoadService::LoadDocument(uri, referrerUri, nsnull, PR_FALSE,
getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
rv = handleNode(document, aCompiler);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -93,7 +93,7 @@
#include "nsWyciwygProtocolHandler.h"
#include "nsContentAreaDragDrop.h"
#include "nsContentList.h"
#include "nsISyncLoadDOMService.h"
#include "nsSyncLoadService.h"
#include "nsBox.h"
#include "nsIFrameTraversal.h"
#ifndef MOZ_CAIRO_GFX
@ -341,7 +341,6 @@ nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult);
nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
nsresult NS_NewXBLService(nsIXBLService** aResult);
nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
nsresult NS_NewSyncLoadDOMService(nsISyncLoadDOMService** aResult);
nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult);
NS_IMETHODIMP NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
@ -461,7 +460,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsInspectorCSSUtils)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentAreaDragDrop)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy)
MAKE_CTOR(CreateSyncLoadDOMService, nsISyncLoadDOMService, NS_NewSyncLoadDOMService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoadService)
MAKE_CTOR(CreatePluginDocument, nsIDocument, NS_NewPluginDocument)
#ifdef MOZ_ENABLE_CANVAS
@ -1162,7 +1161,7 @@ static const nsModuleComponentInfo gComponents[] = {
{ "SyncLoad DOM Service",
NS_SYNCLOADDOMSERVICE_CID,
NS_SYNCLOADDOMSERVICE_CONTRACTID,
CreateSyncLoadDOMService },
nsSyncLoadServiceConstructor },
// DOM objects
{ "Script Object Factory",