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

Side by Side Diff: Source/core/css/invalidation/StyleInvalidator.cpp

Issue 1349543004: CSS: Avoid invalidating style when only descendants need updating (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: invalidatesSelf Created 5 years, 3 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 | « Source/core/css/invalidation/InvalidationSet.cpp ('k') | 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 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "config.h" 6 #include "config.h"
7 7
8 #include "core/css/invalidation/StyleInvalidator.h" 8 #include "core/css/invalidation/StyleInvalidator.h"
9 9
10 #include "core/css/invalidation/InvalidationSet.h" 10 #include "core/css/invalidation/InvalidationSet.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 void StyleInvalidator::scheduleInvalidation(PassRefPtrWillBeRawPtr<InvalidationS et> invalidationSet, Element& element) 43 void StyleInvalidator::scheduleInvalidation(PassRefPtrWillBeRawPtr<InvalidationS et> invalidationSet, Element& element)
44 { 44 {
45 ASSERT(element.inActiveDocument()); 45 ASSERT(element.inActiveDocument());
46 if (element.styleChangeType() >= SubtreeStyleChange) 46 if (element.styleChangeType() >= SubtreeStyleChange)
47 return; 47 return;
48 if (invalidationSet->wholeSubtreeInvalid()) { 48 if (invalidationSet->wholeSubtreeInvalid()) {
49 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::StyleInvalidator)); 49 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac ing::create(StyleChangeReason::StyleInvalidator));
50 clearInvalidation(element); 50 clearInvalidation(element);
51 return; 51 return;
52 } 52 }
53 if (invalidationSet->isEmpty()) { 53 if (invalidationSet->invalidatesSelf())
54 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::StyleInvalidator)); 54 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracin g::create(StyleChangeReason::StyleInvalidator));
55
56 if (invalidationSet->isEmpty())
55 return; 57 return;
56 }
57 58
58 InvalidationList& list = ensurePendingInvalidationList(element); 59 InvalidationList& list = ensurePendingInvalidationList(element);
59 list.append(invalidationSet); 60 list.append(invalidationSet);
60 element.setNeedsStyleInvalidation(); 61 element.setNeedsStyleInvalidation();
61 } 62 }
62 63
63 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL ist(Element& element) 64 StyleInvalidator::InvalidationList& StyleInvalidator::ensurePendingInvalidationL ist(Element& element)
64 { 65 {
65 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(& element, nullptr); 66 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(& element, nullptr);
66 if (addResult.isNewEntry) 67 if (addResult.isNewEntry)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 122
122 return false; 123 return false;
123 } 124 }
124 125
125 ALWAYS_INLINE bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element & element, StyleInvalidator::RecursionData& recursionData) 126 ALWAYS_INLINE bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element & element, StyleInvalidator::RecursionData& recursionData)
126 { 127 {
127 if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSu btreeInvalid()) { 128 if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSu btreeInvalid()) {
128 recursionData.setWholeSubtreeInvalid(); 129 recursionData.setWholeSubtreeInvalid();
129 return false; 130 return false;
130 } 131 }
132 bool thisElementNeedsStyleRecalc = recursionData.matchesCurrentInvalidationS ets(element);
131 if (element.needsStyleInvalidation()) { 133 if (element.needsStyleInvalidation()) {
132 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) { 134 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) {
133 for (const auto& invalidationSet : *invalidationList) 135 for (const auto& invalidationSet : *invalidationList)
134 recursionData.pushInvalidationSet(*invalidationSet); 136 recursionData.pushInvalidationSet(*invalidationSet);
135 if (UNLIKELY(*s_tracingEnabled)) { 137 if (UNLIKELY(*s_tracingEnabled)) {
136 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e.invalidationTracking"), 138 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e.invalidationTracking"),
137 "StyleInvalidatorInvalidationTracking", 139 "StyleInvalidatorInvalidationTracking",
138 TRACE_EVENT_SCOPE_THREAD, 140 TRACE_EVENT_SCOPE_THREAD,
139 "data", InspectorStyleInvalidatorInvalidateEvent::invalidati onList(element, *invalidationList)); 141 "data", InspectorStyleInvalidatorInvalidateEvent::invalidati onList(element, *invalidationList));
140 } 142 }
141 return true;
142 } 143 }
143 } 144 }
144 145 return thisElementNeedsStyleRecalc;
145 return recursionData.matchesCurrentInvalidationSets(element);
146 } 146 }
147 147
148 bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::Re cursionData& recursionData) 148 bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::Re cursionData& recursionData)
149 { 149 {
150 bool someChildrenNeedStyleRecalc = false; 150 bool someChildrenNeedStyleRecalc = false;
151 for (ShadowRoot* root = element.youngestShadowRoot(); root; root = root->old erShadowRoot()) { 151 for (ShadowRoot* root = element.youngestShadowRoot(); root; root = root->old erShadowRoot()) {
152 if (!recursionData.treeBoundaryCrossing() && !root->childNeedsStyleInval idation() && !root->needsStyleInvalidation()) 152 if (!recursionData.treeBoundaryCrossing() && !root->childNeedsStyleInval idation() && !root->needsStyleInvalidation())
153 continue; 153 continue;
154 for (Element* child = ElementTraversal::firstChild(*root); child; child = ElementTraversal::nextSibling(*child)) { 154 for (Element* child = ElementTraversal::firstChild(*root); child; child = ElementTraversal::nextSibling(*child)) {
155 bool childRecalced = invalidate(*child, recursionData); 155 bool childRecalced = invalidate(*child, recursionData);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 DEFINE_TRACE(StyleInvalidator) 200 DEFINE_TRACE(StyleInvalidator)
201 { 201 {
202 #if ENABLE(OILPAN) 202 #if ENABLE(OILPAN)
203 visitor->trace(m_pendingInvalidationMap); 203 visitor->trace(m_pendingInvalidationMap);
204 #endif 204 #endif
205 } 205 }
206 206
207 } // namespace blink 207 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/invalidation/InvalidationSet.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698