| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "core/style/StyleInheritedData.h" | 44 #include "core/style/StyleInheritedData.h" |
| 45 #include <algorithm> | 45 #include <algorithm> |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, | 49 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, |
| 50 const SelectorFilter& filter, ComputedStyle* style) | 50 const SelectorFilter& filter, ComputedStyle* style) |
| 51 : m_context(context) | 51 : m_context(context) |
| 52 , m_selectorFilter(filter) | 52 , m_selectorFilter(filter) |
| 53 , m_style(style) | 53 , m_style(style) |
| 54 , m_pseudoStyleRequest(NOPSEUDO) | 54 , m_pseudoStyleRequest(PseudoIdNone) |
| 55 , m_mode(SelectorChecker::ResolvingStyle) | 55 , m_mode(SelectorChecker::ResolvingStyle) |
| 56 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(context.parent
Node())) | 56 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(context.parent
Node())) |
| 57 , m_sameOriginOnly(false) | 57 , m_sameOriginOnly(false) |
| 58 , m_matchingUARules(false) | 58 , m_matchingUARules(false) |
| 59 , m_includeEmptyRules(false) | 59 , m_includeEmptyRules(false) |
| 60 { } | 60 { } |
| 61 | 61 |
| 62 ElementRuleCollector::~ElementRuleCollector() | 62 ElementRuleCollector::~ElementRuleCollector() |
| 63 { | 63 { |
| 64 } | 64 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 const StylePropertySet& properties = rule->properties(); | 157 const StylePropertySet& properties = rule->properties(); |
| 158 if (properties.isEmpty() && !m_includeEmptyRules) | 158 if (properties.isEmpty() && !m_includeEmptyRules) |
| 159 continue; | 159 continue; |
| 160 | 160 |
| 161 SelectorChecker::MatchResult result; | 161 SelectorChecker::MatchResult result; |
| 162 context.selector = &ruleData.selector(); | 162 context.selector = &ruleData.selector(); |
| 163 if (!checker.match(context, result)) { | 163 if (!checker.match(context, result)) { |
| 164 rejected++; | 164 rejected++; |
| 165 continue; | 165 continue; |
| 166 } | 166 } |
| 167 if (m_pseudoStyleRequest.pseudoId != NOPSEUDO && m_pseudoStyleRequest.ps
eudoId != result.dynamicPseudo) { | 167 if (m_pseudoStyleRequest.pseudoId != PseudoIdNone && m_pseudoStyleReques
t.pseudoId != result.dynamicPseudo) { |
| 168 rejected++; | 168 rejected++; |
| 169 continue; | 169 continue; |
| 170 } | 170 } |
| 171 | 171 |
| 172 matched++; | 172 matched++; |
| 173 didMatchRule(ruleData, result, cascadeOrder, matchRequest); | 173 didMatchRule(ruleData, result, cascadeOrder, matchRequest); |
| 174 } | 174 } |
| 175 | 175 |
| 176 StyleEngine& styleEngine = m_context.element()->document().styleEngine(); | 176 StyleEngine& styleEngine = m_context.element()->document().styleEngine(); |
| 177 if (!styleEngine.stats()) | 177 if (!styleEngine.stats()) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 const RuleData* ruleData = m_matchedRules[i].ruleData(); | 287 const RuleData* ruleData = m_matchedRules[i].ruleData(); |
| 288 m_result.addMatchedProperties(&ruleData->rule()->properties(), ruleData-
>linkMatchType(), ruleData->propertyWhitelist(m_matchingUARules)); | 288 m_result.addMatchedProperties(&ruleData->rule()->properties(), ruleData-
>linkMatchType(), ruleData->propertyWhitelist(m_matchingUARules)); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const Selector
Checker::MatchResult& result, CascadeOrder cascadeOrder, const MatchRequest& mat
chRequest) | 292 void ElementRuleCollector::didMatchRule(const RuleData& ruleData, const Selector
Checker::MatchResult& result, CascadeOrder cascadeOrder, const MatchRequest& mat
chRequest) |
| 293 { | 293 { |
| 294 PseudoId dynamicPseudo = result.dynamicPseudo; | 294 PseudoId dynamicPseudo = result.dynamicPseudo; |
| 295 // If we're matching normal rules, set a pseudo bit if | 295 // If we're matching normal rules, set a pseudo bit if |
| 296 // we really just matched a pseudo-element. | 296 // we really just matched a pseudo-element. |
| 297 if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO)
{ | 297 if (dynamicPseudo != PseudoIdNone && m_pseudoStyleRequest.pseudoId == Pseudo
IdNone) { |
| 298 if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == SelectorC
hecker::CollectingStyleRules) | 298 if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == SelectorC
hecker::CollectingStyleRules) |
| 299 return; | 299 return; |
| 300 // FIXME: Matching should not modify the style directly. | 300 // FIXME: Matching should not modify the style directly. |
| 301 if (!m_style || dynamicPseudo >= FIRST_INTERNAL_PSEUDOID) | 301 if (!m_style || dynamicPseudo >= FirstInternalPseudoId) |
| 302 return; | 302 return; |
| 303 if ((dynamicPseudo == BEFORE || dynamicPseudo == AFTER) && !ruleData.rul
e()->properties().hasProperty(CSSPropertyContent)) | 303 if ((dynamicPseudo == PseudoIdBefore || dynamicPseudo == PseudoIdAfter)
&& !ruleData.rule()->properties().hasProperty(CSSPropertyContent)) |
| 304 return; | 304 return; |
| 305 m_style->setHasPseudoStyle(dynamicPseudo); | 305 m_style->setHasPseudoStyle(dynamicPseudo); |
| 306 } else { | 306 } else { |
| 307 if (m_style && ruleData.containsUncommonAttributeSelector()) | 307 if (m_style && ruleData.containsUncommonAttributeSelector()) |
| 308 m_style->setUnique(); | 308 m_style->setUnique(); |
| 309 | 309 |
| 310 m_matchedRules.append(MatchedRule(&ruleData, result.specificity, cascade
Order, matchRequest.styleSheetIndex, matchRequest.styleSheet)); | 310 m_matchedRules.append(MatchedRule(&ruleData, result.specificity, cascade
Order, matchRequest.styleSheetIndex, matchRequest.styleSheet)); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 335 // should not see the element's treescope. Because RuleSet has no | 335 // should not see the element's treescope. Because RuleSet has no |
| 336 // information about "scope". | 336 // information about "scope". |
| 337 MatchRequest matchRequest(ruleSet); | 337 MatchRequest matchRequest(ruleSet); |
| 338 collectMatchingRules(matchRequest); | 338 collectMatchingRules(matchRequest); |
| 339 collectMatchingShadowHostRules(matchRequest); | 339 collectMatchingShadowHostRules(matchRequest); |
| 340 | 340 |
| 341 return !m_matchedRules.isEmpty(); | 341 return !m_matchedRules.isEmpty(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace blink | 344 } // namespace blink |
| OLD | NEW |