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

Side by Side Diff: third_party/WebKit/Source/core/css/invalidation/InvalidationSet.cpp

Issue 1480973002: CSS Invalidation: Avoid virtual functions in InvalidationSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no protected destructor Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
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_GROUP_ENABLED(TRACE_DISABLED _BY_DEFAULT("devtools.timeline.invalidationTracking")); 51 s_tracingEnabled = TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(TRACE_DISABLED _BY_DEFAULT("devtools.timeline.invalidationTracking"));
52 } 52 }
53 53
54 InvalidationSet::InvalidationSet() 54 InvalidationSet::InvalidationSet(InvalidationType type)
55 : m_allDescendantsMightBeInvalid(false) 55 : m_type(type)
56 , m_allDescendantsMightBeInvalid(false)
56 , m_invalidatesSelf(false) 57 , m_invalidatesSelf(false)
57 , m_customPseudoInvalid(false) 58 , m_customPseudoInvalid(false)
58 , m_treeBoundaryCrossing(false) 59 , m_treeBoundaryCrossing(false)
59 , m_insertionPointCrossing(false) 60 , m_insertionPointCrossing(false)
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)
(...skipping 26 matching lines...) Expand all
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 ASSERT(m_type == other.m_type);
104
102 // 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.
103 if (wholeSubtreeInvalid()) 106 if (wholeSubtreeInvalid())
104 return; 107 return;
105 108
106 if (other.wholeSubtreeInvalid()) { 109 if (other.wholeSubtreeInvalid()) {
107 setWholeSubtreeInvalid(); 110 setWholeSubtreeInvalid();
108 return; 111 return;
109 } 112 }
110 113
111 if (other.invalidatesSelf()) 114 if (other.invalidatesSelf())
(...skipping 22 matching lines...) Expand all
134 for (const auto& tagName : *other.m_tagNames) 137 for (const auto& tagName : *other.m_tagNames)
135 addTagName(tagName); 138 addTagName(tagName);
136 } 139 }
137 140
138 if (other.m_attributes) { 141 if (other.m_attributes) {
139 for (const auto& attribute : *other.m_attributes) 142 for (const auto& attribute : *other.m_attributes)
140 addAttribute(attribute); 143 addAttribute(attribute);
141 } 144 }
142 } 145 }
143 146
147 void InvalidationSet::destroy()
148 {
149 if (isDescendantInvalidationSet())
150 delete toDescendantInvalidationSet(this);
151 else
152 delete toSiblingInvalidationSet(this);
153 }
154
144 HashSet<AtomicString>& InvalidationSet::ensureClassSet() 155 HashSet<AtomicString>& InvalidationSet::ensureClassSet()
145 { 156 {
146 if (!m_classes) 157 if (!m_classes)
147 m_classes = adoptPtr(new HashSet<AtomicString>); 158 m_classes = adoptPtr(new HashSet<AtomicString>);
148 return *m_classes; 159 return *m_classes;
149 } 160 }
150 161
151 HashSet<AtomicString>& InvalidationSet::ensureIdSet() 162 HashSet<AtomicString>& InvalidationSet::ensureIdSet()
152 { 163 {
153 if (!m_ids) 164 if (!m_ids)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 { 274 {
264 RefPtr<TracedValue> value = TracedValue::create(); 275 RefPtr<TracedValue> value = TracedValue::create();
265 value->beginArray("InvalidationSet"); 276 value->beginArray("InvalidationSet");
266 toTracedValue(value.get()); 277 toTracedValue(value.get());
267 value->endArray(); 278 value->endArray();
268 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data()); 279 fprintf(stderr, "%s\n", value->asTraceFormat().ascii().data());
269 } 280 }
270 #endif // NDEBUG 281 #endif // NDEBUG
271 282
272 SiblingInvalidationSet::SiblingInvalidationSet() 283 SiblingInvalidationSet::SiblingInvalidationSet()
273 : m_maxDirectAdjacentSelectors(1) 284 : InvalidationSet(InvalidateSiblings)
285 , m_maxDirectAdjacentSelectors(1)
274 , m_descendantInvalidationSet(DescendantInvalidationSet::create()) 286 , m_descendantInvalidationSet(DescendantInvalidationSet::create())
275 { 287 {
276 } 288 }
277 289
278 void SiblingInvalidationSet::combine(const SiblingInvalidationSet& other) 290 void SiblingInvalidationSet::combine(const SiblingInvalidationSet& other)
279 { 291 {
280 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other. m_maxDirectAdjacentSelectors); 292 m_maxDirectAdjacentSelectors = std::max(m_maxDirectAdjacentSelectors, other. m_maxDirectAdjacentSelectors);
281 m_descendantInvalidationSet->combine(other.descendants()); 293 m_descendantInvalidationSet->combine(other.descendants());
282 294
283 InvalidationSet::combine(other); 295 InvalidationSet::combine(other);
284 } 296 }
285 297
286 } // namespace blink 298 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698