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

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: 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
1114 if (isStyledElement()) {
1115 if (name == styleAttr) {
1116 styleAttributeChanged(newValue, reason);
1117 } else if (isPresentationAttribute(name)) {
1118 elementData()->m_presentationAttributeStyleIsDirty = true;
1119 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1120 }
1121 }
1122 1112
1123 if (name == HTMLNames::idAttr) { 1113 if (name == HTMLNames::idAttr) {
1124 AtomicString oldId = elementData()->idForStyleResolution(); 1114 AtomicString oldId = elementData()->idForStyleResolution();
1125 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 1115 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1126 if (newId != oldId) { 1116 if (newId != oldId) {
1127 elementData()->setIdForStyleResolution(newId); 1117 elementData()->setIdForStyleResolution(newId);
1118 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styleChangeType() < SubtreeStyleChange;
Mike West 2015/06/07 13:59:43 Nit: You can fold this into the `if` on the next l
sof 2015/06/07 19:01:15 Or give it a better name :)
1128 if (testShouldInvalidateStyle) 1119 if (testShouldInvalidateStyle)
1129 document().styleEngine().idChangedForElement(oldId, newId, *this ); 1120 document().styleEngine().idChangedForElement(oldId, newId, *this );
1130 } 1121 }
1131 } else if (name == classAttr) { 1122 } else if (name == classAttr) {
1132 classAttributeChanged(newValue); 1123 classAttributeChanged(newValue);
1133 } else if (name == HTMLNames::nameAttr) { 1124 } else if (name == HTMLNames::nameAttr) {
1134 setHasName(!newValue.isNull()); 1125 setHasName(!newValue.isNull());
1126 } else if (isStyledElement()) {
1127 if (name == styleAttr) {
1128 styleAttributeChanged(newValue, reason);
1129 } else if (isPresentationAttribute(name)) {
1130 elementData()->m_presentationAttributeStyleIsDirty = true;
1131 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::f romAttribute(name));
1132 }
1135 } 1133 }
1136 1134
1137 invalidateNodeListCachesInAncestors(&name, this); 1135 invalidateNodeListCachesInAncestors(&name, this);
1138 1136
1139 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1137 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
1140 if (!styleResolver) 1138 if (!styleResolver)
1141 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name)); 1139 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fro mAttribute(name));
1142 1140
1143 if (AXObjectCache* cache = document().existingAXObjectCache()) 1141 if (AXObjectCache* cache = document().existingAXObjectCache())
1144 cache->handleAttributeChanged(name, this); 1142 cache->handleAttributeChanged(name, this);
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 { 3451 {
3454 #if ENABLE(OILPAN) 3452 #if ENABLE(OILPAN)
3455 if (hasRareData()) 3453 if (hasRareData())
3456 visitor->trace(elementRareData()); 3454 visitor->trace(elementRareData());
3457 visitor->trace(m_elementData); 3455 visitor->trace(m_elementData);
3458 #endif 3456 #endif
3459 ContainerNode::trace(visitor); 3457 ContainerNode::trace(visitor);
3460 } 3458 }
3461 3459
3462 } // namespace blink 3460 } // 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