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

Side by Side Diff: Source/core/dom/custom/CustomElementScheduler.cpp

Issue 296703009: Oilpan: move custom element objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Round of improvements Created 6 years, 7 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 29 matching lines...) Expand all
40 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 40 #include "core/dom/custom/CustomElementMicrotaskImportStep.h"
41 #include "core/dom/custom/CustomElementMicrotaskQueue.h" 41 #include "core/dom/custom/CustomElementMicrotaskQueue.h"
42 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" 42 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h"
43 #include "core/dom/custom/CustomElementRegistrationContext.h" 43 #include "core/dom/custom/CustomElementRegistrationContext.h"
44 #include "core/html/imports/HTMLImportChild.h" 44 #include "core/html/imports/HTMLImportChild.h"
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 class HTMLImport; 48 class HTMLImport;
49 49
50 void CustomElementScheduler::scheduleCallback(PassRefPtr<CustomElementLifecycleC allbacks> callbacks, PassRefPtr<Element> element, CustomElementLifecycleCallback s::CallbackType type) 50 void CustomElementScheduler::scheduleCallback(PassRefPtr<CustomElementLifecycleC allbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, CustomElementLifec ycleCallbacks::CallbackType type)
51 { 51 {
52 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChanged); 52 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChanged);
53 53
54 if (!callbacks->hasCallback(type)) 54 if (!callbacks->hasCallback(type))
55 return; 55 return;
56 56
57 CustomElementCallbackQueue& queue = instance().schedule(element); 57 CustomElementCallbackQueue& queue = instance().schedule(element);
58 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe)); 58 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe));
59 } 59 }
60 60
61 void CustomElementScheduler::scheduleAttributeChangedCallback(PassRefPtr<CustomE lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const AtomicSt ring& name, const AtomicString& oldValue, const AtomicString& newValue) 61 void CustomElementScheduler::scheduleAttributeChangedCallback(PassRefPtr<CustomE lementLifecycleCallbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, co nst AtomicString& name, const AtomicString& oldValue, const AtomicString& newVal ue)
62 { 62 {
63 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange d)) 63 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange d))
64 return; 64 return;
65 65
66 CustomElementCallbackQueue& queue = instance().schedule(element); 66 CustomElementCallbackQueue& queue = instance().schedule(element);
67 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue)); 67 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue));
68 } 68 }
69 69
70 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtr<CustomElemen tRegistrationContext> context, PassRefPtr<Element> element, const CustomElementD escriptor& descriptor) 70 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr< CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> eleme nt, const CustomElementDescriptor& descriptor)
71 { 71 {
72 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { 72 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) {
73 context->resolve(element.get(), descriptor); 73 context->resolve(element.get(), descriptor);
74 return; 74 return;
75 } 75 }
76 76
77 HTMLImportLoader* loader = element->document().importLoader(); 77 HTMLImportLoader* loader = element->document().importLoader();
78 OwnPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe solutionStep::create(context, element, descriptor); 78 OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElemen tMicrotaskResolutionStep::create(context, element, descriptor);
79 CustomElementMicrotaskDispatcher::instance().enqueue(loader, step.release()) ; 79 CustomElementMicrotaskDispatcher::instance().enqueue(loader, step.release()) ;
80 } 80 }
81 81
82 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp ortChild* import) 82 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp ortChild* import)
83 { 83 {
84 ASSERT(!import->isDone()); 84 ASSERT(!import->isDone());
85 ASSERT(import->parent()); 85 ASSERT(import->parent());
86 86
87 OwnPtr<CustomElementMicrotaskImportStep> step = CustomElementMicrotaskImport Step::create(import); 87 OwnPtrWillBeRawPtr<CustomElementMicrotaskImportStep> step = CustomElementMic rotaskImportStep::create(import);
88 CustomElementMicrotaskImportStep* rawStep = step.get(); 88 CustomElementMicrotaskImportStep* rawStep = step.get();
89 89
90 // Ownership of the new step is transferred to the parent 90 // Ownership of the new step is transferred to the parent
91 // processing step, or the base queue. 91 // processing step, or the base queue.
92 CustomElementMicrotaskDispatcher::instance().enqueue(import->parent()->loade r(), step.release()); 92 CustomElementMicrotaskDispatcher::instance().enqueue(import->parent()->loade r(), step.release());
93 93
94 return rawStep; 94 return rawStep;
95 } 95 }
96 96
97 CustomElementScheduler& CustomElementScheduler::instance() 97 CustomElementScheduler& CustomElementScheduler::instance()
98 { 98 {
99 #if ENABLE(OILPAN)
100 DEFINE_STATIC_LOCAL(Persistent<CustomElementScheduler>, instance, (new Custo mElementScheduler()));
101 return *instance;
102 #else
99 DEFINE_STATIC_LOCAL(CustomElementScheduler, instance, ()); 103 DEFINE_STATIC_LOCAL(CustomElementScheduler, instance, ());
100 return instance; 104 return instance;
105 #endif
haraken 2014/05/27 01:08:45 Ditto. I'd prefer DEFINE_STATIC_LOCAL(OwnPtrWillBe
101 } 106 }
102 107
103 CustomElementCallbackQueue& CustomElementScheduler::ensureCallbackQueue(PassRefP tr<Element> element) 108 CustomElementCallbackQueue& CustomElementScheduler::ensureCallbackQueue(PassRefP trWillBeRawPtr<Element> element)
104 { 109 {
105 ElementCallbackQueueMap::ValueType* it = m_elementCallbackQueueMap.add(eleme nt.get(), nullptr).storedValue; 110 ElementCallbackQueueMap::ValueType* it = m_elementCallbackQueueMap.add(eleme nt.get(), nullptr).storedValue;
106 if (!it->value) 111 if (!it->value)
107 it->value = CustomElementCallbackQueue::create(element); 112 it->value = CustomElementCallbackQueue::create(element);
108 return *it->value.get(); 113 return *it->value.get();
109 } 114 }
110 115
111 void CustomElementScheduler::callbackDispatcherDidFinish() 116 void CustomElementScheduler::callbackDispatcherDidFinish()
112 { 117 {
113 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) 118 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty())
114 instance().clearElementCallbackQueueMap(); 119 instance().clearElementCallbackQueueMap();
115 } 120 }
116 121
117 void CustomElementScheduler::microtaskDispatcherDidFinish() 122 void CustomElementScheduler::microtaskDispatcherDidFinish()
118 { 123 {
119 ASSERT(!CustomElementCallbackDispatcher::inCallbackDeliveryScope()); 124 ASSERT(!CustomElementCallbackDispatcher::inCallbackDeliveryScope());
120 instance().clearElementCallbackQueueMap(); 125 instance().clearElementCallbackQueueMap();
121 } 126 }
122 127
123 void CustomElementScheduler::clearElementCallbackQueueMap() 128 void CustomElementScheduler::clearElementCallbackQueueMap()
124 { 129 {
125 ElementCallbackQueueMap emptyMap; 130 ElementCallbackQueueMap emptyMap;
126 m_elementCallbackQueueMap.swap(emptyMap); 131 m_elementCallbackQueueMap.swap(emptyMap);
127 } 132 }
128 133
129 // Finds or creates the callback queue for element. 134 // Finds or creates the callback queue for element.
130 CustomElementCallbackQueue& CustomElementScheduler::schedule(PassRefPtr<Element> passElement) 135 CustomElementCallbackQueue& CustomElementScheduler::schedule(PassRefPtrWillBeRaw Ptr<Element> passElement)
131 { 136 {
132 RefPtr<Element> element(passElement); 137 RefPtrWillBeRawPtr<Element> element(passElement);
133 138
134 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element); 139 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element);
135 if (callbackQueue.inCreatedCallback()) { 140 if (callbackQueue.inCreatedCallback()) {
136 // Don't move it. Authors use the createdCallback like a 141 // Don't move it. Authors use the createdCallback like a
137 // constructor. By not moving it, the createdCallback 142 // constructor. By not moving it, the createdCallback
138 // completes before any other callbacks are entered for this 143 // completes before any other callbacks are entered for this
139 // element. 144 // element.
140 return callbackQueue; 145 return callbackQueue;
141 } 146 }
142 147
143 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { 148 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) {
144 // The processing stack is active. 149 // The processing stack is active.
145 CustomElementCallbackDispatcher::instance().enqueue(&callbackQueue); 150 CustomElementCallbackDispatcher::instance().enqueue(&callbackQueue);
146 return callbackQueue; 151 return callbackQueue;
147 } 152 }
148 153
149 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); 154 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue);
150 return callbackQueue; 155 return callbackQueue;
151 } 156 }
152 157
158 void CustomElementScheduler::trace(Visitor* visitor)
159 {
160 visitor->trace(m_elementCallbackQueueMap);
161 }
162
153 } // namespace WebCore 163 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698