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 @@
#ifndef 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"
namespace gfx {
class Canvas;
class GFX_EXPORT CocoaScrollbarPainter {
public:
enum class Orientation {
......@@ -40,13 +39,17 @@ class GFX_EXPORT CocoaScrollbarPainter {
// Paint the thumb. The |thumb_bounds| changes over time when the thumb
// engorges during hover.
static void PaintThumb(gfx::Canvas* canvas,
const gfx::Rect& thumb_bounds,
static void PaintThumb(cc::PaintCanvas* canvas,
const SkIRect& thumb_bounds,
const Params& params);
// Paint the track. |bounds| is the bounds for the track.
static void PaintTrack(gfx::Canvas* canvas,
const gfx::Rect& track_bounds,
// Paint the track. |track_bounds| is the bounds for the track.
static void PaintTrack(cc::PaintCanvas* canvas,
const SkIRect& track_bounds,
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
......
......@@ -102,7 +102,8 @@ void CocoaScrollBarThumb::OnPaint(gfx::Canvas* canvas) {
auto params = cocoa_scroll_bar_->GetPainterParams();
// Set the hover state based only on the thumb.
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) {
......@@ -209,7 +210,8 @@ void CocoaScrollBar::OnPaint(gfx::Canvas* canvas) {
// Transparency of the track is handled by the View opacity, so always draw
// using the non-overlay path.
params.overlay = false;
CocoaScrollbarPainter::PaintTrack(canvas, GetLocalBounds(), params);
CocoaScrollbarPainter::PaintTrack(
canvas->sk_canvas(), gfx::RectToSkIRect(GetLocalBounds()), params);
}
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