/src/mozilla-central/layout/style/Rule.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /* base class for all rule types in a CSS style sheet */ |
8 | | |
9 | | #include "Rule.h" |
10 | | |
11 | | #include "mozilla/css/GroupRule.h" |
12 | | #include "mozilla/dom/DocumentOrShadowRoot.h" |
13 | | #include "nsCCUncollectableMarker.h" |
14 | | #include "nsIDocument.h" |
15 | | #include "nsWrapperCacheInlines.h" |
16 | | |
17 | | using namespace mozilla; |
18 | | using namespace mozilla::dom; |
19 | | |
20 | | namespace mozilla { |
21 | | namespace css { |
22 | | |
23 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(Rule) |
24 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(Rule) |
25 | | |
26 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Rule) |
27 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
28 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
29 | 0 | NS_INTERFACE_MAP_END |
30 | | |
31 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(Rule) |
32 | | |
33 | | bool |
34 | | Rule::IsCCLeaf() const |
35 | 0 | { |
36 | 0 | return !PreservingWrapper(); |
37 | 0 | } |
38 | | |
39 | | bool |
40 | | Rule::IsKnownLive() const |
41 | 0 | { |
42 | 0 | if (HasKnownLiveWrapper()) { |
43 | 0 | return true; |
44 | 0 | } |
45 | 0 | |
46 | 0 | StyleSheet* sheet = GetStyleSheet(); |
47 | 0 | if (!sheet) { |
48 | 0 | return false; |
49 | 0 | } |
50 | 0 | |
51 | 0 | if (!sheet->IsKeptAliveByDocument()) { |
52 | 0 | return false; |
53 | 0 | } |
54 | 0 | |
55 | 0 | return nsCCUncollectableMarker::InGeneration( |
56 | 0 | GetComposedDoc()->GetMarkedCCGeneration()); |
57 | 0 | } |
58 | | |
59 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(Rule) |
60 | 0 | return tmp->IsCCLeaf() || tmp->IsKnownLive(); |
61 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END |
62 | | |
63 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(Rule) |
64 | 0 | // Please see documentation for nsCycleCollectionParticipant::CanSkip* for why |
65 | 0 | // we need to check HasNothingToTrace here but not in the other two CanSkip |
66 | 0 | // methods. |
67 | 0 | return tmp->IsCCLeaf() || |
68 | 0 | (tmp->IsKnownLive() && tmp->HasNothingToTrace(tmp)); |
69 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END |
70 | | |
71 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(Rule) |
72 | 0 | return tmp->IsCCLeaf() || tmp->IsKnownLive(); |
73 | 0 | NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END |
74 | | |
75 | | /* virtual */ void |
76 | | Rule::DropSheetReference() |
77 | 0 | { |
78 | 0 | mSheet = nullptr; |
79 | 0 | } |
80 | | |
81 | | void |
82 | | Rule::SetCssText(const nsAString& aCssText) |
83 | 0 | { |
84 | 0 | // We used to throw for some rule types, but not all. Specifically, we did |
85 | 0 | // not throw for StyleRule. Let's just always not throw. |
86 | 0 | } |
87 | | |
88 | | Rule* |
89 | | Rule::GetParentRule() const |
90 | 0 | { |
91 | 0 | return mParentRule; |
92 | 0 | } |
93 | | |
94 | | } // namespace css |
95 | | } // namespace mozilla |