Commit 9b2181b8 authored by Sarthak Shah's avatar Sarthak Shah Committed by Commit Bot

Fling Animation Curve - Part 2

This CL plumbs the viewport size to the fling controller. There will be
follow up CL which will utilize this value for configuring fling
animation curve. Fling curve uses the viewport size to determine the
upper bound on how much distance a fling can travel/scroll.

Bug: 647137
Change-Id: I25896d9c514661ecc16e4f98b28e3d7c1f3b9f2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884758
Commit-Queue: Sarthak Shah <sarsha@microsoft.com>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713571}
parent a903f923
......@@ -30,6 +30,9 @@ class CONTENT_EXPORT FlingControllerEventSenderClient {
virtual void SendGeneratedGestureScrollEvents(
const GestureEventWithLatencyInfo& gesture_event) = 0;
// Returns the size of visible viewport in screen space, in DIPs.
virtual gfx::Size GetRootWidgetViewportSize() = 0;
};
// Interface with which the fling progress gets scheduled.
......
......@@ -67,6 +67,10 @@ class FlingControllerTest : public FlingControllerEventSenderClient,
last_sent_gesture_ = gesture_event.event;
}
gfx::Size GetRootWidgetViewportSize() override {
return gfx::Size(1920, 1080);
}
// FlingControllerSchedulerClient
void ScheduleFlingProgress(
base::WeakPtr<FlingController> fling_controller) override {
......
......@@ -105,6 +105,9 @@ class FlingSchedulerTest : public testing::Test,
const MouseWheelEventWithLatencyInfo& wheel_event) override {}
void SendGeneratedGestureScrollEvents(
const GestureEventWithLatencyInfo& gesture_event) override {}
gfx::Size GetRootWidgetViewportSize() override {
return gfx::Size(1920, 1080);
}
std::unique_ptr<FlingController> fling_controller_;
std::unique_ptr<FakeFlingScheduler> fling_scheduler_;
......
......@@ -94,6 +94,9 @@ class GestureEventQueueTest : public testing::Test,
const MouseWheelEventWithLatencyInfo& wheel_event) override {}
void SendGeneratedGestureScrollEvents(
const GestureEventWithLatencyInfo& gesture_event) override {}
gfx::Size GetRootWidgetViewportSize() override {
return gfx::Size(1920, 1080);
}
// FlingControllerSchedulerClient
void ScheduleFlingProgress(
......
......@@ -83,6 +83,9 @@ class CONTENT_EXPORT InputRouterClient {
bool up,
bool down) = 0;
virtual void FallbackCursorModeSetCursorVisibility(bool visible) = 0;
// Returns the size of visible viewport in screen space, in DIPs.
virtual gfx::Size GetRootWidgetViewportSize() = 0;
};
} // namespace content
......
......@@ -458,6 +458,10 @@ void InputRouterImpl::SendGeneratedGestureScrollEvents(
gesture_event.latency);
}
gfx::Size InputRouterImpl::GetRootWidgetViewportSize() {
return client_->GetRootWidgetViewportSize();
}
void InputRouterImpl::SendMouseWheelEventImmediately(
const MouseWheelEventWithLatencyInfo& wheel_event) {
mojom::WidgetInputHandler::DispatchEventCallback callback = base::BindOnce(
......
......@@ -156,6 +156,7 @@ class CONTENT_EXPORT InputRouterImpl : public InputRouter,
const MouseWheelEventWithLatencyInfo& wheel_event) override;
void SendGeneratedGestureScrollEvents(
const GestureEventWithLatencyInfo& gesture_event) override;
gfx::Size GetRootWidgetViewportSize() override;
// MouseWheelEventQueueClient
void SendMouseWheelEventImmediately(
......
......@@ -114,6 +114,10 @@ class MockInputRouterImplClient : public InputRouterImplClient {
void FallbackCursorModeSetCursorVisibility(bool visible) override {}
gfx::Size GetRootWidgetViewportSize() override {
return gfx::Size(1920, 1080);
}
MockWidgetInputHandler::MessageVector GetAndResetDispatchedMessages() {
return widget_input_handler_.GetAndResetDispatchedMessages();
}
......
......@@ -90,6 +90,10 @@ bool MockInputRouterClient::IsAutoscrollInProgress() {
return false;
}
gfx::Size MockInputRouterClient::GetRootWidgetViewportSize() {
return gfx::Size(1920, 1080);
}
bool MockInputRouterClient::GetAndResetFilterEventCalled() {
bool filter_input_event_called = filter_input_event_called_;
filter_input_event_called_ = false;
......
......@@ -47,6 +47,7 @@ class MockInputRouterClient : public InputRouterClient,
bool up,
bool down) override {}
void FallbackCursorModeSetCursorVisibility(bool visible) override {}
gfx::Size GetRootWidgetViewportSize() override;
bool GetAndResetFilterEventCalled();
ui::DidOverscrollParams GetAndResetOverscroll();
......
......@@ -3353,4 +3353,9 @@ void RenderWidgetHostImpl::OnZoomToFindInPageRectInMainFrame(
transformed_rect_to_zoom));
}
gfx::Size RenderWidgetHostImpl::GetRootWidgetViewportSize() {
auto* root_view = view_->GetRootView();
return root_view->GetVisibleViewportSize();
}
} // namespace content
......@@ -727,6 +727,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
bool up,
bool down) override;
void FallbackCursorModeSetCursorVisibility(bool visible) override;
gfx::Size GetRootWidgetViewportSize() override;
// FrameTokenMessageQueue::Client:
void OnInvalidFrameToken(uint32_t frame_token) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment