Commit f5cdac12 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Don't trigger main-thread overlay scrollbar animations if composited

There are already hit tests and animations entirely in the impl thread
for such scrollbars.

Bug: 1116800

Change-Id: I2714258717c89e0ea41232eb86abe12570526d28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364972
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800302}
parent 7f1e4aed
......@@ -1578,6 +1578,59 @@ TEST_F(ScrollbarsTestWithVirtualTimer, TestNonCompositedOverlayScrollbarsFade) {
mock_overlay_theme.SetOverlayScrollbarFadeOutDelay(base::TimeDelta());
}
TEST_F(ScrollbarsTestWithVirtualTimer, TestCompositedOverlayScrollbarsNoFade) {
ENABLE_OVERLAY_SCROLLBARS(true);
WebView().MainFrameWidget()->Resize(WebSize(640, 480));
SimRequest request("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
request.Complete(R"HTML(
<!DOCTYPE html>
<style>
#space {
width: 1000px;
height: 1000px;
}
#container {
/* Force composited scrolling */
will-change: transform;
width: 200px;
height: 200px;
overflow: scroll;
}
div { height:1000px; width: 200px; }
</style>
<div id='container'>
<div id='space'></div>
</div>
)HTML");
Compositor().BeginFrame();
Document& document = GetDocument();
Element* container = document.getElementById("container");
ScrollableArea* scrollable_area =
ToLayoutBox(container->GetLayoutObject())->GetScrollableArea();
DCHECK(scrollable_area->UsesCompositedScrolling());
EXPECT_TRUE(scrollable_area->HasOverlayScrollbars());
EXPECT_TRUE(scrollable_area->HasLayerForVerticalScrollbar());
Scrollbar* vertical_scrollbar = scrollable_area->VerticalScrollbar();
scrollable_area->MouseEnteredScrollbar(*vertical_scrollbar);
EXPECT_FALSE(scrollable_area->NeedsShowScrollbarLayers());
scrollable_area->MouseExitedScrollbar(*vertical_scrollbar);
EXPECT_FALSE(scrollable_area->NeedsShowScrollbarLayers());
scrollable_area->MouseCapturedScrollbar();
EXPECT_FALSE(scrollable_area->NeedsShowScrollbarLayers());
scrollable_area->MouseReleasedScrollbar();
EXPECT_FALSE(scrollable_area->NeedsShowScrollbarLayers());
}
class ScrollbarAppearanceTest
: public ScrollbarsTest,
public testing::WithParamInterface</*use_overlay_scrollbars=*/bool> {};
......
......@@ -740,6 +740,11 @@ void ScrollableArea::ShowNonMacOverlayScrollbars() {
!GetPageScrollbarTheme().BlinkControlsOverlayVisibility())
return;
// Don't do this for composited scrollbars. These scrollbars are handled
// by separate code in cc::ScrollbarAnimationController.
if (LayerForVerticalScrollbar() || LayerForHorizontalScrollbar())
return;
SetScrollbarsHiddenIfOverlay(false);
needs_show_scrollbar_layers_ = true;
......
......@@ -551,6 +551,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
vertical_scrollbar_needs_paint_invalidation_ = false;
scroll_corner_needs_paint_invalidation_ = false;
}
void ShowNonMacOverlayScrollbars();
// Called when scrollbar hides/shows for overlay scrollbars. This callback
......
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