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

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

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

Powered by Google App Engine
This is Rietveld 408576698