| 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 17 matching lines...) Expand all Loading... |
| 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 "core/css/invalidation/InvalidationSet.h" | 31 #include "core/css/invalidation/InvalidationSet.h" |
| 32 | 32 |
| 33 #include "core/css/resolver/StyleResolver.h" | 33 #include "core/css/resolver/StyleResolver.h" |
| 34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
| 35 #include "core/inspector/InspectorTraceEvents.h" | 35 #include "core/inspector/InspectorTraceEvents.h" |
| 36 #include "platform/TracedValue.h" | 36 #include "platform/TracedValue.h" |
| 37 #include "wtf/Compiler.h" | 37 #include "wtf/Compiler.h" |
| 38 #include "wtf/PtrUtil.h" | |
| 39 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
| 40 #include <memory> | |
| 41 | 39 |
| 42 namespace blink { | 40 namespace blink { |
| 43 | 41 |
| 44 static const unsigned char* s_tracingEnabled = nullptr; | 42 static const unsigned char* s_tracingEnabled = nullptr; |
| 45 | 43 |
| 46 #define TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, re
ason, invalidationSet, singleSelectorPart) \ | 44 #define TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART_IF_ENABLED(element, re
ason, invalidationSet, singleSelectorPart) \ |
| 47 if (UNLIKELY(*s_tracingEnabled)) \ | 45 if (UNLIKELY(*s_tracingEnabled)) \ |
| 48 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, reason, inval
idationSet, singleSelectorPart); | 46 TRACE_STYLE_INVALIDATOR_INVALIDATION_SELECTORPART(element, reason, inval
idationSet, singleSelectorPart); |
| 49 | 47 |
| 50 void InvalidationSet::cacheTracingFlag() | 48 void InvalidationSet::cacheTracingFlag() |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 { | 161 { |
| 164 if (isDescendantInvalidationSet()) | 162 if (isDescendantInvalidationSet()) |
| 165 delete toDescendantInvalidationSet(this); | 163 delete toDescendantInvalidationSet(this); |
| 166 else | 164 else |
| 167 delete toSiblingInvalidationSet(this); | 165 delete toSiblingInvalidationSet(this); |
| 168 } | 166 } |
| 169 | 167 |
| 170 HashSet<AtomicString>& InvalidationSet::ensureClassSet() | 168 HashSet<AtomicString>& InvalidationSet::ensureClassSet() |
| 171 { | 169 { |
| 172 if (!m_classes) | 170 if (!m_classes) |
| 173 m_classes = wrapUnique(new HashSet<AtomicString>); | 171 m_classes = adoptPtr(new HashSet<AtomicString>); |
| 174 return *m_classes; | 172 return *m_classes; |
| 175 } | 173 } |
| 176 | 174 |
| 177 HashSet<AtomicString>& InvalidationSet::ensureIdSet() | 175 HashSet<AtomicString>& InvalidationSet::ensureIdSet() |
| 178 { | 176 { |
| 179 if (!m_ids) | 177 if (!m_ids) |
| 180 m_ids = wrapUnique(new HashSet<AtomicString>); | 178 m_ids = adoptPtr(new HashSet<AtomicString>); |
| 181 return *m_ids; | 179 return *m_ids; |
| 182 } | 180 } |
| 183 | 181 |
| 184 HashSet<AtomicString>& InvalidationSet::ensureTagNameSet() | 182 HashSet<AtomicString>& InvalidationSet::ensureTagNameSet() |
| 185 { | 183 { |
| 186 if (!m_tagNames) | 184 if (!m_tagNames) |
| 187 m_tagNames = wrapUnique(new HashSet<AtomicString>); | 185 m_tagNames = adoptPtr(new HashSet<AtomicString>); |
| 188 return *m_tagNames; | 186 return *m_tagNames; |
| 189 } | 187 } |
| 190 | 188 |
| 191 HashSet<AtomicString>& InvalidationSet::ensureAttributeSet() | 189 HashSet<AtomicString>& InvalidationSet::ensureAttributeSet() |
| 192 { | 190 { |
| 193 if (!m_attributes) | 191 if (!m_attributes) |
| 194 m_attributes = wrapUnique(new HashSet<AtomicString>); | 192 m_attributes = adoptPtr(new HashSet<AtomicString>); |
| 195 return *m_attributes; | 193 return *m_attributes; |
| 196 } | 194 } |
| 197 | 195 |
| 198 void InvalidationSet::addClass(const AtomicString& className) | 196 void InvalidationSet::addClass(const AtomicString& className) |
| 199 { | 197 { |
| 200 if (wholeSubtreeInvalid()) | 198 if (wholeSubtreeInvalid()) |
| 201 return; | 199 return; |
| 202 ensureClassSet().add(className); | 200 ensureClassSet().add(className); |
| 203 } | 201 } |
| 204 | 202 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 value->pushString(attribute); | 281 value->pushString(attribute); |
| 284 value->endArray(); | 282 value->endArray(); |
| 285 } | 283 } |
| 286 | 284 |
| 287 value->endDictionary(); | 285 value->endDictionary(); |
| 288 } | 286 } |
| 289 | 287 |
| 290 #ifndef NDEBUG | 288 #ifndef NDEBUG |
| 291 void InvalidationSet::show() const | 289 void InvalidationSet::show() const |
| 292 { | 290 { |
| 293 std::unique_ptr<TracedValue> value = TracedValue::create(); | 291 OwnPtr<TracedValue> value = TracedValue::create(); |
| 294 value->beginArray("InvalidationSet"); | 292 value->beginArray("InvalidationSet"); |
| 295 toTracedValue(value.get()); | 293 toTracedValue(value.get()); |
| 296 value->endArray(); | 294 value->endArray(); |
| 297 fprintf(stderr, "%s\n", value->toString().ascii().data()); | 295 fprintf(stderr, "%s\n", value->toString().ascii().data()); |
| 298 } | 296 } |
| 299 #endif // NDEBUG | 297 #endif // NDEBUG |
| 300 | 298 |
| 301 SiblingInvalidationSet::SiblingInvalidationSet(PassRefPtr<DescendantInvalidation
Set> descendants) | 299 SiblingInvalidationSet::SiblingInvalidationSet(PassRefPtr<DescendantInvalidation
Set> descendants) |
| 302 : InvalidationSet(InvalidateSiblings) | 300 : InvalidationSet(InvalidateSiblings) |
| 303 , m_maxDirectAdjacentSelectors(1) | 301 , m_maxDirectAdjacentSelectors(1) |
| 304 , m_descendantInvalidationSet(descendants) | 302 , m_descendantInvalidationSet(descendants) |
| 305 { | 303 { |
| 306 } | 304 } |
| 307 | 305 |
| 308 DescendantInvalidationSet& SiblingInvalidationSet::ensureSiblingDescendants() | 306 DescendantInvalidationSet& SiblingInvalidationSet::ensureSiblingDescendants() |
| 309 { | 307 { |
| 310 if (!m_siblingDescendantInvalidationSet) | 308 if (!m_siblingDescendantInvalidationSet) |
| 311 m_siblingDescendantInvalidationSet = DescendantInvalidationSet::create()
; | 309 m_siblingDescendantInvalidationSet = DescendantInvalidationSet::create()
; |
| 312 return *m_siblingDescendantInvalidationSet; | 310 return *m_siblingDescendantInvalidationSet; |
| 313 } | 311 } |
| 314 | 312 |
| 315 DescendantInvalidationSet& SiblingInvalidationSet::ensureDescendants() | 313 DescendantInvalidationSet& SiblingInvalidationSet::ensureDescendants() |
| 316 { | 314 { |
| 317 if (!m_descendantInvalidationSet) | 315 if (!m_descendantInvalidationSet) |
| 318 m_descendantInvalidationSet = DescendantInvalidationSet::create(); | 316 m_descendantInvalidationSet = DescendantInvalidationSet::create(); |
| 319 return *m_descendantInvalidationSet; | 317 return *m_descendantInvalidationSet; |
| 320 } | 318 } |
| 321 | 319 |
| 322 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |