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

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

Issue 1111643003: Move StyleInvalidator to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid calling ensureUpdatedRuleFeatureSet multiple times Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/Node.cpp » ('j') | 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 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 elementData()->m_presentationAttributeStyleIsDirty = true; 1152 elementData()->m_presentationAttributeStyleIsDirty = true;
1153 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::fromA ttribute(name)); 1153 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::fromA ttribute(name));
1154 } 1154 }
1155 1155
1156 if (isIdAttributeName(name)) { 1156 if (isIdAttributeName(name)) {
1157 AtomicString oldId = elementData()->idForStyleResolution(); 1157 AtomicString oldId = elementData()->idForStyleResolution();
1158 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 1158 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
1159 if (newId != oldId) { 1159 if (newId != oldId) {
1160 elementData()->setIdForStyleResolution(newId); 1160 elementData()->setIdForStyleResolution(newId);
1161 if (testShouldInvalidateStyle) 1161 if (testShouldInvalidateStyle)
1162 styleResolver->ensureUpdatedRuleFeatureSet().scheduleStyleInvali dationForIdChange(oldId, newId, *this); 1162 document().styleEngine().idChangedForElement(oldId, newId, *this );
1163 } 1163 }
1164 } else if (name == classAttr) { 1164 } else if (name == classAttr) {
1165 classAttributeChanged(newValue); 1165 classAttributeChanged(newValue);
1166 } else if (name == HTMLNames::nameAttr) { 1166 } else if (name == HTMLNames::nameAttr) {
1167 setHasName(!newValue.isNull()); 1167 setHasName(!newValue.isNull());
1168 } 1168 }
1169 1169
1170 invalidateNodeListCachesInAncestors(&name, this); 1170 invalidateNodeListCachesInAncestors(&name, this);
1171 1171
1172 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style. 1172 // If there is currently no StyleResolver, we can't be sure that this attrib ute change won't affect style.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 StyleResolver* styleResolver = document().styleResolver(); 1226 StyleResolver* styleResolver = document().styleResolver();
1227 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange; 1227 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
1228 1228
1229 ASSERT(elementData()); 1229 ASSERT(elementData());
1230 if (classStringHasClassName(newClassString)) { 1230 if (classStringHasClassName(newClassString)) {
1231 const bool shouldFoldCase = document().inQuirksMode(); 1231 const bool shouldFoldCase = document().inQuirksMode();
1232 const SpaceSplitString oldClasses = elementData()->classNames(); 1232 const SpaceSplitString oldClasses = elementData()->classNames();
1233 elementData()->setClass(newClassString, shouldFoldCase); 1233 elementData()->setClass(newClassString, shouldFoldCase);
1234 const SpaceSplitString& newClasses = elementData()->classNames(); 1234 const SpaceSplitString& newClasses = elementData()->classNames();
1235 if (testShouldInvalidateStyle) 1235 if (testShouldInvalidateStyle)
1236 styleResolver->ensureUpdatedRuleFeatureSet().scheduleStyleInvalidati onForClassChange(oldClasses, newClasses, *this); 1236 document().styleEngine().classChangedForElement(oldClasses, newClass es, *this);
1237 } else { 1237 } else {
1238 const SpaceSplitString& oldClasses = elementData()->classNames(); 1238 const SpaceSplitString& oldClasses = elementData()->classNames();
1239 if (testShouldInvalidateStyle) 1239 if (testShouldInvalidateStyle)
1240 styleResolver->ensureUpdatedRuleFeatureSet().scheduleStyleInvalidati onForClassChange(oldClasses, *this); 1240 document().styleEngine().classChangedForElement(oldClasses, *this);
1241 elementData()->clearClass(); 1241 elementData()->clearClass();
1242 } 1242 }
1243 1243
1244 if (hasRareData()) 1244 if (hasRareData())
1245 elementRareData()->clearClassListValueForQuirksMode(); 1245 elementRareData()->clearClassListValueForQuirksMode();
1246 } 1246 }
1247 1247
1248 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el ementShadow, const QualifiedName& name, const AtomicString& newValue) 1248 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el ementShadow, const QualifiedName& name, const AtomicString& newValue)
1249 { 1249 {
1250 ASSERT(elementShadow); 1250 ASSERT(elementShadow);
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 ElementShadow& Element::ensureShadow() 1789 ElementShadow& Element::ensureShadow()
1790 { 1790 {
1791 return ensureElementRareData().ensureShadow(); 1791 return ensureElementRareData().ensureShadow();
1792 } 1792 }
1793 1793
1794 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo) 1794 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo)
1795 { 1795 {
1796 StyleResolver* styleResolver = document().styleResolver(); 1796 StyleResolver* styleResolver = document().styleResolver();
1797 1797
1798 if (inActiveDocument() && styleResolver && styleChangeType() < SubtreeStyleC hange) 1798 if (inActiveDocument() && styleResolver && styleChangeType() < SubtreeStyleC hange)
1799 styleResolver->ensureUpdatedRuleFeatureSet().scheduleStyleInvalidationFo rPseudoChange(pseudo, *this); 1799 document().styleEngine().pseudoStateChangedForElement(pseudo, *this);
1800 1800
1801 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this)) 1801 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this))
1802 elementShadow->distributedNodePseudoStateChanged(pseudo); 1802 elementShadow->distributedNodePseudoStateChanged(pseudo);
1803 } 1803 }
1804 1804
1805 void Element::setAnimationStyleChange(bool animationStyleChange) 1805 void Element::setAnimationStyleChange(bool animationStyleChange)
1806 { 1806 {
1807 if (animationStyleChange && document().inStyleRecalc()) 1807 if (animationStyleChange && document().inStyleRecalc())
1808 return; 1808 return;
1809 if (!hasRareData()) 1809 if (!hasRareData())
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 if (!style && !styleAffectedByEmpty()) 1932 if (!style && !styleAffectedByEmpty())
1933 return; 1933 return;
1934 if (styleChangeType() >= SubtreeStyleChange) 1934 if (styleChangeType() >= SubtreeStyleChange)
1935 return; 1935 return;
1936 if (!inActiveDocument()) 1936 if (!inActiveDocument())
1937 return; 1937 return;
1938 if (!document().styleResolver()) 1938 if (!document().styleResolver())
1939 return; 1939 return;
1940 1940
1941 if (!style || (styleAffectedByEmpty() && (!style->emptyState() || hasChildre n()))) 1941 if (!style || (styleAffectedByEmpty() && (!style->emptyState() || hasChildre n())))
1942 document().styleResolver()->ensureUpdatedRuleFeatureSet().scheduleStyleI nvalidationForPseudoChange(CSSSelector::PseudoEmpty, *this); 1942 document().styleEngine().pseudoStateChangedForElement(CSSSelector::Pseud oEmpty, *this);
1943 } 1943 }
1944 1944
1945 void Element::childrenChanged(const ChildrenChange& change) 1945 void Element::childrenChanged(const ChildrenChange& change)
1946 { 1946 {
1947 ContainerNode::childrenChanged(change); 1947 ContainerNode::childrenChanged(change);
1948 1948
1949 checkForEmptyStyleChange(); 1949 checkForEmptyStyleChange();
1950 if (!change.byParser && change.isChildElementChange()) 1950 if (!change.byParser && change.isChildElementChange())
1951 checkForSiblingStyleChanges(change.type == ElementRemoved ? SiblingEleme ntRemoved : SiblingElementInserted, change.siblingBeforeChange, change.siblingAf terChange); 1951 checkForSiblingStyleChanges(change.type == ElementRemoved ? SiblingEleme ntRemoved : SiblingElementInserted, change.siblingBeforeChange, change.siblingAf terChange);
1952 1952
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 3045 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
3046 { 3046 {
3047 if (isIdAttributeName(name)) { 3047 if (isIdAttributeName(name)) {
3048 updateId(oldValue, newValue); 3048 updateId(oldValue, newValue);
3049 } else if (name == HTMLNames::nameAttr) { 3049 } else if (name == HTMLNames::nameAttr) {
3050 updateName(oldValue, newValue); 3050 updateName(oldValue, newValue);
3051 } 3051 }
3052 3052
3053 if (oldValue != newValue) { 3053 if (oldValue != newValue) {
3054 if (inActiveDocument() && document().styleResolver() && styleChangeType( ) < SubtreeStyleChange) 3054 if (inActiveDocument() && document().styleResolver() && styleChangeType( ) < SubtreeStyleChange)
3055 document().ensureStyleResolver().ensureUpdatedRuleFeatureSet().sched uleStyleInvalidationForAttributeChange(name, *this); 3055 document().styleEngine().attributeChangedForElement(name, *this);
3056 3056
3057 if (isUpgradedCustomElement()) 3057 if (isUpgradedCustomElement())
3058 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 3058 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
3059 } 3059 }
3060 3060
3061 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name)) 3061 if (OwnPtrWillBeRawPtr<MutationObserverInterestGroup> recipients = MutationO bserverInterestGroup::createForAttributesMutation(*this, name))
3062 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 3062 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
3063 3063
3064 attributeWillChange(name, oldValue, newValue); 3064 attributeWillChange(name, oldValue, newValue);
3065 3065
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 { 3512 {
3513 #if ENABLE(OILPAN) 3513 #if ENABLE(OILPAN)
3514 if (hasRareData()) 3514 if (hasRareData())
3515 visitor->trace(elementRareData()); 3515 visitor->trace(elementRareData());
3516 visitor->trace(m_elementData); 3516 visitor->trace(m_elementData);
3517 #endif 3517 #endif
3518 ContainerNode::trace(visitor); 3518 ContainerNode::trace(visitor);
3519 } 3519 }
3520 3520
3521 } // namespace blink 3521 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698