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 CSSSupportsRule for stylo */
8 
9 #include "mozilla/ServoSupportsRule.h"
10 
11 #include "mozilla/ServoBindings.h"
12 
13 using namespace mozilla::dom;
14 
15 namespace mozilla {
16 
ServoSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,uint32_t aLine,uint32_t aColumn)17 ServoSupportsRule::ServoSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
18                                      uint32_t aLine, uint32_t aColumn)
19     : CSSSupportsRule(Servo_SupportsRule_GetRules(aRawRule).Consume(), aLine,
20                       aColumn),
21       mRawRule(Move(aRawRule)) {}
22 
~ServoSupportsRule()23 ServoSupportsRule::~ServoSupportsRule() {}
24 
NS_IMPL_ADDREF_INHERITED(ServoSupportsRule,CSSSupportsRule)25 NS_IMPL_ADDREF_INHERITED(ServoSupportsRule, CSSSupportsRule)
26 NS_IMPL_RELEASE_INHERITED(ServoSupportsRule, CSSSupportsRule)
27 
28 // QueryInterface implementation for SupportsRule
29 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoSupportsRule)
30 NS_INTERFACE_MAP_END_INHERITING(CSSSupportsRule)
31 
32 /* virtual */ already_AddRefed<css::Rule> ServoSupportsRule::Clone() const {
33   // Rule::Clone is only used when CSSStyleSheetInner is cloned in
34   // preparation of being mutated. However, ServoStyleSheet never clones
35   // anything, so this method should never be called.
36   MOZ_ASSERT_UNREACHABLE("Shouldn't be cloning ServoSupportsRule");
37   return nullptr;
38 }
39 
40 #ifdef MOZ_OLD_STYLE
UseForPresentation(nsPresContext * aPresContext,nsMediaQueryResultCacheKey & aKey)41 /* virtual */ bool ServoSupportsRule::UseForPresentation(
42     nsPresContext* aPresContext, nsMediaQueryResultCacheKey& aKey) {
43   // GroupRule::UseForPresentation is only used in nsCSSRuleProcessor,
44   // so this should never be called.
45   MOZ_ASSERT_UNREACHABLE("Shouldn't be calling UseForPresentation");
46   return false;
47 }
48 #endif
49 
50 #ifdef DEBUG
List(FILE * out,int32_t aIndent) const51 /* virtual */ void ServoSupportsRule::List(FILE* out, int32_t aIndent) const {
52   nsAutoCString str;
53   for (int32_t i = 0; i < aIndent; i++) {
54     str.AppendLiteral("  ");
55   }
56   Servo_SupportsRule_Debug(mRawRule, &str);
57   fprintf_stderr(out, "%s\n", str.get());
58 }
59 #endif
60 
GetConditionText(nsAString & aConditionText)61 void ServoSupportsRule::GetConditionText(nsAString& aConditionText) {
62   Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText);
63 }
64 
SetConditionText(const nsAString & aConditionText,ErrorResult & aRv)65 void ServoSupportsRule::SetConditionText(const nsAString& aConditionText,
66                                          ErrorResult& aRv) {
67   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
68 }
69 
GetCssText(nsAString & aCssText) const70 /* virtual */ void ServoSupportsRule::GetCssText(nsAString& aCssText) const {
71   Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
72 }
73 
SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const74 /* virtual */ size_t ServoSupportsRule::SizeOfIncludingThis(
75     mozilla::MallocSizeOf aMallocSizeOf) const {
76   // TODO Implement this!
77   return aMallocSizeOf(this);
78 }
79 
80 }  // namespace mozilla
81