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/CSSSupportsRule.h"
9 #include "mozilla/css/GroupRule.h"
10 #include "mozilla/dom/CSSSupportsRuleBinding.h"
11 #include "mozilla/ServoBindings.h"
13 using namespace mozilla::css
;
15 namespace mozilla::dom
{
17 CSSSupportsRule::CSSSupportsRule(RefPtr
<StyleSupportsRule
> aRawRule
,
18 StyleSheet
* aSheet
, css::Rule
* aParentRule
,
19 uint32_t aLine
, uint32_t aColumn
)
20 : css::ConditionRule(aSheet
, aParentRule
, aLine
, aColumn
),
21 mRawRule(std::move(aRawRule
)) {}
23 NS_IMPL_ADDREF_INHERITED(CSSSupportsRule
, ConditionRule
)
24 NS_IMPL_RELEASE_INHERITED(CSSSupportsRule
, ConditionRule
)
26 // QueryInterface implementation for SupportsRule
27 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSSupportsRule
)
28 NS_INTERFACE_MAP_END_INHERITING(ConditionRule
)
32 void CSSSupportsRule::List(FILE* out
, int32_t aIndent
) const {
34 for (int32_t i
= 0; i
< aIndent
; i
++) {
35 str
.AppendLiteral(" ");
37 Servo_SupportsRule_Debug(mRawRule
, &str
);
38 fprintf_stderr(out
, "%s\n", str
.get());
42 StyleCssRuleType
CSSSupportsRule::Type() const {
43 return StyleCssRuleType::Supports
;
46 void CSSSupportsRule::GetConditionText(nsACString
& aConditionText
) {
47 Servo_SupportsRule_GetConditionText(mRawRule
, &aConditionText
);
51 void CSSSupportsRule::GetCssText(nsACString
& aCssText
) const {
52 Servo_SupportsRule_GetCssText(mRawRule
, &aCssText
);
55 void CSSSupportsRule::SetRawAfterClone(RefPtr
<StyleSupportsRule
> aRaw
) {
56 mRawRule
= std::move(aRaw
);
57 css::ConditionRule::DidSetRawAfterClone();
60 already_AddRefed
<StyleLockedCssRules
> CSSSupportsRule::GetOrCreateRawRules() {
61 return Servo_SupportsRule_GetRules(mRawRule
).Consume();
65 size_t CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const {
66 // TODO Implement this!
67 return aMallocSizeOf(this);
71 JSObject
* CSSSupportsRule::WrapObject(JSContext
* aCx
,
72 JS::Handle
<JSObject
*> aGivenProto
) {
73 return CSSSupportsRule_Binding::Wrap(aCx
, this, aGivenProto
);
76 } // namespace mozilla::dom