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

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

Issue 580373002: [Invalidation Tracking] Trace StyleInvalidator setNeedsStyleRecalc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased 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 (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/css/invalidation/DescendantInvalidationSet.h" 32 #include "core/css/invalidation/DescendantInvalidationSet.h"
33 33
34 #include "core/css/resolver/StyleResolver.h" 34 #include "core/css/resolver/StyleResolver.h"
35 #include "core/dom/Element.h" 35 #include "core/dom/Element.h"
36 #include "core/inspector/InspectorTraceEvents.h"
37 #include "platform/TracedValue.h"
38 #include "wtf/text/StringBuilder.h"
36 39
37 namespace blink { 40 namespace blink {
38 41
39 DescendantInvalidationSet::DescendantInvalidationSet() 42 DescendantInvalidationSet::DescendantInvalidationSet()
40 : m_allDescendantsMightBeInvalid(false) 43 : m_allDescendantsMightBeInvalid(false)
41 , m_customPseudoInvalid(false) 44 , m_customPseudoInvalid(false)
42 , m_treeBoundaryCrossing(false) 45 , m_treeBoundaryCrossing(false)
43 { 46 {
44 } 47 }
45 48
46 bool DescendantInvalidationSet::invalidatesElement(Element& element) const 49 bool DescendantInvalidationSet::invalidatesElement(Element& element) const
47 { 50 {
48 if (m_allDescendantsMightBeInvalid) 51 if (m_allDescendantsMightBeInvalid)
49 return true; 52 return true;
50 53
51 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) 54 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) {
55 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS etMatchedTagName, element.tagQName().localName());
52 return true; 56 return true;
57 }
53 58
54 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution ())) 59 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution ())) {
60 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, InvalidationS etMatchedId, element.idForStyleResolution());
55 return true; 61 return true;
62 }
56 63
57 if (element.hasClass() && m_classes) { 64 if (element.hasClass() && m_classes) {
58 const SpaceSplitString& classNames = element.classNames(); 65 const SpaceSplitString& classNames = element.classNames();
59 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg in(); it != m_classes->end(); ++it) { 66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg in(); it != m_classes->end(); ++it) {
60 if (classNames.contains(*it)) 67 if (classNames.contains(*it)) {
68 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval idationSetMatchedClass, *it);
61 return true; 69 return true;
70 }
62 } 71 }
63 } 72 }
64 73
65 if (element.hasAttributes() && m_attributes) { 74 if (element.hasAttributes() && m_attributes) {
66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes-> begin(); it != m_attributes->end(); ++it) { 75 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes-> begin(); it != m_attributes->end(); ++it) {
67 if (element.hasAttribute(*it)) 76 if (element.hasAttribute(*it)) {
77 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, Inval idationSetMatchedAttribute, *it);
68 return true; 78 return true;
79 }
69 } 80 }
70 } 81 }
71 82
72 return false; 83 return false;
73 } 84 }
74 85
75 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) 86 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other)
76 { 87 {
77 // No longer bother combining data structures, since the whole subtree is de emed invalid. 88 // No longer bother combining data structures, since the whole subtree is de emed invalid.
78 if (wholeSubtreeInvalid()) 89 if (wholeSubtreeInvalid())
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void DescendantInvalidationSet::trace(Visitor* visitor) 197 void DescendantInvalidationSet::trace(Visitor* visitor)
187 { 198 {
188 #if ENABLE(OILPAN) 199 #if ENABLE(OILPAN)
189 visitor->trace(m_classes); 200 visitor->trace(m_classes);
190 visitor->trace(m_ids); 201 visitor->trace(m_ids);
191 visitor->trace(m_tagNames); 202 visitor->trace(m_tagNames);
192 visitor->trace(m_attributes); 203 visitor->trace(m_attributes);
193 #endif 204 #endif
194 } 205 }
195 206
207 void DescendantInvalidationSet::toTracedValue(TracedValue* value) const
208 {
209 value->beginArray();
210
211 if (m_allDescendantsMightBeInvalid)
212 value->pushString("*");
caseq 2014/10/01 07:50:49 Can we please get it more structured -- i.e. inste
kouhei (in TOK) 2014/10/02 02:16:46 Done.
213 if (m_customPseudoInvalid)
214 value->pushString("::custom");
215 if (m_treeBoundaryCrossing)
216 value->pushString("::shadow/deep/");
217 if (m_ids) {
218 for (const auto& id : *m_ids) {
219 StringBuilder builder;
220 builder.append("#");
221 builder.append(id);
222 value->pushString(builder.toString());
223 }
224 }
225 if (m_classes) {
226 for (const auto& className : *m_classes) {
227 StringBuilder builder;
228 builder.append(".");
229 builder.append(className);
230 value->pushString(builder.toString());
231 }
232 }
233 if (m_tagNames) {
234 for (const auto& tagName : *m_tagNames) {
235 StringBuilder builder;
236 builder.append("<");
237 builder.append(tagName);
238 builder.append(">");
239 value->pushString(builder.toString());
240 }
241 }
242 if (m_attributes) {
243 for (const auto& attribute : *m_attributes) {
244 StringBuilder builder;
245 builder.append("[");
246 builder.append(attribute);
247 builder.append("]");
248 value->pushString(builder.toString());
249 }
250 }
251
252 value->endArray();
253 }
254
196 #ifndef NDEBUG 255 #ifndef NDEBUG
197 void DescendantInvalidationSet::show() const 256 void DescendantInvalidationSet::show() const
198 { 257 {
199 fprintf(stderr, "DescendantInvalidationSet { "); 258 RefPtr<TracedValue> value = TracedValue::create();
200 if (m_allDescendantsMightBeInvalid) 259 toTracedValue(value.get());
201 fprintf(stderr, "* "); 260 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data());
202 if (m_customPseudoInvalid)
203 fprintf(stderr, "::custom ");
204 if (m_treeBoundaryCrossing)
205 fprintf(stderr, "::shadow/deep/ ");
206 if (m_ids) {
207 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_ids->begin() ; it != m_ids->end(); ++it)
208 fprintf(stderr, "#%s ", (*it).ascii().data());
209 }
210 if (m_classes) {
211 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg in(); it != m_classes->end(); ++it)
212 fprintf(stderr, ".%s ", (*it).ascii().data());
213 }
214 if (m_tagNames) {
215 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_tagNames->be gin(); it != m_tagNames->end(); ++it)
216 fprintf(stderr, "<%s> ", (*it).ascii().data());
217 }
218 if (m_attributes) {
219 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes-> begin(); it != m_attributes->end(); ++it)
220 fprintf(stderr, "[%s] ", (*it).ascii().data());
221 }
222 fprintf(stderr, "}\n");
223 } 261 }
224 #endif // NDEBUG 262 #endif // NDEBUG
225 263
226 } // namespace blink 264 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698