Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / views / controls / scroll_view.cc
index 51db071..ec83c88 100644 (file)
@@ -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,23 @@ class ScrollViewWithBorder : public views::ScrollView {
   DISALLOW_COPY_AND_ASSIGN(ScrollViewWithBorder);
 };
 
+class ScrollCornerView : public views::View {
+ public:
+  ScrollCornerView() {}
+
+  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+    ui::NativeTheme::ExtraParams ignored;
+    GetNativeTheme()->Paint(canvas->sk_canvas(),
+                            ui::NativeTheme::kScrollbarCorner,
+                            ui::NativeTheme::kNormal,
+                            GetLocalBounds(),
+                            ignored);
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(ScrollCornerView);
+};
+
 // 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 +127,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 +142,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 +150,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 +283,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 +315,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.