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/. */
7 #include "mozilla/dom/CSSScopeRule.h"
8 #include "mozilla/dom/CSSScopeRuleBinding.h"
9 #include "mozilla/ServoBindings.h"
11 namespace mozilla::dom
{
13 CSSScopeRule::CSSScopeRule(RefPtr
<StyleScopeRule
> aRawRule
, StyleSheet
* aSheet
,
14 css::Rule
* aParentRule
, uint32_t aLine
,
16 : css::GroupRule(aSheet
, aParentRule
, aLine
, aColumn
),
17 mRawRule(std::move(aRawRule
)) {}
19 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(CSSScopeRule
, css::GroupRule
)
21 // QueryInterface implementation for SupportsRule
24 void CSSScopeRule::List(FILE* out
, int32_t aIndent
) const {
26 for (int32_t i
= 0; i
< aIndent
; i
++) {
27 str
.AppendLiteral(" ");
29 Servo_ScopeRule_Debug(mRawRule
, &str
);
30 fprintf_stderr(out
, "%s\n", str
.get());
34 StyleCssRuleType
CSSScopeRule::Type() const { return StyleCssRuleType::Scope
; }
36 already_AddRefed
<StyleLockedCssRules
> CSSScopeRule::GetOrCreateRawRules() {
37 return Servo_ScopeRule_GetRules(mRawRule
).Consume();
40 void CSSScopeRule::SetRawAfterClone(RefPtr
<StyleScopeRule
> aRaw
) {
41 mRawRule
= std::move(aRaw
);
42 css::GroupRule::DidSetRawAfterClone();
45 void CSSScopeRule::GetCssText(nsACString
& aCssText
) const {
46 Servo_ScopeRule_GetCssText(mRawRule
.get(), &aCssText
);
49 void CSSScopeRule::GetStart(nsACString
& aStart
) const {
50 Servo_ScopeRule_GetStart(mRawRule
.get(), &aStart
);
53 void CSSScopeRule::GetEnd(nsACString
& aEnd
) const {
54 Servo_ScopeRule_GetEnd(mRawRule
.get(), &aEnd
);
57 size_t CSSScopeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const {
58 return aMallocSizeOf(this);
61 JSObject
* CSSScopeRule::WrapObject(JSContext
* aCx
,
62 JS::Handle
<JSObject
*> aGivenProto
) {
63 return CSSScopeRule_Binding::Wrap(aCx
, this, aGivenProto
);
66 } // namespace mozilla::dom