Commit f75f5865 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Add an additional constructor on ScrollView to scroll with layers.

Currently layer scrolling is only enabled on mac by default.

Providing a constructor arg allows users of ScrollView to enable layer
scrolling regardless of platform.

This will initially be used for the ScrollView container that holds the
tabstrip for Tab Scrolling.

Bug: 1129675

Change-Id: Ie1a34d45eac952fcaf08daa313ee15bb36aa58ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416943Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810690}
parent 2c8a4e12
...@@ -25,7 +25,8 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) { ...@@ -25,7 +25,8 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) {
base::Unretained(this))); base::Unretained(this)));
if (base::FeatureList::IsEnabled(features::kScrollableTabStrip)) { if (base::FeatureList::IsEnabled(features::kScrollableTabStrip)) {
views::ScrollView* tab_strip_scroll_container = views::ScrollView* tab_strip_scroll_container =
AddChildView(std::make_unique<views::ScrollView>()); AddChildView(std::make_unique<views::ScrollView>(
views::ScrollView::ScrollWithLayers::kEnabled));
tab_strip_scroll_container->SetBackgroundColor(base::nullopt); tab_strip_scroll_container->SetBackgroundColor(base::nullopt);
tab_strip_scroll_container->SetHideHorizontalScrollBar(true); tab_strip_scroll_container->SetHideHorizontalScrollBar(true);
tab_strip_container_ = tab_strip_scroll_container; tab_strip_container_ = tab_strip_scroll_container;
......
...@@ -162,11 +162,17 @@ class ScrollView::Viewport : public View { ...@@ -162,11 +162,17 @@ class ScrollView::Viewport : public View {
}; };
ScrollView::ScrollView() ScrollView::ScrollView()
: ScrollView(base::FeatureList::IsEnabled(
::features::kUiCompositorScrollWithLayers)
? ScrollWithLayers::kEnabled
: ScrollWithLayers::kDisabled) {}
ScrollView::ScrollView(ScrollWithLayers scroll_with_layers)
: horiz_sb_(PlatformStyle::CreateScrollBar(true)), : horiz_sb_(PlatformStyle::CreateScrollBar(true)),
vert_sb_(PlatformStyle::CreateScrollBar(false)), vert_sb_(PlatformStyle::CreateScrollBar(false)),
corner_view_(std::make_unique<ScrollCornerView>()), corner_view_(std::make_unique<ScrollCornerView>()),
scroll_with_layers_enabled_(base::FeatureList::IsEnabled( scroll_with_layers_enabled_(scroll_with_layers ==
::features::kUiCompositorScrollWithLayers)) { ScrollWithLayers::kEnabled) {
SetNotifyEnterExitOnChild(true); SetNotifyEnterExitOnChild(true);
// Since |contents_viewport_| is accessed during the AddChildView call, make // Since |contents_viewport_| is accessed during the AddChildView call, make
......
...@@ -47,8 +47,16 @@ class VIEWS_EXPORT ScrollView : public View, public ScrollBarController { ...@@ -47,8 +47,16 @@ class VIEWS_EXPORT ScrollView : public View, public ScrollBarController {
public: public:
METADATA_HEADER(ScrollView); METADATA_HEADER(ScrollView);
// Indicates whether or not scroll view is initialized with layer-scrolling.
enum class ScrollWithLayers { kDisabled, kEnabled };
ScrollView(); ScrollView();
// Additional constructor for overriding scrolling as defined by
// |kUiCompositorScrollWithLayers|. See crbug.com/873923 for more details on
// enabling by default this for all platforms.
explicit ScrollView(ScrollWithLayers scroll_with_layers);
~ScrollView() override; ~ScrollView() override;
// Creates a ScrollView with a theme specific border. // Creates a ScrollView with a theme specific border.
......
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