1635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/*
206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen * Copyright (C) 2010 Google Inc. All rights reserved.
30bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch *
4635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Redistribution and use in source and binary forms, with or without
5635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * modification, are permitted provided that the following conditions are
6635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * met:
70bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch *
8635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project *     * Redistributions of source code must retain the above copyright
9635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer.
10635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project *     * Redistributions in binary form must reproduce the above
11635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * copyright notice, this list of conditions and the following disclaimer
12635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * in the documentation and/or other materials provided with the
13635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * distribution.
14635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project *     * Neither the name of Google Inc. nor the names of its
15635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * contributors may be used to endorse or promote products derived from
16635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * this software without specific prior written permission.
170bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch *
18635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */
30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
3106ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#ifndef DragScrollTimer_h
3206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#define DragScrollTimer_h
33635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
3406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#include "IntSize.h"
3506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#include "Timer.h"
3606ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#include "WebPoint.h"
37d0825bca7fe65beaee391d30da42e937db621564Steve Block
3806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsennamespace WebCore { class FrameView; }
39635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
4006ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsennamespace WebKit {
41635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
4206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen//
4306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen// Encapsulating a timer and associated state management for
4406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen// scroll-on-drag behaviour.
4506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen//
4606ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsenclass DragScrollTimer {
4706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsenpublic:
4806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    DragScrollTimer();
4906ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    ~DragScrollTimer();
50635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
5106ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    void fired(WebCore::Timer<DragScrollTimer>*) { update(); }
5206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    void triggerScroll(WebCore::FrameView*, const WebPoint&);
5306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    void stop();
5406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen
5506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsenprivate:
5606ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    void scroll();
5706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    void update();
5806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    WebCore::IntSize scrollDistanceFor(WebCore::FrameView*, const WebPoint&) const;
5906ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    bool shouldScroll() const { return !m_lastDistance.isZero(); }
60635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
6106ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    WebCore::Timer<DragScrollTimer> m_timer;
6206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    WebCore::FrameView* m_view;
6306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    WebCore::IntSize m_lastDistance;
6406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    bool m_scrolling;
6506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen};
66d0825bca7fe65beaee391d30da42e937db621564Steve Block
6706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen} // namespace WebKit
68635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project
6906ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#endif
70