CSSSupportsRule.cpp (2458B)
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 #include "mozilla/dom/CSSSupportsRule.h" 8 9 #include "mozilla/ServoBindings.h" 10 #include "mozilla/css/GroupRule.h" 11 #include "mozilla/dom/CSSSupportsRuleBinding.h" 12 13 using namespace mozilla::css; 14 15 namespace mozilla::dom { 16 17 CSSSupportsRule::CSSSupportsRule(RefPtr<StyleSupportsRule> aRawRule, 18 StyleSheet* aSheet, css::Rule* aParentRule, 19 uint32_t aLine, uint32_t aColumn) 20 : css::ConditionRule(aSheet, aParentRule, aLine, aColumn), 21 mRawRule(std::move(aRawRule)) {} 22 23 NS_IMPL_ADDREF_INHERITED(CSSSupportsRule, ConditionRule) 24 NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, ConditionRule) 25 26 // QueryInterface implementation for SupportsRule 27 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSSupportsRule) 28 NS_INTERFACE_MAP_END_INHERITING(ConditionRule) 29 30 #ifdef DEBUG 31 /* virtual */ 32 void CSSSupportsRule::List(FILE* out, int32_t aIndent) const { 33 nsAutoCString str; 34 for (int32_t i = 0; i < aIndent; i++) { 35 str.AppendLiteral(" "); 36 } 37 Servo_SupportsRule_Debug(mRawRule, &str); 38 fprintf_stderr(out, "%s\n", str.get()); 39 } 40 #endif 41 42 StyleCssRuleType CSSSupportsRule::Type() const { 43 return StyleCssRuleType::Supports; 44 } 45 46 void CSSSupportsRule::GetConditionText(nsACString& aConditionText) { 47 Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText); 48 } 49 50 /* virtual */ 51 void CSSSupportsRule::GetCssText(nsACString& aCssText) const { 52 Servo_SupportsRule_GetCssText(mRawRule, &aCssText); 53 } 54 55 void CSSSupportsRule::SetRawAfterClone(RefPtr<StyleSupportsRule> aRaw) { 56 mRawRule = std::move(aRaw); 57 css::ConditionRule::DidSetRawAfterClone(); 58 } 59 60 already_AddRefed<StyleLockedCssRules> CSSSupportsRule::GetOrCreateRawRules() { 61 return Servo_SupportsRule_GetRules(mRawRule).Consume(); 62 } 63 64 /* virtual */ 65 size_t CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { 66 // TODO Implement this! 67 return aMallocSizeOf(this); 68 } 69 70 /* virtual */ 71 JSObject* CSSSupportsRule::WrapObject(JSContext* aCx, 72 JS::Handle<JSObject*> aGivenProto) { 73 return CSSSupportsRule_Binding::Wrap(aCx, this, aGivenProto); 74 } 75 76 } // namespace mozilla::dom