mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 757485, remove nsIXBLService and use nsXBLService directly, r=bz
This commit is contained in:
parent
0f43ea2990
commit
b9d2d5f9e3
@ -73,7 +73,6 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
@ -68,7 +68,6 @@
|
||||
#include "nsIJSON.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIMultiPartChannel.h"
|
||||
#include "nsIRefreshURI.h"
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPIBoxObject.h"
|
||||
#include "nsClientRect.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "mozilla/css/StyleRule.h"
|
||||
#include "nsRuleWalker.h"
|
||||
|
@ -10,7 +10,7 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PARALLEL_DIRS = public src builtin
|
||||
PARALLEL_DIRS = src builtin
|
||||
|
||||
TEST_DIRS += test
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
#
|
||||
# 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/.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
|
||||
EXPORTS = \
|
||||
nsIXBLService.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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/. */
|
||||
|
||||
/*
|
||||
|
||||
Private interface to the XBL service
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIXBLService_h__
|
||||
#define nsIXBLService_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDOMNodeList;
|
||||
class nsXBLBinding;
|
||||
class nsXBLDocumentInfo;
|
||||
class nsIURI;
|
||||
class nsIAtom;
|
||||
class nsIPrincipal;
|
||||
|
||||
#define NS_IXBLSERVICE_IID \
|
||||
{ 0x8a25483c, 0x1ac6, 0x4796, { 0xa6, 0x12, 0x5a, 0xe0, 0x5c, 0x83, 0x65, 0x0b } }
|
||||
|
||||
class nsIXBLService : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXBLSERVICE_IID)
|
||||
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
// onto the element. aOriginPrincipal must not be null here.
|
||||
NS_IMETHOD LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal, bool aAugmentFlag,
|
||||
nsXBLBinding** aBinding, bool* aResolveStyle) = 0;
|
||||
|
||||
// Indicates whether or not a binding is fully loaded.
|
||||
NS_IMETHOD BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady) = 0;
|
||||
|
||||
// Retrieves our base class (e.g., tells us what type of frame and content node to build)
|
||||
NS_IMETHOD ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult) = 0;
|
||||
|
||||
// This method checks the hashtable and then calls FetchBindingDocument on a
|
||||
// miss. aOriginPrincipal or aBoundDocument may be null to bypass security
|
||||
// checks.
|
||||
NS_IMETHOD LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsIURI* aBindingURI,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
bool aForceSyncLoad,
|
||||
nsXBLDocumentInfo** aResult) = 0;
|
||||
|
||||
// Hooks up the global key event handlers to the document root.
|
||||
NS_IMETHOD AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget) = 0;
|
||||
NS_IMETHOD DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget) = 0;
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIXBLService, NS_IXBLSERVICE_IID)
|
||||
|
||||
#endif // nsIXBLService_h__
|
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
@ -845,11 +845,9 @@ nsBindingManager::AddLayeredBinding(nsIContent* aContent, nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal)
|
||||
{
|
||||
// First we need to load our binding.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXBLService> xblService =
|
||||
do_GetService("@mozilla.org/xbl;1", &rv);
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Load the bindings.
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
@ -920,11 +918,9 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc,
|
||||
NS_PRECONDITION(aURL, "Must have a URI to load!");
|
||||
|
||||
// First we need to load our binding.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXBLService> xblService =
|
||||
do_GetService("@mozilla.org/xbl;1", &rv);
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Load the binding doc.
|
||||
nsRefPtr<nsXBLDocumentInfo> info;
|
||||
|
@ -23,7 +23,6 @@ class nsIAtom;
|
||||
class nsIDocument;
|
||||
class nsIScriptContext;
|
||||
class nsSupportsHashtable;
|
||||
class nsIXBLService;
|
||||
class nsFixedSizeAllocator;
|
||||
class nsXBLProtoImplField;
|
||||
class nsXBLBinding;
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXBLResourceLoader.h"
|
||||
#include "nsXBLPrototypeResources.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXBLResourceLoader.h"
|
||||
#include "nsXBLPrototypeResources.h"
|
||||
@ -202,7 +202,10 @@ nsXBLResourceLoader::AddResourceListener(nsIContent* aBoundElement)
|
||||
void
|
||||
nsXBLResourceLoader::NotifyBoundElements()
|
||||
{
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return;
|
||||
|
||||
nsIURI* bindingURI = mBinding->BindingURI();
|
||||
|
||||
PRUint32 eltCount = mBoundElements.Count();
|
||||
|
@ -58,6 +58,8 @@ using namespace mozilla;
|
||||
|
||||
#define NS_MAX_XBL_BINDING_RECURSION 20
|
||||
|
||||
nsXBLService* nsXBLService::gInstance = nsnull;
|
||||
|
||||
static bool
|
||||
IsAncestorBinding(nsIDocument* aDocument,
|
||||
nsIURI* aChildBindingURI,
|
||||
@ -127,8 +129,7 @@ public:
|
||||
|
||||
// Get the binding.
|
||||
bool ready = false;
|
||||
gXBLService->BindingReady(mBoundElement, mBindingURI, &ready);
|
||||
|
||||
nsXBLService::GetInstance()->BindingReady(mBoundElement, mBindingURI, &ready);
|
||||
if (!ready)
|
||||
return;
|
||||
|
||||
@ -156,26 +157,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static nsIXBLService* gXBLService;
|
||||
static int gRefCnt;
|
||||
|
||||
protected:
|
||||
nsXBLBindingRequest(nsIURI* aURI, nsIContent* aBoundElement)
|
||||
: mBindingURI(aURI),
|
||||
mBoundElement(aBoundElement)
|
||||
{
|
||||
gRefCnt++;
|
||||
if (gRefCnt == 1) {
|
||||
CallGetService("@mozilla.org/xbl;1", &gXBLService);
|
||||
}
|
||||
}
|
||||
|
||||
~nsXBLBindingRequest()
|
||||
{
|
||||
gRefCnt--;
|
||||
if (gRefCnt == 0) {
|
||||
NS_IF_RELEASE(gXBLService);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@ -193,9 +179,6 @@ static const PRInt32 kNumBuckets = sizeof(kBucketSizes)/sizeof(size_t);
|
||||
static const PRInt32 kNumElements = 64;
|
||||
static const PRInt32 kInitialSize = sizeof(nsXBLBindingRequest) * kNumElements;
|
||||
|
||||
nsIXBLService* nsXBLBindingRequest::gXBLService = nsnull;
|
||||
int nsXBLBindingRequest::gRefCnt = 0;
|
||||
|
||||
// nsXBLStreamListener, a helper class used for
|
||||
// asynchronous parsing of URLs
|
||||
/* Header file */
|
||||
@ -207,8 +190,7 @@ public:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
nsXBLStreamListener(nsXBLService* aXBLService,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsXBLStreamListener(nsIDocument* aBoundDocument,
|
||||
nsIXMLContentSink* aSink,
|
||||
nsIDocument* aBindingDocument);
|
||||
~nsXBLStreamListener();
|
||||
@ -217,8 +199,6 @@ public:
|
||||
bool HasRequest(nsIURI* aURI, nsIContent* aBoundElement);
|
||||
|
||||
private:
|
||||
nsXBLService* mXBLService; // [WEAK]
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mInner;
|
||||
nsAutoTArray<nsXBLBindingRequest*, 8> mBindingRequests;
|
||||
|
||||
@ -233,14 +213,12 @@ NS_IMPL_ISUPPORTS3(nsXBLStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIDOMEventListener)
|
||||
|
||||
nsXBLStreamListener::nsXBLStreamListener(nsXBLService* aXBLService,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsXBLStreamListener::nsXBLStreamListener(nsIDocument* aBoundDocument,
|
||||
nsIXMLContentSink* aSink,
|
||||
nsIDocument* aBindingDocument)
|
||||
: mSink(aSink), mBindingDocument(aBindingDocument)
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
mXBLService = aXBLService;
|
||||
mBoundDocument = do_GetWeakReference(aBoundDocument);
|
||||
}
|
||||
|
||||
@ -248,7 +226,7 @@ nsXBLStreamListener::~nsXBLStreamListener()
|
||||
{
|
||||
for (PRUint32 i = 0; i < mBindingRequests.Length(); i++) {
|
||||
nsXBLBindingRequest* req = mBindingRequests.ElementAt(i);
|
||||
nsXBLBindingRequest::Destroy(mXBLService->mPool, req);
|
||||
nsXBLBindingRequest::Destroy(nsXBLService::GetInstance()->mPool, req);
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,7 +390,6 @@ nsXBLStreamListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
// Implementation /////////////////////////////////////////////////////////////////
|
||||
|
||||
// Static member variable initialization
|
||||
PRUint32 nsXBLService::gRefCnt = 0;
|
||||
bool nsXBLService::gAllowDataURIs = false;
|
||||
|
||||
nsHashtable* nsXBLService::gClassTable = nsnull;
|
||||
@ -422,38 +399,45 @@ PRUint32 nsXBLService::gClassLRUListLength = 0;
|
||||
PRUint32 nsXBLService::gClassLRUListQuota = 64;
|
||||
|
||||
// Implement our nsISupports methods
|
||||
NS_IMPL_ISUPPORTS3(nsXBLService, nsIXBLService, nsIObserver, nsISupportsWeakReference)
|
||||
NS_IMPL_ISUPPORTS2(nsXBLService, nsIObserver, nsISupportsWeakReference)
|
||||
|
||||
void
|
||||
nsXBLService::Init()
|
||||
{
|
||||
gInstance = new nsXBLService();
|
||||
NS_ADDREF(gInstance);
|
||||
|
||||
// Register the first (and only) nsXBLService as a memory pressure observer
|
||||
// so it can flush the LRU list in low-memory situations.
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(gInstance, "memory-pressure", true);
|
||||
}
|
||||
|
||||
// Constructors/Destructors
|
||||
nsXBLService::nsXBLService(void)
|
||||
{
|
||||
mPool.Init("XBL Binding Requests", kBucketSizes, kNumBuckets, kInitialSize);
|
||||
|
||||
gRefCnt++;
|
||||
if (gRefCnt == 1) {
|
||||
gClassTable = new nsHashtable();
|
||||
}
|
||||
gClassTable = new nsHashtable();
|
||||
|
||||
Preferences::AddBoolVarCache(&gAllowDataURIs, "layout.debug.enable_data_xbl");
|
||||
}
|
||||
|
||||
nsXBLService::~nsXBLService(void)
|
||||
{
|
||||
gRefCnt--;
|
||||
if (gRefCnt == 0) {
|
||||
// Walk the LRU list removing and deleting the nsXBLJSClasses.
|
||||
FlushMemory();
|
||||
// Walk the LRU list removing and deleting the nsXBLJSClasses.
|
||||
FlushMemory();
|
||||
|
||||
// Any straggling nsXBLJSClass instances held by unfinalized JS objects
|
||||
// created for bindings will be deleted when those objects are finalized
|
||||
// (and not put on gClassLRUList, because length >= quota).
|
||||
gClassLRUListLength = gClassLRUListQuota = 0;
|
||||
// Any straggling nsXBLJSClass instances held by unfinalized JS objects
|
||||
// created for bindings will be deleted when those objects are finalized
|
||||
// (and not put on gClassLRUList, because length >= quota).
|
||||
gClassLRUListLength = gClassLRUListQuota = 0;
|
||||
|
||||
// At this point, the only hash table entries should be for referenced
|
||||
// XBL class structs held by unfinalized JS binding objects.
|
||||
delete gClassTable;
|
||||
gClassTable = nsnull;
|
||||
}
|
||||
// At this point, the only hash table entries should be for referenced
|
||||
// XBL class structs held by unfinalized JS binding objects.
|
||||
delete gClassTable;
|
||||
gClassTable = nsnull;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -471,7 +455,7 @@ nsXBLService::IsChromeOrResourceURI(nsIURI* aURI)
|
||||
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
// onto the element.
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal, bool aAugmentFlag,
|
||||
nsXBLBinding** aBinding, bool* aResolveStyle)
|
||||
@ -610,18 +594,6 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
|
||||
nsIAtom** aResult)
|
||||
{
|
||||
nsIDocument* document = aContent->OwnerDoc();
|
||||
*aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID);
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// AttachGlobalKeyHandler
|
||||
//
|
||||
@ -629,7 +601,7 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
|
||||
// event receiver (either a document or an content node). If the receiver is content,
|
||||
// then extra work needs to be done to hook it up to the document (XXX WHY??)
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsXBLService::AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget)
|
||||
{
|
||||
// check if the receiver is a content node (not a document), and hook
|
||||
@ -686,7 +658,7 @@ nsXBLService::AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget)
|
||||
//
|
||||
// Removes a key handler added by DeatchGlobalKeyHandler.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsXBLService::DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEventTarget> piTarget = aTarget;
|
||||
@ -749,9 +721,10 @@ nsXBLService::FlushMemory()
|
||||
|
||||
// Internal helper methods ////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsXBLService::BindingReady(nsIContent* aBoundElement,
|
||||
nsIURI* aURI,
|
||||
bool* aIsReady)
|
||||
nsresult
|
||||
nsXBLService::BindingReady(nsIContent* aBoundElement,
|
||||
nsIURI* aURI,
|
||||
bool* aIsReady)
|
||||
{
|
||||
// Don't do a security check here; we know this binding is set to go.
|
||||
return GetBinding(aBoundElement, aURI, true, nsnull, aIsReady, nsnull);
|
||||
@ -921,7 +894,7 @@ IsSystemOrChromeURLPrincipal(nsIPrincipal* aPrincipal)
|
||||
return NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsIURI* aBindingURI,
|
||||
@ -1130,7 +1103,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
||||
if (!aForceSyncLoad) {
|
||||
// We can be asynchronous
|
||||
nsXBLStreamListener* xblListener =
|
||||
new nsXBLStreamListener(this, aBoundDocument, xblSink, doc);
|
||||
new nsXBLStreamListener(aBoundDocument, xblSink, doc);
|
||||
NS_ENSURE_TRUE(xblListener,NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Add ourselves to the list of loading docs.
|
||||
@ -1183,25 +1156,3 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult NS_NewXBLService(nsIXBLService** aResult);
|
||||
|
||||
nsresult
|
||||
NS_NewXBLService(nsIXBLService** aResult)
|
||||
{
|
||||
nsXBLService* result = new nsXBLService;
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult = result);
|
||||
|
||||
// Register the first (and only) nsXBLService as a memory pressure observer
|
||||
// so it can flush the LRU list in low-memory situations.
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->AddObserver(result, "memory-pressure", true);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "jsapi.h" // nsXBLJSClass derives from JSClass
|
||||
@ -17,49 +17,56 @@ class nsXBLBinding;
|
||||
class nsXBLDocumentInfo;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
class nsSupportsHashtable;
|
||||
class nsHashtable;
|
||||
class nsIDOMEventTarget;
|
||||
|
||||
class nsXBLService : public nsIXBLService,
|
||||
public nsIObserver,
|
||||
class nsXBLService : public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
static nsXBLService* gInstance;
|
||||
|
||||
static void Init();
|
||||
|
||||
static void Shutdown() {
|
||||
NS_IF_RELEASE(gInstance);
|
||||
}
|
||||
|
||||
static nsXBLService* GetInstance() { return gInstance; }
|
||||
|
||||
static bool IsChromeOrResourceURI(nsIURI* aURI);
|
||||
|
||||
// This function loads a particular XBL file and installs all of the bindings
|
||||
// onto the element. aOriginPrincipal must not be null here.
|
||||
NS_IMETHOD LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal, bool aAugmentFlag,
|
||||
nsXBLBinding** aBinding, bool* aResolveStyle);
|
||||
nsresult LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal, bool aAugmentFlag,
|
||||
nsXBLBinding** aBinding, bool* aResolveStyle);
|
||||
|
||||
// Indicates whether or not a binding is fully loaded.
|
||||
NS_IMETHOD BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady);
|
||||
|
||||
// Gets the object's base class type.
|
||||
NS_IMETHOD ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult);
|
||||
nsresult BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady);
|
||||
|
||||
// This method checks the hashtable and then calls FetchBindingDocument on a
|
||||
// miss. aOriginPrincipal or aBoundDocument may be null to bypass security
|
||||
// checks.
|
||||
NS_IMETHOD LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsIURI* aBindingURI,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
bool aForceSyncLoad,
|
||||
nsXBLDocumentInfo** aResult);
|
||||
nsresult LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
||||
nsIDocument* aBoundDocument,
|
||||
nsIURI* aBindingURI,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
bool aForceSyncLoad,
|
||||
nsXBLDocumentInfo** aResult);
|
||||
|
||||
// Used by XUL key bindings and for window XBL.
|
||||
NS_IMETHOD AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
|
||||
NS_IMETHOD DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
|
||||
static nsresult AttachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
|
||||
static nsresult DetachGlobalKeyHandler(nsIDOMEventTarget* aTarget);
|
||||
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
public:
|
||||
private:
|
||||
nsXBLService();
|
||||
virtual ~nsXBLService();
|
||||
|
||||
@ -106,8 +113,6 @@ protected:
|
||||
|
||||
// MEMBER VARIABLES
|
||||
public:
|
||||
static PRUint32 gRefCnt; // A count of XBLservice instances.
|
||||
|
||||
static bool gDisableChromeCache;
|
||||
|
||||
static nsHashtable* gClassTable; // A table of nsXBLJSClass objects.
|
||||
|
@ -71,10 +71,8 @@ void nsXBLSpecialDocInfo::LoadDocInfo()
|
||||
return;
|
||||
mInitialized = true;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXBLService> xblService =
|
||||
do_GetService("@mozilla.org/xbl;1", &rv);
|
||||
if (NS_FAILED(rv) || !xblService)
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return;
|
||||
|
||||
// Obtain the platform doc info
|
||||
|
@ -14,7 +14,6 @@ class nsIDOMElement;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDOMKeyEvent;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIXBLDocumentInfo;
|
||||
class nsXBLSpecialDocInfo;
|
||||
class nsXBLPrototypeHandler;
|
||||
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
@ -105,9 +104,6 @@
|
||||
|
||||
namespace css = mozilla::css;
|
||||
|
||||
// Global object maintenance
|
||||
nsIXBLService * nsXULElement::gXBLService = nsnull;
|
||||
|
||||
/**
|
||||
* A tearoff class for nsXULElement to implement nsIScriptEventHandlerOwner.
|
||||
*/
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsAttrAndChildArray.h"
|
||||
#include "nsGkAtoms.h"
|
||||
@ -389,20 +388,6 @@ public:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
public:
|
||||
static nsIXBLService* GetXBLService() {
|
||||
if (!gXBLService)
|
||||
CallGetService("@mozilla.org/xbl;1", &gXBLService);
|
||||
return gXBLService;
|
||||
}
|
||||
static void ReleaseGlobals() {
|
||||
NS_IF_RELEASE(gXBLService);
|
||||
}
|
||||
|
||||
protected:
|
||||
// pseudo-constants
|
||||
static nsIXBLService* gXBLService;
|
||||
|
||||
public:
|
||||
nsXULElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
||||
#include "rdf.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
@ -1699,10 +1699,7 @@ nsXULDocument::AddElementToDocumentPost(Element* aElement)
|
||||
// We need to pay special attention to the keyset tag to set up a listener
|
||||
if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) {
|
||||
// Create our XUL key listener and hook it up.
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
if (xblService) {
|
||||
xblService->AttachGlobalKeyHandler(aElement);
|
||||
}
|
||||
nsXBLService::AttachGlobalKeyHandler(aElement);
|
||||
}
|
||||
|
||||
// See if we need to attach a XUL template to this node
|
||||
@ -1775,10 +1772,7 @@ nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aContent)
|
||||
nsresult rv;
|
||||
|
||||
if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) {
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
if (xblService) {
|
||||
xblService->DetachGlobalKeyHandler(aElement);
|
||||
}
|
||||
nsXBLService::DetachGlobalKeyHandler(aElement);
|
||||
}
|
||||
|
||||
// 1. Remove any children from the document.
|
||||
|
@ -153,7 +153,7 @@
|
||||
#include "nsDOMCSSAttrDeclaration.h"
|
||||
|
||||
// XBL related includes.
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -8030,7 +8030,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// We have a binding that must be installed.
|
||||
bool dummy;
|
||||
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
|
@ -183,7 +183,7 @@
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
|
||||
// used for popup blocking, needs to be converted to something
|
||||
// belonging to the back-end like nsIContentPolicy
|
||||
@ -1718,10 +1718,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
nsIDOMWindow* privateRoot = nsGlobalWindow::GetPrivateRoot();
|
||||
|
||||
if (privateRoot == static_cast<nsIDOMWindow*>(this)) {
|
||||
nsCOMPtr<nsIXBLService> xblService = do_GetService("@mozilla.org/xbl;1");
|
||||
if (xblService) {
|
||||
xblService->AttachGlobalKeyHandler(mChromeEventHandler);
|
||||
}
|
||||
nsXBLService::AttachGlobalKeyHandler(mChromeEventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@
|
||||
|
||||
#include "nsIScrollableFrame.h"
|
||||
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsXBLService.h"
|
||||
|
||||
#undef NOISY_FIRST_LETTER
|
||||
|
||||
@ -194,9 +194,6 @@ NS_NewSVGFEUnstyledLeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
// Global object maintenance
|
||||
nsIXBLService * nsCSSFrameConstructor::gXBLService = nsnull;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Set the environment variable GECKO_FRAMECTOR_DEBUG_FLAGS to one or
|
||||
// more of the following flags (comma separated) for handy debug
|
||||
@ -1415,17 +1412,6 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument,
|
||||
#endif
|
||||
}
|
||||
|
||||
nsIXBLService * nsCSSFrameConstructor::GetXBLService()
|
||||
{
|
||||
if (!gXBLService) {
|
||||
nsresult rv = CallGetService("@mozilla.org/xbl;1", &gXBLService);
|
||||
if (NS_FAILED(rv))
|
||||
gXBLService = nsnull;
|
||||
}
|
||||
|
||||
return gXBLService;
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSFrameConstructor::NotifyDestroyingFrame(nsIFrame* aFrame)
|
||||
{
|
||||
@ -2307,7 +2293,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
|
||||
nsresult rv;
|
||||
bool resolveStyle;
|
||||
|
||||
nsIXBLService * xblService = GetXBLService();
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -5044,7 +5030,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
|
||||
{
|
||||
// Ensure that our XBL bindings are installed.
|
||||
|
||||
nsIXBLService * xblService = GetXBLService();
|
||||
nsXBLService* xblService = nsXBLService::GetInstance();
|
||||
if (!xblService)
|
||||
return;
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsQuoteList.h"
|
||||
#include "nsCounterManager.h"
|
||||
#include "nsHashKeys.h"
|
||||
@ -63,10 +62,6 @@ public:
|
||||
struct RestyleData;
|
||||
friend struct RestyleData;
|
||||
|
||||
// Maintain global objects - gXBLService
|
||||
static nsIXBLService * GetXBLService();
|
||||
static void ReleaseGlobals() { NS_IF_RELEASE(gXBLService); }
|
||||
|
||||
// get the alternate text for a content node
|
||||
static void GetAlternateTextFor(nsIContent* aContent,
|
||||
nsIAtom* aTag, // content object's tag
|
||||
@ -1832,8 +1827,6 @@ private:
|
||||
|
||||
RestyleTracker mPendingRestyles;
|
||||
RestyleTracker mPendingAnimationRestyles;
|
||||
|
||||
static nsIXBLService * gXBLService;
|
||||
};
|
||||
|
||||
#endif /* nsCSSFrameConstructor_h___ */
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsCaret.h"
|
||||
#include "nsPlainTextSerializer.h"
|
||||
#include "nsXMLContentSerializer.h"
|
||||
@ -403,7 +402,6 @@ nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult);
|
||||
nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
|
||||
nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult);
|
||||
nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
|
||||
nsresult NS_NewXBLService(nsIXBLService** aResult);
|
||||
nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
|
||||
|
||||
nsresult NS_NewEventListenerService(nsIEventListenerService** aResult);
|
||||
@ -474,7 +472,6 @@ MAKE_CTOR(CreateXMLContentSerializer, nsIContentSerializer, NS_NewXML
|
||||
MAKE_CTOR(CreateHTMLContentSerializer, nsIContentSerializer, NS_NewHTMLContentSerializer)
|
||||
MAKE_CTOR(CreateXHTMLContentSerializer, nsIContentSerializer, NS_NewXHTMLContentSerializer)
|
||||
MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer, NS_NewPlainTextSerializer)
|
||||
MAKE_CTOR(CreateXBLService, nsIXBLService, NS_NewXBLService)
|
||||
MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy)
|
||||
#ifdef MOZ_XUL
|
||||
MAKE_CTOR(CreateXULSortService, nsIXULSortService, NS_NewXULSortService)
|
||||
@ -672,7 +669,6 @@ NS_DEFINE_NAMED_CID(NS_HTMLCONTENTSERIALIZER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PLAINTEXTSERIALIZER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PARSERUTILS_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SCRIPTABLEUNESCAPEHTML_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_XBLSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CONTENTPOLICY_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DATADOCUMENTCONTENTPOLICY_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NODATAPROTOCOLCONTENTPOLICY_CID);
|
||||
@ -942,7 +938,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
{ &kNS_PLAINTEXTSERIALIZER_CID, false, NULL, CreatePlainTextSerializer },
|
||||
{ &kNS_PARSERUTILS_CID, false, NULL, nsParserUtilsConstructor },
|
||||
{ &kNS_SCRIPTABLEUNESCAPEHTML_CID, false, NULL, nsParserUtilsConstructor },
|
||||
{ &kNS_XBLSERVICE_CID, false, NULL, CreateXBLService },
|
||||
{ &kNS_CONTENTPOLICY_CID, false, NULL, CreateContentPolicy },
|
||||
{ &kNS_DATADOCUMENTCONTENTPOLICY_CID, false, NULL, nsDataDocumentContentPolicyConstructor },
|
||||
{ &kNS_NODATAPROTOCOLCONTENTPOLICY_CID, false, NULL, nsNoDataProtocolContentPolicyConstructor },
|
||||
@ -1084,7 +1079,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
||||
{ NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/plain", &kNS_PLAINTEXTSERIALIZER_CID },
|
||||
{ NS_PARSERUTILS_CONTRACTID, &kNS_PARSERUTILS_CID },
|
||||
{ NS_SCRIPTABLEUNESCAPEHTML_CONTRACTID, &kNS_SCRIPTABLEUNESCAPEHTML_CID },
|
||||
{ "@mozilla.org/xbl;1", &kNS_XBLSERVICE_CID },
|
||||
{ NS_CONTENTPOLICY_CONTRACTID, &kNS_CONTENTPOLICY_CID },
|
||||
{ NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID, &kNS_DATADOCUMENTCONTENTPOLICY_CID },
|
||||
{ NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID, &kNS_NODATAPROTOCOLCONTENTPOLICY_CID },
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsContentDLF.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsCSSKeywords.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsCSSProps.h"
|
||||
@ -38,6 +37,7 @@
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsTextControlFrame.h"
|
||||
#include "nsXBLWindowKeyHandler.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "txMozillaXSLTProcessor.h"
|
||||
#include "nsDOMStorage.h"
|
||||
#include "nsTreeSanitizer.h"
|
||||
@ -61,7 +61,6 @@
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPopupManager.h"
|
||||
#include "nsXULContentUtils.h"
|
||||
#include "nsXULElement.h"
|
||||
#include "nsXULPrototypeCache.h"
|
||||
#include "nsXULTooltipListener.h"
|
||||
|
||||
@ -129,6 +128,7 @@ nsLayoutStatics::Initialize()
|
||||
|
||||
nsGlobalWindow::Init();
|
||||
Navigator::Init();
|
||||
nsXBLService::Init();
|
||||
|
||||
rv = nsContentUtils::Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -279,14 +279,12 @@ nsLayoutStatics::Shutdown()
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
nsXULContentUtils::Finish();
|
||||
nsXULElement::ReleaseGlobals();
|
||||
nsXULPrototypeCache::ReleaseGlobals();
|
||||
nsSprocketLayout::Shutdown();
|
||||
#endif
|
||||
|
||||
nsMathMLOperators::ReleaseTable();
|
||||
|
||||
nsCSSFrameConstructor::ReleaseGlobals();
|
||||
nsFloatManager::Shutdown();
|
||||
nsImageFrame::ReleaseGlobals();
|
||||
|
||||
@ -305,6 +303,7 @@ nsLayoutStatics::Shutdown()
|
||||
nsDOMClassInfo::ShutDown();
|
||||
nsListControlFrame::Shutdown();
|
||||
nsXBLWindowKeyHandler::ShutDown();
|
||||
nsXBLService::Shutdown();
|
||||
nsAutoCopyListener::Shutdown();
|
||||
|
||||
#ifdef MOZ_SYDNEYAUDIO
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIRollupListener.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
@ -672,16 +672,10 @@ void nsMenuX::GetMenuPopupContent(nsIContent** aResult)
|
||||
return;
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXBLService> xblService = do_GetService("@mozilla.org/xbl;1", &rv);
|
||||
if (!xblService)
|
||||
return;
|
||||
|
||||
// Check to see if we are a "menupopup" node (if we are a native menu).
|
||||
{
|
||||
PRInt32 dummy;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
xblService->ResolveTag(mContent, &dummy, getter_AddRefs(tag));
|
||||
nsCOMPtr<nsIAtom> tag = mContent->OwnerDoc()->BindingManager()->ResolveTag(mContent, &dummy);
|
||||
if (tag == nsGkAtoms::menupopup) {
|
||||
*aResult = mContent;
|
||||
NS_ADDREF(*aResult);
|
||||
@ -696,8 +690,7 @@ void nsMenuX::GetMenuPopupContent(nsIContent** aResult)
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
PRInt32 dummy;
|
||||
nsIContent *child = mContent->GetChildAt(i);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
xblService->ResolveTag(child, &dummy, getter_AddRefs(tag));
|
||||
nsCOMPtr<nsIAtom> tag = child->OwnerDoc()->BindingManager()->ResolveTag(child, &dummy);
|
||||
if (tag == nsGkAtoms::menupopup) {
|
||||
*aResult = child;
|
||||
NS_ADDREF(*aResult);
|
||||
|
Loading…
Reference in New Issue
Block a user