| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/css/CSSSelector.h" | 33 #include "core/css/CSSSelector.h" |
| 34 #include "core/css/SelectorCheckerFastPath.h" | 34 #include "core/css/SelectorCheckerFastPath.h" |
| 35 #include "core/css/SiblingTraversalStrategies.h" | 35 #include "core/css/SiblingTraversalStrategies.h" |
| 36 #include "core/css/StylePropertySet.h" | 36 #include "core/css/StylePropertySet.h" |
| 37 #include "core/css/resolver/StyleResolver.h" | 37 #include "core/css/resolver/StyleResolver.h" |
| 38 #include "core/rendering/RenderRegion.h" | 38 #include "core/rendering/RenderRegion.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, | 42 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, |
| 43 const SelectorFilter& filter, RenderStyle* style, InspectorCSSOMWrappers& in
spectorWrappers) | 43 const SelectorFilter& filter, RenderStyle* style) |
| 44 : m_context(context) | 44 : m_context(context) |
| 45 , m_selectorFilter(filter) | 45 , m_selectorFilter(filter) |
| 46 , m_inspectorCSSOMWrappers(inspectorWrappers) | |
| 47 , m_style(style) | 46 , m_style(style) |
| 48 , m_regionForStyling(0) | 47 , m_regionForStyling(0) |
| 49 , m_pseudoStyleRequest(NOPSEUDO) | 48 , m_pseudoStyleRequest(NOPSEUDO) |
| 50 , m_mode(SelectorChecker::ResolvingStyle) | 49 , m_mode(SelectorChecker::ResolvingStyle) |
| 51 , m_behaviorAtBoundary(SelectorChecker::DoesNotCrossBoundary) | 50 , m_behaviorAtBoundary(SelectorChecker::DoesNotCrossBoundary) |
| 52 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(context.parent
Node())) | 51 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(context.parent
Node())) |
| 53 , m_sameOriginOnly(false) | 52 , m_sameOriginOnly(false) |
| 54 , m_matchingUARules(false) | 53 , m_matchingUARules(false) |
| 55 { } | 54 { } |
| 56 | 55 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return false; | 215 return false; |
| 217 return true; | 216 return true; |
| 218 } | 217 } |
| 219 | 218 |
| 220 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, const
MatchRequest& matchRequest, RuleRange& ruleRange) | 219 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, const
MatchRequest& matchRequest, RuleRange& ruleRange) |
| 221 { | 220 { |
| 222 if (m_canUseFastReject && m_selectorFilter.fastRejectSelector(ruleData.selec
tor())) | 221 if (m_canUseFastReject && m_selectorFilter.fastRejectSelector(ruleData.selec
tor())) |
| 223 return; | 222 return; |
| 224 | 223 |
| 225 StyleRule* rule = ruleData.rule(); | 224 StyleRule* rule = ruleData.rule(); |
| 226 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchR
ule(document(), rule, m_inspectorCSSOMWrappers, document()->styleSheetCollection
()); | |
| 227 PseudoId dynamicPseudo = NOPSEUDO; | 225 PseudoId dynamicPseudo = NOPSEUDO; |
| 228 if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) { | 226 if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) { |
| 229 // If the rule has no properties to apply, then ignore it in the non-deb
ug mode. | 227 // If the rule has no properties to apply, then ignore it in the non-deb
ug mode. |
| 230 const StylePropertySet* properties = rule->properties(); | 228 const StylePropertySet* properties = rule->properties(); |
| 231 if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyR
ules)) { | 229 if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyR
ules)) |
| 232 InspectorInstrumentation::didMatchRule(cookie, false); | |
| 233 return; | 230 return; |
| 234 } | |
| 235 // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the
only reason this is needed. | 231 // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the
only reason this is needed. |
| 236 if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { | 232 if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) |
| 237 InspectorInstrumentation::didMatchRule(cookie, false); | |
| 238 return; | 233 return; |
| 239 } | |
| 240 // If we're matching normal rules, set a pseudo bit if | 234 // If we're matching normal rules, set a pseudo bit if |
| 241 // we really just matched a pseudo-element. | 235 // we really just matched a pseudo-element. |
| 242 if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEU
DO) { | 236 if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEU
DO) { |
| 243 if (m_mode == SelectorChecker::CollectingRules) { | 237 if (m_mode == SelectorChecker::CollectingRules) |
| 244 InspectorInstrumentation::didMatchRule(cookie, false); | |
| 245 return; | 238 return; |
| 246 } | |
| 247 // FIXME: Matching should not modify the style directly. | 239 // FIXME: Matching should not modify the style directly. |
| 248 if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) | 240 if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) |
| 249 m_style->setHasPseudoStyle(dynamicPseudo); | 241 m_style->setHasPseudoStyle(dynamicPseudo); |
| 250 } else { | 242 } else { |
| 251 // Update our first/last rule indices in the matched rules array. | 243 // Update our first/last rule indices in the matched rules array. |
| 252 ++ruleRange.lastRuleIndex; | 244 ++ruleRange.lastRuleIndex; |
| 253 if (ruleRange.firstRuleIndex == -1) | 245 if (ruleRange.firstRuleIndex == -1) |
| 254 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; | 246 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; |
| 255 | 247 |
| 256 // Add this rule to our list of matched rules. | 248 // Add this rule to our list of matched rules. |
| 257 addMatchedRule(&ruleData); | 249 addMatchedRule(&ruleData); |
| 258 InspectorInstrumentation::didMatchRule(cookie, true); | |
| 259 return; | 250 return; |
| 260 } | 251 } |
| 261 } | 252 } |
| 262 InspectorInstrumentation::didMatchRule(cookie, false); | |
| 263 } | 253 } |
| 264 | 254 |
| 265 void ElementRuleCollector::collectMatchingRulesForList(const RuleData* rules, co
nst MatchRequest& matchRequest, RuleRange& ruleRange) | 255 void ElementRuleCollector::collectMatchingRulesForList(const RuleData* rules, co
nst MatchRequest& matchRequest, RuleRange& ruleRange) |
| 266 { | 256 { |
| 267 if (!rules) | 257 if (!rules) |
| 268 return; | 258 return; |
| 269 while (!rules->isLastInArray()) | 259 while (!rules->isLastInArray()) |
| 270 collectRuleIfMatches(*rules++, matchRequest, ruleRange); | 260 collectRuleIfMatches(*rules++, matchRequest, ruleRange); |
| 271 collectRuleIfMatches(*rules, matchRequest, ruleRange); | 261 collectRuleIfMatches(*rules, matchRequest, ruleRange); |
| 272 } | 262 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 303 // information about "scope". | 293 // information about "scope". |
| 304 m_behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope; | 294 m_behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope; |
| 305 int firstRuleIndex = -1, lastRuleIndex = -1; | 295 int firstRuleIndex = -1, lastRuleIndex = -1; |
| 306 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); | 296 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); |
| 307 collectMatchingRules(MatchRequest(ruleSet), ruleRange); | 297 collectMatchingRules(MatchRequest(ruleSet), ruleRange); |
| 308 | 298 |
| 309 return m_matchedRules && !m_matchedRules->isEmpty(); | 299 return m_matchedRules && !m_matchedRules->isEmpty(); |
| 310 } | 300 } |
| 311 | 301 |
| 312 } // namespace WebCore | 302 } // namespace WebCore |
| OLD | NEW |