| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 CustomElementProcessingStack::instance().enqueue(&callbackQueue); | 82 CustomElementProcessingStack::instance().enqueue(&callbackQueue); |
| 83 return callbackQueue; | 83 return callbackQueue; |
| 84 } | 84 } |
| 85 | 85 |
| 86 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); | 86 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); |
| 87 return callbackQueue; | 87 return callbackQueue; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void CustomElementScheduler::scheduleCallback(RawPtr<CustomElementLifecycleCallb
acks> callbacks, RawPtr<Element> element, CustomElementLifecycleCallbacks::Callb
ackType type) | 90 void CustomElementScheduler::scheduleCallback(RawPtr<CustomElementLifecycleCallb
acks> callbacks, RawPtr<Element> element, CustomElementLifecycleCallbacks::Callb
ackType type) |
| 91 { | 91 { |
| 92 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChangedCallback); | 92 DCHECK(type != CustomElementLifecycleCallbacks::AttributeChangedCallback); |
| 93 | 93 |
| 94 if (!callbacks->hasCallback(type)) | 94 if (!callbacks->hasCallback(type)) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); | 97 CustomElementCallbackQueue& queue = scheduleCallbackQueue(element); |
| 98 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty
pe)); | 98 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty
pe)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void CustomElementScheduler::scheduleAttributeChangedCallback(RawPtr<CustomEleme
ntLifecycleCallbacks> callbacks, RawPtr<Element> element, const AtomicString& na
me, const AtomicString& oldValue, const AtomicString& newValue) | 101 void CustomElementScheduler::scheduleAttributeChangedCallback(RawPtr<CustomEleme
ntLifecycleCallbacks> callbacks, RawPtr<Element> element, const AtomicString& na
me, const AtomicString& oldValue, const AtomicString& newValue) |
| 102 { | 102 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 Document& document = element->document(); | 117 Document& document = element->document(); |
| 118 RawPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe
solutionStep::create(context, element, descriptor); | 118 RawPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe
solutionStep::create(context, element, descriptor); |
| 119 enqueueMicrotaskStep(document, step.release()); | 119 enqueueMicrotaskStep(document, step.release()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp
ortChild* import) | 122 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp
ortChild* import) |
| 123 { | 123 { |
| 124 ASSERT(!import->hasFinishedLoading()); | 124 DCHECK(!import->hasFinishedLoading()); |
| 125 ASSERT(import->parent()); | 125 DCHECK(import->parent()); |
| 126 | 126 |
| 127 // Ownership of the new step is transferred to the parent | 127 // Ownership of the new step is transferred to the parent |
| 128 // processing step, or the base queue. | 128 // processing step, or the base queue. |
| 129 RawPtr<CustomElementMicrotaskImportStep> step = CustomElementMicrotaskImport
Step::create(import); | 129 RawPtr<CustomElementMicrotaskImportStep> step = CustomElementMicrotaskImport
Step::create(import); |
| 130 CustomElementMicrotaskImportStep* rawStep = step.get(); | 130 CustomElementMicrotaskImportStep* rawStep = step.get(); |
| 131 enqueueMicrotaskStep(*(import->parent()->document()), step.release(), import
->isSync()); | 131 enqueueMicrotaskStep(*(import->parent()->document()), step.release(), import
->isSync()); |
| 132 return rawStep; | 132 return rawStep; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void CustomElementScheduler::enqueueMicrotaskStep(Document& document, RawPtr<Cus
tomElementMicrotaskStep> step, bool importIsSync) | 135 void CustomElementScheduler::enqueueMicrotaskStep(Document& document, RawPtr<Cus
tomElementMicrotaskStep> step, bool importIsSync) |
| 136 { | 136 { |
| 137 Document& master = document.importsController() ? *(document.importsControll
er()->master()) : document; | 137 Document& master = document.importsController() ? *(document.importsControll
er()->master()) : document; |
| 138 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st
ep, importIsSync); | 138 master.customElementMicrotaskRunQueue()->enqueue(document.importLoader(), st
ep, importIsSync); |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 void CustomElementScheduler::callbackDispatcherDidFinish() | 142 void CustomElementScheduler::callbackDispatcherDidFinish() |
| 143 { | 143 { |
| 144 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) | 144 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) |
| 145 callbackQueues().clear(); | 145 callbackQueues().clear(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void CustomElementScheduler::microtaskDispatcherDidFinish() | 148 void CustomElementScheduler::microtaskDispatcherDidFinish() |
| 149 { | 149 { |
| 150 ASSERT(!CustomElementProcessingStack::inCallbackDeliveryScope()); | 150 DCHECK(!CustomElementProcessingStack::inCallbackDeliveryScope()); |
| 151 callbackQueues().clear(); | 151 callbackQueues().clear(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |