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 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 static bool containsUncommonAttributeSelector(const CSSSelector& selector) | 72 static bool containsUncommonAttributeSelector(const CSSSelector& selector) |
73 { | 73 { |
74 const CSSSelector* current = &selector; | 74 const CSSSelector* current = &selector; |
75 for (; current; current = current->tagHistory()) { | 75 for (; current; current = current->tagHistory()) { |
76 // Allow certain common attributes (used in the default style) in the se
lectors that match the current element. | 76 // Allow certain common attributes (used in the default style) in the se
lectors that match the current element. |
77 if (current->isAttributeSelector() && !isCommonAttributeSelectorAttribut
e(current->attribute())) | 77 if (current->isAttributeSelector() && !isCommonAttributeSelectorAttribut
e(current->attribute())) |
78 return true; | 78 return true; |
79 if (selectorListContainsUncommonAttributeSelector(current)) | 79 if (selectorListContainsUncommonAttributeSelector(current)) |
80 return true; | 80 return true; |
81 if (current->relationIsAffectedByPseudoContent() | 81 if (current->relationIsAffectedByPseudoContent() || current->pseudoType(
) == CSSSelector::PseudoSlotted) |
82 || current->pseudoType() == CSSSelector::PseudoHost | |
83 || current->pseudoType() == CSSSelector::PseudoHostContext | |
84 || current->pseudoType() == CSSSelector::PseudoSlotted) { | |
85 return false; | 82 return false; |
86 } | |
87 if (current->relation() != CSSSelector::SubSelector) { | 83 if (current->relation() != CSSSelector::SubSelector) { |
88 current = current->tagHistory(); | 84 current = current->tagHistory(); |
89 break; | 85 break; |
90 } | 86 } |
91 } | 87 } |
92 | 88 |
93 for (; current; current = current->tagHistory()) { | 89 for (; current; current = current->tagHistory()) { |
94 if (current->isAttributeSelector()) | 90 if (current->isAttributeSelector()) |
95 return true; | 91 return true; |
96 if (selectorListContainsUncommonAttributeSelector(current)) | 92 if (selectorListContainsUncommonAttributeSelector(current)) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 m_shadowHostRules.append(ruleData); | 211 m_shadowHostRules.append(ruleData); |
216 return true; | 212 return true; |
217 } | 213 } |
218 | 214 |
219 return false; | 215 return false; |
220 } | 216 } |
221 | 217 |
222 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
uleFlags) | 218 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
uleFlags) |
223 { | 219 { |
224 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); | 220 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); |
225 m_features.collectFeaturesFromRuleData(ruleData); | 221 if (m_features.collectFeaturesFromRuleData(ruleData) == RuleFeatureSet::Sele
ctorNeverMatches) |
| 222 return; |
226 | 223 |
227 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) { | 224 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) { |
228 // If we didn't find a specialized map to stick it in, file under univer
sal rules. | 225 // If we didn't find a specialized map to stick it in, file under univer
sal rules. |
229 m_universalRules.append(ruleData); | 226 m_universalRules.append(ruleData); |
230 } | 227 } |
231 } | 228 } |
232 | 229 |
233 void RuleSet::addPageRule(StyleRulePage* rule) | 230 void RuleSet::addPageRule(StyleRulePage* rule) |
234 { | 231 { |
235 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called. | 232 ensurePendingRules(); // So that m_pageRules.shrinkToFit() gets called. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 401 |
405 #ifndef NDEBUG | 402 #ifndef NDEBUG |
406 void RuleSet::show() const | 403 void RuleSet::show() const |
407 { | 404 { |
408 for (const auto& rule: m_allRules) | 405 for (const auto& rule: m_allRules) |
409 rule.selector().show(); | 406 rule.selector().show(); |
410 } | 407 } |
411 #endif | 408 #endif |
412 | 409 |
413 } // namespace blink | 410 } // namespace blink |
OLD | NEW |