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"
17 bool CSSCounterStyleRule::IsCCLeaf() const { return Rule::IsCCLeaf(); }
20 void CSSCounterStyleRule::List(FILE* out
, int32_t aIndent
) const {
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());
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
) {
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
) {
56 StyleSheet
* sheet
= GetStyleSheet();
61 if (aCallback() && sheet
) {
62 sheet
->RuleChanged(this, StyleRuleChangeKind::Generic
);
66 void CSSCounterStyleRule::SetName(const nsAString
& aName
) {
68 NS_ConvertUTF16toUTF8
name(aName
);
69 return Servo_CounterStyleRule_SetName(mRawRule
, &name
);
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); \
79 void CSSCounterStyleRule::Set##method_(const nsACString& aValue) { \
81 return Servo_CounterStyleRule_SetDescriptor( \
82 mRawRule, eCSSCounterDesc_##method_, &aValue); \
85 #include "nsCSSCounterDescList.h"
86 #undef CSS_COUNTER_DESC
89 size_t CSSCounterStyleRule::SizeOfIncludingThis(
90 MallocSizeOf aMallocSizeOf
) const {
91 return aMallocSizeOf(this);
95 JSObject
* CSSCounterStyleRule::WrapObject(JSContext
* aCx
,
96 JS::Handle
<JSObject
*> aGivenProto
) {
97 return CSSCounterStyleRule_Binding::Wrap(aCx
, this, aGivenProto
);
101 } // namespace mozilla