Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / CSSCounterStyleRule.cpp
blob2a3f5a0f821d3941f3abfee60858891d8e76f18f
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/CSSCounterStyleRule.h"
9 #include "mozAutoDocUpdate.h"
10 #include "mozilla/dom/CSSCounterStyleRuleBinding.h"
11 #include "mozilla/ServoBindings.h"
12 #include "nsStyleUtil.h"
14 namespace mozilla {
15 namespace dom {
17 bool CSSCounterStyleRule::IsCCLeaf() const { return Rule::IsCCLeaf(); }
19 #ifdef DEBUG
20 void CSSCounterStyleRule::List(FILE* out, int32_t aIndent) const {
21 nsAutoCString str;
22 for (int32_t i = 0; i < aIndent; i++) {
23 str.AppendLiteral(" ");
25 Servo_CounterStyleRule_Debug(mRawRule, &str);
26 fprintf_stderr(out, "%s\n", str.get());
28 #endif
30 StyleCssRuleType CSSCounterStyleRule::Type() const {
31 return StyleCssRuleType::CounterStyle;
34 void CSSCounterStyleRule::SetRawAfterClone(
35 RefPtr<StyleLockedCounterStyleRule> aRaw) {
36 mRawRule = std::move(aRaw);
39 void CSSCounterStyleRule::GetCssText(nsACString& aCssText) const {
40 Servo_CounterStyleRule_GetCssText(mRawRule, &aCssText);
43 void CSSCounterStyleRule::GetName(nsAString& aName) {
44 aName.Truncate();
45 nsAtom* name = Servo_CounterStyleRule_GetName(mRawRule);
46 nsDependentAtomString nameStr(name);
47 nsStyleUtil::AppendEscapedCSSIdent(nameStr, aName);
50 template <typename Func>
51 void CSSCounterStyleRule::ModifyRule(Func aCallback) {
52 if (IsReadOnly()) {
53 return;
56 StyleSheet* sheet = GetStyleSheet();
57 if (sheet) {
58 sheet->WillDirty();
61 if (aCallback() && sheet) {
62 sheet->RuleChanged(this, StyleRuleChangeKind::Generic);
66 void CSSCounterStyleRule::SetName(const nsAString& aName) {
67 ModifyRule([&] {
68 NS_ConvertUTF16toUTF8 name(aName);
69 return Servo_CounterStyleRule_SetName(mRawRule, &name);
70 });
73 #define CSS_COUNTER_DESC(name_, method_) \
74 void CSSCounterStyleRule::Get##method_(nsACString& aValue) { \
75 MOZ_ASSERT(aValue.IsEmpty()); \
76 Servo_CounterStyleRule_GetDescriptorCssText( \
77 mRawRule, eCSSCounterDesc_##method_, &aValue); \
78 } \
79 void CSSCounterStyleRule::Set##method_(const nsACString& aValue) { \
80 ModifyRule([&] { \
81 return Servo_CounterStyleRule_SetDescriptor( \
82 mRawRule, eCSSCounterDesc_##method_, &aValue); \
83 }); \
85 #include "nsCSSCounterDescList.h"
86 #undef CSS_COUNTER_DESC
88 /* virtual */
89 size_t CSSCounterStyleRule::SizeOfIncludingThis(
90 MallocSizeOf aMallocSizeOf) const {
91 return aMallocSizeOf(this);
94 /* virtual */
95 JSObject* CSSCounterStyleRule::WrapObject(JSContext* aCx,
96 JS::Handle<JSObject*> aGivenProto) {
97 return CSSCounterStyleRule_Binding::Wrap(aCx, this, aGivenProto);
100 } // namespace dom
101 } // namespace mozilla