OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 { | 102 { |
103 if (!m_cssRuleList) | 103 if (!m_cssRuleList) |
104 m_cssRuleList = StaticCSSRuleList::create(); | 104 m_cssRuleList = StaticCSSRuleList::create(); |
105 return m_cssRuleList.get(); | 105 return m_cssRuleList.get(); |
106 } | 106 } |
107 | 107 |
108 void ElementRuleCollector::addElementStyleProperties(const StylePropertySet* pro
pertySet, bool isCacheable) | 108 void ElementRuleCollector::addElementStyleProperties(const StylePropertySet* pro
pertySet, bool isCacheable) |
109 { | 109 { |
110 if (!propertySet) | 110 if (!propertySet) |
111 return; | 111 return; |
112 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size(); | 112 |
113 if (m_result.ranges.firstAuthorRule == -1) | 113 m_result.ranges.authorRuleRange().shiftLast(m_result.matchedProperties.size(
)); |
114 m_result.ranges.firstAuthorRule = m_result.ranges.lastAuthorRule; | |
115 m_result.addMatchedProperties(propertySet); | 114 m_result.addMatchedProperties(propertySet); |
116 if (!isCacheable) | 115 if (!isCacheable) |
117 m_result.isCacheable = false; | 116 m_result.isCacheable = false; |
118 } | 117 } |
119 | 118 |
120 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
ainerNode* scopingNode, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary,
bool elementApplyAuthorStyles) | 119 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
ainerNode* scopingNode, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary,
bool elementApplyAuthorStyles) |
121 { | 120 { |
122 TreeScope& treeScope = element->treeScope(); | 121 TreeScope& treeScope = element->treeScope(); |
123 | 122 |
124 // [skipped, because already checked] a) it's a UA rule | 123 // [skipped, because already checked] a) it's a UA rule |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // If we're matching normal rules, set a pseudo bit if | 293 // If we're matching normal rules, set a pseudo bit if |
295 // we really just matched a pseudo-element. | 294 // we really just matched a pseudo-element. |
296 if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEU
DO) { | 295 if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEU
DO) { |
297 if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == Selec
torChecker::CollectingStyleRules) | 296 if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == Selec
torChecker::CollectingStyleRules) |
298 return; | 297 return; |
299 // FIXME: Matching should not modify the style directly. | 298 // FIXME: Matching should not modify the style directly. |
300 if (m_style && dynamicPseudo < FIRST_INTERNAL_PSEUDOID) | 299 if (m_style && dynamicPseudo < FIRST_INTERNAL_PSEUDOID) |
301 m_style->setHasPseudoStyle(dynamicPseudo); | 300 m_style->setHasPseudoStyle(dynamicPseudo); |
302 } else { | 301 } else { |
303 // Update our first/last rule indices in the matched rules array. | 302 // Update our first/last rule indices in the matched rules array. |
304 ++ruleRange.lastRuleIndex; | 303 ruleRange.shiftLastByOne(); |
305 if (ruleRange.firstRuleIndex == -1) | |
306 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; | |
307 | |
308 // Add this rule to our list of matched rules. | 304 // Add this rule to our list of matched rules. |
309 addMatchedRule(&ruleData, result.specificity, cascadeScope, cascadeO
rder, matchRequest.styleSheetIndex, matchRequest.styleSheet); | 305 addMatchedRule(&ruleData, result.specificity, cascadeScope, cascadeO
rder, matchRequest.styleSheetIndex, matchRequest.styleSheet); |
310 return; | 306 return; |
311 } | 307 } |
312 } | 308 } |
313 } | 309 } |
314 | 310 |
315 static inline bool compareRules(const MatchedRule& matchedRule1, const MatchedRu
le& matchedRule2) | 311 static inline bool compareRules(const MatchedRule& matchedRule1, const MatchedRu
le& matchedRule2) |
316 { | 312 { |
317 if (matchedRule1.cascadeScope() != matchedRule2.cascadeScope()) | 313 if (matchedRule1.cascadeScope() != matchedRule2.cascadeScope()) |
(...skipping 14 matching lines...) Expand all Loading... |
332 } | 328 } |
333 | 329 |
334 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) | 330 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) |
335 { | 331 { |
336 clearMatchedRules(); | 332 clearMatchedRules(); |
337 | 333 |
338 m_mode = SelectorChecker::SharingRules; | 334 m_mode = SelectorChecker::SharingRules; |
339 // To check whether a given RuleSet has any rule matching a given element, | 335 // To check whether a given RuleSet has any rule matching a given element, |
340 // should not see the element's treescope. Because RuleSet has no | 336 // should not see the element's treescope. Because RuleSet has no |
341 // information about "scope". | 337 // information about "scope". |
342 int firstRuleIndex = -1, lastRuleIndex = -1; | |
343 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); | |
344 // FIXME: Verify whether it's ok to ignore CascadeScope here. | 338 // FIXME: Verify whether it's ok to ignore CascadeScope here. |
| 339 RuleRange ruleRange; |
345 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay
sWithinTreeScope); | 340 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay
sWithinTreeScope); |
346 | 341 |
347 return m_matchedRules && !m_matchedRules->isEmpty(); | 342 return m_matchedRules && !m_matchedRules->isEmpty(); |
348 } | 343 } |
349 | 344 |
350 } // namespace WebCore | 345 } // namespace WebCore |
OLD | NEW |