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); |
| 125 void closeOriginOrScope() { m_result.closeOriginOrScope(m_matchingUARules);
} |
130 | 126 |
131 private: | 127 private: |
132 template<typename RuleDataListType> | 128 template<typename RuleDataListType> |
133 void collectMatchingRulesForList(const RuleDataListType*, CascadeOrder, cons
t MatchRequest&); | 129 void collectMatchingRulesForList(const RuleDataListType*, const MatchRequest
&); |
134 | 130 |
135 void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, Casc
adeOrder, const MatchRequest&); | 131 void didMatchRule(const RuleData&, const SelectorChecker::MatchResult&, cons
t MatchRequest&); |
136 | 132 |
137 template<class CSSRuleCollection> | 133 template<class CSSRuleCollection> |
138 CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*); | 134 CSSRule* findStyleRule(CSSRuleCollection*, StyleRule*); |
139 void appendCSSOMWrapperForRule(CSSStyleSheet*, StyleRule*); | 135 void appendCSSOMWrapperForRule(CSSStyleSheet*, StyleRule*); |
140 | 136 |
141 void sortMatchedRules(); | 137 void sortMatchedRules(); |
142 | 138 |
143 StaticCSSRuleList* ensureRuleList(); | 139 StaticCSSRuleList* ensureRuleList(); |
144 StyleRuleList* ensureStyleRuleList(); | 140 StyleRuleList* ensureStyleRuleList(); |
145 | 141 |
(...skipping 13 matching lines...) Expand all Loading... |
159 | 155 |
160 // Output. | 156 // Output. |
161 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; | 157 RefPtrWillBeMember<StaticCSSRuleList> m_cssRuleList; |
162 RefPtrWillBeMember<StyleRuleList> m_styleRuleList; | 158 RefPtrWillBeMember<StyleRuleList> m_styleRuleList; |
163 MatchResult m_result; | 159 MatchResult m_result; |
164 }; | 160 }; |
165 | 161 |
166 } // namespace blink | 162 } // namespace blink |
167 | 163 |
168 #endif // ElementRuleCollector_h | 164 #endif // ElementRuleCollector_h |
OLD | NEW |