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 CSSMozDocumentRule for stylo */
8 :
9 : #include "mozilla/ServoBindings.h"
10 : #include "mozilla/ServoDocumentRule.h"
11 :
12 : using namespace mozilla::dom;
13 :
14 : namespace mozilla {
15 :
16 0 : ServoDocumentRule::ServoDocumentRule(RefPtr<RawServoDocumentRule> aRawRule,
17 0 : uint32_t aLine, uint32_t aColumn)
18 0 : : CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume())
19 0 : , mRawRule(Move(aRawRule))
20 : {
21 0 : }
22 :
23 0 : ServoDocumentRule::~ServoDocumentRule()
24 : {
25 0 : }
26 :
27 0 : NS_IMPL_ADDREF_INHERITED(ServoDocumentRule, CSSMozDocumentRule)
28 0 : NS_IMPL_RELEASE_INHERITED(ServoDocumentRule, CSSMozDocumentRule)
29 :
30 : // QueryInterface implementation for MozDocumentRule
31 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServoDocumentRule)
32 0 : NS_INTERFACE_MAP_END_INHERITING(CSSMozDocumentRule)
33 :
34 : /* virtual */ already_AddRefed<css::Rule>
35 0 : ServoDocumentRule::Clone() const
36 : {
37 : // Rule::Clone is only used when CSSStyleSheetInner is cloned in
38 : // preparation of being mutated. However, ServoStyleSheet never clones
39 : // anything, so this method should never be called.
40 0 : MOZ_ASSERT_UNREACHABLE("Shouldn't be cloning ServoDocumentRule");
41 : return nullptr;
42 : }
43 :
44 : /* virtual */ bool
45 0 : ServoDocumentRule::UseForPresentation(nsPresContext* aPresContext,
46 : nsMediaQueryResultCacheKey& aKey)
47 : {
48 : // GroupRule::UseForPresentation is only used in nsCSSRuleProcessor,
49 : // so this should never be called.
50 0 : MOZ_ASSERT_UNREACHABLE("Shouldn't be calling UseForPresentation");
51 : return false;
52 : }
53 :
54 : #ifdef DEBUG
55 : /* virtual */ void
56 0 : ServoDocumentRule::List(FILE* out, int32_t aIndent) const
57 : {
58 0 : nsAutoCString str;
59 0 : for (int32_t i = 0; i < aIndent; i++) {
60 0 : str.AppendLiteral(" ");
61 : }
62 0 : Servo_DocumentRule_Debug(mRawRule, &str);
63 0 : fprintf_stderr(out, "%s\n", str.get());
64 0 : }
65 : #endif
66 :
67 : // nsIDOMCSSConditionRule methods
68 :
69 : NS_IMETHODIMP
70 0 : ServoDocumentRule::GetConditionText(nsAString& aConditionText)
71 : {
72 0 : Servo_DocumentRule_GetConditionText(mRawRule, &aConditionText);
73 0 : return NS_OK;
74 : }
75 :
76 : NS_IMETHODIMP
77 0 : ServoDocumentRule::SetConditionText(const nsAString& aConditionText)
78 : {
79 0 : return NS_ERROR_NOT_IMPLEMENTED;
80 : }
81 :
82 : /* virtual */ void
83 0 : ServoDocumentRule::GetCssTextImpl(nsAString& aCssText) const
84 : {
85 0 : Servo_DocumentRule_GetCssText(mRawRule, &aCssText);
86 0 : }
87 :
88 : /* virtual */ size_t
89 0 : ServoDocumentRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
90 : const
91 : {
92 : // TODO Implement this!
93 0 : return aMallocSizeOf(this);
94 : }
95 :
96 : } // namespace mozilla
|