Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1560693002: Avoid unnecessary invalidation scheduling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 { 1191 {
1192 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) { 1192 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) {
1193 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 1193 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
1194 parentElementShadow->setNeedsDistributionRecalc(); 1194 parentElementShadow->setNeedsDistributionRecalc();
1195 } 1195 }
1196 1196
1197 parseAttribute(name, oldValue, newValue); 1197 parseAttribute(name, oldValue, newValue);
1198 1198
1199 document().incDOMTreeVersion(); 1199 document().incDOMTreeVersion();
1200 1200
1201 StyleResolver* styleResolver = document().styleResolver();
1202
1203 if (name == HTMLNames::idAttr) { 1201 if (name == HTMLNames::idAttr) {
1204 AtomicString oldId = elementData()->idForStyleResolution(); 1202 AtomicString oldId = elementData()->idForStyleResolution();
1205 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 1203 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1206 if (newId != oldId) { 1204 if (newId != oldId) {
1207 elementData()->setIdForStyleResolution(newId); 1205 elementData()->setIdForStyleResolution(newId);
1208 if (inActiveDocument() && styleResolver) 1206 document().styleEngine().idChangedForElement(oldId, newId, *this);
1209 document().styleEngine().idChangedForElement(oldId, newId, *this );
1210 } 1207 }
1211 } else if (name == classAttr) { 1208 } else if (name == classAttr) {
1212 classAttributeChanged(newValue); 1209 classAttributeChanged(newValue);
1213 } else if (name == HTMLNames::nameAttr) { 1210 } else if (name == HTMLNames::nameAttr) {
1214 setHasName(!newValue.isNull()); 1211 setHasName(!newValue.isNull());
1215 } else if (isStyledElement()) { 1212 } else if (isStyledElement()) {
1216 if (name == styleAttr) { 1213 if (name == styleAttr) {
1217 styleAttributeChanged(newValue, reason); 1214 styleAttributeChanged(newValue, reason);
1218 } else if (isPresentationAttribute(name)) { 1215 } else if (isPresentationAttribute(name)) {
1219 elementData()->m_presentationAttributeStyleIsDirty = true; 1216 elementData()->m_presentationAttributeStyleIsDirty = true;
1220 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name)); 1217 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1221 } 1218 }
1222 } 1219 }
1223 1220
1224 invalidateNodeListCachesInAncestors(&name, this); 1221 invalidateNodeListCachesInAncestors(&name, this);
1225 1222
1226 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1223 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1227 if (!styleResolver) 1224 if (!document().styleResolver())
1228 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name)); 1225 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1229 1226
1230 if (inDocument()) { 1227 if (inDocument()) {
1231 if (AXObjectCache* cache = document().existingAXObjectCache()) 1228 if (AXObjectCache* cache = document().existingAXObjectCache())
1232 cache->handleAttributeChanged(name, this); 1229 cache->handleAttributeChanged(name, this);
1233 } 1230 }
1234 } 1231 }
1235 1232
1236 bool Element::hasLegalLinkAttribute(const QualifiedName&) const 1233 bool Element::hasLegalLinkAttribute(const QualifiedName&) const
1237 { 1234 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 if (!length) 1274 if (!length)
1278 return ClassStringContent::Empty; 1275 return ClassStringContent::Empty;
1279 1276
1280 if (newClassString.is8Bit()) 1277 if (newClassString.is8Bit())
1281 return classStringHasClassName(newClassString.characters8(), length); 1278 return classStringHasClassName(newClassString.characters8(), length);
1282 return classStringHasClassName(newClassString.characters16(), length); 1279 return classStringHasClassName(newClassString.characters16(), length);
1283 } 1280 }
1284 1281
1285 void Element::classAttributeChanged(const AtomicString& newClassString) 1282 void Element::classAttributeChanged(const AtomicString& newClassString)
1286 { 1283 {
1287 StyleResolver* styleResolver = document().styleResolver();
1288 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver;
1289
1290 ASSERT(elementData()); 1284 ASSERT(elementData());
1291 ClassStringContent classStringContentType = classStringHasClassName(newClass String); 1285 ClassStringContent classStringContentType = classStringHasClassName(newClass String);
1292 const bool shouldFoldCase = document().inQuirksMode(); 1286 const bool shouldFoldCase = document().inQuirksMode();
1293 if (classStringContentType == ClassStringContent::HasClasses) { 1287 if (classStringContentType == ClassStringContent::HasClasses) {
1294 const SpaceSplitString oldClasses = elementData()->classNames(); 1288 const SpaceSplitString oldClasses = elementData()->classNames();
1295 elementData()->setClass(newClassString, shouldFoldCase); 1289 elementData()->setClass(newClassString, shouldFoldCase);
1296 const SpaceSplitString& newClasses = elementData()->classNames(); 1290 const SpaceSplitString& newClasses = elementData()->classNames();
1297 if (testShouldInvalidateStyle) 1291 document().styleEngine().classChangedForElement(oldClasses, newClasses, *this);
1298 document().styleEngine().classChangedForElement(oldClasses, newClass es, *this);
1299 } else { 1292 } else {
1300 const SpaceSplitString& oldClasses = elementData()->classNames(); 1293 const SpaceSplitString& oldClasses = elementData()->classNames();
1301 if (testShouldInvalidateStyle) 1294 document().styleEngine().classChangedForElement(oldClasses, *this);
1302 document().styleEngine().classChangedForElement(oldClasses, *this);
1303 if (classStringContentType == ClassStringContent::WhiteSpaceOnly) 1295 if (classStringContentType == ClassStringContent::WhiteSpaceOnly)
1304 elementData()->setClass(newClassString, shouldFoldCase); 1296 elementData()->setClass(newClassString, shouldFoldCase);
1305 else 1297 else
1306 elementData()->clearClass(); 1298 elementData()->clearClass();
1307 } 1299 }
1308 1300
1309 if (hasRareData()) 1301 if (hasRareData())
1310 elementRareData()->clearClassListValueForQuirksMode(); 1302 elementRareData()->clearClassListValueForQuirksMode();
1311 } 1303 }
1312 1304
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1858 }
1867 1859
1868 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo) 1860 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo)
1869 { 1861 {
1870 // We can't schedule invaliation sets from inside style recalc otherwise 1862 // We can't schedule invaliation sets from inside style recalc otherwise
1871 // we'd never process them. 1863 // we'd never process them.
1872 // TODO(esprehn): Make this an ASSERT and fix places that call into this 1864 // TODO(esprehn): Make this an ASSERT and fix places that call into this
1873 // like HTMLSelectElement. 1865 // like HTMLSelectElement.
1874 if (document().inStyleRecalc()) 1866 if (document().inStyleRecalc())
1875 return; 1867 return;
1876 StyleResolver* styleResolver = document().styleResolver(); 1868 document().styleEngine().pseudoStateChangedForElement(pseudo, *this);
1877 if (inActiveDocument() && styleResolver)
1878 document().styleEngine().pseudoStateChangedForElement(pseudo, *this);
1879 } 1869 }
1880 1870
1881 void Element::setAnimationStyleChange(bool animationStyleChange) 1871 void Element::setAnimationStyleChange(bool animationStyleChange)
1882 { 1872 {
1883 if (animationStyleChange && document().inStyleRecalc()) 1873 if (animationStyleChange && document().inStyleRecalc())
1884 return; 1874 return;
1885 if (!hasRareData()) 1875 if (!hasRareData())
1886 return; 1876 return;
1887 if (ElementAnimations* elementAnimations = elementRareData()->elementAnimati ons()) 1877 if (ElementAnimations* elementAnimations = elementRareData()->elementAnimati ons())
1888 elementAnimations->setAnimationStyleChange(animationStyleChange); 1878 elementAnimations->setAnimationStyleChange(animationStyleChange);
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 updateExtraNamedItemRegistration(oldId, newId); 3106 updateExtraNamedItemRegistration(oldId, newId);
3117 } 3107 }
3118 3108
3119 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 3109 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
3120 { 3110 {
3121 if (name == HTMLNames::nameAttr) { 3111 if (name == HTMLNames::nameAttr) {
3122 updateName(oldValue, newValue); 3112 updateName(oldValue, newValue);
3123 } 3113 }
3124 3114
3125 if (oldValue != newValue) { 3115 if (oldValue != newValue) {
3126 if (inActiveDocument() && document().styleResolver()) 3116 document().styleEngine().attributeChangedForElement(name, *this);
3127 document().styleEngine().attributeChangedForElement(name, *this);
3128
3129 if (isUpgradedCustomElement()) 3117 if (isUpgradedCustomElement())
3130 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 3118 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
3131 } 3119 }
3132 3120
3133 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name)) 3121 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name))
3134 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 3122 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
3135 3123
3136 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); 3124 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue);
3137 } 3125 }
3138 3126
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 { 3624 {
3637 #if ENABLE(OILPAN) 3625 #if ENABLE(OILPAN)
3638 if (hasRareData()) 3626 if (hasRareData())
3639 visitor->trace(elementRareData()); 3627 visitor->trace(elementRareData());
3640 visitor->trace(m_elementData); 3628 visitor->trace(m_elementData);
3641 #endif 3629 #endif
3642 ContainerNode::trace(visitor); 3630 ContainerNode::trace(visitor);
3643 } 3631 }
3644 3632
3645 } // namespace blink 3633 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698