OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 class CSSStyleSheet; | 35 class CSSStyleSheet; |
36 class CSSRuleList; | 36 class CSSRuleList; |
37 class RuleData; | 37 class RuleData; |
38 class RuleSet; | 38 class RuleSet; |
39 class SelectorFilter; | 39 class SelectorFilter; |
40 class StaticCSSRuleList; | 40 class StaticCSSRuleList; |
41 | 41 |
42 typedef unsigned CascadeOrder; | |
43 | |
44 const CascadeOrder ignoreCascadeOrder = 0; | |
45 | |
46 class MatchedRule { | 42 class MatchedRule { |
47 ALLOW_ONLY_INLINE_ALLOCATION(); | 43 ALLOW_ONLY_INLINE_ALLOCATION(); |
48 public: | 44 public: |
49 MatchedRule(const RuleData* ruleData, unsigned specificity, CascadeOrder cas
cadeOrder, unsigned styleSheetIndex, const CSSStyleSheet* parentStyleSheet) | 45 MatchedRule(const RuleData* ruleData, unsigned specificity, unsigned styleSh
eetIndex, const CSSStyleSheet* parentStyleSheet) |
50 : m_ruleData(ruleData) | 46 : m_ruleData(ruleData) |
51 , m_specificity(specificity) | 47 , m_specificity(specificity) |
52 , m_parentStyleSheet(parentStyleSheet) | 48 , m_parentStyleSheet(parentStyleSheet) |
53 { | 49 { |
54 ASSERT(m_ruleData); | 50 ASSERT(m_ruleData); |
55 static const unsigned BitsForPositionInRuleData = 18; | 51 static const unsigned BitsForPositionInRuleData = 18; |
56 static const unsigned BitsForStyleSheetIndex = 32; | 52 m_position = ((uint64_t)styleSheetIndex << BitsForPositionInRuleData) +
m_ruleData->position(); |
57 m_position = ((uint64_t)cascadeOrder << (BitsForStyleSheetIndex + BitsFo
rPositionInRuleData)) + ((uint64_t)styleSheetIndex << BitsForPositionInRuleData)
+ m_ruleData->position(); | |
58 } | 53 } |
59 | 54 |
60 const RuleData* ruleData() const { return m_ruleData; } | 55 const RuleData* ruleData() const { return m_ruleData; } |
61 uint64_t position() const { return m_position; } | 56 uint64_t position() const { return m_position; } |
62 unsigned specificity() const { return ruleData()->specificity() + m_specific
ity; } | 57 unsigned specificity() const { return ruleData()->specificity() + m_specific
ity; } |
63 const CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } | 58 const CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } |
64 DEFINE_INLINE_TRACE() | 59 DEFINE_INLINE_TRACE() |
65 { | 60 { |
66 visitor->trace(m_parentStyleSheet); | 61 visitor->trace(m_parentStyleSheet); |
67 } | 62 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 110 |
116 void setMatchingUARules(bool matchingUARules) { m_matchingUARules = matching
UARules; } | 111 void setMatchingUARules(bool matchingUARules) { m_matchingUARules = matching
UARules; } |
117 void setScopeContainsLastMatchedElement(bool scopeContainsLastMatchedElement
) { m_scopeContainsLastMatchedElement = scopeContainsLastMatchedElement; } | 112 void setScopeContainsLastMatchedElement(bool scopeContainsLastMatchedElement
) { m_scopeContainsLastMatchedElement = scopeContainsLastMatchedElement; } |
118 bool scopeContainsLastMatchedElement() const { return m_scopeContainsLastMat
chedElement; } | 113 bool scopeContainsLastMatchedElement() const { return m_scopeContainsLastMat
chedElement; } |
119 bool hasAnyMatchingRules(RuleSet*); | 114 bool hasAnyMatchingRules(RuleSet*); |
120 | 115 |
121 const MatchResult& matchedResult() const; | 116 const MatchResult& matchedResult() const; |
122 PassRefPtrWillBeRawPtr<StyleRuleList> matchedStyleRuleList(); | 117 PassRefPtrWillBeRawPtr<StyleRuleList> matchedStyleRuleList(); |
123 PassRefPtrWillBeRawPtr<CSSRuleList> matchedCSSRuleList(); | 118 PassRefPtrWillBeRawPtr<CSSRuleList> matchedCSSRuleList(); |
124 | 119 |
125 void collectMatchingRules(const MatchRequest&, CascadeOrder = ignoreCascadeO
rder, bool matchingTreeBoundaryRules = false); | 120 void collectMatchingRules(const MatchRequest&, bool matchingTreeBoundaryRule
s = false); |
126 void collectMatchingShadowHostRules(const MatchRequest&, CascadeOrder = igno
reCascadeOrder, bool matchingTreeBoundaryRules = false); | 121 void collectMatchingShadowHostRules(const MatchRequest&, bool matchingTreeBo
undaryRules = false); |
127 void sortAndTransferMatchedRules(); | 122 void sortAndTransferMatchedRules(); |
128 void clearMatchedRules(); | 123 void clearMatchedRules(); |
129 void addElementStyleProperties(const StylePropertySet*, bool isCacheable = t
rue); | 124 void addElementStyleProperties(const StylePropertySet*, bool isCacheable = t
rue); |
130 void finishAddingUARules() { m_result.finishAddingUARules(); } | 125 void finishAddingUARules() { m_result.finishAddingUARules(); } |
131 void finishAddingAuthorRulesForTreeScope() { m_result.finishAddingAuthorRule
sForTreeScope(); } | 126 void finishAddingAuthorRulesForTreeScope() { m_result.finishAddingAuthorRule
sForTreeScope(); } |
132 | 127 |
133 private: | 128 private: |
134 template<typename RuleDataListType> | 129 template<typename RuleDataListType> |
135 void collectMatchingRulesForList(const RuleDataListType*, CascadeOrder, cons
t MatchRequest&); | 130 void collectMatchingRulesForList(const RuleDataListType*, const MatchRequest
&); |
136 | 131 |
137 void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, Casc
adeOrder, const MatchRequest&); | 132 void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, cons
t MatchRequest&); |
138 | 133 |
139 template<class CSSRuleCollection> | 134 template<class CSSRuleCollection> |
140 CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*); | 135 CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*); |
141 void appendCSSOMWrapperForRule(CSSStyleSheet*, StyleRule*); | 136 void appendCSSOMWrapperForRule(CSSStyleSheet*, StyleRule*); |
142 | 137 |
143 void sortMatchedRules(); | 138 void sortMatchedRules(); |
144 | 139 |
145 StaticCSSRuleList* ensureRuleList(); | 140 StaticCSSRuleList* ensureRuleList(); |
146 StyleRuleList* ensureStyleRuleList(); | 141 StyleRuleList* ensureStyleRuleList(); |
147 | 142 |
(...skipping 13 matching lines...) Expand all Loading... |
161 | 156 |
162 // Output. | 157 // Output. |
163 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; | 158 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; |
164 RefPtrWillBeMember<StyleRuleList> m_styleRuleList; | 159 RefPtrWillBeMember<StyleRuleList> m_styleRuleList; |
165 MatchResult m_result; | 160 MatchResult m_result; |
166 }; | 161 }; |
167 | 162 |
168 } // namespace blink | 163 } // namespace blink |
169 | 164 |
170 #endif // ElementRuleCollector_h | 165 #endif // ElementRuleCollector_h |
OLD | NEW |