| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/css/ElementRuleCollector.h" | 30 #include "core/css/ElementRuleCollector.h" |
| 31 | 31 |
| 32 #include "core/css/CSSImportRule.h" | 32 #include "core/css/CSSImportRule.h" |
| 33 #include "core/css/CSSKeyframesRule.h" | 33 #include "core/css/CSSKeyframesRule.h" |
| 34 #include "core/css/CSSMediaRule.h" | 34 #include "core/css/CSSMediaRule.h" |
| 35 #include "core/css/CSSRuleList.h" | 35 #include "core/css/CSSRuleList.h" |
| 36 #include "core/css/CSSSelector.h" | 36 #include "core/css/CSSSelector.h" |
| 37 #include "core/css/CSSStyleRule.h" | 37 #include "core/css/CSSStyleRule.h" |
| 38 #include "core/css/CSSStyleSheet.h" | 38 #include "core/css/CSSStyleSheet.h" |
| 39 #include "core/css/CSSSupportsRule.h" | 39 #include "core/css/CSSSupportsRule.h" |
| 40 #include "core/css/SelectorCheckerFastPath.h" | |
| 41 #include "core/css/SiblingTraversalStrategies.h" | 40 #include "core/css/SiblingTraversalStrategies.h" |
| 42 #include "core/css/StylePropertySet.h" | 41 #include "core/css/StylePropertySet.h" |
| 43 #include "core/css/resolver/StyleResolver.h" | 42 #include "core/css/resolver/StyleResolver.h" |
| 44 #include "core/dom/shadow/ShadowRoot.h" | 43 #include "core/dom/shadow/ShadowRoot.h" |
| 45 | 44 |
| 46 namespace WebCore { | 45 namespace WebCore { |
| 47 | 46 |
| 48 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, | 47 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, |
| 49 const SelectorFilter& filter, RenderStyle* style) | 48 const SelectorFilter& filter, RenderStyle* style) |
| 50 : m_context(context) | 49 : m_context(context) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // FIXME: Matching should not modify the style directly. | 251 // FIXME: Matching should not modify the style directly. |
| 253 const RuleData* ruleData = matchedRules[i].ruleData(); | 252 const RuleData* ruleData = matchedRules[i].ruleData(); |
| 254 if (m_style && ruleData->containsUncommonAttributeSelector()) | 253 if (m_style && ruleData->containsUncommonAttributeSelector()) |
| 255 m_style->setUnique(); | 254 m_style->setUnique(); |
| 256 m_result.addMatchedProperties(&ruleData->rule()->properties(), ruleData-
>rule(), ruleData->linkMatchType(), ruleData->propertyWhitelistType(m_matchingUA
Rules)); | 255 m_result.addMatchedProperties(&ruleData->rule()->properties(), ruleData-
>rule(), ruleData->linkMatchType(), ruleData->propertyWhitelistType(m_matchingUA
Rules)); |
| 257 } | 256 } |
| 258 } | 257 } |
| 259 | 258 |
| 260 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co
ntainerNode* scope, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary, Sele
ctorChecker::MatchResult* result) | 259 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co
ntainerNode* scope, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary, Sele
ctorChecker::MatchResult* result) |
| 261 { | 260 { |
| 262 // Scoped rules can't match because the fast path uses a pool of tag/class/i
ds, collected from | |
| 263 // elements in that tree and those will never match the host, since it's in
a different pool. | |
| 264 if (ruleData.hasFastCheckableSelector() && !scope) { | |
| 265 // We know this selector does not include any pseudo elements. | |
| 266 if (m_pseudoStyleRequest.pseudoId != NOPSEUDO) | |
| 267 return false; | |
| 268 // We know a sufficiently simple single part selector matches simply bec
ause we found it from the rule hash. | |
| 269 // This is limited to HTML only so we don't need to check the namespace. | |
| 270 ASSERT(m_context.element()); | |
| 271 if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_cont
ext.element()->isHTMLElement()) { | |
| 272 if (!ruleData.hasMultipartSelector()) | |
| 273 return true; | |
| 274 } | |
| 275 if (ruleData.selector().m_match == CSSSelector::Tag && !SelectorChecker:
:tagMatches(*m_context.element(), ruleData.selector().tagQName())) | |
| 276 return false; | |
| 277 SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), *m_
context.element()); | |
| 278 if (!selectorCheckerFastPath.matchesRightmostAttributeSelector()) | |
| 279 return false; | |
| 280 | |
| 281 return selectorCheckerFastPath.matches(); | |
| 282 } | |
| 283 | |
| 284 // Slow path. | |
| 285 SelectorChecker selectorChecker(m_context.element()->document(), m_mode); | 261 SelectorChecker selectorChecker(m_context.element()->document(), m_mode); |
| 286 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont
ext.element(), SelectorChecker::VisitedMatchEnabled); | 262 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont
ext.element(), SelectorChecker::VisitedMatchEnabled); |
| 287 context.elementStyle = m_style.get(); | 263 context.elementStyle = m_style.get(); |
| 288 context.scope = scope; | 264 context.scope = scope; |
| 289 context.pseudoId = m_pseudoStyleRequest.pseudoId; | 265 context.pseudoId = m_pseudoStyleRequest.pseudoId; |
| 290 context.scrollbar = m_pseudoStyleRequest.scrollbar; | 266 context.scrollbar = m_pseudoStyleRequest.scrollbar; |
| 291 context.scrollbarPart = m_pseudoStyleRequest.scrollbarPart; | 267 context.scrollbarPart = m_pseudoStyleRequest.scrollbarPart; |
| 292 context.behaviorAtBoundary = behaviorAtBoundary; | 268 context.behaviorAtBoundary = behaviorAtBoundary; |
| 293 SelectorChecker::Match match = selectorChecker.match(context, DOMSiblingTrav
ersalStrategy(), result); | 269 SelectorChecker::Match match = selectorChecker.match(context, DOMSiblingTrav
ersalStrategy(), result); |
| 294 if (match != SelectorChecker::SelectorMatches) | 270 if (match != SelectorChecker::SelectorMatches) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // information about "scope". | 341 // information about "scope". |
| 366 int firstRuleIndex = -1, lastRuleIndex = -1; | 342 int firstRuleIndex = -1, lastRuleIndex = -1; |
| 367 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); | 343 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); |
| 368 // FIXME: Verify whether it's ok to ignore CascadeScope here. | 344 // FIXME: Verify whether it's ok to ignore CascadeScope here. |
| 369 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay
sWithinTreeScope); | 345 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay
sWithinTreeScope); |
| 370 | 346 |
| 371 return m_matchedRules && !m_matchedRules->isEmpty(); | 347 return m_matchedRules && !m_matchedRules->isEmpty(); |
| 372 } | 348 } |
| 373 | 349 |
| 374 } // namespace WebCore | 350 } // namespace WebCore |
| OLD | NEW |