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

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

Issue 1317533002: Sibling invalidation sets (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sibling-inserted 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #define TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, re ason, invalidationSet, singleSelectorPart) \ 45 #define TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, re ason, invalidationSet, singleSelectorPart) \
46 if (UNLIKELY(*s_tracingEnabled)) \ 46 if (UNLIKELY(*s_tracingEnabled)) \
47 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, reason, inval idationSet, singleSelectorPart); 47 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, reason, inval idationSet, singleSelectorPart);
48 48
49 void DescendantInvalidationSet::cacheTracingFlag() 49 void DescendantInvalidationSet::cacheTracingFlag()
50 { 50 {
51 s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DE FAULT("devtools.timeline.invalidationTracking")); 51 s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_ENABLED(TRACE_DISABLED_BY_DE FAULT("devtools.timeline.invalidationTracking"));
52 } 52 }
53 53
54 DescendantInvalidationSet::DescendantInvalidationSet() 54 DescendantInvalidationSet::DescendantInvalidationSet()
55 : m_allDescendantsMightBeInvalid(false) 55 : m_maxDirectAdjacentSelectors(1)
56 , m_siblingInvalid(false)
57 , m_allDescendantsMightBeInvalid(false)
56 , m_customPseudoInvalid(false) 58 , m_customPseudoInvalid(false)
57 , m_treeBoundaryCrossing(false) 59 , m_treeBoundaryCrossing(false)
58 , m_insertionPointCrossing(false) 60 , m_insertionPointCrossing(false)
59 { 61 {
60 } 62 }
61 63
62 bool DescendantInvalidationSet::invalidatesElement(Element& element) const 64 bool DescendantInvalidationSet::invalidatesElement(Element& element) const
63 { 65 {
64 if (m_allDescendantsMightBeInvalid) 66 if (m_allDescendantsMightBeInvalid)
65 return true; 67 return true;
(...skipping 25 matching lines...) Expand all
91 return true; 93 return true;
92 } 94 }
93 } 95 }
94 } 96 }
95 97
96 return false; 98 return false;
97 } 99 }
98 100
99 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) 101 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other)
100 { 102 {
103 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other. m_maxDirectAdjacentSelectors);
104
101 // No longer bother combining data structures, since the whole subtree is de emed invalid. 105 // No longer bother combining data structures, since the whole subtree is de emed invalid.
102 if (wholeSubtreeInvalid()) 106 if (wholeSubtreeInvalid())
103 return; 107 return;
104 108
105 if (other.wholeSubtreeInvalid()) { 109 if (other.wholeSubtreeInvalid()) {
106 setWholeSubtreeInvalid(); 110 setWholeSubtreeInvalid();
107 return; 111 return;
108 } 112 }
109 113
114 if (other.siblingInvalid())
115 setSiblingInvalid();
116
110 if (other.customPseudoInvalid()) 117 if (other.customPseudoInvalid())
111 setCustomPseudoInvalid(); 118 setCustomPseudoInvalid();
112 119
113 if (other.treeBoundaryCrossing()) 120 if (other.treeBoundaryCrossing())
114 setTreeBoundaryCrossing(); 121 setTreeBoundaryCrossing();
115 122
116 if (other.insertionPointCrossing()) 123 if (other.insertionPointCrossing())
117 setInsertionPointCrossing(); 124 setInsertionPointCrossing();
118 125
119 if (other.m_classes) { 126 if (other.m_classes) {
120 for (const auto& className : *other.m_classes) 127 for (const auto& className : *other.m_classes)
121 addClass(className); 128 addClass(className);
122 } 129 }
123 130
124 if (other.m_ids) { 131 if (other.m_ids) {
125 for (const auto& id : *other.m_ids) 132 for (const auto& id : *other.m_ids)
126 addId(id); 133 addId(id);
127 } 134 }
128 135
129 if (other.m_tagNames) { 136 if (other.m_tagNames) {
130 for (const auto& tagName : *other.m_tagNames) 137 for (const auto& tagName : *other.m_tagNames)
131 addTagName(tagName); 138 addTagName(tagName);
132 } 139 }
133 140
134 if (other.m_attributes) { 141 if (other.m_attributes) {
135 for (const auto& attribute : *other.m_attributes) 142 for (const auto& attribute : *other.m_attributes)
136 addAttribute(attribute); 143 addAttribute(attribute);
137 } 144 }
145
146 if (other.descendants())
147 ensureDescendantInvalidationSet().combine(*other.descendants());
148
149 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other. maxDirectAdjacentSelectors());
138 } 150 }
139 151
140 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureClassSet() 152 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureClassSet()
141 { 153 {
142 if (!m_classes) 154 if (!m_classes)
143 m_classes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); 155 m_classes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>);
144 return *m_classes; 156 return *m_classes;
145 } 157 }
146 158
147 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureIdSet() 159 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureIdSet()
(...skipping 10 matching lines...) Expand all
158 return *m_tagNames; 170 return *m_tagNames;
159 } 171 }
160 172
161 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureAttributeSet() 173 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureAttributeSet()
162 { 174 {
163 if (!m_attributes) 175 if (!m_attributes)
164 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); 176 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>);
165 return *m_attributes; 177 return *m_attributes;
166 } 178 }
167 179
180 DescendantInvalidationSet& DescendantInvalidationSet::ensureDescendantInvalidati onSet()
181 {
182 if (!m_descendantInvalidationSet)
183 m_descendantInvalidationSet = DescendantInvalidationSet::create();
184
185 return *m_descendantInvalidationSet;
186 }
187
168 void DescendantInvalidationSet::addClass(const AtomicString& className) 188 void DescendantInvalidationSet::addClass(const AtomicString& className)
169 { 189 {
170 if (wholeSubtreeInvalid()) 190 if (wholeSubtreeInvalid())
171 return; 191 return;
172 ensureClassSet().add(className); 192 ensureClassSet().add(className);
173 } 193 }
174 194
175 void DescendantInvalidationSet::addId(const AtomicString& id) 195 void DescendantInvalidationSet::addId(const AtomicString& id)
176 { 196 {
177 if (wholeSubtreeInvalid()) 197 if (wholeSubtreeInvalid())
(...skipping 14 matching lines...) Expand all
192 return; 212 return;
193 ensureAttributeSet().add(attribute); 213 ensureAttributeSet().add(attribute);
194 } 214 }
195 215
196 void DescendantInvalidationSet::setWholeSubtreeInvalid() 216 void DescendantInvalidationSet::setWholeSubtreeInvalid()
197 { 217 {
198 if (m_allDescendantsMightBeInvalid) 218 if (m_allDescendantsMightBeInvalid)
199 return; 219 return;
200 220
201 m_allDescendantsMightBeInvalid = true; 221 m_allDescendantsMightBeInvalid = true;
222 m_siblingInvalid = false;
202 m_customPseudoInvalid = false; 223 m_customPseudoInvalid = false;
203 m_treeBoundaryCrossing = false; 224 m_treeBoundaryCrossing = false;
204 m_insertionPointCrossing = false; 225 m_insertionPointCrossing = false;
205 m_classes = nullptr; 226 m_classes = nullptr;
206 m_ids = nullptr; 227 m_ids = nullptr;
207 m_tagNames = nullptr; 228 m_tagNames = nullptr;
208 m_attributes = nullptr; 229 m_attributes = nullptr;
230 m_descendantInvalidationSet = nullptr;
209 } 231 }
210 232
211 DEFINE_TRACE(DescendantInvalidationSet) 233 DEFINE_TRACE(DescendantInvalidationSet)
212 { 234 {
213 #if ENABLE(OILPAN) 235 #if ENABLE(OILPAN)
214 visitor->trace(m_classes); 236 visitor->trace(m_classes);
215 visitor->trace(m_ids); 237 visitor->trace(m_ids);
216 visitor->trace(m_tagNames); 238 visitor->trace(m_tagNames);
217 visitor->trace(m_attributes); 239 visitor->trace(m_attributes);
218 #endif 240 #endif
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 { 291 {
270 RefPtr<TracedValue> value = TracedValue::create(); 292 RefPtr<TracedValue> value = TracedValue::create();
271 value->beginArray("DescendantInvalidationSet"); 293 value->beginArray("DescendantInvalidationSet");
272 toTracedValue(value.get()); 294 toTracedValue(value.get());
273 value->endArray(); 295 value->endArray();
274 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); 296 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data());
275 } 297 }
276 #endif // NDEBUG 298 #endif // NDEBUG
277 299
278 } // namespace blink 300 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698