2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
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 ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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 THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ScriptedAnimationController_h
27 #define ScriptedAnimationController_h
29 #include "core/dom/FrameRequestCallbackCollection.h"
30 #include "platform/heap/Handle.h"
31 #include "wtf/ListHashSet.h"
32 #include "wtf/RefCounted.h"
33 #include "wtf/RefPtr.h"
34 #include "wtf/Vector.h"
35 #include "wtf/text/AtomicString.h"
36 #include "wtf/text/StringImpl.h"
43 class FrameRequestCallback
;
44 class MediaQueryListListener
;
46 class ScriptedAnimationController
: public RefCountedWillBeGarbageCollected
<ScriptedAnimationController
> {
47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ScriptedAnimationController
);
49 static PassRefPtrWillBeRawPtr
<ScriptedAnimationController
> create(Document
* document
)
51 return adoptRefWillBeNoop(new ScriptedAnimationController(document
));
55 void clearDocumentPointer() { m_document
= nullptr; }
57 typedef int CallbackId
;
59 int registerCallback(FrameRequestCallback
*);
60 void cancelCallback(CallbackId
);
61 void serviceScriptedAnimations(double monotonicTimeNow
);
63 void enqueueEvent(PassRefPtrWillBeRawPtr
<Event
>);
64 void enqueuePerFrameEvent(PassRefPtrWillBeRawPtr
<Event
>);
65 void enqueueMediaQueryChangeListeners(WillBeHeapVector
<RefPtrWillBeMember
<MediaQueryListListener
>>&);
70 void dispatchEventsAndCallbacksForPrinting();
72 explicit ScriptedAnimationController(Document
*);
74 void scheduleAnimationIfNeeded();
76 void dispatchEvents(const AtomicString
& eventInterfaceFilter
= AtomicString());
77 void executeCallbacks(double monotonicTimeNow
);
78 void callMediaQueryListListeners();
80 bool hasScheduledItems() const;
82 RawPtrWillBeMember
<Document
> m_document
;
83 FrameRequestCallbackCollection m_callbackCollection
;
85 WillBeHeapVector
<RefPtrWillBeMember
<Event
>> m_eventQueue
;
86 WillBeHeapListHashSet
<std::pair
<RawPtrWillBeMember
<const EventTarget
>, const StringImpl
*>> m_perFrameEvents
;
87 using MediaQueryListListeners
= WillBeHeapListHashSet
<RefPtrWillBeMember
<MediaQueryListListener
>>;
88 MediaQueryListListeners m_mediaQueryListListeners
;
93 #endif // ScriptedAnimationController_h