LCOV - code coverage report
Current view: top level - layout/style - ServoCSSRuleList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 9 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.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             : /* representation of CSSRuleList for stylo */
       8             : 
       9             : #ifndef mozilla_ServoCSSRuleList_h
      10             : #define mozilla_ServoCSSRuleList_h
      11             : 
      12             : #include "mozilla/ServoBindingTypes.h"
      13             : #include "mozilla/dom/CSSRuleList.h"
      14             : #include "nsDataHashtable.h"
      15             : 
      16             : namespace mozilla {
      17             : 
      18             : class ServoStyleRule;
      19             : class ServoStyleSheet;
      20             : namespace css {
      21             : class GroupRule;
      22             : class Rule;
      23             : } // namespace css
      24             : 
      25             : class ServoCSSRuleList final : public dom::CSSRuleList
      26             : {
      27             : public:
      28             :   // @param aDirectOwnerStyleSheet should be set to the owner stylesheet
      29             :   // if this rule list is owned directly by a stylesheet, which means it
      30             :   // is a top level CSSRuleList. If it's owned by a group rule, nullptr.
      31             :   // If this param is set, the caller doesn't need to call SetStyleSheet.
      32             :   ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
      33             :                    ServoStyleSheet* aDirectOwnerStyleSheet);
      34           0 :   css::GroupRule* GetParentRule() const { return mParentRule; }
      35             :   void SetParentRule(css::GroupRule* aParentRule);
      36             :   void SetStyleSheet(StyleSheet* aSheet);
      37             : 
      38             :   NS_DECL_ISUPPORTS_INHERITED
      39           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoCSSRuleList, dom::CSSRuleList)
      40             : 
      41           0 :   ServoStyleSheet* GetParentObject() final { return mStyleSheet; }
      42             : 
      43             :   css::Rule* IndexedGetter(uint32_t aIndex, bool& aFound) final;
      44           0 :   uint32_t Length() final { return mRules.Length(); }
      45             : 
      46             :   void DropReference();
      47             : 
      48             :   css::Rule* GetRule(uint32_t aIndex);
      49             :   nsresult InsertRule(const nsAString& aRule, uint32_t aIndex);
      50             :   nsresult DeleteRule(uint32_t aIndex);
      51             : 
      52             :   uint16_t GetRuleType(uint32_t aIndex) const;
      53             : 
      54             : private:
      55             :   virtual ~ServoCSSRuleList();
      56             : 
      57             :   // XXX Is it possible to have an address lower than or equal to 255?
      58             :   //     Is it possible to have more than 255 CSS rule types?
      59             :   static const uintptr_t kMaxRuleType = UINT8_MAX;
      60             : 
      61           0 :   static uintptr_t CastToUint(css::Rule* aPtr) {
      62           0 :     return reinterpret_cast<uintptr_t>(aPtr);
      63             :   }
      64           0 :   static css::Rule* CastToPtr(uintptr_t aInt) {
      65           0 :     MOZ_ASSERT(aInt > kMaxRuleType);
      66           0 :     return reinterpret_cast<css::Rule*>(aInt);
      67             :   }
      68             : 
      69             :   template<typename Func>
      70             :   void EnumerateInstantiatedRules(Func aCallback);
      71             : 
      72             :   void DropAllRules();
      73             : 
      74             :   // mStyleSheet may be nullptr when it drops the reference to us.
      75             :   ServoStyleSheet* mStyleSheet = nullptr;
      76             :   // mParentRule is nullptr if it isn't a nested rule list.
      77             :   css::GroupRule* mParentRule = nullptr;
      78             :   RefPtr<ServoCssRules> mRawRules;
      79             :   // Array stores either a number indicating rule type, or a pointer to
      80             :   // css::Rule. If the value is less than kMaxRuleType, the given rule
      81             :   // instance has not been constructed, and the value means the type
      82             :   // of the rule. Otherwise, it is a pointer.
      83             :   nsTArray<uintptr_t> mRules;
      84             : };
      85             : 
      86             : } // namespace mozilla
      87             : 
      88             : #endif // mozilla_ServoCSSRuleList_h

Generated by: LCOV version 1.13