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/CSSContainerRule.h"
9 #include "mozilla/css/GroupRule.h"
10 #include "mozilla/dom/CSSContainerRuleBinding.h"
11 #include "mozilla/ServoBindings.h"
13 using namespace mozilla::css
;
15 namespace mozilla::dom
{
17 CSSContainerRule::CSSContainerRule(RefPtr
<StyleContainerRule
> 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 CSSContainerRule::~CSSContainerRule() = default;
25 NS_IMPL_ADDREF_INHERITED(CSSContainerRule
, ConditionRule
)
26 NS_IMPL_RELEASE_INHERITED(CSSContainerRule
, ConditionRule
)
28 // QueryInterface implementation for ContainerRule
29 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSContainerRule
)
30 NS_INTERFACE_MAP_END_INHERITING(ConditionRule
)
34 void CSSContainerRule::List(FILE* out
, int32_t aIndent
) const {
36 for (int32_t i
= 0; i
< aIndent
; i
++) {
37 str
.AppendLiteral(" ");
39 Servo_ContainerRule_Debug(mRawRule
, &str
);
40 fprintf_stderr(out
, "%s\n", str
.get());
44 already_AddRefed
<StyleLockedCssRules
> CSSContainerRule::GetOrCreateRawRules() {
45 return Servo_ContainerRule_GetRules(mRawRule
).Consume();
48 StyleCssRuleType
CSSContainerRule::Type() const {
49 return StyleCssRuleType::Container
;
52 void CSSContainerRule::GetConditionText(nsACString
& aConditionText
) {
53 Servo_ContainerRule_GetConditionText(mRawRule
, &aConditionText
);
57 void CSSContainerRule::GetCssText(nsACString
& aCssText
) const {
58 Servo_ContainerRule_GetCssText(mRawRule
, &aCssText
);
61 void CSSContainerRule::GetContainerName(nsACString
& aName
) const {
62 Servo_ContainerRule_GetContainerName(mRawRule
, &aName
);
65 void CSSContainerRule::GetContainerQuery(nsACString
& aQuery
) const {
66 Servo_ContainerRule_GetContainerQuery(mRawRule
, &aQuery
);
69 Element
* CSSContainerRule::QueryContainerFor(const Element
& aElement
) const {
70 return const_cast<Element
*>(
71 Servo_ContainerRule_QueryContainerFor(mRawRule
, &aElement
));
74 void CSSContainerRule::SetRawAfterClone(RefPtr
<StyleContainerRule
> aRaw
) {
75 mRawRule
= std::move(aRaw
);
76 css::ConditionRule::DidSetRawAfterClone();
80 size_t CSSContainerRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const {
81 // TODO Implement this!
82 return aMallocSizeOf(this);
86 JSObject
* CSSContainerRule::WrapObject(JSContext
* aCx
,
87 JS::Handle
<JSObject
*> aGivenProto
) {
88 return CSSContainerRule_Binding::Wrap(aCx
, this, aGivenProto
);
91 } // namespace mozilla::dom