tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

StyleSheetList.h (1859B)


      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 #ifndef mozilla_dom_StyleSheetList_h
      8 #define mozilla_dom_StyleSheetList_h
      9 
     10 #include "mozilla/dom/DocumentOrShadowRoot.h"
     11 #include "nsContentUtils.h"
     12 #include "nsStubMutationObserver.h"
     13 #include "nsWrapperCache.h"
     14 
     15 class nsINode;
     16 
     17 namespace mozilla {
     18 class StyleSheet;
     19 
     20 namespace dom {
     21 
     22 class StyleSheetList final : public nsStubMutationObserver,
     23                             public nsWrapperCache {
     24 public:
     25  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     26  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(StyleSheetList)
     27 
     28  NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
     29 
     30  explicit StyleSheetList(DocumentOrShadowRoot& aScope);
     31 
     32  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
     33 
     34  nsINode* GetParentObject() const {
     35    return mDocumentOrShadowRoot ? &mDocumentOrShadowRoot->AsNode() : nullptr;
     36  }
     37 
     38  uint32_t Length() const {
     39    return mDocumentOrShadowRoot ? mDocumentOrShadowRoot->SheetCount() : 0;
     40  }
     41 
     42  StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) const {
     43    if (!mDocumentOrShadowRoot) {
     44      aFound = false;
     45      return nullptr;
     46    }
     47 
     48    StyleSheet* sheet = mDocumentOrShadowRoot->SheetAt(aIndex);
     49    aFound = !!sheet;
     50    return sheet;
     51  }
     52 
     53  StyleSheet* Item(uint32_t aIndex) const {
     54    bool dummy = false;
     55    return IndexedGetter(aIndex, dummy);
     56  }
     57 
     58 protected:
     59  virtual ~StyleSheetList();
     60 
     61  DocumentOrShadowRoot*
     62      mDocumentOrShadowRoot;  // Weak, cleared on "NodeWillBeDestroyed".
     63 };
     64 
     65 }  // namespace dom
     66 }  // namespace mozilla
     67 
     68 #endif  // mozilla_dom_StyleSheetList_h