Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: ui/views/controls/scroll_view.cc

Issue 2813353002: Ensure that the focus ring in the bookmarks bar does not paint outside the parent view. (Closed)
Patch Set: Rename layer notification to OnChildLayerChanged() Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/scroll_view.cc
diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc
index 74cefcc61f7e9dd75aea8fc1593af824d7066290..18f498cd631a5a86e72ef18112df6f1fa1d8df2e 100644
--- a/ui/views/controls/scroll_view.cc
+++ b/ui/views/controls/scroll_view.cc
@@ -32,6 +32,11 @@ const base::Feature kToolkitViewsScrollWithLayers {
#endif
};
+// Set if the kToolkitViewsScrollWithLayers feature is enabled.
+// TODO(ananta)
+// Remove this when the feature is enabled by default.
+bool g_scroll_with_layers_enabled = false;
+
class ScrollCornerView : public View {
public:
ScrollCornerView() {}
@@ -67,7 +72,8 @@ void ConstrainScrollToBounds(View* viewport, View* view) {
// Note that even when ScrollView::ScrollsWithLayers() is true, the header row
// scrolls by repainting.
- const bool scrolls_with_layers = viewport->layer() != nullptr;
+ const bool scrolls_with_layers =
+ g_scroll_with_layers_enabled && viewport->layer() != nullptr;
sky 2017/04/17 15:24:01 Make ScrollView have a member for scroll_with_laye
ananta 2017/04/18 03:04:25 Done.
if (scrolls_with_layers) {
DCHECK(view->layer());
DCHECK_EQ(0, view->x());
@@ -166,8 +172,11 @@ ScrollView::ScrollView()
vert_sb_->set_controller(this);
corner_view_->SetVisible(false);
- if (!base::FeatureList::IsEnabled(kToolkitViewsScrollWithLayers))
+ g_scroll_with_layers_enabled =
+ base::FeatureList::IsEnabled(kToolkitViewsScrollWithLayers);
+ if (!g_scroll_with_layers_enabled)
return;
+
EnableViewPortLayer();
}
@@ -527,6 +536,10 @@ void ScrollView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
UpdateBorder();
}
+void ScrollView::OnChildLayerChanged(View* child) {
+ EnableViewPortLayer();
+}
+
void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
if (!contents_)
return;
@@ -717,12 +730,18 @@ void ScrollView::ScrollToOffset(const gfx::ScrollOffset& offset) {
}
bool ScrollView::ScrollsWithLayers() const {
+ if (!g_scroll_with_layers_enabled)
+ return false;
// Just check for the presence of a layer since it's cheaper than querying the
// Feature flag each time.
return contents_viewport_->layer() != nullptr;
}
void ScrollView::EnableViewPortLayer() {
+ if (viewport_layer_enabled_)
+ return;
+
+ viewport_layer_enabled_ = true;
background_color_ = SK_ColorWHITE;
contents_viewport_->set_background(
Background::CreateSolidBackground(background_color_));

Powered by Google App Engine
This is Rietveld 408576698