dom/xbl/nsXBLService.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xbl/nsXBLService.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +//////////////////////////////////////////////////////////////////////////////////////////
    1.10 +
    1.11 +#ifndef nsXBLService_h_
    1.12 +#define nsXBLService_h_
    1.13 +
    1.14 +#include "nsString.h"
    1.15 +#include "nsWeakReference.h"
    1.16 +#include "nsTArray.h"
    1.17 +#include "nsDataHashtable.h"
    1.18 +#include "nsHashKeys.h"
    1.19 +
    1.20 +class nsXBLBinding;
    1.21 +class nsXBLDocumentInfo;
    1.22 +class nsIContent;
    1.23 +class nsIDocument;
    1.24 +class nsString;
    1.25 +class nsIURI;
    1.26 +class nsIPrincipal;
    1.27 +
    1.28 +namespace mozilla {
    1.29 +namespace dom {
    1.30 +class EventTarget;
    1.31 +}
    1.32 +}
    1.33 +
    1.34 +class nsXBLService MOZ_FINAL : public nsSupportsWeakReference
    1.35 +{
    1.36 +  NS_DECL_ISUPPORTS
    1.37 +
    1.38 +  static nsXBLService* gInstance;
    1.39 +
    1.40 +  static void Init();
    1.41 +
    1.42 +  static void Shutdown() {
    1.43 +    NS_IF_RELEASE(gInstance);
    1.44 +  }
    1.45 +
    1.46 +  static nsXBLService* GetInstance() { return gInstance; }
    1.47 +
    1.48 +  static bool IsChromeOrResourceURI(nsIURI* aURI);
    1.49 +
    1.50 +  // This function loads a particular XBL file and installs all of the bindings
    1.51 +  // onto the element.  aOriginPrincipal must not be null here.
    1.52 +  nsresult LoadBindings(nsIContent* aContent, nsIURI* aURL,
    1.53 +                        nsIPrincipal* aOriginPrincipal,
    1.54 +                        nsXBLBinding** aBinding, bool* aResolveStyle);
    1.55 +
    1.56 +  // Indicates whether or not a binding is fully loaded.
    1.57 +  nsresult BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady);
    1.58 +
    1.59 +  // This method checks the hashtable and then calls FetchBindingDocument on a
    1.60 +  // miss.  aOriginPrincipal or aBoundDocument may be null to bypass security
    1.61 +  // checks.
    1.62 +  nsresult LoadBindingDocumentInfo(nsIContent* aBoundElement,
    1.63 +                                   nsIDocument* aBoundDocument,
    1.64 +                                   nsIURI* aBindingURI,
    1.65 +                                   nsIPrincipal* aOriginPrincipal,
    1.66 +                                   bool aForceSyncLoad,
    1.67 +                                   nsXBLDocumentInfo** aResult);
    1.68 +
    1.69 +  // Used by XUL key bindings and for window XBL.
    1.70 +  static nsresult AttachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
    1.71 +  static nsresult DetachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
    1.72 +
    1.73 +private:
    1.74 +  nsXBLService();
    1.75 +  virtual ~nsXBLService();
    1.76 +
    1.77 +protected:
    1.78 +  // This function clears out the bindings on a given content node.
    1.79 +  nsresult FlushStyleBindings(nsIContent* aContent);
    1.80 +
    1.81 +  // This method synchronously loads and parses an XBL file.
    1.82 +  nsresult FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoundDocument,
    1.83 +                                nsIURI* aDocumentURI, nsIURI* aBindingURI,
    1.84 +                                bool aForceSyncLoad, nsIDocument** aResult);
    1.85 +
    1.86 +  /**
    1.87 +   * This method calls the one below with an empty |aDontExtendURIs| array.
    1.88 +   */
    1.89 +  nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
    1.90 +                      bool aPeekFlag, nsIPrincipal* aOriginPrincipal,
    1.91 +                      bool* aIsReady, nsXBLBinding** aResult);
    1.92 +
    1.93 +  /**
    1.94 +   * This method loads a binding doc and then builds the specific binding
    1.95 +   * required. It can also peek without building.
    1.96 +   * @param aBoundElement the element to get a binding for
    1.97 +   * @param aURI the binding URI
    1.98 +   * @param aPeekFlag if true then just peek to see if the binding is ready
    1.99 +   * @param aIsReady [out] if the binding is ready or not
   1.100 +   * @param aResult [out] where to store the resulting binding (not used if
   1.101 +   *                      aPeekFlag is true, otherwise it must be non-null)
   1.102 +   * @param aDontExtendURIs a set of URIs that are already bound to this
   1.103 +   *        element. If a binding extends any of these then further loading
   1.104 +   *        is aborted (because it would lead to the binding extending itself)
   1.105 +   *        and NS_ERROR_ILLEGAL_VALUE is returned.
   1.106 +   *
   1.107 +   * @note This method always calls LoadBindingDocumentInfo(), so it's
   1.108 +   *       enough to funnel all security checks through that function.
   1.109 +   */
   1.110 +  nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
   1.111 +                      bool aPeekFlag, nsIPrincipal* aOriginPrincipal,
   1.112 +                      bool* aIsReady, nsXBLBinding** aResult,
   1.113 +                      nsTArray<nsIURI*>& aDontExtendURIs);
   1.114 +
   1.115 +// MEMBER VARIABLES
   1.116 +public:
   1.117 +  static bool gDisableChromeCache;
   1.118 +  static bool     gAllowDataURIs;            // Whether we should allow data
   1.119 +                                             // urls in -moz-binding. Needed for
   1.120 +                                             // testing.
   1.121 +};
   1.122 +
   1.123 +#endif

mercurial