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

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

Issue 220013003: Simplify CustomElementScheduler by passing the enum for callback type directly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/custom/CustomElementScheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CustomElementMicrotaskDispatcher.h" 39 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
40 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 40 #include "core/dom/custom/CustomElementMicrotaskImportStep.h"
41 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" 41 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h"
42 #include "core/dom/custom/CustomElementRegistrationContext.h" 42 #include "core/dom/custom/CustomElementRegistrationContext.h"
43 #include "core/html/imports/HTMLImportChild.h" 43 #include "core/html/imports/HTMLImportChild.h"
44 44
45 namespace WebCore { 45 namespace WebCore {
46 46
47 class HTMLImport; 47 class HTMLImport;
48 48
49 void CustomElementScheduler::scheduleCreatedCallback(PassRefPtr<CustomElementLif ecycleCallbacks> callbacks, PassRefPtr<Element> element) 49 void CustomElementScheduler::scheduleCallback(PassRefPtr<CustomElementLifecycleC allbacks> callbacks, PassRefPtr<Element> element, CustomElementLifecycleCallback s::CallbackType type)
50 { 50 {
51 ASSERT(type != CustomElementLifecycleCallbacks::AttributeChanged);
52
53 if (!callbacks->hasCallback(type))
54 return;
55
51 CustomElementCallbackQueue& queue = instance().schedule(element); 56 CustomElementCallbackQueue& queue = instance().schedule(element);
52 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, Cu stomElementLifecycleCallbacks::Created)); 57 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, ty pe));
53 } 58 }
54 59
55 void CustomElementScheduler::scheduleAttributeChangedCallback(PassRefPtr<CustomE lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const AtomicSt ring& name, const AtomicString& oldValue, const AtomicString& newValue) 60 void CustomElementScheduler::scheduleAttributeChangedCallback(PassRefPtr<CustomE lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const AtomicSt ring& name, const AtomicString& oldValue, const AtomicString& newValue)
56 { 61 {
57 if (!callbacks->hasAttributeChangedCallback()) 62 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange d))
58 return; 63 return;
59 64
60 CustomElementCallbackQueue& queue = instance().schedule(element); 65 CustomElementCallbackQueue& queue = instance().schedule(element);
61 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue)); 66 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati on(callbacks, name, oldValue, newValue));
62 } 67 }
63 68
64 void CustomElementScheduler::scheduleAttachedCallback(PassRefPtr<CustomElementLi fecycleCallbacks> callbacks, PassRefPtr<Element> element)
65 {
66 if (!callbacks->hasAttachedCallback())
67 return;
68
69 CustomElementCallbackQueue& queue = instance().schedule(element);
70 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, Cu stomElementLifecycleCallbacks::Attached));
71 }
72
73 void CustomElementScheduler::scheduleDetachedCallback(PassRefPtr<CustomElementLi fecycleCallbacks> callbacks, PassRefPtr<Element> element)
74 {
75 if (!callbacks->hasDetachedCallback())
76 return;
77
78 CustomElementCallbackQueue& queue = instance().schedule(element);
79 queue.append(CustomElementCallbackInvocation::createInvocation(callbacks, Cu stomElementLifecycleCallbacks::Detached));
80 }
81
82 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtr<CustomElemen tRegistrationContext> context, PassRefPtr<Element> element, const CustomElementD escriptor& descriptor) 69 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtr<CustomElemen tRegistrationContext> context, PassRefPtr<Element> element, const CustomElementD escriptor& descriptor)
83 { 70 {
84 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { 71 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) {
85 context->resolve(element.get(), descriptor); 72 context->resolve(element.get(), descriptor);
86 return; 73 return;
87 } 74 }
88 75
89 HTMLImport* import = element->document().import(); 76 HTMLImport* import = element->document().import();
90 OwnPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe solutionStep::create(context, element, descriptor); 77 OwnPtr<CustomElementMicrotaskResolutionStep> step = CustomElementMicrotaskRe solutionStep::create(context, element, descriptor);
91 CustomElementMicrotaskDispatcher::instance().enqueue(import, step.release()) ; 78 CustomElementMicrotaskDispatcher::instance().enqueue(import, step.release()) ;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // The processing stack is active. 143 // The processing stack is active.
157 CustomElementCallbackDispatcher::instance().enqueue(&callbackQueue); 144 CustomElementCallbackDispatcher::instance().enqueue(&callbackQueue);
158 return callbackQueue; 145 return callbackQueue;
159 } 146 }
160 147
161 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); 148 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue);
162 return callbackQueue; 149 return callbackQueue;
163 } 150 }
164 151
165 } // namespace WebCore 152 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/custom/CustomElementScheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698