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 | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All |
6 * rights reserved. | 6 * rights reserved. |
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 else if (!features.hasFeatures()) | 460 else if (!features.hasFeatures()) |
461 features.forceSubtree = true; | 461 features.forceSubtree = true; |
462 if (features.hasNthPseudo) | 462 if (features.hasNthPseudo) |
463 addFeaturesToInvalidationSet(ensureNthInvalidationSet(), features); | 463 addFeaturesToInvalidationSet(ensureNthInvalidationSet(), features); |
464 if (features.hasBeforeOrAfter) | 464 if (features.hasBeforeOrAfter) |
465 updateInvalidationSetsForContentAttribute(ruleData); | 465 updateInvalidationSetsForContentAttribute(ruleData); |
466 | 466 |
467 const CSSSelector* nextCompound = | 467 const CSSSelector* nextCompound = |
468 lastInCompound ? lastInCompound->tagHistory() : &ruleData.selector(); | 468 lastInCompound ? lastInCompound->tagHistory() : &ruleData.selector(); |
469 if (!nextCompound) { | 469 if (!nextCompound) { |
470 if (!features.hasFeaturesForRuleSetInvalidation) | 470 updateRuleSetInvalidation(features); |
471 m_metadata.needsFullRecalcForRuleSetInvalidation = true; | |
472 return; | 471 return; |
473 } | 472 } |
474 if (lastInCompound) | 473 if (lastInCompound) |
475 updateFeaturesFromCombinator(*lastInCompound, nullptr, features, | 474 updateFeaturesFromCombinator(*lastInCompound, nullptr, features, |
476 siblingFeatures, features); | 475 siblingFeatures, features); |
477 | 476 |
478 addFeaturesToInvalidationSets(*nextCompound, siblingFeatures, features); | 477 addFeaturesToInvalidationSets(*nextCompound, siblingFeatures, features); |
| 478 updateRuleSetInvalidation(features); |
| 479 } |
479 | 480 |
480 if (!features.hasFeaturesForRuleSetInvalidation) | 481 void RuleFeatureSet::updateRuleSetInvalidation( |
481 m_metadata.needsFullRecalcForRuleSetInvalidation = true; | 482 const InvalidationSetFeatures& features) { |
| 483 if (!features.hasFeaturesForRuleSetInvalidation) { |
| 484 if (features.forceSubtree || features.tagNames.isEmpty()) |
| 485 m_metadata.needsFullRecalcForRuleSetInvalidation = true; |
| 486 else |
| 487 addTagNamesToTypeRuleInvalidationSet(features.tagNames); |
| 488 } |
482 } | 489 } |
483 | 490 |
484 void RuleFeatureSet::updateInvalidationSetsForContentAttribute( | 491 void RuleFeatureSet::updateInvalidationSetsForContentAttribute( |
485 const RuleData& ruleData) { | 492 const RuleData& ruleData) { |
486 // If any ::before and ::after rules specify 'content: attr(...)', we | 493 // If any ::before and ::after rules specify 'content: attr(...)', we |
487 // need to create invalidation sets for those attributes to have content | 494 // need to create invalidation sets for those attributes to have content |
488 // changes applied through style recalc. | 495 // changes applied through style recalc. |
489 | 496 |
490 const StylePropertySet& propertySet = ruleData.rule()->properties(); | 497 const StylePropertySet& propertySet = ruleData.rule()->properties(); |
491 | 498 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 if (extractInvalidationSetFeaturesFromSelectorList(*simpleSelector, | 608 if (extractInvalidationSetFeaturesFromSelectorList(*simpleSelector, |
602 features, position) == | 609 features, position) == |
603 RequiresSubtreeInvalidation) { | 610 RequiresSubtreeInvalidation) { |
604 DCHECK(features.forceSubtree); | 611 DCHECK(features.forceSubtree); |
605 return nullptr; | 612 return nullptr; |
606 } | 613 } |
607 | 614 |
608 if (!simpleSelector->tagHistory() || | 615 if (!simpleSelector->tagHistory() || |
609 simpleSelector->relation() != CSSSelector::SubSelector) { | 616 simpleSelector->relation() != CSSSelector::SubSelector) { |
610 features.hasFeaturesForRuleSetInvalidation = | 617 features.hasFeaturesForRuleSetInvalidation = |
611 features.hasTagIdClassOrAttribute(); | 618 features.hasIdClassOrAttribute(); |
612 return simpleSelector; | 619 return simpleSelector; |
613 } | 620 } |
614 } | 621 } |
615 } | 622 } |
616 | 623 |
617 // Add features extracted from the rightmost compound selector to descendant | 624 // Add features extracted from the rightmost compound selector to descendant |
618 // invalidation sets for features found in other compound selectors. | 625 // invalidation sets for features found in other compound selectors. |
619 // | 626 // |
620 // We use descendant invalidation for descendants, sibling invalidation for | 627 // We use descendant invalidation for descendants, sibling invalidation for |
621 // siblings and their subtrees. | 628 // siblings and their subtrees. |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 universalSet.updateMaxDirectAdjacentSelectors( | 1160 universalSet.updateMaxDirectAdjacentSelectors( |
1154 siblingFeatures.maxDirectAdjacentSelectors); | 1161 siblingFeatures.maxDirectAdjacentSelectors); |
1155 | 1162 |
1156 if (&siblingFeatures == &descendantFeatures) | 1163 if (&siblingFeatures == &descendantFeatures) |
1157 universalSet.setInvalidatesSelf(); | 1164 universalSet.setInvalidatesSelf(); |
1158 else | 1165 else |
1159 addFeaturesToInvalidationSet(universalSet.ensureSiblingDescendants(), | 1166 addFeaturesToInvalidationSet(universalSet.ensureSiblingDescendants(), |
1160 descendantFeatures); | 1167 descendantFeatures); |
1161 } | 1168 } |
1162 | 1169 |
| 1170 void RuleFeatureSet::addTagNamesToTypeRuleInvalidationSet( |
| 1171 const Vector<AtomicString>& tagNames) { |
| 1172 DCHECK(!tagNames.isEmpty()); |
| 1173 ensureTypeRuleInvalidationSet(); |
| 1174 for (auto tagName : tagNames) |
| 1175 m_typeRuleInvalidationSet->addTagName(tagName); |
| 1176 } |
| 1177 |
1163 DEFINE_TRACE(RuleFeatureSet) { | 1178 DEFINE_TRACE(RuleFeatureSet) { |
1164 visitor->trace(m_siblingRules); | 1179 visitor->trace(m_siblingRules); |
1165 visitor->trace(m_uncommonAttributeRules); | 1180 visitor->trace(m_uncommonAttributeRules); |
1166 visitor->trace(m_viewportDependentMediaQueryResults); | 1181 visitor->trace(m_viewportDependentMediaQueryResults); |
1167 visitor->trace(m_deviceDependentMediaQueryResults); | 1182 visitor->trace(m_deviceDependentMediaQueryResults); |
1168 } | 1183 } |
1169 | 1184 |
1170 void RuleFeatureSet::InvalidationSetFeatures::add( | 1185 void RuleFeatureSet::InvalidationSetFeatures::add( |
1171 const InvalidationSetFeatures& other) { | 1186 const InvalidationSetFeatures& other) { |
1172 classes.appendVector(other.classes); | 1187 classes.appendVector(other.classes); |
(...skipping 10 matching lines...) Expand all Loading... |
1183 contentPseudoCrossing |= other.contentPseudoCrossing; | 1198 contentPseudoCrossing |= other.contentPseudoCrossing; |
1184 invalidatesSlotted |= other.invalidatesSlotted; | 1199 invalidatesSlotted |= other.invalidatesSlotted; |
1185 hasNthPseudo |= other.hasNthPseudo; | 1200 hasNthPseudo |= other.hasNthPseudo; |
1186 } | 1201 } |
1187 | 1202 |
1188 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { | 1203 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { |
1189 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || | 1204 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || |
1190 !tagNames.isEmpty() || customPseudoElement; | 1205 !tagNames.isEmpty() || customPseudoElement; |
1191 } | 1206 } |
1192 | 1207 |
1193 bool RuleFeatureSet::InvalidationSetFeatures::hasTagIdClassOrAttribute() const { | 1208 bool RuleFeatureSet::InvalidationSetFeatures::hasIdClassOrAttribute() const { |
1194 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || | 1209 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty(); |
1195 !tagNames.isEmpty(); | |
1196 } | 1210 } |
1197 | 1211 |
1198 } // namespace blink | 1212 } // namespace blink |
OLD | NEW |