Commit 41478570 authored by Marcin Simonides's avatar Marcin Simonides Committed by Commit Bot

Express the last scroll offset in DIPs.

The RWHVAura::GetLastScrollOffset() method should return values in view
coordinates (device independent pixels) as do other implementations of
RWHV.

When zoom-for-DSF is enabled the coordinates from compositor are
expressed in pixel coordinates which are different from view coordinates
on HiDPI screens.  Therefore the last_scroll_offset_ value needs to be
scaled to view coordinates

BUG: 778228
Change-Id: Ic8da1fdbf821d0073fb2a22a75ecbc40441ce00e
Reviewed-on: https://chromium-review.googlesource.com/610148
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512549}
parent c914fba0
...@@ -930,6 +930,14 @@ void RenderWidgetHostViewAura::SubmitCompositorFrame( ...@@ -930,6 +930,14 @@ void RenderWidgetHostViewAura::SubmitCompositorFrame(
UpdateBackgroundColorFromRenderer(frame.metadata.root_background_color); UpdateBackgroundColorFromRenderer(frame.metadata.root_background_color);
last_scroll_offset_ = frame.metadata.root_scroll_offset; last_scroll_offset_ = frame.metadata.root_scroll_offset;
if (IsUseZoomForDSFEnabled()) {
// With zoom-for-DSF Blink pixel coordinates are used and zoom is used to
// adjusts for the device scale factor. That's why last_scroll_offset_
// needs to be scaled to view coordinates.
// Without zoom-for-DSF the values are already in view coordinates.
last_scroll_offset_.Scale(1.0f / current_device_scale_factor_);
}
if (delegated_frame_host_) { if (delegated_frame_host_) {
delegated_frame_host_->SubmitCompositorFrame(local_surface_id, delegated_frame_host_->SubmitCompositorFrame(local_surface_id,
std::move(frame)); std::move(frame));
......
...@@ -988,6 +988,80 @@ IN_PROC_BROWSER_TEST_P( ...@@ -988,6 +988,80 @@ IN_PROC_BROWSER_TEST_P(
video_frame); video_frame);
} }
class CompositingRenderWidgetHostViewBrowserTestHiDPI
: public CompositingRenderWidgetHostViewBrowserTest {
public:
CompositingRenderWidgetHostViewBrowserTestHiDPI() {}
protected:
void SetUpCommandLine(base::CommandLine* cmd) override {
CompositingRenderWidgetHostViewBrowserTest::SetUpCommandLine(cmd);
cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
base::StringPrintf("%f", scale()));
}
GURL TestUrl() override { return GURL(test_url_); }
void SetTestUrl(const std::string& url) { test_url_ = url; }
bool ShouldContinueAfterTestURLLoad() {
// Short-circuit a pass for platforms where setting up high-DPI fails.
const float actual_scale_factor =
GetScaleFactorForView(GetRenderWidgetHostView());
if (actual_scale_factor != scale()) {
LOG(WARNING) << "Blindly passing this test; unable to force device scale "
<< "factor: seems to be " << actual_scale_factor
<< " but expected " << scale();
return false;
}
VLOG(1)
<< ("Successfully forced device scale factor. Moving forward with "
"this test! :-)");
return true;
}
static float scale() { return 2.0f; }
private:
std::string test_url_;
DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewBrowserTestHiDPI);
};
IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestHiDPI,
ScrollOffset) {
const int kContentHeight = 2000;
const int kScrollAmount = 100;
SetTestUrl(
base::StringPrintf("data:text/html,<!doctype html>"
"<div class='box'></div>"
"<style>"
"body { padding: 0; margin: 0; }"
".box { position: absolute;"
" background: #0ff;"
" width: 100%%;"
" height: %dpx;"
"}"
"</style>"
"<script>"
" addEventListener(\"scroll\", function() {"
" domAutomationController.send(\"DONE\"); });"
" window.scrollTo(0, %d);"
"</script>",
kContentHeight, kScrollAmount));
SET_UP_SURFACE_OR_PASS_TEST("\"DONE\"");
if (!ShouldContinueAfterTestURLLoad())
return;
RenderWidgetHostViewBase* rwhv = GetRenderWidgetHostView();
gfx::Vector2dF scroll_offset = rwhv->GetLastScrollOffset();
EXPECT_EQ(scroll_offset.x(), 0);
EXPECT_EQ(scroll_offset.y(), kScrollAmount);
}
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// On ChromeOS there is no software compositing. // On ChromeOS there is no software compositing.
static const auto kTestCompositingModes = testing::Values(GL_COMPOSITING); static const auto kTestCompositingModes = testing::Values(GL_COMPOSITING);
...@@ -1006,6 +1080,9 @@ INSTANTIATE_TEST_CASE_P( ...@@ -1006,6 +1080,9 @@ INSTANTIATE_TEST_CASE_P(
GLAndSoftwareCompositing, GLAndSoftwareCompositing,
CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI,
kTestCompositingModes); kTestCompositingModes);
INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing,
CompositingRenderWidgetHostViewBrowserTestHiDPI,
kTestCompositingModes);
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
......
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