Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/RuleFeature.h" | 30 #include "core/css/RuleFeature.h" |
| 31 | 31 |
| 32 #include "HTMLNames.h" | 32 #include "HTMLNames.h" |
| 33 #include "RuntimeEnabledFeatures.h" | 33 #include "RuntimeEnabledFeatures.h" |
| 34 #include "core/css/CSSSelector.h" | 34 #include "core/css/CSSSelector.h" |
| 35 #include "core/css/CSSSelectorList.h" | 35 #include "core/css/CSSSelectorList.h" |
| 36 #include "core/css/RuleSet.h" | 36 #include "core/css/RuleSet.h" |
| 37 #include "core/css/invalidation/StyleInvalidator.h" | |
| 38 #include "core/dom/Document.h" | |
| 39 #include "core/dom/Element.h" | 37 #include "core/dom/Element.h" |
| 40 #include "core/dom/ElementTraversal.h" | |
| 41 #include "core/dom/Node.h" | 38 #include "core/dom/Node.h" |
| 42 #include "core/dom/NodeRenderStyle.h" | |
| 43 #include "core/dom/shadow/ElementShadow.h" | |
| 44 #include "core/dom/shadow/ShadowRoot.h" | |
| 45 #include "core/rendering/RenderObject.h" | |
| 46 #include "wtf/BitVector.h" | 39 #include "wtf/BitVector.h" |
| 47 | 40 |
| 48 namespace WebCore { | 41 namespace WebCore { |
| 49 | 42 |
| 50 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) | 43 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) |
| 51 { | 44 { |
| 52 if (selector.m_match == CSSSelector::Tag | 45 if (selector.m_match == CSSSelector::Tag |
| 53 || selector.m_match == CSSSelector::Id | 46 || selector.m_match == CSSSelector::Id |
| 54 || selector.isAttributeSelector()) | 47 || selector.isAttributeSelector()) |
| 55 return true; | 48 return true; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 } | 102 } |
| 110 | 103 |
| 111 // This method is somewhat conservative in what it accepts. | 104 // This method is somewhat conservative in what it accepts. |
| 112 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) | 105 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) |
| 113 { | 106 { |
| 114 bool foundDescendantRelation = false; | 107 bool foundDescendantRelation = false; |
| 115 bool foundIdent = false; | 108 bool foundIdent = false; |
| 116 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { | 109 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { |
| 117 | 110 |
| 118 // FIXME: next up: Tag and Id. | 111 // FIXME: next up: Tag and Id. |
| 119 if (component->m_match == CSSSelector::Class) { | 112 if (component->m_match == CSSSelector::Class || component->isAttributeSe lector()) { |
| 120 if (!foundDescendantRelation) | 113 if (!foundDescendantRelation) |
| 121 foundIdent = true; | 114 foundIdent = true; |
| 122 } else if (!isSkippableComponentForInvalidation(*component)) { | 115 } else if (!isSkippableComponentForInvalidation(*component)) { |
| 123 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; | 116 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; |
| 124 } | 117 } |
| 125 switch (component->relation()) { | 118 switch (component->relation()) { |
| 126 case CSSSelector::Descendant: | 119 case CSSSelector::Descendant: |
| 127 case CSSSelector::Child: | 120 case CSSSelector::Child: |
| 128 case CSSSelector::Shadow: | 121 case CSSSelector::Shadow: |
| 129 case CSSSelector::ShadowDeep: | 122 case CSSSelector::ShadowDeep: |
| 130 foundDescendantRelation = true; | 123 foundDescendantRelation = true; |
| 131 // Fall through! | 124 // Fall through! |
| 132 case CSSSelector::SubSelector: | 125 case CSSSelector::SubSelector: |
| 133 continue; | 126 continue; |
| 134 default: | 127 default: |
| 135 return UseLocalStyleChange; | 128 return UseLocalStyleChange; |
| 136 } | 129 } |
| 137 } | 130 } |
| 138 return foundIdent ? AddFeatures : UseLocalStyleChange; | 131 return foundIdent ? AddFeatures : UseLocalStyleChange; |
| 139 } | 132 } |
| 140 | 133 |
| 141 void extractClassIdOrTag(const CSSSelector& selector, Vector<AtomicString>& clas ses, AtomicString& id, AtomicString& tagName) | 134 void extractClassIdTagOrAttribute(const CSSSelector& selector, Vector<AtomicStri ng>& classes, AtomicString& id, AtomicString& tagName, Vector<AtomicString>& att ributes) |
| 142 { | 135 { |
| 143 if (selector.m_match == CSSSelector::Tag) | 136 if (selector.m_match == CSSSelector::Tag) |
| 144 tagName = selector.tagQName().localName(); | 137 tagName = selector.tagQName().localName(); |
| 145 else if (selector.m_match == CSSSelector::Id) | 138 else if (selector.m_match == CSSSelector::Id) |
| 146 id = selector.value(); | 139 id = selector.value(); |
| 147 else if (selector.m_match == CSSSelector::Class) | 140 else if (selector.m_match == CSSSelector::Class) |
| 148 classes.append(selector.value()); | 141 classes.append(selector.value()); |
| 142 else if (selector.isAttributeSelector()) | |
| 143 attributes.append(selector.attribute().localName()); | |
| 149 } | 144 } |
| 150 | 145 |
| 151 RuleFeatureSet::RuleFeatureSet() | 146 RuleFeatureSet::RuleFeatureSet() |
| 152 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) | 147 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) |
| 153 { | 148 { |
| 154 } | 149 } |
| 155 | 150 |
| 156 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateClassInvalidationSets( const CSSSelector& selector) | 151 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector) |
| 152 { | |
| 153 if (selector.m_match == CSSSelector::Class) | |
| 154 return &ensureClassInvalidationSet(selector.value()); | |
| 155 if (selector.isAttributeSelector()) | |
| 156 return &ensureAttributeInvalidationSet(selector.attribute().localName()) ; | |
| 157 return 0; | |
| 158 } | |
| 159 | |
| 160 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) | |
| 157 { | 161 { |
| 158 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); | 162 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); |
| 159 if (mode != AddFeatures) | 163 if (mode != AddFeatures) |
| 160 return mode; | 164 return mode; |
| 161 | 165 |
| 162 Vector<AtomicString> classes; | 166 Vector<AtomicString> classes; |
| 163 AtomicString id; | 167 AtomicString id; |
| 164 AtomicString tagName; | 168 AtomicString tagName; |
| 169 Vector<AtomicString> attributes; | |
| 165 | 170 |
| 166 const CSSSelector* lastSelector = &selector; | 171 const CSSSelector* lastSelector = &selector; |
| 167 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 172 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
| 168 extractClassIdOrTag(*lastSelector, classes, id, tagName); | 173 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib utes); |
| 169 if (lastSelector->m_match == CSSSelector::Class) | 174 // Initialize the entry in the invalidation set map, if supported. |
| 170 ensureClassInvalidationSet(lastSelector->value()); | 175 invalidationSetForSelector(*lastSelector); |
| 176 | |
| 171 if (lastSelector->relation() != CSSSelector::SubSelector) | 177 if (lastSelector->relation() != CSSSelector::SubSelector) |
| 172 break; | 178 break; |
| 173 } | 179 } |
| 174 | 180 |
| 175 if (!lastSelector) | 181 if (!lastSelector) |
| 176 return AddFeatures; | 182 return AddFeatures; |
| 177 | |
| 178 for (const CSSSelector* current = lastSelector->tagHistory(); current; curre nt = current->tagHistory()) { | 183 for (const CSSSelector* current = lastSelector->tagHistory(); current; curre nt = current->tagHistory()) { |
| 179 if (current->m_match == CSSSelector::Class) { | 184 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { |
| 180 DescendantInvalidationSet& invalidationSet = ensureClassInvalidation Set(current->value()); | |
| 181 if (!id.isEmpty()) | 185 if (!id.isEmpty()) |
| 182 invalidationSet.addId(id); | 186 invalidationSet->addId(id); |
| 183 if (!tagName.isEmpty()) | 187 if (!tagName.isEmpty()) |
| 184 invalidationSet.addTagName(tagName); | 188 invalidationSet->addTagName(tagName); |
| 185 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) { | 189 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) |
| 186 invalidationSet.addClass(*it); | 190 invalidationSet->addClass(*it); |
| 187 } | 191 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i t != attributes.end(); ++it) |
| 192 invalidationSet->addAttribute(*it); | |
| 188 } | 193 } |
| 189 } | 194 } |
| 190 return AddFeatures; | 195 return AddFeatures; |
| 191 } | 196 } |
| 192 | 197 |
| 193 void RuleFeatureSet::addAttributeInASelector(const AtomicString& attributeName) | 198 void RuleFeatureSet::addAttributeFromAContentAttrValue(const AtomicString& attri buteName) |
|
esprehn
2014/03/21 23:01:44
Remove "A" from the method name, it makes it harde
chrishtr
2014/03/21 23:11:21
Done.
| |
| 194 { | 199 { |
| 195 m_metadata.attrsInRules.add(attributeName); | 200 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); |
| 201 invalidationSet.setWholeSubtreeInvalid(); | |
| 196 } | 202 } |
| 197 | 203 |
| 198 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 204 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 199 { | 205 { |
| 200 FeatureMetadata metadata; | 206 FeatureMetadata metadata; |
| 201 InvalidationSetMode mode = UseSubtreeStyleChange; | 207 InvalidationSetMode mode = UseSubtreeStyleChange; |
| 202 if (m_targetedStyleRecalcEnabled) | 208 if (m_targetedStyleRecalcEnabled) |
| 203 mode = updateClassInvalidationSets(ruleData.selector()); | 209 mode = updateInvalidationSets(ruleData.selector()); |
| 204 | 210 |
| 205 collectFeaturesFromSelector(ruleData.selector(), metadata, mode); | 211 collectFeaturesFromSelector(ruleData.selector(), metadata, mode); |
| 206 m_metadata.add(metadata); | 212 m_metadata.add(metadata); |
| 207 | 213 |
| 208 if (metadata.foundSiblingSelector) | 214 if (metadata.foundSiblingSelector) |
| 209 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex( ), ruleData.hasDocumentSecurityOrigin())); | 215 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex( ), ruleData.hasDocumentSecurityOrigin())); |
| 210 if (ruleData.containsUncommonAttributeSelector()) | 216 if (ruleData.containsUncommonAttributeSelector()) |
| 211 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele ctorIndex(), ruleData.hasDocumentSecurityOrigin())); | 217 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele ctorIndex(), ruleData.hasDocumentSecurityOrigin())); |
| 212 } | 218 } |
| 213 | 219 |
| 214 DescendantInvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(const Atom icString& className) | 220 DescendantInvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(const Atom icString& className) |
| 215 { | 221 { |
| 216 InvalidationSetMap::AddResult addResult = m_classInvalidationSets.add(classN ame, nullptr); | 222 InvalidationSetMap::AddResult addResult = m_classInvalidationSets.add(classN ame, nullptr); |
| 217 if (addResult.isNewEntry) | 223 if (addResult.isNewEntry) |
| 218 addResult.storedValue->value = DescendantInvalidationSet::create(); | 224 addResult.storedValue->value = DescendantInvalidationSet::create(); |
| 219 return *addResult.storedValue->value; | 225 return *addResult.storedValue->value; |
| 220 } | 226 } |
| 221 | 227 |
| 228 DescendantInvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet(const AtomicString& attributeName) | |
| 229 { | |
| 230 InvalidationSetMap::AddResult addResult = m_attributeInvalidationSets.add(at tributeName, nullptr); | |
| 231 if (addResult.isNewEntry) | |
| 232 addResult.storedValue->value = DescendantInvalidationSet::create(); | |
| 233 return *addResult.storedValue->value; | |
| 234 } | |
| 222 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) | 235 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) |
| 223 { | 236 { |
| 224 collectFeaturesFromSelector(selector, m_metadata, UseSubtreeStyleChange); | 237 collectFeaturesFromSelector(selector, m_metadata, UseSubtreeStyleChange); |
| 225 } | 238 } |
| 226 | 239 |
| 227 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru leFeatureSet::FeatureMetadata& metadata, InvalidationSetMode mode) | 240 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru leFeatureSet::FeatureMetadata& metadata, InvalidationSetMode mode) |
| 228 { | 241 { |
| 229 unsigned maxDirectAdjacentSelectors = 0; | 242 unsigned maxDirectAdjacentSelectors = 0; |
| 230 | 243 |
| 231 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 244 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
| 232 if (current->m_match == CSSSelector::Id) { | 245 if (current->m_match == CSSSelector::Id) { |
| 233 metadata.idsInRules.add(current->value()); | 246 metadata.idsInRules.add(current->value()); |
| 234 } else if (current->m_match == CSSSelector::Class && mode != AddFeatures ) { | 247 } else if (mode != AddFeatures && (current->m_match == CSSSelector::Clas s || current->isAttributeSelector())) { |
| 235 DescendantInvalidationSet& invalidationSet = ensureClassInvalidation Set(current->value()); | 248 DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current); |
| 249 ASSERT(invalidationSet); | |
| 236 if (mode == UseSubtreeStyleChange) | 250 if (mode == UseSubtreeStyleChange) |
| 237 invalidationSet.setWholeSubtreeInvalid(); | 251 invalidationSet->setWholeSubtreeInvalid(); |
| 238 } else if (current->isAttributeSelector()) { | |
| 239 metadata.attrsInRules.add(current->attribute().localName()); | |
| 240 } | 252 } |
| 241 if (current->pseudoType() == CSSSelector::PseudoFirstLine) | 253 if (current->pseudoType() == CSSSelector::PseudoFirstLine) |
| 242 metadata.usesFirstLineRules = true; | 254 metadata.usesFirstLineRules = true; |
| 243 if (current->isDirectAdjacentSelector()) { | 255 if (current->isDirectAdjacentSelector()) { |
| 244 maxDirectAdjacentSelectors++; | 256 maxDirectAdjacentSelectors++; |
| 245 } else if (maxDirectAdjacentSelectors) { | 257 } else if (maxDirectAdjacentSelectors) { |
| 246 if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors ) | 258 if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors ) |
| 247 metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors ; | 259 metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors ; |
| 248 maxDirectAdjacentSelectors = 0; | 260 maxDirectAdjacentSelectors = 0; |
| 249 } | 261 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 269 } | 281 } |
| 270 | 282 |
| 271 void RuleFeatureSet::FeatureMetadata::add(const FeatureMetadata& other) | 283 void RuleFeatureSet::FeatureMetadata::add(const FeatureMetadata& other) |
| 272 { | 284 { |
| 273 usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules; | 285 usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules; |
| 274 maxDirectAdjacentSelectors = std::max(maxDirectAdjacentSelectors, other.maxD irectAdjacentSelectors); | 286 maxDirectAdjacentSelectors = std::max(maxDirectAdjacentSelectors, other.maxD irectAdjacentSelectors); |
| 275 | 287 |
| 276 HashSet<AtomicString>::const_iterator end = other.idsInRules.end(); | 288 HashSet<AtomicString>::const_iterator end = other.idsInRules.end(); |
| 277 for (HashSet<AtomicString>::const_iterator it = other.idsInRules.begin(); it != end; ++it) | 289 for (HashSet<AtomicString>::const_iterator it = other.idsInRules.begin(); it != end; ++it) |
| 278 idsInRules.add(*it); | 290 idsInRules.add(*it); |
| 279 end = other.attrsInRules.end(); | |
| 280 for (HashSet<AtomicString>::const_iterator it = other.attrsInRules.begin(); it != end; ++it) | |
| 281 attrsInRules.add(*it); | |
| 282 } | 291 } |
| 283 | 292 |
| 284 void RuleFeatureSet::FeatureMetadata::clear() | 293 void RuleFeatureSet::FeatureMetadata::clear() |
| 285 { | 294 { |
| 286 idsInRules.clear(); | 295 idsInRules.clear(); |
| 287 attrsInRules.clear(); | |
| 288 usesFirstLineRules = false; | 296 usesFirstLineRules = false; |
| 289 foundSiblingSelector = false; | 297 foundSiblingSelector = false; |
| 290 maxDirectAdjacentSelectors = 0; | 298 maxDirectAdjacentSelectors = 0; |
| 291 } | 299 } |
| 292 | 300 |
| 293 void RuleFeatureSet::add(const RuleFeatureSet& other) | 301 void RuleFeatureSet::add(const RuleFeatureSet& other) |
| 294 { | 302 { |
| 295 for (InvalidationSetMap::const_iterator it = other.m_classInvalidationSets.b egin(); it != other.m_classInvalidationSets.end(); ++it) { | 303 for (InvalidationSetMap::const_iterator it = other.m_classInvalidationSets.b egin(); it != other.m_classInvalidationSets.end(); ++it) |
| 296 ensureClassInvalidationSet(it->key).combine(*it->value); | 304 ensureClassInvalidationSet(it->key).combine(*it->value); |
| 297 } | 305 for (InvalidationSetMap::const_iterator it = other.m_attributeInvalidationSe ts.begin(); it != other.m_attributeInvalidationSets.end(); ++it) |
| 306 ensureAttributeInvalidationSet(it->key).combine(*it->value); | |
| 298 | 307 |
| 299 m_metadata.add(other.m_metadata); | 308 m_metadata.add(other.m_metadata); |
| 300 | 309 |
| 301 siblingRules.appendVector(other.siblingRules); | 310 siblingRules.appendVector(other.siblingRules); |
| 302 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); | 311 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); |
| 303 } | 312 } |
| 304 | 313 |
| 305 void RuleFeatureSet::clear() | 314 void RuleFeatureSet::clear() |
| 306 { | 315 { |
| 307 siblingRules.clear(); | 316 siblingRules.clear(); |
| 308 uncommonAttributeRules.clear(); | 317 uncommonAttributeRules.clear(); |
| 309 m_metadata.clear(); | 318 m_metadata.clear(); |
| 310 m_classInvalidationSets.clear(); | 319 m_classInvalidationSets.clear(); |
| 320 m_attributeInvalidationSets.clear(); | |
| 311 m_pendingInvalidationMap.clear(); | 321 m_pendingInvalidationMap.clear(); |
| 312 } | 322 } |
| 313 | 323 |
| 314 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& changedClasses, Element* element) | 324 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& changedClasses, Element* element) |
| 315 { | 325 { |
| 316 unsigned changedSize = changedClasses.size(); | 326 unsigned changedSize = changedClasses.size(); |
| 317 for (unsigned i = 0; i < changedSize; ++i) { | 327 for (unsigned i = 0; i < changedSize; ++i) { |
| 318 addClassToInvalidationSet(changedClasses[i], element); | 328 addClassToInvalidationSet(changedClasses[i], element); |
| 319 } | 329 } |
| 320 } | 330 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 345 } | 355 } |
| 346 | 356 |
| 347 for (unsigned i = 0; i < oldClasses.size(); ++i) { | 357 for (unsigned i = 0; i < oldClasses.size(); ++i) { |
| 348 if (remainingClassBits.quickGet(i)) | 358 if (remainingClassBits.quickGet(i)) |
| 349 continue; | 359 continue; |
| 350 // Class was removed. | 360 // Class was removed. |
| 351 addClassToInvalidationSet(oldClasses[i], element); | 361 addClassToInvalidationSet(oldClasses[i], element); |
| 352 } | 362 } |
| 353 } | 363 } |
| 354 | 364 |
| 365 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified Name& attributeName, Element* element) | |
| 366 { | |
| 367 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_attributeInvalidat ionSets.get(attributeName.localName())) { | |
| 368 ensurePendingInvalidationList(element).append(invalidationSet); | |
| 369 element->setNeedsStyleInvalidation(); | |
| 370 } | |
| 371 } | |
| 372 | |
| 355 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement* element) | 373 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement* element) |
| 356 { | 374 { |
| 357 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className)) { | 375 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className)) { |
| 358 ensurePendingInvalidationList(element).append(invalidationSet); | 376 ensurePendingInvalidationList(element).append(invalidationSet); |
| 359 element->setNeedsStyleInvalidation(); | 377 element->setNeedsStyleInvalidation(); |
| 360 } | 378 } |
| 361 } | 379 } |
| 362 | 380 |
| 363 RuleFeatureSet::InvalidationList& RuleFeatureSet::ensurePendingInvalidationList( Element* element) | 381 RuleFeatureSet::InvalidationList& RuleFeatureSet::ensurePendingInvalidationList( Element* element) |
| 364 { | 382 { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 375 if (node->isElementNode()) | 393 if (node->isElementNode()) |
| 376 m_pendingInvalidationMap.remove(toElement(node)); | 394 m_pendingInvalidationMap.remove(toElement(node)); |
| 377 } | 395 } |
| 378 | 396 |
| 379 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() | 397 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() |
| 380 { | 398 { |
| 381 return m_pendingInvalidationMap; | 399 return m_pendingInvalidationMap; |
| 382 } | 400 } |
| 383 | 401 |
| 384 } // namespace WebCore | 402 } // namespace WebCore |
| OLD | NEW |