OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class Document; | 39 class Document; |
40 class Event; | 40 class Event; |
41 class EventTarget; | 41 class EventTarget; |
42 class FrameRequestCallback; | 42 class FrameRequestCallback; |
43 class MediaQueryListListener; | 43 class MediaQueryListListener; |
44 | 44 |
45 class CORE_EXPORT ScriptedAnimationController | 45 class CORE_EXPORT ScriptedAnimationController |
46 : public GarbageCollected<ScriptedAnimationController> { | 46 : public GarbageCollectedFinalized<ScriptedAnimationController> { |
47 public: | 47 public: |
48 static ScriptedAnimationController* create(Document* document) { | 48 static ScriptedAnimationController* create(Document* document) { |
49 return new ScriptedAnimationController(document); | 49 return new ScriptedAnimationController(document); |
50 } | 50 } |
51 | 51 |
52 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
53 void clearDocumentPointer() { m_document = nullptr; } | 53 void clearDocumentPointer() { m_document = nullptr; } |
54 | 54 |
| 55 // Animation frame callbacks are used for requestAnimationFrame(). |
55 typedef int CallbackId; | 56 typedef int CallbackId; |
| 57 CallbackId registerCallback(FrameRequestCallback*); |
| 58 void cancelCallback(CallbackId); |
56 | 59 |
57 int registerCallback(FrameRequestCallback*); | 60 // Animation frame events are used for resize events, scroll events, etc. |
58 void cancelCallback(CallbackId); | |
59 void serviceScriptedAnimations(double monotonicTimeNow); | |
60 | |
61 void enqueueEvent(Event*); | 61 void enqueueEvent(Event*); |
62 void enqueuePerFrameEvent(Event*); | 62 void enqueuePerFrameEvent(Event*); |
| 63 |
| 64 // Animation frame tasks are used for Fullscreen. |
| 65 void enqueueTask(std::unique_ptr<WTF::Closure>); |
| 66 |
| 67 // Used for the MediaQueryList change event. |
63 void enqueueMediaQueryChangeListeners( | 68 void enqueueMediaQueryChangeListeners( |
64 HeapVector<Member<MediaQueryListListener>>&); | 69 HeapVector<Member<MediaQueryListListener>>&); |
65 | 70 |
| 71 // Invokes callbacks, dispatches events, etc. The order is defined by HTML: |
| 72 // https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processin
g-model |
| 73 void serviceScriptedAnimations(double monotonicTimeNow); |
| 74 |
66 void suspend(); | 75 void suspend(); |
67 void resume(); | 76 void resume(); |
68 | 77 |
69 void dispatchEventsAndCallbacksForPrinting(); | 78 void dispatchEventsAndCallbacksForPrinting(); |
70 | 79 |
71 private: | 80 private: |
72 explicit ScriptedAnimationController(Document*); | 81 explicit ScriptedAnimationController(Document*); |
73 | 82 |
74 void scheduleAnimationIfNeeded(); | 83 void scheduleAnimationIfNeeded(); |
75 | 84 |
| 85 void runTasks(); |
76 void dispatchEvents( | 86 void dispatchEvents( |
77 const AtomicString& eventInterfaceFilter = AtomicString()); | 87 const AtomicString& eventInterfaceFilter = AtomicString()); |
78 void executeCallbacks(double monotonicTimeNow); | 88 void executeCallbacks(double monotonicTimeNow); |
79 void callMediaQueryListListeners(); | 89 void callMediaQueryListListeners(); |
80 | 90 |
81 bool hasScheduledItems() const; | 91 bool hasScheduledItems() const; |
82 | 92 |
83 Member<Document> m_document; | 93 Member<Document> m_document; |
84 FrameRequestCallbackCollection m_callbackCollection; | 94 FrameRequestCallbackCollection m_callbackCollection; |
85 int m_suspendCount; | 95 int m_suspendCount; |
| 96 Vector<std::unique_ptr<WTF::Closure>> m_taskQueue; |
86 HeapVector<Member<Event>> m_eventQueue; | 97 HeapVector<Member<Event>> m_eventQueue; |
87 HeapListHashSet<std::pair<Member<const EventTarget>, const StringImpl*>> | 98 HeapListHashSet<std::pair<Member<const EventTarget>, const StringImpl*>> |
88 m_perFrameEvents; | 99 m_perFrameEvents; |
89 using MediaQueryListListeners = | 100 using MediaQueryListListeners = |
90 HeapListHashSet<Member<MediaQueryListListener>>; | 101 HeapListHashSet<Member<MediaQueryListListener>>; |
91 MediaQueryListListeners m_mediaQueryListListeners; | 102 MediaQueryListListeners m_mediaQueryListListeners; |
92 }; | 103 }; |
93 | 104 |
94 } // namespace blink | 105 } // namespace blink |
95 | 106 |
96 #endif // ScriptedAnimationController_h | 107 #endif // ScriptedAnimationController_h |
OLD | NEW |