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

Side by Side Diff: Source/core/dom/ScriptedAnimationController.h

Issue 1043903003: rAF: Introduce FrameRequestCallbackCollection for managing rAF callbacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 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
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND A NY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND A NY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR A NY 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR A NY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THI S 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THI S
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 * 23 *
24 */ 24 */
25 25
26 #ifndef ScriptedAnimationController_h 26 #ifndef ScriptedAnimationController_h
27 #define ScriptedAnimationController_h 27 #define ScriptedAnimationController_h
28 28
29 #include "core/dom/FrameRequestCallbackCollection.h"
29 #include "platform/heap/Handle.h" 30 #include "platform/heap/Handle.h"
30 #include "wtf/ListHashSet.h" 31 #include "wtf/ListHashSet.h"
31 #include "wtf/RefCounted.h" 32 #include "wtf/RefCounted.h"
32 #include "wtf/RefPtr.h" 33 #include "wtf/RefPtr.h"
33 #include "wtf/Vector.h" 34 #include "wtf/Vector.h"
34 #include "wtf/text/AtomicString.h" 35 #include "wtf/text/AtomicString.h"
35 #include "wtf/text/StringImpl.h" 36 #include "wtf/text/StringImpl.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 class Document; 40 class Document;
40 class Event; 41 class Event;
41 class EventTarget; 42 class EventTarget;
43 class FrameRequestCallback;
42 class MediaQueryListListener; 44 class MediaQueryListListener;
43 class RequestAnimationFrameCallback;
44 45
45 class ScriptedAnimationController : public RefCountedWillBeGarbageCollected<Scri ptedAnimationController> { 46 class ScriptedAnimationController : public RefCountedWillBeGarbageCollected<Scri ptedAnimationController> {
46 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ScriptedAnimationController); 47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ScriptedAnimationController);
47 public: 48 public:
48 static PassRefPtrWillBeRawPtr<ScriptedAnimationController> create(Document* document) 49 static PassRefPtrWillBeRawPtr<ScriptedAnimationController> create(Document* document)
49 { 50 {
50 return adoptRefWillBeNoop(new ScriptedAnimationController(document)); 51 return adoptRefWillBeNoop(new ScriptedAnimationController(document));
51 } 52 }
52 53
53 DECLARE_TRACE(); 54 DECLARE_TRACE();
54 void clearDocumentPointer() { m_document = nullptr; } 55 void clearDocumentPointer() { m_document = nullptr; }
55 56
56 typedef int CallbackId; 57 typedef int CallbackId;
57 58
58 int registerCallback(RequestAnimationFrameCallback*); 59 int registerCallback(FrameRequestCallback*);
59 void cancelCallback(CallbackId); 60 void cancelCallback(CallbackId);
60 void serviceScriptedAnimations(double monotonicTimeNow); 61 void serviceScriptedAnimations(double monotonicTimeNow);
61 62
62 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); 63 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>);
63 void enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Event>); 64 void enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Event>);
64 void enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMember<Me diaQueryListListener>>&); 65 void enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMember<Me diaQueryListListener>>&);
65 66
66 void suspend(); 67 void suspend();
67 void resume(); 68 void resume();
68 69
69 void dispatchEventsAndCallbacksForPrinting(); 70 void dispatchEventsAndCallbacksForPrinting();
70 private: 71 private:
71 explicit ScriptedAnimationController(Document*); 72 explicit ScriptedAnimationController(Document*);
72 73
73 void scheduleAnimationIfNeeded(); 74 void scheduleAnimationIfNeeded();
74 75
75 void dispatchEvents(const AtomicString& eventInterfaceFilter = AtomicString( )); 76 void dispatchEvents(const AtomicString& eventInterfaceFilter = AtomicString( ));
76 void executeCallbacks(double monotonicTimeNow); 77 void executeCallbacks(double monotonicTimeNow);
77 void callMediaQueryListListeners(); 78 void callMediaQueryListListeners();
78 79
79 typedef PersistentHeapVectorWillBeHeapVector<Member<RequestAnimationFrameCal lback>> CallbackList;
80 CallbackList m_callbacks;
81 CallbackList m_callbacksToInvoke; // only non-empty while inside executeCall backs
82
83 RawPtrWillBeMember<Document> m_document; 80 RawPtrWillBeMember<Document> m_document;
84 CallbackId m_nextCallbackId; 81 FrameRequestCallbackCollection m_callbackCollection;
85 int m_suspendCount; 82 int m_suspendCount;
86 WillBeHeapVector<RefPtrWillBeMember<Event>> m_eventQueue; 83 WillBeHeapVector<RefPtrWillBeMember<Event>> m_eventQueue;
87 WillBeHeapListHashSet<std::pair<RawPtrWillBeMember<const EventTarget>, const StringImpl*>> m_perFrameEvents; 84 WillBeHeapListHashSet<std::pair<RawPtrWillBeMember<const EventTarget>, const StringImpl*>> m_perFrameEvents;
88 typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener>> Me diaQueryListListeners; 85 typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener>> Me diaQueryListListeners;
89 MediaQueryListListeners m_mediaQueryListListeners; 86 MediaQueryListListeners m_mediaQueryListListeners;
90 }; 87 };
91 88
92 } // namespace blink 89 } // namespace blink
93 90
94 #endif // ScriptedAnimationController_h 91 #endif // ScriptedAnimationController_h
OLDNEW
« no previous file with comments | « Source/core/dom/RequestAnimationFrameCallback.idl ('k') | Source/core/dom/ScriptedAnimationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698