CSSKeyframesRule.h (2151B)
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_CSSKeyframesRule_h 8 #define mozilla_dom_CSSKeyframesRule_h 9 10 #include "mozilla/css/Rule.h" 11 #include "mozilla/dom/CSSKeyframeRule.h" 12 13 namespace mozilla::dom { 14 15 class CSSKeyframeList; 16 17 class CSSKeyframesRule final : public css::Rule { 18 public: 19 CSSKeyframesRule(RefPtr<StyleLockedKeyframesRule> aRawRule, 20 StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine, 21 uint32_t aColumn); 22 23 NS_DECL_ISUPPORTS_INHERITED 24 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSKeyframesRule, css::Rule) 25 26 bool IsCCLeaf() const final; 27 28 #ifdef DEBUG 29 void List(FILE* out = stdout, int32_t aIndent = 0) const final; 30 #endif 31 32 void DropSheetReference() final; 33 34 // WebIDL interface 35 StyleCssRuleType Type() const final; 36 const StyleLockedKeyframesRule* Raw() const { return mRawRule.get(); } 37 void SetRawAfterClone(RefPtr<StyleLockedKeyframesRule>); 38 39 void GetCssText(nsACString& aCssText) const final; 40 void GetName(nsAString& aName) const; 41 void SetName(const nsAString& aName); 42 CSSRuleList* CssRules(); 43 44 CSSKeyframeRule* IndexedGetter(uint32_t aIndex, bool& aFound); 45 uint32_t Length(); 46 47 void AppendRule(const nsAString& aRule); 48 void DeleteRule(const nsAString& aKey); 49 CSSKeyframeRule* FindRule(const nsAString& aKey); 50 51 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final; 52 53 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final; 54 55 private: 56 CSSKeyframeList* EnsureRules(); 57 uint32_t FindRuleIndexForKey(const nsAString& aKey); 58 59 template <typename Func> 60 nsresult UpdateRule(Func aCallback); 61 62 virtual ~CSSKeyframesRule(); 63 64 RefPtr<StyleLockedKeyframesRule> mRawRule; 65 RefPtr<CSSKeyframeList> mKeyframeList; // lazily constructed 66 }; 67 68 } // namespace mozilla::dom 69 70 #endif // mozilla_dom_CSSKeyframesRule_h