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

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

Issue 624133003: Revert of [Invalidation Tracking] Trace StyleInvalidator setNeedsStyleRecalc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
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/DescendantInvalidationSet.h" 10 #include "core/css/invalidation/DescendantInvalidationSet.h"
11 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
12 #include "core/dom/Element.h" 12 #include "core/dom/Element.h"
13 #include "core/dom/ElementTraversal.h" 13 #include "core/dom/ElementTraversal.h"
14 #include "core/dom/shadow/ElementShadow.h" 14 #include "core/dom/shadow/ElementShadow.h"
15 #include "core/dom/shadow/ShadowRoot.h" 15 #include "core/dom/shadow/ShadowRoot.h"
16 #include "core/inspector/InspectorTraceEvents.h"
17 #include "core/rendering/RenderObject.h" 16 #include "core/rendering/RenderObject.h"
18 17
19 namespace blink { 18 namespace blink {
20 19
21 void StyleInvalidator::invalidate(Document& document) 20 void StyleInvalidator::invalidate(Document& document)
22 { 21 {
23 RecursionData recursionData; 22 RecursionData recursionData;
24 if (Element* documentElement = document.documentElement()) 23 if (Element* documentElement = document.documentElement())
25 invalidate(*documentElement, recursionData); 24 invalidate(*documentElement, recursionData);
26 document.clearChildNeedsStyleInvalidation(); 25 document.clearChildNeedsStyleInvalidation();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return; 79 return;
81 } 80 }
82 m_invalidationSets.append(&invalidationSet); 81 m_invalidationSets.append(&invalidationSet);
83 m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid(); 82 m_invalidateCustomPseudo = invalidationSet.customPseudoInvalid();
84 } 83 }
85 84
86 bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& el ement) 85 bool StyleInvalidator::RecursionData::matchesCurrentInvalidationSets(Element& el ement)
87 { 86 {
88 ASSERT(!m_wholeSubtreeInvalid); 87 ASSERT(!m_wholeSubtreeInvalid);
89 88
90 if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom) { 89 if (m_invalidateCustomPseudo && element.shadowPseudoId() != nullAtom)
91 TRACE_STYLE_INVALIDATOR_INVALIDATION(element, InvalidateCustomPseudo);
92 return true; 90 return true;
93 }
94 91
95 for (InvalidationSets::iterator it = m_invalidationSets.begin(); it != m_inv alidationSets.end(); ++it) { 92 for (InvalidationSets::iterator it = m_invalidationSets.begin(); it != m_inv alidationSets.end(); ++it) {
96 if ((*it)->invalidatesElement(element)) 93 if ((*it)->invalidatesElement(element))
97 return true; 94 return true;
98 } 95 }
99 96
100 return false; 97 return false;
101 } 98 }
102 99
103 bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, Sty leInvalidator::RecursionData& recursionData) 100 bool StyleInvalidator::checkInvalidationSetsAgainstElement(Element& element, Sty leInvalidator::RecursionData& recursionData)
104 { 101 {
105 if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSu btreeInvalid()) { 102 if (element.styleChangeType() >= SubtreeStyleChange || recursionData.wholeSu btreeInvalid()) {
106 recursionData.setWholeSubtreeInvalid(); 103 recursionData.setWholeSubtreeInvalid();
107 return false; 104 return false;
108 } 105 }
109 if (element.needsStyleInvalidation()) { 106 if (element.needsStyleInvalidation()) {
110 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) { 107 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(&e lement)) {
111 for (InvalidationList::const_iterator it = invalidationList->begin() ; it != invalidationList->end(); ++it) 108 for (InvalidationList::const_iterator it = invalidationList->begin() ; it != invalidationList->end(); ++it)
112 recursionData.pushInvalidationSet(**it); 109 recursionData.pushInvalidationSet(**it);
113 // FIXME: It's really only necessary to clone the render style for t his element, not full style recalc. 110 // FIXME: It's really only necessary to clone the render style for t his element, not full style recalc.
114 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.in validationTracking"),
115 "StyleInvalidatorInvalidationTracking",
116 "data", InspectorStyleInvalidatorInvalidateEvent::invalidationLi st(element, *invalidationList));
117 return true; 111 return true;
118 } 112 }
119 } 113 }
120
121 return recursionData.matchesCurrentInvalidationSets(element); 114 return recursionData.matchesCurrentInvalidationSets(element);
122 } 115 }
123 116
124 bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::Re cursionData& recursionData) 117 bool StyleInvalidator::invalidateChildren(Element& element, StyleInvalidator::Re cursionData& recursionData)
125 { 118 {
126 bool someChildrenNeedStyleRecalc = false; 119 bool someChildrenNeedStyleRecalc = false;
127 for (ShadowRoot* root = element.youngestShadowRoot(); root; root = root->old erShadowRoot()) { 120 for (ShadowRoot* root = element.youngestShadowRoot(); root; root = root->old erShadowRoot()) {
128 if (!recursionData.treeBoundaryCrossing() && !root->childNeedsStyleInval idation() && !root->needsStyleInvalidation()) 121 if (!recursionData.treeBoundaryCrossing() && !root->childNeedsStyleInval idation() && !root->needsStyleInvalidation())
129 continue; 122 continue;
130 for (Element* child = ElementTraversal::firstChild(*root); child; child = ElementTraversal::nextSibling(*child)) { 123 for (Element* child = ElementTraversal::firstChild(*root); child; child = ElementTraversal::nextSibling(*child)) {
(...skipping 17 matching lines...) Expand all
148 bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement(eleme nt, recursionData); 141 bool thisElementNeedsStyleRecalc = checkInvalidationSetsAgainstElement(eleme nt, recursionData);
149 142
150 bool someChildrenNeedStyleRecalc = false; 143 bool someChildrenNeedStyleRecalc = false;
151 if (recursionData.hasInvalidationSets() || element.childNeedsStyleInvalidati on()) 144 if (recursionData.hasInvalidationSets() || element.childNeedsStyleInvalidati on())
152 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData) ; 145 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData) ;
153 146
154 if (thisElementNeedsStyleRecalc) { 147 if (thisElementNeedsStyleRecalc) {
155 element.setNeedsStyleRecalc(recursionData.wholeSubtreeInvalid() ? Subtre eStyleChange : LocalStyleChange, StyleChangeReasonForTracing::create(StyleChange Reason::StyleInvalidator)); 148 element.setNeedsStyleRecalc(recursionData.wholeSubtreeInvalid() ? Subtre eStyleChange : LocalStyleChange, StyleChangeReasonForTracing::create(StyleChange Reason::StyleInvalidator));
156 } else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecal c) { 149 } else if (recursionData.hasInvalidationSets() && someChildrenNeedStyleRecal c) {
157 // Clone the RenderStyle in order to preserve correct style sharing, if possible. Otherwise recalc style. 150 // Clone the RenderStyle in order to preserve correct style sharing, if possible. Otherwise recalc style.
158 if (RenderObject* renderer = element.renderer()) { 151 if (RenderObject* renderer = element.renderer())
159 renderer->setStyleInternal(RenderStyle::clone(renderer->style())); 152 renderer->setStyleInternal(RenderStyle::clone(renderer->style()));
160 } else { 153 else
161 TRACE_STYLE_INVALIDATOR_INVALIDATION(element, PreventStyleSharingFor Parent);
162 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::StyleInvalidator)); 154 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::StyleInvalidator));
163 }
164 } 155 }
165 156
166 element.clearChildNeedsStyleInvalidation(); 157 element.clearChildNeedsStyleInvalidation();
167 element.clearNeedsStyleInvalidation(); 158 element.clearNeedsStyleInvalidation();
168 159
169 return thisElementNeedsStyleRecalc; 160 return thisElementNeedsStyleRecalc;
170 } 161 }
171 162
172 void StyleInvalidator::trace(Visitor* visitor) 163 void StyleInvalidator::trace(Visitor* visitor)
173 { 164 {
174 #if ENABLE(OILPAN) 165 #if ENABLE(OILPAN)
175 visitor->trace(m_pendingInvalidationMap); 166 visitor->trace(m_pendingInvalidationMap);
176 #endif 167 #endif
177 } 168 }
178 169
179 } // namespace blink 170 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/invalidation/DescendantInvalidationSet.cpp ('k') | Source/core/inspector/InspectorTraceEvents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698