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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/V0CustomElementScheduler.cpp

Issue 1914923002: Rename all existing custom element classes as V0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CustomElementV0 -> V0CustomElement Created 4 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/dom/custom/CustomElementScheduler.h" 31 #include "core/dom/custom/V0CustomElementScheduler.h"
32 32
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 #include "core/dom/custom/CustomElementCallbackInvocation.h" 35 #include "core/dom/custom/V0CustomElementCallbackInvocation.h"
36 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" 36 #include "core/dom/custom/V0CustomElementLifecycleCallbacks.h"
37 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" 37 #include "core/dom/custom/V0CustomElementMicrotaskDispatcher.h"
38 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 38 #include "core/dom/custom/V0CustomElementMicrotaskImportStep.h"
39 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" 39 #include "core/dom/custom/V0CustomElementMicrotaskResolutionStep.h"
40 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 40 #include "core/dom/custom/V0CustomElementMicrotaskRunQueue.h"
41 #include "core/dom/custom/CustomElementProcessingStack.h" 41 #include "core/dom/custom/V0CustomElementProcessingStack.h"
42 #include "core/dom/custom/CustomElementRegistrationContext.h" 42 #include "core/dom/custom/V0CustomElementRegistrationContext.h"
43 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" 43 #include "core/dom/custom/V0CustomElementSyncMicrotaskQueue.h"
44 #include "core/html/imports/HTMLImportChild.h" 44 #include "core/html/imports/HTMLImportChild.h"
45 #include "core/html/imports/HTMLImportsController.h" 45 #include "core/html/imports/HTMLImportsController.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 // FIXME: Consider moving the element's callback queue to ElementRareData. 49 // FIXME: Consider moving the element's callback queue to ElementRareData.
50 typedef HeapHashMap<Member<Element>, Member<CustomElementCallbackQueue>> Element CallbackQueueMap; 50 typedef HeapHashMap<Member<Element>, Member<V0CustomElementCallbackQueue>> Eleme ntCallbackQueueMap;
51 51
52 static ElementCallbackQueueMap& callbackQueues() 52 static ElementCallbackQueueMap& callbackQueues()
53 { 53 {
54 DEFINE_STATIC_LOCAL(ElementCallbackQueueMap, map, (new ElementCallbackQueueM ap)); 54 DEFINE_STATIC_LOCAL(ElementCallbackQueueMap, map, (new ElementCallbackQueueM ap));
55 return map; 55 return map;
56 } 56 }
57 57
58 static CustomElementCallbackQueue& ensureCallbackQueue(Element* element) 58 static V0CustomElementCallbackQueue& ensureCallbackQueue(Element* element)
59 { 59 {
60 ElementCallbackQueueMap::ValueType* it = callbackQueues().add(element, nullp tr).storedValue; 60 ElementCallbackQueueMap::ValueType* it = callbackQueues().add(element, nullp tr).storedValue;
61 if (!it->value) 61 if (!it->value)
62 it->value = CustomElementCallbackQueue::create(element); 62 it->value = V0CustomElementCallbackQueue::create(element);
63 return *it->value.get(); 63 return *it->value.get();
64 } 64 }
65 65
66 // Finds or creates the callback queue for element. 66 // Finds or creates the callback queue for element.
67 static CustomElementCallbackQueue& scheduleCallbackQueue(Element* element) 67 static V0CustomElementCallbackQueue& scheduleCallbackQueue(Element* element)
68 { 68 {
69 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element); 69 V0CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element);
70 if (callbackQueue.inCreatedCallback()) { 70 if (callbackQueue.inCreatedCallback()) {
71 // Don't move it. Authors use the createdCallback like a 71 // Don't move it. Authors use the createdCallback like a
72 // constructor. By not moving it, the createdCallback 72 // constructor. By not moving it, the createdCallback
73 // completes before any other callbacks are entered for this 73 // completes before any other callbacks are entered for this
74 // element. 74 // element.
75 return callbackQueue; 75 return callbackQueue;
76 } 76 }
77 77
78 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { 78 if (V0CustomElementProcessingStack::inCallbackDeliveryScope()) {
79 // The processing stack is active. 79 // The processing stack is active.
80 CustomElementProcessingStack::instance().enqueue(&callbackQueue); 80 V0CustomElementProcessingStack::instance().enqueue(&callbackQueue);
81 return callbackQueue; 81 return callbackQueue;
82 } 82 }
83 83
84 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); 84 V0CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue);
85 return callbackQueue; 85 return callbackQueue;
86 } 86 }
87 87
88 void CustomElementScheduler::scheduleCallback(CustomElementLifecycleCallbacks* c allbacks, Element* element, CustomElementLifecycleCallbacks::CallbackType type) 88 void V0CustomElementScheduler::scheduleCallback(V0CustomElementLifecycleCallback s* callbacks, Element* element, V0CustomElementLifecycleCallbacks::CallbackType type)
89 { 89 {
90 DCHECK(type != CustomElementLifecycleCallbacks::AttributeChangedCallback); 90 DCHECK(type != V0CustomElementLifecycleCallbacks::AttributeChangedCallback);
91 91
92 if (!callbacks->hasCallback(type)) 92 if (!callbacks->hasCallback(type))
93 return; 93 return;
94 94
95 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); 95 V0CustomElementCallbackQueue& queue = scheduleCallbackQueue(element);
96 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe)); 96 queue.append(V0CustomElementCallbackInvocation::createInvocation(callbacks, type));
97 } 97 }
98 98
99 void CustomElementScheduler::scheduleAttributeChangedCallback(CustomElementLifec ycleCallbacks* callbacks, Element* element, const AtomicString& name, const Atom icString& oldValue, const AtomicString& newValue) 99 void V0CustomElementScheduler::scheduleAttributeChangedCallback(V0CustomElementL ifecycleCallbacks* callbacks, Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
100 { 100 {
101 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange dCallback)) 101 if (!callbacks->hasCallback(V0CustomElementLifecycleCallbacks::AttributeChan gedCallback))
102 return; 102 return;
103 103
104 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); 104 V0CustomElementCallbackQueue& queue = scheduleCallbackQueue(element);
105 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue)); 105 queue.append(V0CustomElementCallbackInvocation::createAttributeChangedInvoca tion(callbacks, name, oldValue, newValue));
106 } 106 }
107 107
108 void CustomElementScheduler::resolveOrScheduleResolution(CustomElementRegistrati onContext* context, Element* element, const CustomElementDescriptor& descriptor) 108 void V0CustomElementScheduler::resolveOrScheduleResolution(V0CustomElementRegist rationContext* context, Element* element, const V0CustomElementDescriptor& descr iptor)
109 { 109 {
110 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { 110 if (V0CustomElementProcessingStack::inCallbackDeliveryScope()) {
111 context->resolve(element, descriptor); 111 context->resolve(element, descriptor);
112 return; 112 return;
113 } 113 }
114 114
115 Document& document = element->document(); 115 Document& document = element->document();
116 CustomElementMicrotaskResolutionStep* step = CustomElementMicrotaskResolutio nStep::create(context, element, descriptor); 116 V0CustomElementMicrotaskResolutionStep* step = V0CustomElementMicrotaskResol utionStep::create(context, element, descriptor);
117 enqueueMicrotaskStep(document, step); 117 enqueueMicrotaskStep(document, step);
118 } 118 }
119 119
120 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp ortChild* import) 120 V0CustomElementMicrotaskImportStep* V0CustomElementScheduler::scheduleImport(HTM LImportChild* import)
121 { 121 {
122 DCHECK(!import->hasFinishedLoading()); 122 DCHECK(!import->hasFinishedLoading());
123 DCHECK(import->parent()); 123 DCHECK(import->parent());
124 124
125 // Ownership of the new step is transferred to the parent 125 // Ownership of the new step is transferred to the parent
126 // processing step, or the base queue. 126 // processing step, or the base queue.
127 CustomElementMicrotaskImportStep* step = CustomElementMicrotaskImportStep::c reate(import); 127 V0CustomElementMicrotaskImportStep* step = V0CustomElementMicrotaskImportSte p::create(import);
128 CustomElementMicrotaskImportStep* rawStep = step; 128 V0CustomElementMicrotaskImportStep* rawStep = step;
129 enqueueMicrotaskStep(*(import->parent()->document()), step, import->isSync() ); 129 enqueueMicrotaskStep(*(import->parent()->document()), step, import->isSync() );
130 return rawStep; 130 return rawStep;
131 } 131 }
132 132
133 void CustomElementScheduler::enqueueMicrotaskStep(Document& document, CustomElem entMicrotaskStep* step, bool importIsSync) 133 void V0CustomElementScheduler::enqueueMicrotaskStep(Document& document, V0Custom ElementMicrotaskStep* step, bool importIsSync)
134 { 134 {
135 Document& master = document.importsController() ? *(document.importsControll er()->master()) : document; 135 Document& master = document.importsController() ? *(document.importsControll er()->master()) : document;
136 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st ep, importIsSync); 136 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st ep, importIsSync);
137 } 137 }
138 138
139 139
140 void CustomElementScheduler::callbackDispatcherDidFinish() 140 void V0CustomElementScheduler::callbackDispatcherDidFinish()
141 { 141 {
142 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) 142 if (V0CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty())
143 callbackQueues().clear(); 143 callbackQueues().clear();
144 } 144 }
145 145
146 void CustomElementScheduler::microtaskDispatcherDidFinish() 146 void V0CustomElementScheduler::microtaskDispatcherDidFinish()
147 { 147 {
148 DCHECK(!CustomElementProcessingStack::inCallbackDeliveryScope()); 148 DCHECK(!V0CustomElementProcessingStack::inCallbackDeliveryScope());
149 callbackQueues().clear(); 149 callbackQueues().clear();
150 } 150 }
151 151
152 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698