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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_allDescendantsMightBeInvalid(false) |
56 , m_invalidatesSelf(false) | 56 , m_invalidatesSelf(false) |
57 , m_customPseudoInvalid(false) | 57 , m_customPseudoInvalid(false) |
58 , m_treeBoundaryCrossing(false) | 58 , m_treeBoundaryCrossing(false) |
59 , m_insertionPointCrossing(false) | 59 , m_insertionPointCrossing(false) |
| 60 , m_maxDirectAdjacentSelectors(1) |
60 { | 61 { |
61 } | 62 } |
62 | 63 |
63 bool InvalidationSet::invalidatesElement(Element& element) const | 64 bool InvalidationSet::invalidatesElement(Element& element) const |
64 { | 65 { |
65 if (m_allDescendantsMightBeInvalid) | 66 if (m_allDescendantsMightBeInvalid) |
66 return true; | 67 return true; |
67 | 68 |
68 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) { | 69 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) { |
69 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, In
validationSetMatchedTagName, *this, element.tagQName().localName()); | 70 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, In
validationSetMatchedTagName, *this, element.tagQName().localName()); |
(...skipping 22 matching lines...) Expand all Loading... |
92 return true; | 93 return true; |
93 } | 94 } |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 return false; | 98 return false; |
98 } | 99 } |
99 | 100 |
100 void InvalidationSet::combine(const InvalidationSet& other) | 101 void InvalidationSet::combine(const InvalidationSet& other) |
101 { | 102 { |
| 103 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other.
m_maxDirectAdjacentSelectors); |
| 104 |
| 105 if (other.descendants()) |
| 106 ensureDescendantInvalidationSet().combine(*other.descendants()); |
| 107 |
102 // No longer bother combining data structures, since the whole subtree is de
emed invalid. | 108 // No longer bother combining data structures, since the whole subtree is de
emed invalid. |
103 if (wholeSubtreeInvalid()) | 109 if (wholeSubtreeInvalid()) |
104 return; | 110 return; |
105 | 111 |
106 if (other.wholeSubtreeInvalid()) { | 112 if (other.wholeSubtreeInvalid()) { |
107 setWholeSubtreeInvalid(); | 113 setWholeSubtreeInvalid(); |
108 return; | 114 return; |
109 } | 115 } |
110 | 116 |
111 if (other.invalidatesSelf()) | 117 if (other.invalidatesSelf()) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return *m_tagNames; | 168 return *m_tagNames; |
163 } | 169 } |
164 | 170 |
165 WillBeHeapHashSet<AtomicString>& InvalidationSet::ensureAttributeSet() | 171 WillBeHeapHashSet<AtomicString>& InvalidationSet::ensureAttributeSet() |
166 { | 172 { |
167 if (!m_attributes) | 173 if (!m_attributes) |
168 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); | 174 m_attributes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); |
169 return *m_attributes; | 175 return *m_attributes; |
170 } | 176 } |
171 | 177 |
| 178 InvalidationSet& InvalidationSet::ensureDescendantInvalidationSet() |
| 179 { |
| 180 if (!m_descendantInvalidationSet) |
| 181 m_descendantInvalidationSet = InvalidationSet::create(); |
| 182 |
| 183 return *m_descendantInvalidationSet; |
| 184 } |
| 185 |
172 void InvalidationSet::addClass(const AtomicString& className) | 186 void InvalidationSet::addClass(const AtomicString& className) |
173 { | 187 { |
174 if (wholeSubtreeInvalid()) | 188 if (wholeSubtreeInvalid()) |
175 return; | 189 return; |
176 ensureClassSet().add(className); | 190 ensureClassSet().add(className); |
177 } | 191 } |
178 | 192 |
179 void InvalidationSet::addId(const AtomicString& id) | 193 void InvalidationSet::addId(const AtomicString& id) |
180 { | 194 { |
181 if (wholeSubtreeInvalid()) | 195 if (wholeSubtreeInvalid()) |
(...skipping 30 matching lines...) Expand all Loading... |
212 m_attributes = nullptr; | 226 m_attributes = nullptr; |
213 } | 227 } |
214 | 228 |
215 DEFINE_TRACE(InvalidationSet) | 229 DEFINE_TRACE(InvalidationSet) |
216 { | 230 { |
217 #if ENABLE(OILPAN) | 231 #if ENABLE(OILPAN) |
218 visitor->trace(m_classes); | 232 visitor->trace(m_classes); |
219 visitor->trace(m_ids); | 233 visitor->trace(m_ids); |
220 visitor->trace(m_tagNames); | 234 visitor->trace(m_tagNames); |
221 visitor->trace(m_attributes); | 235 visitor->trace(m_attributes); |
| 236 visitor->trace(m_descendantInvalidationSet); |
222 #endif | 237 #endif |
223 } | 238 } |
224 | 239 |
225 void InvalidationSet::toTracedValue(TracedValue* value) const | 240 void InvalidationSet::toTracedValue(TracedValue* value) const |
226 { | 241 { |
227 value->beginDictionary(); | 242 value->beginDictionary(); |
228 | 243 |
229 value->setString("id", descendantInvalidationSetToIdString(*this)); | 244 value->setString("id", descendantInvalidationSetToIdString(*this)); |
230 | 245 |
231 if (m_allDescendantsMightBeInvalid) | 246 if (m_allDescendantsMightBeInvalid) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 { | 288 { |
274 RefPtr<TracedValue> value = TracedValue::create(); | 289 RefPtr<TracedValue> value = TracedValue::create(); |
275 value->beginArray("InvalidationSet"); | 290 value->beginArray("InvalidationSet"); |
276 toTracedValue(value.get()); | 291 toTracedValue(value.get()); |
277 value->endArray(); | 292 value->endArray(); |
278 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); | 293 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); |
279 } | 294 } |
280 #endif // NDEBUG | 295 #endif // NDEBUG |
281 | 296 |
282 } // namespace blink | 297 } // namespace blink |
OLD | NEW |