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

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

Issue 1169633002: Optimize Element::attributeChanged() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unneeded local var Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) { 1102 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) {
1103 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 1103 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
1104 parentElementShadow->setNeedsDistributionRecalc(); 1104 parentElementShadow->setNeedsDistributionRecalc();
1105 } 1105 }
1106 1106
1107 parseAttribute(name, newValue); 1107 parseAttribute(name, newValue);
1108 1108
1109 document().incDOMTreeVersion(); 1109 document().incDOMTreeVersion();
1110 1110
1111 StyleResolver* styleResolver = document().styleResolver(); 1111 StyleResolver* styleResolver = document().styleResolver();
1112 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
1113 1112
1114 if (isStyledElement()) { 1113 if (name == HTMLNames::idAttr) {
1114 AtomicString oldId = elementData()->idForStyleResolution();
1115 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1116 if (newId != oldId) {
1117 elementData()->setIdForStyleResolution(newId);
1118 if (inActiveDocument() && styleResolver && styleChangeType() < Subtr eeStyleChange)
1119 document().styleEngine().idChangedForElement(oldId, newId, *this );
1120 }
1121 } else if (name == classAttr) {
1122 classAttributeChanged(newValue);
1123 } else if (name == HTMLNames::nameAttr) {
1124 setHasName(!newValue.isNull());
1125 } else if (isStyledElement()) {
1115 if (name == styleAttr) { 1126 if (name == styleAttr) {
1116 styleAttributeChanged(newValue, reason); 1127 styleAttributeChanged(newValue, reason);
1117 } else if (isPresentationAttribute(name)) { 1128 } else if (isPresentationAttribute(name)) {
1118 elementData()->m_presentationAttributeStyleIsDirty = true; 1129 elementData()->m_presentationAttributeStyleIsDirty = true;
1119 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name)); 1130 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1120 } 1131 }
1121 } 1132 }
1122 1133
1123 if (name == HTMLNames::idAttr) {
1124 AtomicString oldId = elementData()->idForStyleResolution();
1125 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1126 if (newId != oldId) {
1127 elementData()->setIdForStyleResolution(newId);
1128 if (testShouldInvalidateStyle)
1129 document().styleEngine().idChangedForElement(oldId, newId, *this );
1130 }
1131 } else if (name == classAttr) {
1132 classAttributeChanged(newValue);
1133 } else if (name == HTMLNames::nameAttr) {
1134 setHasName(!newValue.isNull());
1135 }
1136
1137 invalidateNodeListCachesInAncestors(&name, this); 1134 invalidateNodeListCachesInAncestors(&name, this);
1138 1135
1139 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1136 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1140 if (!styleResolver) 1137 if (!styleResolver)
1141 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name)); 1138 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1142 1139
1143 if (AXObjectCache* cache = document().existingAXObjectCache()) 1140 if (AXObjectCache* cache = document().existingAXObjectCache())
1144 cache->handleAttributeChanged(name, this); 1141 cache->handleAttributeChanged(name, this);
1145 } 1142 }
1146 1143
(...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 { 3450 {
3454 #if ENABLE(OILPAN) 3451 #if ENABLE(OILPAN)
3455 if (hasRareData()) 3452 if (hasRareData())
3456 visitor->trace(elementRareData()); 3453 visitor->trace(elementRareData());
3457 visitor->trace(m_elementData); 3454 visitor->trace(m_elementData);
3458 #endif 3455 #endif
3459 ContainerNode::trace(visitor); 3456 ContainerNode::trace(visitor);
3460 } 3457 }
3461 3458
3462 } // namespace blink 3459 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698