OLD | NEW |
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 Loading... |
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 InvalidationSet::cacheTracingFlag() | 49 void InvalidationSet::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 InvalidationSet::InvalidationSet() | 54 InvalidationSet::InvalidationSet() |
55 : m_allDescendantsMightBeInvalid(false) | 55 : m_maxDirectAdjacentSelectors(1) |
| 56 , m_appliesDirectly(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 InvalidationSet::invalidatesElement(Element& element) const | 64 bool InvalidationSet::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 Loading... |
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 InvalidationSet::combine(const InvalidationSet& other) | 101 void InvalidationSet::combine(const InvalidationSet& other) |
100 { | 102 { |
| 103 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other.
m_maxDirectAdjacentSelectors); |
| 104 |
| 105 if (other.descendants()) |
| 106 ensureDescendantInvalidationSet().combine(*other.descendants()); |
| 107 |
| 108 if (other.appliesDirectly()) |
| 109 setAppliesDirectly(); |
| 110 |
101 // No longer bother combining data structures, since the whole subtree is de
emed invalid. | 111 // No longer bother combining data structures, since the whole subtree is de
emed invalid. |
102 if (wholeSubtreeInvalid()) | 112 if (wholeSubtreeInvalid()) |
103 return; | 113 return; |
104 | 114 |
105 if (other.wholeSubtreeInvalid()) { | 115 if (other.wholeSubtreeInvalid()) { |
106 setWholeSubtreeInvalid(); | 116 setWholeSubtreeInvalid(); |
107 return; | 117 return; |
108 } | 118 } |
109 | 119 |
110 if (other.customPseudoInvalid()) | 120 if (other.customPseudoInvalid()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return *m_tagNames; | 168 return *m_tagNames; |
159 } | 169 } |
160 | 170 |
161 WillBeHeapHashSet<AtomicString>& InvalidationSet::ensureAttributeSet() | 171 WillBeHeapHashSet<AtomicString>& InvalidationSet::ensureAttributeSet() |
162 { | 172 { |
163 if (!m_attributes) | 173 if (!m_attributes) |
164 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); | 174 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); |
165 return *m_attributes; | 175 return *m_attributes; |
166 } | 176 } |
167 | 177 |
| 178 InvalidationSet& InvalidationSet::ensureDescendantInvalidationSet() |
| 179 { |
| 180 if (!m_descendantInvalidationSet) |
| 181 m_descendantInvalidationSet = InvalidationSet::create(); |
| 182 |
| 183 return *m_descendantInvalidationSet; |
| 184 } |
| 185 |
168 void InvalidationSet::addClass(const AtomicString& className) | 186 void InvalidationSet::addClass(const AtomicString& className) |
169 { | 187 { |
170 if (wholeSubtreeInvalid()) | 188 if (wholeSubtreeInvalid()) |
171 return; | 189 return; |
172 ensureClassSet().add(className); | 190 ensureClassSet().add(className); |
173 } | 191 } |
174 | 192 |
175 void InvalidationSet::addId(const AtomicString& id) | 193 void InvalidationSet::addId(const AtomicString& id) |
176 { | 194 { |
177 if (wholeSubtreeInvalid()) | 195 if (wholeSubtreeInvalid()) |
(...skipping 30 matching lines...) Expand all Loading... |
208 m_attributes = nullptr; | 226 m_attributes = nullptr; |
209 } | 227 } |
210 | 228 |
211 DEFINE_TRACE(InvalidationSet) | 229 DEFINE_TRACE(InvalidationSet) |
212 { | 230 { |
213 #if ENABLE(OILPAN) | 231 #if ENABLE(OILPAN) |
214 visitor->trace(m_classes); | 232 visitor->trace(m_classes); |
215 visitor->trace(m_ids); | 233 visitor->trace(m_ids); |
216 visitor->trace(m_tagNames); | 234 visitor->trace(m_tagNames); |
217 visitor->trace(m_attributes); | 235 visitor->trace(m_attributes); |
| 236 visitor->trace(m_descendantInvalidationSet); |
218 #endif | 237 #endif |
219 } | 238 } |
220 | 239 |
221 void InvalidationSet::toTracedValue(TracedValue* value) const | 240 void InvalidationSet::toTracedValue(TracedValue* value) const |
222 { | 241 { |
223 value->beginDictionary(); | 242 value->beginDictionary(); |
224 | 243 |
225 value->setString("id", descendantInvalidationSetToIdString(*this)); | 244 value->setString("id", descendantInvalidationSetToIdString(*this)); |
226 | 245 |
227 if (m_allDescendantsMightBeInvalid) | 246 if (m_allDescendantsMightBeInvalid) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 { | 288 { |
270 RefPtr<TracedValue> value = TracedValue::create(); | 289 RefPtr<TracedValue> value = TracedValue::create(); |
271 value->beginArray("InvalidationSet"); | 290 value->beginArray("InvalidationSet"); |
272 toTracedValue(value.get()); | 291 toTracedValue(value.get()); |
273 value->endArray(); | 292 value->endArray(); |
274 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); | 293 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); |
275 } | 294 } |
276 #endif // NDEBUG | 295 #endif // NDEBUG |
277 | 296 |
278 } // namespace blink | 297 } // namespace blink |
OLD | NEW |