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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 28 matching lines...) Expand all
39 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" 39 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h"
40 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 40 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
41 #include "core/dom/custom/CustomElementProcessingStack.h" 41 #include "core/dom/custom/CustomElementProcessingStack.h"
42 #include "core/dom/custom/CustomElementRegistrationContext.h" 42 #include "core/dom/custom/CustomElementRegistrationContext.h"
43 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" 43 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.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 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementScheduler)
50
51 // FIXME: Consider moving the element's callback queue to ElementRareData. 49 // FIXME: Consider moving the element's callback queue to ElementRareData.
52 typedef WillBeHeapHashMap<RawPtrWillBeMember<Element>, OwnPtrWillBeMember<Custom ElementCallbackQueue>> ElementCallbackQueueMap; 50 typedef HeapHashMap<Member<Element>, Member<CustomElementCallbackQueue>> Element CallbackQueueMap;
53 51
54 static ElementCallbackQueueMap& callbackQueues() 52 static ElementCallbackQueueMap& callbackQueues()
55 { 53 {
56 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ElementCallbackQueueMap>, map, (a doptPtrWillBeNoop(new ElementCallbackQueueMap()))); 54 DEFINE_STATIC_LOCAL(Persistent<ElementCallbackQueueMap>, map, (new ElementCa llbackQueueMap()));
57 return *map; 55 return *map;
58 } 56 }
59 57
60 static CustomElementCallbackQueue& ensureCallbackQueue(PassRefPtrWillBeRawPtr<El ement> element) 58 static CustomElementCallbackQueue& ensureCallbackQueue(RawPtr<Element> element)
61 { 59 {
62 ElementCallbackQueueMap::ValueType* it = callbackQueues().add(element.get(), nullptr).storedValue; 60 ElementCallbackQueueMap::ValueType* it = callbackQueues().add(element.get(), nullptr).storedValue;
63 if (!it->value) 61 if (!it->value)
64 it->value = CustomElementCallbackQueue::create(element); 62 it->value = CustomElementCallbackQueue::create(element);
65 return *it->value.get(); 63 return *it->value.get();
66 } 64 }
67 65
68 // Finds or creates the callback queue for element. 66 // Finds or creates the callback queue for element.
69 static CustomElementCallbackQueue& scheduleCallbackQueue(PassRefPtrWillBeRawPtr< Element> passElement) 67 static CustomElementCallbackQueue& scheduleCallbackQueue(RawPtr<Element> passEle ment)
70 { 68 {
71 RefPtrWillBeRawPtr<Element> element(passElement); 69 RawPtr<Element> element(passElement);
72 70
73 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element); 71 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element);
74 if (callbackQueue.inCreatedCallback()) { 72 if (callbackQueue.inCreatedCallback()) {
75 // Don't move it. Authors use the createdCallback like a 73 // Don't move it. Authors use the createdCallback like a
76 // constructor. By not moving it, the createdCallback 74 // constructor. By not moving it, the createdCallback
77 // completes before any other callbacks are entered for this 75 // completes before any other callbacks are entered for this
78 // element. 76 // element.
79 return callbackQueue; 77 return callbackQueue;
80 } 78 }
81 79
82 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { 80 if (CustomElementProcessingStack::inCallbackDeliveryScope()) {
83 // The processing stack is active. 81 // The processing stack is active.
84 CustomElementProcessingStack::instance().enqueue(&callbackQueue); 82 CustomElementProcessingStack::instance().enqueue(&callbackQueue);
85 return callbackQueue; 83 return callbackQueue;
86 } 84 }
87 85
88 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); 86 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue);
89 return callbackQueue; 87 return callbackQueue;
90 } 88 }
91 89
92 void CustomElementScheduler::scheduleCallback(PassRefPtrWillBeRawPtr<CustomEleme ntLifecycleCallbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, Custom ElementLifecycleCallbacks::CallbackType type) 90 void CustomElementScheduler::scheduleCallback(RawPtr<CustomElementLifecycleCallb acks> callbacks, RawPtr<Element> element, CustomElementLifecycleCallbacks::Callb ackType type)
93 { 91 {
94 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChangedCallback); 92 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChangedCallback);
95 93
96 if (!callbacks->hasCallback(type)) 94 if (!callbacks->hasCallback(type))
97 return; 95 return;
98 96
99 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); 97 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element);
100 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe)); 98 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe));
101 } 99 }
102 100
103 void CustomElementScheduler::scheduleAttributeChangedCallback(PassRefPtrWillBeRa wPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, const AtomicString& name, const AtomicString& oldValue, const AtomicSt ring& newValue) 101 void CustomElementScheduler::scheduleAttributeChangedCallback(RawPtr<CustomEleme ntLifecycleCallbacks> callbacks, RawPtr<Element> element, const AtomicString& na me, const AtomicString& oldValue, const AtomicString& newValue)
104 { 102 {
105 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange dCallback)) 103 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange dCallback))
106 return; 104 return;
107 105
108 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); 106 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element);
109 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue)); 107 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue));
110 } 108 }
111 109
112 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr< CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> eleme nt, const CustomElementDescriptor& descriptor) 110 void CustomElementScheduler::resolveOrScheduleResolution(RawPtr<CustomElementReg istrationContext> context, RawPtr<Element> element, const CustomElementDescripto r& descriptor)
113 { 111 {
114 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { 112 if (CustomElementProcessingStack::inCallbackDeliveryScope()) {
115 context->resolve(element.get(), descriptor); 113 context->resolve(element.get(), descriptor);
116 return; 114 return;
117 } 115 }
118 116
119 Document& document = element->document(); 117 Document& document = element->document();
120 OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElemen tMicrotaskResolutionStep::create(context, element, descriptor); 118 RawPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe solutionStep::create(context, element, descriptor);
121 enqueueMicrotaskStep(document, step.release()); 119 enqueueMicrotaskStep(document, step.release());
122 } 120 }
123 121
124 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp ortChild* import) 122 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp ortChild* import)
125 { 123 {
126 ASSERT(!import->hasFinishedLoading()); 124 ASSERT(!import->hasFinishedLoading());
127 ASSERT(import->parent()); 125 ASSERT(import->parent());
128 126
129 // Ownership of the new step is transferred to the parent 127 // Ownership of the new step is transferred to the parent
130 // processing step, or the base queue. 128 // processing step, or the base queue.
131 OwnPtrWillBeRawPtr<CustomElementMicrotaskImportStep> step = CustomElementMic rotaskImportStep::create(import); 129 RawPtr<CustomElementMicrotaskImportStep> step = CustomElementMicrotaskImport Step::create(import);
132 CustomElementMicrotaskImportStep* rawStep = step.get(); 130 CustomElementMicrotaskImportStep* rawStep = step.get();
133 enqueueMicrotaskStep(*(import->parent()->document()), step.release(), import ->isSync()); 131 enqueueMicrotaskStep(*(import->parent()->document()), step.release(), import ->isSync());
134 return rawStep; 132 return rawStep;
135 } 133 }
136 134
137 void CustomElementScheduler::enqueueMicrotaskStep(Document& document, PassOwnPtr WillBeRawPtr<CustomElementMicrotaskStep> step, bool importIsSync) 135 void CustomElementScheduler::enqueueMicrotaskStep(Document& document, RawPtr<Cus tomElementMicrotaskStep> step, bool importIsSync)
138 { 136 {
139 Document& master = document.importsController() ? *(document.importsControll er()->master()) : document; 137 Document& master = document.importsController() ? *(document.importsControll er()->master()) : document;
140 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st ep, importIsSync); 138 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st ep, importIsSync);
141 } 139 }
142 140
143 141
144 void CustomElementScheduler::callbackDispatcherDidFinish() 142 void CustomElementScheduler::callbackDispatcherDidFinish()
145 { 143 {
146 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) 144 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty())
147 callbackQueues().clear(); 145 callbackQueues().clear();
148 } 146 }
149 147
150 void CustomElementScheduler::microtaskDispatcherDidFinish() 148 void CustomElementScheduler::microtaskDispatcherDidFinish()
151 { 149 {
152 ASSERT(!CustomElementProcessingStack::inCallbackDeliveryScope()); 150 ASSERT(!CustomElementProcessingStack::inCallbackDeliveryScope());
153 callbackQueues().clear(); 151 callbackQueues().clear();
154 } 152 }
155 153
156 } // namespace blink 154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698