Rename NativeTheme::PaintArrowButton extra_param arg
Renaming the ScrollbarArrowExtraParams argument from "arrow" to
"extra_params".
This CL re-lands the parts that don't affect functionality from the
reverted CL:5038216.
Bug: 1495415
, 1520638
Change-Id: Ie978e2014b98c10fc5342fb6afdb64dcd21b4e36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5225879
Reviewed-by: Yaroslav Shalivskyy <yshalivskyy@microsoft.com>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Gaston Rodriguez <gastonr@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1251766}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
61c4f0c1dc
commit
87df1670a8
@ -186,7 +186,7 @@ void NativeThemeAura::PaintArrowButton(
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const {
|
||||
const ScrollbarArrowExtraParams& extra_params) const {
|
||||
SkColor bg_color =
|
||||
GetControlColor(kScrollbarArrowBackground, color_scheme, color_provider);
|
||||
// Aura-win uses slightly different arrow colors.
|
||||
@ -214,20 +214,21 @@ void NativeThemeAura::PaintArrowButton(
|
||||
case kNumStates:
|
||||
break;
|
||||
}
|
||||
if (arrow.thumb_color.has_value() &&
|
||||
arrow.thumb_color.value() == gfx::kPlaceholderColor) {
|
||||
// TODO(crbug.com/1473075): Remove this and the below checks for placeholderColor.
|
||||
DLOG(ERROR) << "thumb_color with a placeholderColor value encountered";
|
||||
if (extra_params.thumb_color.has_value() &&
|
||||
extra_params.thumb_color.value() == gfx::kPlaceholderColor) {
|
||||
// TODO(crbug.com/1473075): Remove this and the below checks for
|
||||
// placeholderColor.
|
||||
DLOG(ERROR) << "thumb_color with a placeholderColor value encountered";
|
||||
}
|
||||
if (arrow.thumb_color.has_value() &&
|
||||
arrow.thumb_color.value() != gfx::kPlaceholderColor) {
|
||||
if (extra_params.thumb_color.has_value() &&
|
||||
extra_params.thumb_color.value() != gfx::kPlaceholderColor) {
|
||||
// TODO(crbug.com/891944): Adjust thumb_color based on `state`.
|
||||
arrow_color = arrow.thumb_color.value();
|
||||
arrow_color = extra_params.thumb_color.value();
|
||||
}
|
||||
if (arrow.track_color.has_value() &&
|
||||
arrow.track_color.value() != gfx::kPlaceholderColor) {
|
||||
if (extra_params.track_color.has_value() &&
|
||||
extra_params.track_color.value() != gfx::kPlaceholderColor) {
|
||||
// TODO(crbug.com/891944): Adjust track_color based on `state`.
|
||||
bg_color = arrow.track_color.value();
|
||||
bg_color = extra_params.track_color.value();
|
||||
}
|
||||
DCHECK_NE(arrow_color, gfx::kPlaceholderColor);
|
||||
|
||||
@ -235,7 +236,7 @@ void NativeThemeAura::PaintArrowButton(
|
||||
flags.setColor(bg_color);
|
||||
|
||||
if (base::FeatureList::IsEnabled(kNewScrollbarArrowRadius) &&
|
||||
!arrow.needs_rounded_corner) {
|
||||
!extra_params.needs_rounded_corner) {
|
||||
canvas->drawIRect(gfx::RectToSkIRect(rect), flags);
|
||||
} else {
|
||||
// TODO(crbug.com/1493088): Also draw rounded corner for left and right
|
||||
@ -244,15 +245,15 @@ void NativeThemeAura::PaintArrowButton(
|
||||
SkScalar lower_left_radius = 0;
|
||||
SkScalar upper_right_radius = 0;
|
||||
SkScalar lower_right_radius = 0;
|
||||
float zoom = arrow.zoom ? arrow.zoom : 1.0;
|
||||
float zoom = extra_params.zoom ? extra_params.zoom : 1.0;
|
||||
if (direction == kScrollbarUpArrow) {
|
||||
if (arrow.right_to_left) {
|
||||
if (extra_params.right_to_left) {
|
||||
upper_left_radius = kScrollbarArrowRadius * zoom;
|
||||
} else {
|
||||
upper_right_radius = kScrollbarArrowRadius * zoom;
|
||||
}
|
||||
} else if (direction == kScrollbarDownArrow) {
|
||||
if (arrow.right_to_left) {
|
||||
if (extra_params.right_to_left) {
|
||||
lower_left_radius = kScrollbarArrowRadius * zoom;
|
||||
} else {
|
||||
lower_right_radius = kScrollbarArrowRadius * zoom;
|
||||
|
@ -45,13 +45,14 @@ class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase {
|
||||
const gfx::Rect& rect,
|
||||
const MenuItemExtraParams& menu_item,
|
||||
ColorScheme color_scheme) const override;
|
||||
void PaintArrowButton(cc::PaintCanvas* gc,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const override;
|
||||
void PaintArrowButton(
|
||||
cc::PaintCanvas* gc,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& extra_params) const override;
|
||||
void PaintScrollbarTrack(cc::PaintCanvas* canvas,
|
||||
const ColorProvider* color_provider,
|
||||
Part part,
|
||||
|
@ -370,13 +370,14 @@ void NativeThemeBase::PaintArrowButton(
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const {
|
||||
const ScrollbarArrowExtraParams& extra_params) const {
|
||||
cc::PaintFlags flags;
|
||||
|
||||
// Calculate button color.
|
||||
SkScalar track_hsv[3];
|
||||
SkColorToHSV(arrow.track_color.value_or(GetColor(kTrackColor, color_scheme)),
|
||||
track_hsv);
|
||||
SkColorToHSV(
|
||||
extra_params.track_color.value_or(GetColor(kTrackColor, color_scheme)),
|
||||
track_hsv);
|
||||
SkColor button_color = SaturateAndBrighten(track_hsv, 0, 0.2f);
|
||||
SkColor background_color = button_color;
|
||||
if (state == kPressed) {
|
||||
@ -448,8 +449,8 @@ void NativeThemeBase::PaintArrowButton(
|
||||
|
||||
// TODO(crbug.com/891944): Adjust thumb_color based on `state`.
|
||||
const SkColor arrow_color =
|
||||
arrow.thumb_color.has_value()
|
||||
? arrow.thumb_color.value()
|
||||
extra_params.thumb_color.has_value()
|
||||
? extra_params.thumb_color.value()
|
||||
: GetArrowColor(state, color_scheme, color_provider);
|
||||
PaintArrow(canvas, rect, direction, arrow_color);
|
||||
}
|
||||
|
@ -100,13 +100,14 @@ class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme {
|
||||
~NativeThemeBase() override;
|
||||
|
||||
// Draw the arrow. Used by scrollbar and inner spin button.
|
||||
virtual void PaintArrowButton(cc::PaintCanvas* gc,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const;
|
||||
virtual void PaintArrowButton(
|
||||
cc::PaintCanvas* gc,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& extra_params) const;
|
||||
// Paint the scrollbar track. Done before the thumb so that it can contain
|
||||
// alpha.
|
||||
virtual void PaintScrollbarTrack(
|
||||
|
@ -47,10 +47,11 @@ void NativeThemeFluent::PaintArrowButton(
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const {
|
||||
PaintButton(canvas, color_provider, rect, direction, color_scheme, arrow);
|
||||
const ScrollbarArrowExtraParams& extra_params) const {
|
||||
PaintButton(canvas, color_provider, rect, direction, color_scheme,
|
||||
extra_params);
|
||||
PaintArrow(canvas, color_provider, rect, direction, state, color_scheme,
|
||||
arrow);
|
||||
extra_params);
|
||||
}
|
||||
|
||||
void NativeThemeFluent::PaintScrollbarTrack(
|
||||
@ -185,11 +186,11 @@ void NativeThemeFluent::PaintButton(
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const {
|
||||
const ScrollbarArrowExtraParams& extra_params) const {
|
||||
cc::PaintFlags flags;
|
||||
const SkColor button_color =
|
||||
arrow.track_color.has_value()
|
||||
? arrow.track_color.value()
|
||||
extra_params.track_color.has_value()
|
||||
? extra_params.track_color.value()
|
||||
: color_provider->GetColor(kColorWebNativeControlScrollbarTrack);
|
||||
flags.setColor(button_color);
|
||||
gfx::Rect button_fill_rect = rect;
|
||||
@ -243,14 +244,14 @@ void NativeThemeFluent::PaintArrow(
|
||||
Part part,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const {
|
||||
const ScrollbarArrowExtraParams& extra_params) const {
|
||||
const ColorId arrow_color_id =
|
||||
state == NativeTheme::kPressed || state == NativeTheme::kHovered
|
||||
? kColorWebNativeControlScrollbarArrowForegroundPressed
|
||||
: kColorWebNativeControlScrollbarArrowForeground;
|
||||
// TODO(crbug.com/891944): Adjust thumb_color based on `state`.
|
||||
const SkColor arrow_color = arrow.thumb_color.has_value()
|
||||
? arrow.thumb_color.value()
|
||||
const SkColor arrow_color = extra_params.thumb_color.has_value()
|
||||
? extra_params.thumb_color.value()
|
||||
: color_provider->GetColor(arrow_color_id);
|
||||
cc::PaintFlags flags;
|
||||
flags.setColor(arrow_color);
|
||||
@ -312,10 +313,11 @@ gfx::RectF NativeThemeFluent::GetArrowRect(const gfx::Rect& rect,
|
||||
}
|
||||
|
||||
int NativeThemeFluent::GetArrowSideLength(State state) const {
|
||||
if (state == NativeTheme::kPressed)
|
||||
if (state == NativeTheme::kPressed) {
|
||||
return ArrowIconsAvailable()
|
||||
? kFluentScrollbarPressedArrowRectLength
|
||||
: kFluentScrollbarPressedArrowRectFallbackLength;
|
||||
}
|
||||
|
||||
return kFluentScrollbarArrowRectLength;
|
||||
}
|
||||
|
@ -29,13 +29,14 @@ class NATIVE_THEME_EXPORT NativeThemeFluent : public NativeThemeBase {
|
||||
|
||||
static NativeThemeFluent* web_instance();
|
||||
|
||||
void PaintArrowButton(cc::PaintCanvas* canvas,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const override;
|
||||
void PaintArrowButton(
|
||||
cc::PaintCanvas* canvas,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& extra_params) const override;
|
||||
void PaintScrollbarTrack(cc::PaintCanvas* canvas,
|
||||
const ColorProvider* color_provider,
|
||||
Part part,
|
||||
@ -69,14 +70,14 @@ class NATIVE_THEME_EXPORT NativeThemeFluent : public NativeThemeBase {
|
||||
const gfx::Rect& rect,
|
||||
Part direction,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const;
|
||||
const ScrollbarArrowExtraParams& extra_params) const;
|
||||
void PaintArrow(cc::PaintCanvas* canvas,
|
||||
const ColorProvider* color_provider,
|
||||
const gfx::Rect& rect,
|
||||
Part part,
|
||||
State state,
|
||||
ColorScheme color_scheme,
|
||||
const ScrollbarArrowExtraParams& arrow) const;
|
||||
const ScrollbarArrowExtraParams& extra_params) const;
|
||||
|
||||
// Calculates and returns the position and dimensions of the scaled arrow rect
|
||||
// within the scrollbar button rect. The goal is to keep the arrow in the
|
||||
|
Reference in New Issue
Block a user