Chromium Code Reviews| Index: ui/views/controls/scroll_view.cc |
| diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc |
| index 51db071b71f81d025effdb67000fe404465e4a2e..3a6a9ee8fdbee58bc8a93d7abb5feefe3c6db9f9 100644 |
| --- a/ui/views/controls/scroll_view.cc |
| +++ b/ui/views/controls/scroll_view.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/logging.h" |
| #include "ui/events/event.h" |
| +#include "ui/gfx/canvas.h" |
| #include "ui/native_theme/native_theme.h" |
| #include "ui/views/border.h" |
| #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| @@ -33,6 +34,18 @@ class ScrollViewWithBorder : public views::ScrollView { |
| DISALLOW_COPY_AND_ASSIGN(ScrollViewWithBorder); |
| }; |
| +class ScrollCornerView : public views::View { |
| + public: |
| + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| + ui::NativeTheme::ExtraParams ignored; |
| + GetNativeTheme()->Paint(canvas->sk_canvas(), |
| + ui::NativeTheme::kScrollbarCorner, |
| + ui::NativeTheme::kNormal, |
| + GetLocalBounds(), |
| + ignored); |
| + } |
| +}; |
|
sky
2014/08/13 03:33:11
private: DISALLOW...
Andre
2014/08/13 17:53:35
Done.
|
| + |
| // Returns the position for the view so that it isn't scrolled off the visible |
| // region. |
| int CheckScrollBounds(int viewport_size, int content_size, int current_pos) { |
| @@ -109,7 +122,7 @@ ScrollView::ScrollView() |
| header_viewport_(new Viewport()), |
| horiz_sb_(new NativeScrollBar(true)), |
| vert_sb_(new NativeScrollBar(false)), |
| - resize_corner_(NULL), |
| + corner_view_(new ScrollCornerView()), |
| min_height_(-1), |
| max_height_(-1), |
| hide_horizontal_scrollbar_(false) { |
| @@ -124,8 +137,7 @@ ScrollView::ScrollView() |
| horiz_sb_->set_controller(this); |
| vert_sb_->SetVisible(false); |
| vert_sb_->set_controller(this); |
| - if (resize_corner_) |
| - resize_corner_->SetVisible(false); |
| + corner_view_->SetVisible(false); |
| } |
| ScrollView::~ScrollView() { |
| @@ -133,9 +145,7 @@ ScrollView::~ScrollView() { |
| // deleted. |
| delete horiz_sb_; |
| delete vert_sb_; |
| - |
| - if (resize_corner_ && !resize_corner_->parent()) |
| - delete resize_corner_; |
| + delete corner_view_; |
| } |
| // static |
| @@ -268,12 +278,11 @@ void ScrollView::Layout() { |
| &horiz_sb_required, |
| &vert_sb_required); |
| } |
| - bool resize_corner_required = resize_corner_ && horiz_sb_required && |
| - vert_sb_required; |
| + bool corner_view_required = horiz_sb_required && vert_sb_required; |
| // Take action. |
| SetControlVisibility(horiz_sb_, horiz_sb_required); |
| SetControlVisibility(vert_sb_, vert_sb_required); |
| - SetControlVisibility(resize_corner_, resize_corner_required); |
| + SetControlVisibility(corner_view_, corner_view_required); |
| // Non-default. |
| if (horiz_sb_required) { |
| @@ -301,12 +310,12 @@ void ScrollView::Layout() { |
| vert_sb_width + width_offset, |
| viewport_bounds.bottom()); |
| } |
| - if (resize_corner_required) { |
| + if (corner_view_required) { |
| // Show the resize corner. |
| - resize_corner_->SetBounds(viewport_bounds.right(), |
| - viewport_bounds.bottom(), |
| - vert_sb_width, |
| - horiz_sb_height); |
| + corner_view_->SetBounds(viewport_bounds.right(), |
| + viewport_bounds.bottom(), |
| + vert_sb_width, |
| + horiz_sb_height); |
| } |
| // Update to the real client size with the visible scrollbars. |