| 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 23 matching lines...) Expand all Loading... |
| 34 #include "sky/engine/core/dom/custom/CustomElementCallbackQueue.h" | 34 #include "sky/engine/core/dom/custom/CustomElementCallbackQueue.h" |
| 35 #include "sky/engine/core/dom/custom/CustomElementLifecycleCallbacks.h" | 35 #include "sky/engine/core/dom/custom/CustomElementLifecycleCallbacks.h" |
| 36 #include "sky/engine/platform/heap/Handle.h" | 36 #include "sky/engine/platform/heap/Handle.h" |
| 37 #include "sky/engine/wtf/HashMap.h" | 37 #include "sky/engine/wtf/HashMap.h" |
| 38 #include "sky/engine/wtf/OwnPtr.h" | 38 #include "sky/engine/wtf/OwnPtr.h" |
| 39 #include "sky/engine/wtf/PassRefPtr.h" | 39 #include "sky/engine/wtf/PassRefPtr.h" |
| 40 #include "sky/engine/wtf/text/AtomicString.h" | 40 #include "sky/engine/wtf/text/AtomicString.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class CustomElementDescriptor; | |
| 45 class CustomElementMicrotaskImportStep; | 44 class CustomElementMicrotaskImportStep; |
| 46 class CustomElementMicrotaskStep; | 45 class CustomElementMicrotaskStep; |
| 47 class CustomElementRegistrationContext; | 46 class CustomElementRegistrationContext; |
| 48 class Document; | 47 class Document; |
| 49 class Element; | 48 class Element; |
| 50 class HTMLImportChild; | 49 class HTMLImportChild; |
| 51 | 50 |
| 52 class CustomElementScheduler final { | 51 class CustomElementScheduler final { |
| 53 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementScheduler); | 52 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementScheduler); |
| 54 public: | 53 public: |
| 55 | 54 |
| 56 static void scheduleCallback(PassRefPtr<CustomElementLifecycleCallbacks>, Pa
ssRefPtr<Element>, CustomElementLifecycleCallbacks::CallbackType); | 55 static void scheduleCallback(PassRefPtr<CustomElementLifecycleCallbacks>, Pa
ssRefPtr<Element>, CustomElementLifecycleCallbacks::CallbackType); |
| 57 static void scheduleAttributeChangedCallback(PassRefPtr<CustomElementLifecyc
leCallbacks>, PassRefPtr<Element>, const AtomicString& name, const AtomicString&
oldValue, const AtomicString& newValue); | 56 static void scheduleAttributeChangedCallback(PassRefPtr<CustomElementLifecyc
leCallbacks>, PassRefPtr<Element>, const AtomicString& name, const AtomicString&
oldValue, const AtomicString& newValue); |
| 58 | 57 |
| 59 static void resolveOrScheduleResolution(PassRefPtr<CustomElementRegistration
Context>, PassRefPtr<Element>, const CustomElementDescriptor&); | 58 static void resolveOrScheduleResolution(PassRefPtr<CustomElementRegistration
Context>, PassRefPtr<Element>); |
| 60 static CustomElementMicrotaskImportStep* scheduleImport(HTMLImportChild*); | 59 static CustomElementMicrotaskImportStep* scheduleImport(HTMLImportChild*); |
| 61 | 60 |
| 62 static void microtaskDispatcherDidFinish(); | 61 static void microtaskDispatcherDidFinish(); |
| 63 static void callbackDispatcherDidFinish(); | 62 static void callbackDispatcherDidFinish(); |
| 64 | 63 |
| 65 private: | 64 private: |
| 66 CustomElementScheduler() { } | 65 CustomElementScheduler() { } |
| 67 | 66 |
| 68 static CustomElementScheduler& instance(); | 67 static CustomElementScheduler& instance(); |
| 69 static void enqueueMicrotaskStep(Document&, PassOwnPtr<CustomElementMicrotas
kStep>, bool importIsSync = true); | 68 static void enqueueMicrotaskStep(Document&, PassOwnPtr<CustomElementMicrotas
kStep>, bool importIsSync = true); |
| 70 | 69 |
| 71 CustomElementCallbackQueue& ensureCallbackQueue(PassRefPtr<Element>); | 70 CustomElementCallbackQueue& ensureCallbackQueue(PassRefPtr<Element>); |
| 72 CustomElementCallbackQueue& schedule(PassRefPtr<Element>); | 71 CustomElementCallbackQueue& schedule(PassRefPtr<Element>); |
| 73 | 72 |
| 74 // FIXME: Consider moving the element's callback queue to | 73 // FIXME: Consider moving the element's callback queue to |
| 75 // ElementRareData. Then the scheduler can become completely | 74 // ElementRareData. Then the scheduler can become completely |
| 76 // static. | 75 // static. |
| 77 void clearElementCallbackQueueMap(); | 76 void clearElementCallbackQueueMap(); |
| 78 | 77 |
| 79 // The element -> callback queue map is populated by the scheduler | 78 // The element -> callback queue map is populated by the scheduler |
| 80 // and owns the lifetimes of the CustomElementCallbackQueues. | 79 // and owns the lifetimes of the CustomElementCallbackQueues. |
| 81 typedef HashMap<RawPtr<Element>, OwnPtr<CustomElementCallbackQueue> > Elemen
tCallbackQueueMap; | 80 typedef HashMap<RawPtr<Element>, OwnPtr<CustomElementCallbackQueue> > Elemen
tCallbackQueueMap; |
| 82 ElementCallbackQueueMap m_elementCallbackQueueMap; | 81 ElementCallbackQueueMap m_elementCallbackQueueMap; |
| 83 }; | 82 }; |
| 84 | 83 |
| 85 } | 84 } |
| 86 | 85 |
| 87 #endif // SKY_ENGINE_CORE_DOM_CUSTOM_CUSTOMELEMENTSCHEDULER_H_ | 86 #endif // SKY_ENGINE_CORE_DOM_CUSTOM_CUSTOMELEMENTSCHEDULER_H_ |
| OLD | NEW |