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

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

Issue 1514733002: Avoid unnecessary invalidation scheduling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary isMaster check Created 5 years 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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 { 1194 {
1195 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) { 1195 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) {
1196 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 1196 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
1197 parentElementShadow->setNeedsDistributionRecalc(); 1197 parentElementShadow->setNeedsDistributionRecalc();
1198 } 1198 }
1199 1199
1200 parseAttribute(name, oldValue, newValue); 1200 parseAttribute(name, oldValue, newValue);
1201 1201
1202 document().incDOMTreeVersion(); 1202 document().incDOMTreeVersion();
1203 1203
1204 StyleResolver* styleResolver = document().styleResolver();
1205
1206 if (name == HTMLNames::idAttr) { 1204 if (name == HTMLNames::idAttr) {
1207 AtomicString oldId = elementData()->idForStyleResolution(); 1205 AtomicString oldId = elementData()->idForStyleResolution();
1208 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 1206 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1209 if (newId != oldId) { 1207 if (newId != oldId) {
1210 elementData()->setIdForStyleResolution(newId); 1208 elementData()->setIdForStyleResolution(newId);
1211 if (inActiveDocument() && styleResolver) 1209 document().styleEngine().idChangedForElement(oldId, newId, *this);
1212 document().styleEngine().idChangedForElement(oldId, newId, *this );
1213 } 1210 }
1214 } else if (name == classAttr) { 1211 } else if (name == classAttr) {
1215 classAttributeChanged(newValue); 1212 classAttributeChanged(newValue);
1216 } else if (name == HTMLNames::nameAttr) { 1213 } else if (name == HTMLNames::nameAttr) {
1217 setHasName(!newValue.isNull()); 1214 setHasName(!newValue.isNull());
1218 } else if (isStyledElement()) { 1215 } else if (isStyledElement()) {
1219 if (name == styleAttr) { 1216 if (name == styleAttr) {
1220 styleAttributeChanged(newValue, reason); 1217 styleAttributeChanged(newValue, reason);
1221 } else if (isPresentationAttribute(name)) { 1218 } else if (isPresentationAttribute(name)) {
1222 elementData()->m_presentationAttributeStyleIsDirty = true; 1219 elementData()->m_presentationAttributeStyleIsDirty = true;
1223 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name)); 1220 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1224 } 1221 }
1225 } 1222 }
1226 1223
1227 invalidateNodeListCachesInAncestors(&name, this); 1224 invalidateNodeListCachesInAncestors(&name, this);
1228 1225
1229 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1230 if (!styleResolver)
1231 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1232
1233 if (inDocument()) { 1226 if (inDocument()) {
1234 if (AXObjectCache* cache = document().existingAXObjectCache()) 1227 if (AXObjectCache* cache = document().existingAXObjectCache())
1235 cache->handleAttributeChanged(name, this); 1228 cache->handleAttributeChanged(name, this);
1236 } 1229 }
1237 } 1230 }
1238 1231
1239 bool Element::hasLegalLinkAttribute(const QualifiedName&) const 1232 bool Element::hasLegalLinkAttribute(const QualifiedName&) const
1240 { 1233 {
1241 return false; 1234 return false;
1242 } 1235 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 if (!length) 1273 if (!length)
1281 return ClassStringContent::Empty; 1274 return ClassStringContent::Empty;
1282 1275
1283 if (newClassString.is8Bit()) 1276 if (newClassString.is8Bit())
1284 return classStringHasClassName(newClassString.characters8(), length); 1277 return classStringHasClassName(newClassString.characters8(), length);
1285 return classStringHasClassName(newClassString.characters16(), length); 1278 return classStringHasClassName(newClassString.characters16(), length);
1286 } 1279 }
1287 1280
1288 void Element::classAttributeChanged(const AtomicString& newClassString) 1281 void Element::classAttributeChanged(const AtomicString& newClassString)
1289 { 1282 {
1290 StyleResolver* styleResolver = document().styleResolver();
1291 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver;
1292
1293 ASSERT(elementData()); 1283 ASSERT(elementData());
1294 ClassStringContent classStringContentType = classStringHasClassName(newClass String); 1284 ClassStringContent classStringContentType = classStringHasClassName(newClass String);
1295 const bool shouldFoldCase = document().inQuirksMode(); 1285 const bool shouldFoldCase = document().inQuirksMode();
1296 if (classStringContentType == ClassStringContent::HasClasses) { 1286 if (classStringContentType == ClassStringContent::HasClasses) {
1297 const SpaceSplitString oldClasses = elementData()->classNames(); 1287 const SpaceSplitString oldClasses = elementData()->classNames();
1298 elementData()->setClass(newClassString, shouldFoldCase); 1288 elementData()->setClass(newClassString, shouldFoldCase);
1299 const SpaceSplitString& newClasses = elementData()->classNames(); 1289 const SpaceSplitString& newClasses = elementData()->classNames();
1300 if (testShouldInvalidateStyle) 1290 document().styleEngine().classChangedForElement(oldClasses, newClasses, *this);
1301 document().styleEngine().classChangedForElement(oldClasses, newClass es, *this);
1302 } else { 1291 } else {
1303 const SpaceSplitString& oldClasses = elementData()->classNames(); 1292 const SpaceSplitString& oldClasses = elementData()->classNames();
1304 if (testShouldInvalidateStyle) 1293 document().styleEngine().classChangedForElement(oldClasses, *this);
1305 document().styleEngine().classChangedForElement(oldClasses, *this);
1306 if (classStringContentType == ClassStringContent::WhiteSpaceOnly) 1294 if (classStringContentType == ClassStringContent::WhiteSpaceOnly)
1307 elementData()->setClass(newClassString, shouldFoldCase); 1295 elementData()->setClass(newClassString, shouldFoldCase);
1308 else 1296 else
1309 elementData()->clearClass(); 1297 elementData()->clearClass();
1310 } 1298 }
1311 1299
1312 if (hasRareData()) 1300 if (hasRareData())
1313 elementRareData()->clearClassListValueForQuirksMode(); 1301 elementRareData()->clearClassListValueForQuirksMode();
1314 } 1302 }
1315 1303
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 } 1857 }
1870 1858
1871 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo) 1859 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo)
1872 { 1860 {
1873 // We can't schedule invaliation sets from inside style recalc otherwise 1861 // We can't schedule invaliation sets from inside style recalc otherwise
1874 // we'd never process them. 1862 // we'd never process them.
1875 // TODO(esprehn): Make this an ASSERT and fix places that call into this 1863 // TODO(esprehn): Make this an ASSERT and fix places that call into this
1876 // like HTMLSelectElement. 1864 // like HTMLSelectElement.
1877 if (document().inStyleRecalc()) 1865 if (document().inStyleRecalc())
1878 return; 1866 return;
1879 StyleResolver* styleResolver = document().styleResolver(); 1867 document().styleEngine().pseudoStateChangedForElement(pseudo, *this);
1880 if (inActiveDocument() && styleResolver)
1881 document().styleEngine().pseudoStateChangedForElement(pseudo, *this);
1882 } 1868 }
1883 1869
1884 void Element::setAnimationStyleChange(bool animationStyleChange) 1870 void Element::setAnimationStyleChange(bool animationStyleChange)
1885 { 1871 {
1886 if (animationStyleChange && document().inStyleRecalc()) 1872 if (animationStyleChange && document().inStyleRecalc())
1887 return; 1873 return;
1888 if (!hasRareData()) 1874 if (!hasRareData())
1889 return; 1875 return;
1890 if (ElementAnimations* elementAnimations = elementRareData()->elementAnimati ons()) 1876 if (ElementAnimations* elementAnimations = elementRareData()->elementAnimati ons())
1891 elementAnimations->setAnimationStyleChange(animationStyleChange); 1877 elementAnimations->setAnimationStyleChange(animationStyleChange);
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 updateExtraNamedItemRegistration(oldId, newId); 3110 updateExtraNamedItemRegistration(oldId, newId);
3125 } 3111 }
3126 3112
3127 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 3113 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
3128 { 3114 {
3129 if (name == HTMLNames::nameAttr) { 3115 if (name == HTMLNames::nameAttr) {
3130 updateName(oldValue, newValue); 3116 updateName(oldValue, newValue);
3131 } 3117 }
3132 3118
3133 if (oldValue != newValue) { 3119 if (oldValue != newValue) {
3134 if (inActiveDocument() && document().styleResolver()) 3120 document().styleEngine().attributeChangedForElement(name, *this);
3135 document().styleEngine().attributeChangedForElement(name, *this);
3136
3137 if (isUpgradedCustomElement()) 3121 if (isUpgradedCustomElement())
3138 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 3122 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
3139 } 3123 }
3140 3124
3141 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name)) 3125 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name))
3142 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 3126 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
3143 3127
3144 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); 3128 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue);
3145 } 3129 }
3146 3130
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 { 3628 {
3645 #if ENABLE(OILPAN) 3629 #if ENABLE(OILPAN)
3646 if (hasRareData()) 3630 if (hasRareData())
3647 visitor->trace(elementRareData()); 3631 visitor->trace(elementRareData());
3648 visitor->trace(m_elementData); 3632 visitor->trace(m_elementData);
3649 #endif 3633 #endif
3650 ContainerNode::trace(visitor); 3634 ContainerNode::trace(visitor);
3651 } 3635 }
3652 3636
3653 } // namespace blink 3637 } // 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