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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 m_result.isCacheable = false; | 82 m_result.isCacheable = false; |
83 } | 83 } |
84 | 84 |
85 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
, RuleRange& ruleRange) | 85 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
, RuleRange& ruleRange) |
86 { | 86 { |
87 ASSERT(matchRequest.ruleSet); | 87 ASSERT(matchRequest.ruleSet); |
88 ASSERT(m_state.element()); | 88 ASSERT(m_state.element()); |
89 | 89 |
90 const StyleResolverState& state = m_state; | 90 const StyleResolverState& state = m_state; |
91 Element* element = state.element(); | 91 Element* element = state.element(); |
92 const Element* styledElement = state.styledElement(); | |
93 const AtomicString& pseudoId = element->shadowPseudoId(); | 92 const AtomicString& pseudoId = element->shadowPseudoId(); |
94 if (!pseudoId.isEmpty()) { | 93 if (!pseudoId.isEmpty()) { |
95 ASSERT(styledElement); | 94 ASSERT(element->isStyledElement()); |
96 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRul
es(pseudoId.impl()), matchRequest, ruleRange); | 95 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRul
es(pseudoId.impl()), matchRequest, ruleRange); |
97 } | 96 } |
98 | 97 |
99 if (element->isWebVTTElement()) | 98 if (element->isWebVTTElement()) |
100 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matc
hRequest, ruleRange); | 99 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matc
hRequest, ruleRange); |
101 // Check whether other types of rules are applicable in the current tree sco
pe. Criteria for this: | 100 // Check whether other types of rules are applicable in the current tree sco
pe. Criteria for this: |
102 // a) it's a UA rule | 101 // a) it's a UA rule |
103 // b) the tree scope allows author rules | 102 // b) the tree scope allows author rules |
104 // c) the rules comes from a scoped style sheet within the same tree scope | 103 // c) the rules comes from a scoped style sheet within the same tree scope |
105 TreeScope* treeScope = element->treeScope(); | 104 TreeScope* treeScope = element->treeScope(); |
106 if (!m_matchingUARules | 105 if (!m_matchingUARules |
107 && !treeScope->applyAuthorStyles() | 106 && !treeScope->applyAuthorStyles() |
108 && (!matchRequest.scope || matchRequest.scope->treeScope() != treeScope) | 107 && (!matchRequest.scope || matchRequest.scope->treeScope() != treeScope) |
109 && (m_behaviorAtBoundary & SelectorChecker::BoundaryBehaviorMask) == Sel
ectorChecker::DoesNotCrossBoundary) | 108 && (m_behaviorAtBoundary & SelectorChecker::BoundaryBehaviorMask) == Sel
ectorChecker::DoesNotCrossBoundary) |
110 return; | 109 return; |
111 | 110 |
112 // We need to collect the rules for id, class, tag, and everything else into
a buffer and | 111 // We need to collect the rules for id, class, tag, and everything else into
a buffer and |
113 // then sort the buffer. | 112 // then sort the buffer. |
114 if (element->hasID()) | 113 if (element->hasID()) |
115 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element->idFor
StyleResolution().impl()), matchRequest, ruleRange); | 114 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element->idFor
StyleResolution().impl()), matchRequest, ruleRange); |
116 if (styledElement && styledElement->hasClass()) { | 115 if (element->isStyledElement() && element->hasClass()) { |
117 for (size_t i = 0; i < styledElement->classNames().size(); ++i) | 116 for (size_t i = 0; i < element->classNames().size(); ++i) |
118 collectMatchingRulesForList(matchRequest.ruleSet->classRules(styledE
lement->classNames()[i].impl()), matchRequest, ruleRange); | 117 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element
->classNames()[i].impl()), matchRequest, ruleRange); |
119 } | 118 } |
120 | 119 |
121 if (element->isLink()) | 120 if (element->isLink()) |
122 collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules()
, matchRequest, ruleRange); | 121 collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules()
, matchRequest, ruleRange); |
123 if (SelectorChecker::matchesFocusPseudoClass(element)) | 122 if (SelectorChecker::matchesFocusPseudoClass(element)) |
124 collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(
), matchRequest, ruleRange); | 123 collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(
), matchRequest, ruleRange); |
125 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localNam
e().impl()), matchRequest, ruleRange); | 124 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localNam
e().impl()), matchRequest, ruleRange); |
126 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchReq
uest, ruleRange); | 125 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchReq
uest, ruleRange); |
127 } | 126 } |
128 | 127 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // information about "scope". | 290 // information about "scope". |
292 m_behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope; | 291 m_behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope; |
293 int firstRuleIndex = -1, lastRuleIndex = -1; | 292 int firstRuleIndex = -1, lastRuleIndex = -1; |
294 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); | 293 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); |
295 collectMatchingRules(MatchRequest(ruleSet), ruleRange); | 294 collectMatchingRules(MatchRequest(ruleSet), ruleRange); |
296 | 295 |
297 return m_matchedRules && !m_matchedRules->isEmpty(); | 296 return m_matchedRules && !m_matchedRules->isEmpty(); |
298 } | 297 } |
299 | 298 |
300 } // namespace WebCore | 299 } // namespace WebCore |
OLD | NEW |