1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CCInputHandler_h
6 #define CCInputHandler_h
8 #include "base/basictypes.h"
9 #include <wtf/PassOwnPtr.h>
16 // The CCInputHandler is a way for the embedders to interact with
17 // the impl thread side of the compositor implementation.
19 // There is one CCInputHandler for every CCLayerTreeHost. It is
20 // created on the main thread and used only on the impl thread.
22 // The CCInputHandler is constructed with a CCInputHandlerClient, which is the
23 // interface by which the handler can manipulate the LayerTree.
24 class CCInputHandlerClient
{
26 enum ScrollStatus
{ ScrollOnMainThread
, ScrollStarted
, ScrollIgnored
};
27 enum ScrollInputType
{ Gesture
, Wheel
};
29 // Selects a layer to be scrolled at a given point in window coordinates.
30 // Returns ScrollStarted if the layer at the coordinates can be scrolled,
31 // ScrollOnMainThread if the scroll event should instead be delegated to the
32 // main thread, or ScrollIgnored if there is nothing to be scrolled at the
34 virtual ScrollStatus
scrollBegin(const IntPoint
&, ScrollInputType
) = 0;
36 // Scroll the selected layer starting at the given window coordinate. If
37 // there is no room to move the layer in the requested direction, its first
38 // ancestor layer that can be scrolled will be moved instead. Should only be
39 // called if scrollBegin() returned ScrollStarted.
40 virtual void scrollBy(const IntPoint
&, const IntSize
&) = 0;
42 // Stop scrolling the selected layer. Should only be called if scrollBegin()
43 // returned ScrollStarted.
44 virtual void scrollEnd() = 0;
46 virtual void pinchGestureBegin() = 0;
47 virtual void pinchGestureUpdate(float magnifyDelta
, const IntPoint
& anchor
) = 0;
48 virtual void pinchGestureEnd() = 0;
50 virtual void startPageScaleAnimation(const IntSize
& targetPosition
,
56 // Request another callback to CCInputHandler::animate().
57 virtual void scheduleAnimation() = 0;
60 CCInputHandlerClient() { }
61 virtual ~CCInputHandlerClient() { }
64 DISALLOW_COPY_AND_ASSIGN(CCInputHandlerClient
);
67 class CCInputHandler
{
69 virtual ~CCInputHandler() { }
71 virtual void bindToClient(CCInputHandlerClient
*) = 0;
72 virtual void animate(double monotonicTime
) = 0;
78 DISALLOW_COPY_AND_ASSIGN(CCInputHandler
);