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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (!propertySet) | 111 if (!propertySet) |
112 return; | 112 return; |
113 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size(); | 113 m_result.ranges.lastAuthorRule = m_result.matchedProperties.size(); |
114 if (m_result.ranges.firstAuthorRule == -1) | 114 if (m_result.ranges.firstAuthorRule == -1) |
115 m_result.ranges.firstAuthorRule = m_result.ranges.lastAuthorRule; | 115 m_result.ranges.firstAuthorRule = m_result.ranges.lastAuthorRule; |
116 m_result.addMatchedProperties(propertySet); | 116 m_result.addMatchedProperties(propertySet); |
117 if (!isCacheable) | 117 if (!isCacheable) |
118 m_result.isCacheable = false; | 118 m_result.isCacheable = false; |
119 } | 119 } |
120 | 120 |
121 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
ainerNode* scopingNode, bool elementApplyAuthorStyles) | 121 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
ainerNode* scopingNode, bool matchingTreeBoundaryRules) |
122 { | 122 { |
123 TreeScope& treeScope = element->treeScope(); | |
124 | |
125 // [skipped, because already checked] a) it's a UA rule | 123 // [skipped, because already checked] a) it's a UA rule |
126 // b) element is allowed to apply author rules | 124 // b) We're mathcing tree boundary rules. |
127 if (elementApplyAuthorStyles) | 125 if (matchingTreeBoundaryRules) |
128 return true; | 126 return true; |
129 // c) the rules comes from a scoped style sheet within the same tree scope | 127 // c) the rules comes from a scoped style sheet within the same tree scope |
130 if (!scopingNode || treeScope == scopingNode->treeScope()) | 128 if (!scopingNode || element->treeScope() == scopingNode->treeScope()) |
131 return true; | 129 return true; |
132 // d) the rules comes from a scoped style sheet within an active shadow root
whose host is the given element | 130 // d) the rules comes from a scoped style sheet within an active shadow root
whose host is the given element |
133 if (SelectorChecker::isHostInItsShadowTree(*element, scopingNode)) | 131 if (SelectorChecker::isHostInItsShadowTree(*element, scopingNode)) |
134 return true; | 132 return true; |
135 return false; | 133 return false; |
136 } | 134 } |
137 | 135 |
138 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
, RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope
cascadeScope, CascadeOrder cascadeOrder) | 136 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
, RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope
cascadeScope, CascadeOrder cascadeOrder, bool matchingTreeBoundaryRules) |
139 { | 137 { |
140 ASSERT(matchRequest.ruleSet); | 138 ASSERT(matchRequest.ruleSet); |
141 ASSERT(m_context.element()); | 139 ASSERT(m_context.element()); |
142 | 140 |
143 Element& element = *m_context.element(); | 141 Element& element = *m_context.element(); |
144 const AtomicString& pseudoId = element.shadowPseudoId(); | 142 const AtomicString& pseudoId = element.shadowPseudoId(); |
145 if (!pseudoId.isEmpty()) { | 143 if (!pseudoId.isEmpty()) { |
146 ASSERT(element.isStyledElement()); | 144 ASSERT(element.isStyledElement()); |
147 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRul
es(pseudoId), contextFlags, ignoreCascadeScope, cascadeOrder, matchRequest, rule
Range); | 145 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRul
es(pseudoId), contextFlags, ignoreCascadeScope, cascadeOrder, matchRequest, rule
Range); |
148 } | 146 } |
149 | 147 |
150 if (element.isVTTElement()) | 148 if (element.isVTTElement()) |
151 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), cont
extFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange); | 149 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), cont
extFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange); |
152 // Check whether other types of rules are applicable in the current tree sco
pe. Criteria for this: | 150 // Check whether other types of rules are applicable in the current tree sco
pe. Criteria for this: |
153 // a) it's a UA rule | 151 // a) it's a UA rule |
154 // b) the tree scope allows author rules | 152 // b) the rules comes from a scoped style sheet within the same tree scope |
155 // c) the rules comes from a scoped style sheet within the same tree scope | 153 // c) the rules comes from a scoped style sheet within an active shadow root
whose host is the given element |
156 // d) the rules comes from a scoped style sheet within an active shadow root
whose host is the given element | 154 // d) the rules can cross boundaries |
157 // e) the rules can cross boundaries | |
158 // b)-e) is checked in rulesApplicableInCurrentTreeScope. | 155 // b)-e) is checked in rulesApplicableInCurrentTreeScope. |
159 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match
Request.scope, matchRequest.elementApplyAuthorStyles)) | 156 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match
Request.scope, matchingTreeBoundaryRules)) |
160 return; | 157 return; |
161 | 158 |
162 // We need to collect the rules for id, class, tag, and everything else into
a buffer and | 159 // We need to collect the rules for id, class, tag, and everything else into
a buffer and |
163 // then sort the buffer. | 160 // then sort the buffer. |
164 if (element.hasID()) | 161 if (element.hasID()) |
165 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS
tyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR
ange); | 162 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS
tyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR
ange); |
166 if (element.isStyledElement() && element.hasClass()) { | 163 if (element.isStyledElement() && element.hasClass()) { |
167 for (size_t i = 0; i < element.classNames().size(); ++i) | 164 for (size_t i = 0; i < element.classNames().size(); ++i) |
168 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element
.classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR
ange); | 165 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element
.classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR
ange); |
169 } | 166 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // information about "scope". | 340 // information about "scope". |
344 int firstRuleIndex = -1, lastRuleIndex = -1; | 341 int firstRuleIndex = -1, lastRuleIndex = -1; |
345 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); | 342 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); |
346 // FIXME: Verify whether it's ok to ignore CascadeScope here. | 343 // FIXME: Verify whether it's ok to ignore CascadeScope here. |
347 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Defa
ultBehavior); | 344 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Defa
ultBehavior); |
348 | 345 |
349 return m_matchedRules && !m_matchedRules->isEmpty(); | 346 return m_matchedRules && !m_matchedRules->isEmpty(); |
350 } | 347 } |
351 | 348 |
352 } // namespace blink | 349 } // namespace blink |
OLD | NEW |