LCOV - code coverage report
Current view: top level - dom/xbl - nsXBLService.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 4 25.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : //////////////////////////////////////////////////////////////////////////////////////////
       8             : 
       9             : #ifndef nsXBLService_h_
      10             : #define nsXBLService_h_
      11             : 
      12             : #include "nsString.h"
      13             : #include "nsWeakReference.h"
      14             : #include "nsTArray.h"
      15             : #include "nsDataHashtable.h"
      16             : #include "nsHashKeys.h"
      17             : 
      18             : class nsXBLBinding;
      19             : class nsXBLDocumentInfo;
      20             : class nsIContent;
      21             : class nsIDocument;
      22             : class nsString;
      23             : class nsIURI;
      24             : class nsIPrincipal;
      25             : 
      26             : namespace mozilla {
      27             : namespace dom {
      28             : class EventTarget;
      29             : } // namespace dom
      30             : } // namespace mozilla
      31             : 
      32             : class nsXBLService final : public nsSupportsWeakReference
      33             : {
      34             :   NS_DECL_ISUPPORTS
      35             : 
      36             :   static nsXBLService* gInstance;
      37             : 
      38             :   static void Init();
      39             : 
      40           0 :   static void Shutdown() {
      41           0 :     NS_IF_RELEASE(gInstance);
      42           0 :   }
      43             : 
      44         367 :   static nsXBLService* GetInstance() { return gInstance; }
      45             : 
      46             :   static bool IsChromeOrResourceURI(nsIURI* aURI);
      47             : 
      48             :   // This function loads a particular XBL file and installs all of the bindings
      49             :   // onto the element.  aOriginPrincipal must not be null here.
      50             :   nsresult LoadBindings(nsIContent* aContent, nsIURI* aURL,
      51             :                         nsIPrincipal* aOriginPrincipal,
      52             :                         nsXBLBinding** aBinding, bool* aResolveStyle);
      53             : 
      54             :   // Indicates whether or not a binding is fully loaded.
      55             :   nsresult BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady);
      56             : 
      57             :   // This method checks the hashtable and then calls FetchBindingDocument on a
      58             :   // miss.  aOriginPrincipal or aBoundDocument may be null to bypass security
      59             :   // checks.
      60             :   nsresult LoadBindingDocumentInfo(nsIContent* aBoundElement,
      61             :                                    nsIDocument* aBoundDocument,
      62             :                                    nsIURI* aBindingURI,
      63             :                                    nsIPrincipal* aOriginPrincipal,
      64             :                                    bool aForceSyncLoad,
      65             :                                    nsXBLDocumentInfo** aResult);
      66             : 
      67             :   // Used by XUL key bindings and for window XBL.
      68             :   static nsresult AttachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
      69             :   static nsresult DetachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget);
      70             : 
      71             : private:
      72             :   nsXBLService();
      73             :   virtual ~nsXBLService();
      74             : 
      75             : protected:
      76             :   // This function clears out the bindings on a given content node.
      77             :   nsresult FlushStyleBindings(nsIContent* aContent);
      78             : 
      79             :   // This method synchronously loads and parses an XBL file.
      80             :   nsresult FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoundDocument,
      81             :                                 nsIURI* aDocumentURI, nsIURI* aBindingURI,
      82             :                                 nsIPrincipal* aOriginPrincipal, bool aForceSyncLoad,
      83             :                                 nsIDocument** aResult);
      84             : 
      85             :   /**
      86             :    * This method calls the one below with an empty |aDontExtendURIs| array.
      87             :    */
      88             :   nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
      89             :                       bool aPeekFlag, nsIPrincipal* aOriginPrincipal,
      90             :                       bool* aIsReady, nsXBLBinding** aResult);
      91             : 
      92             :   /**
      93             :    * This method loads a binding doc and then builds the specific binding
      94             :    * required. It can also peek without building.
      95             :    * @param aBoundElement the element to get a binding for
      96             :    * @param aURI the binding URI
      97             :    * @param aPeekFlag if true then just peek to see if the binding is ready
      98             :    * @param aIsReady [out] if the binding is ready or not
      99             :    * @param aResult [out] where to store the resulting binding (not used if
     100             :    *                      aPeekFlag is true, otherwise it must be non-null)
     101             :    * @param aDontExtendURIs a set of URIs that are already bound to this
     102             :    *        element. If a binding extends any of these then further loading
     103             :    *        is aborted (because it would lead to the binding extending itself)
     104             :    *        and NS_ERROR_ILLEGAL_VALUE is returned.
     105             :    *
     106             :    * @note This method always calls LoadBindingDocumentInfo(), so it's
     107             :    *       enough to funnel all security checks through that function.
     108             :    */
     109             :   nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
     110             :                       bool aPeekFlag, nsIPrincipal* aOriginPrincipal,
     111             :                       bool* aIsReady, nsXBLBinding** aResult,
     112             :                       nsTArray<nsCOMPtr<nsIURI>>& aDontExtendURIs);
     113             : 
     114             : // MEMBER VARIABLES
     115             : public:
     116             :   static bool gDisableChromeCache;
     117             :   static bool     gAllowDataURIs;            // Whether we should allow data
     118             :                                              // urls in -moz-binding. Needed for
     119             :                                              // testing.
     120             : };
     121             : 
     122             : #endif

Generated by: LCOV version 1.13