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/. */
|
2000-05-28 08:10:50 +04:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-11-20 05:05:34 +04:00
|
|
|
#ifndef nsXBLService_h_
|
|
|
|
#define nsXBLService_h_
|
|
|
|
|
2012-05-23 22:46:04 +04:00
|
|
|
#include "nsString.h"
|
2000-09-20 09:44:19 +04:00
|
|
|
#include "nsWeakReference.h"
|
2006-11-09 04:58:12 +03:00
|
|
|
#include "nsTArray.h"
|
2014-03-19 01:25:39 +04:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2000-07-01 06:36:18 +04:00
|
|
|
|
2005-02-26 01:07:01 +03:00
|
|
|
class nsXBLBinding;
|
2010-07-15 05:53:11 +04:00
|
|
|
class nsXBLDocumentInfo;
|
2000-05-28 08:10:50 +04:00
|
|
|
class nsIContent;
|
|
|
|
class nsIURI;
|
2012-05-23 22:46:04 +04:00
|
|
|
class nsIPrincipal;
|
2013-04-06 04:44:26 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2019-01-02 16:05:23 +03:00
|
|
|
class Document;
|
2013-04-06 04:44:26 +04:00
|
|
|
class EventTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2000-05-28 08:10:50 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsXBLService final : public nsSupportsWeakReference {
|
2000-05-28 08:10:50 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2012-05-23 22:46:04 +04:00
|
|
|
static nsXBLService* gInstance;
|
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
|
|
|
static void Shutdown() { NS_IF_RELEASE(gInstance); }
|
|
|
|
|
|
|
|
static nsXBLService* GetInstance() { return gInstance; }
|
|
|
|
|
2011-11-04 00:39:07 +04:00
|
|
|
static bool IsChromeOrResourceURI(nsIURI* aURI);
|
|
|
|
|
2000-05-28 08:10:50 +04:00
|
|
|
// This function loads a particular XBL file and installs all of the bindings
|
2007-07-19 01:56:57 +04:00
|
|
|
// onto the element. aOriginPrincipal must not be null here.
|
2017-12-05 20:05:51 +03:00
|
|
|
nsresult LoadBindings(mozilla::dom::Element* aElement, nsIURI* aURL,
|
2013-01-24 21:45:50 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal, nsXBLBinding** aBinding,
|
2012-05-23 22:46:04 +04:00
|
|
|
bool* aResolveStyle);
|
2000-05-28 08:10:50 +04:00
|
|
|
|
2000-08-14 08:04:18 +04:00
|
|
|
// Indicates whether or not a binding is fully loaded.
|
2012-05-23 22:46:04 +04:00
|
|
|
nsresult BindingReady(nsIContent* aBoundElement, nsIURI* aURI,
|
|
|
|
bool* aIsReady);
|
2000-05-28 08:10:50 +04:00
|
|
|
|
2007-07-19 01:56:57 +04:00
|
|
|
// This method checks the hashtable and then calls FetchBindingDocument on a
|
|
|
|
// miss. aOriginPrincipal or aBoundDocument may be null to bypass security
|
|
|
|
// checks.
|
2012-05-23 22:46:04 +04:00
|
|
|
nsresult LoadBindingDocumentInfo(nsIContent* aBoundElement,
|
2019-01-02 16:05:23 +03:00
|
|
|
mozilla::dom::Document* aBoundDocument,
|
2012-05-23 22:46:04 +04:00
|
|
|
nsIURI* aBindingURI,
|
|
|
|
nsIPrincipal* aOriginPrincipal,
|
|
|
|
bool aForceSyncLoad,
|
|
|
|
nsXBLDocumentInfo** aResult);
|
2000-08-17 12:11:11 +04:00
|
|
|
|
2000-09-22 09:02:20 +04:00
|
|
|
// Used by XUL key bindings and for window XBL.
|
2013-04-06 04:44:26 +04:00
|
|
|
static nsresult AttachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
|
|
|
|
static nsresult DetachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
|
2000-09-22 09:02:20 +04:00
|
|
|
|
2012-05-23 22:46:04 +04:00
|
|
|
private:
|
2000-05-28 08:10:50 +04:00
|
|
|
nsXBLService();
|
|
|
|
virtual ~nsXBLService();
|
|
|
|
|
2005-02-26 01:07:01 +03:00
|
|
|
protected:
|
2017-12-05 20:05:51 +03:00
|
|
|
// This function clears out the bindings on a given element.
|
|
|
|
void FlushStyleBindings(mozilla::dom::Element*);
|
2003-03-04 04:04:27 +03:00
|
|
|
|
2000-05-28 08:10:50 +04:00
|
|
|
// This method synchronously loads and parses an XBL file.
|
2003-03-04 04:04:27 +03:00
|
|
|
nsresult FetchBindingDocument(nsIContent* aBoundElement,
|
2019-01-02 16:05:23 +03:00
|
|
|
mozilla::dom::Document* aBoundDocument,
|
2014-03-19 01:25:39 +04:00
|
|
|
nsIURI* aDocumentURI, nsIURI* aBindingURI,
|
2014-09-21 20:38:38 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal,
|
2019-01-02 16:05:23 +03:00
|
|
|
bool aForceSyncLoad,
|
|
|
|
mozilla::dom::Document** aResult);
|
2003-03-04 04:04:27 +03:00
|
|
|
|
2006-11-09 04:58:12 +03:00
|
|
|
/**
|
|
|
|
* This method calls the one below with an empty |aDontExtendURIs| array.
|
|
|
|
*/
|
2005-02-26 01:07:01 +03:00
|
|
|
nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI, bool aPeekFlag,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal, bool* aIsReady,
|
|
|
|
nsXBLBinding** aResult);
|
2000-08-14 08:04:18 +04:00
|
|
|
|
2006-11-09 04:58:12 +03:00
|
|
|
/**
|
|
|
|
* This method loads a binding doc and then builds the specific binding
|
|
|
|
* required. It can also peek without building.
|
|
|
|
* @param aBoundElement the element to get a binding for
|
|
|
|
* @param aURI the binding URI
|
|
|
|
* @param aPeekFlag if true then just peek to see if the binding is ready
|
|
|
|
* @param aIsReady [out] if the binding is ready or not
|
|
|
|
* @param aResult [out] where to store the resulting binding (not used if
|
|
|
|
* aPeekFlag is true, otherwise it must be non-null)
|
|
|
|
* @param aDontExtendURIs a set of URIs that are already bound to this
|
|
|
|
* element. If a binding extends any of these then further loading
|
|
|
|
* is aborted (because it would lead to the binding extending itself)
|
|
|
|
* and NS_ERROR_ILLEGAL_VALUE is returned.
|
2007-07-19 01:56:57 +04:00
|
|
|
*
|
|
|
|
* @note This method always calls LoadBindingDocumentInfo(), so it's
|
|
|
|
* enough to funnel all security checks through that function.
|
2006-11-09 04:58:12 +03:00
|
|
|
*/
|
|
|
|
nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI, bool aPeekFlag,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIPrincipal* aOriginPrincipal, bool* aIsReady,
|
|
|
|
nsXBLBinding** aResult,
|
2015-09-10 00:08:10 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIURI>>& aDontExtendURIs);
|
2006-11-09 04:58:12 +03:00
|
|
|
|
2000-05-28 08:10:50 +04:00
|
|
|
// MEMBER VARIABLES
|
2000-07-01 06:36:18 +04:00
|
|
|
public:
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gDisableChromeCache;
|
|
|
|
static bool gAllowDataURIs; // Whether we should allow data
|
2008-04-29 03:56:07 +04:00
|
|
|
// urls in -moz-binding. Needed for
|
|
|
|
// testing.
|
2000-05-28 08:10:50 +04:00
|
|
|
};
|
|
|
|
|
2012-11-20 05:05:34 +04:00
|
|
|
#endif
|