Commit b3589492 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Update CocoaScrollbarPainter in preparation for use in blink

Change interfaces to use cc::PaintCanvas and SkIRect. Immediately
convert back to gfx types.

Touch up colors so that the diffs in layout tests will be minimized.

Add code to paint the corner. Share this with the track painting code,
and split the track painting code into helper functions for this
purpose.

Bug: 961835
Change-Id: I451f16711afce8e4a0bff5e963f1dc3e06f22410
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896044Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711935}
parent 84f4134a
This diff is collapsed.
...@@ -5,13 +5,12 @@ ...@@ -5,13 +5,12 @@
#ifndef UI_GFX_MAC_COCOA_SCROLLBAR_PAINTER_H_ #ifndef UI_GFX_MAC_COCOA_SCROLLBAR_PAINTER_H_
#define UI_GFX_MAC_COCOA_SCROLLBAR_PAINTER_H_ #define UI_GFX_MAC_COCOA_SCROLLBAR_PAINTER_H_
#include "ui/gfx/geometry/rect.h" #include "cc/paint/paint_canvas.h"
#include "third_party/skia/include/core/SkRect.h"
#include "ui/gfx/gfx_export.h" #include "ui/gfx/gfx_export.h"
namespace gfx { namespace gfx {
class Canvas;
class GFX_EXPORT CocoaScrollbarPainter { class GFX_EXPORT CocoaScrollbarPainter {
public: public:
enum class Orientation { enum class Orientation {
...@@ -40,13 +39,17 @@ class GFX_EXPORT CocoaScrollbarPainter { ...@@ -40,13 +39,17 @@ class GFX_EXPORT CocoaScrollbarPainter {
// Paint the thumb. The |thumb_bounds| changes over time when the thumb // Paint the thumb. The |thumb_bounds| changes over time when the thumb
// engorges during hover. // engorges during hover.
static void PaintThumb(gfx::Canvas* canvas, static void PaintThumb(cc::PaintCanvas* canvas,
const gfx::Rect& thumb_bounds, const SkIRect& thumb_bounds,
const Params& params); const Params& params);
// Paint the track. |bounds| is the bounds for the track. // Paint the track. |track_bounds| is the bounds for the track.
static void PaintTrack(gfx::Canvas* canvas, static void PaintTrack(cc::PaintCanvas* canvas,
const gfx::Rect& track_bounds, const SkIRect& track_bounds,
const Params& params); const Params& params);
// Paint the corner. |corner_bounds| is the bounds for the corner.
static void PaintCorner(cc::PaintCanvas* canvas,
const SkIRect& corner_bounds,
const Params& params);
}; };
} // namespace gfx } // namespace gfx
......
...@@ -102,7 +102,8 @@ void CocoaScrollBarThumb::OnPaint(gfx::Canvas* canvas) { ...@@ -102,7 +102,8 @@ void CocoaScrollBarThumb::OnPaint(gfx::Canvas* canvas) {
auto params = cocoa_scroll_bar_->GetPainterParams(); auto params = cocoa_scroll_bar_->GetPainterParams();
// Set the hover state based only on the thumb. // Set the hover state based only on the thumb.
params.hovered = IsStateHovered() || IsStatePressed(); params.hovered = IsStateHovered() || IsStatePressed();
CocoaScrollbarPainter::PaintThumb(canvas, GetLocalBounds(), params); CocoaScrollbarPainter::PaintThumb(
canvas->sk_canvas(), gfx::RectToSkIRect(GetLocalBounds()), params);
} }
bool CocoaScrollBarThumb::OnMousePressed(const ui::MouseEvent& event) { bool CocoaScrollBarThumb::OnMousePressed(const ui::MouseEvent& event) {
...@@ -209,7 +210,8 @@ void CocoaScrollBar::OnPaint(gfx::Canvas* canvas) { ...@@ -209,7 +210,8 @@ void CocoaScrollBar::OnPaint(gfx::Canvas* canvas) {
// Transparency of the track is handled by the View opacity, so always draw // Transparency of the track is handled by the View opacity, so always draw
// using the non-overlay path. // using the non-overlay path.
params.overlay = false; params.overlay = false;
CocoaScrollbarPainter::PaintTrack(canvas, GetLocalBounds(), params); CocoaScrollbarPainter::PaintTrack(
canvas->sk_canvas(), gfx::RectToSkIRect(GetLocalBounds()), params);
} }
bool CocoaScrollBar::OnMousePressed(const ui::MouseEvent& event) { bool CocoaScrollBar::OnMousePressed(const ui::MouseEvent& event) {
......
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