| Index: content/browser/renderer_host/input/wheel_event_queue.h
|
| diff --git a/content/browser/renderer_host/input/wheel_event_queue.h b/content/browser/renderer_host/input/wheel_event_queue.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..65eb6f866fe328f337fcc9e1282cd2502ae9629d
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/input/wheel_event_queue.h
|
| @@ -0,0 +1,84 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_WHEEL_EVENT_QUEUE_H_
|
| +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_WHEEL_EVENT_QUEUE_H_
|
| +
|
| +#include <deque>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/timer/timer.h"
|
| +#include "content/browser/renderer_host/event_with_latency_info.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/common/input/input_event_ack_state.h"
|
| +#include "third_party/WebKit/public/web/WebInputEvent.h"
|
| +
|
| +namespace content {
|
| +
|
| +// Interface with which the WheelEventQueue can forward wheel events, and
|
| +// dispatch wheel event responses.
|
| +class CONTENT_EXPORT WheelEventQueueClient {
|
| + public:
|
| + virtual ~WheelEventQueueClient() {}
|
| +
|
| + virtual void SendWheelEventImmediately(
|
| + const MouseWheelEventWithLatencyInfo& event) = 0;
|
| +
|
| + virtual void OnWheelEventAck(const MouseWheelEventWithLatencyInfo& event,
|
| + InputEventAckState ack_result) = 0;
|
| +
|
| + virtual void SetNeedsFlush() = 0;
|
| +};
|
| +
|
| +class CONTENT_EXPORT WheelEventQueue {
|
| + public:
|
| + // |client| must outlive the WheelEventQueue.
|
| + WheelEventQueue(WheelEventQueueClient* client, bool buffer_until_flush);
|
| + ~WheelEventQueue();
|
| +
|
| + // Adds a wheel event to the queue, forwarding if appropriate.
|
| + void QueueEvent(const MouseWheelEventWithLatencyInfo& wheel_event);
|
| +
|
| + // Indicates that the caller has received an acknowledgement from the renderer
|
| + // with state |ack_result| and event |type|. May send wheel events if the
|
| + // queue is not empty.
|
| + void ProcessWheelAck(InputEventAckState ack_result,
|
| + const ui::LatencyInfo& latency);
|
| +
|
| + // Called in response to a flush request made through the client.
|
| + void Flush();
|
| +
|
| + bool empty() const {
|
| + return !mouse_wheel_pending_ && coalesced_wheel_events_.empty();
|
| + }
|
| +
|
| + private:
|
| + void SendEvent(const MouseWheelEventWithLatencyInfo& wheel_event);
|
| +
|
| + WheelEventQueueClient* const client_;
|
| +
|
| + // Whether to buffer wheel events until a call to |FlushInput()|.
|
| + const bool buffer_until_flush_;
|
| +
|
| + // True if a wheel event was sent and we are waiting for a corresponding ack.
|
| + bool mouse_wheel_pending_;
|
| + MouseWheelEventWithLatencyInfo current_wheel_event_;
|
| +
|
| + // Whether we're inside a call to |Flush()|.
|
| + bool flushing_;
|
| +
|
| + // The next mouse wheel events to send. Mouse wheel events received while one
|
| + // is pending are coalesced (by accumulating deltas) if they match the
|
| + // previous event in modifiers. On the Mac, in particular, mouse wheel events
|
| + // are received at a high rate; not waiting for the ack results in jankiness,
|
| + // and using the same mechanism as for mouse moves (just dropping old events
|
| + // when multiple ones/ would be queued) results in very slow scrolling.
|
| + std::deque<MouseWheelEventWithLatencyInfo> coalesced_wheel_events_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WheelEventQueue);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_WHEEL_EVENT_QUEUE_H_
|
|
|