Chromium Code Reviews| Index: ui/native_theme/native_theme_base.cc |
| diff --git a/ui/native_theme/native_theme_base.cc b/ui/native_theme/native_theme_base.cc |
| index cc94eafb7b432d0af3abfcb0c9dcabb5b9cde16b..abd7edbe82b0ae9d904736b29df23dfd9be6c192 100644 |
| --- a/ui/native_theme/native_theme_base.cc |
| +++ b/ui/native_theme/native_theme_base.cc |
| @@ -358,43 +358,49 @@ void NativeThemeBase::PaintArrow(SkCanvas* gc, |
| const gfx::Rect& rect, |
| Part direction, |
| SkColor color) const { |
| - int width_middle, length_middle; |
| - if (direction == kScrollbarUpArrow || direction == kScrollbarDownArrow) { |
| - width_middle = rect.width() / 2 + 1; |
| - length_middle = rect.height() / 2 + 1; |
| - } else { |
| - length_middle = rect.width() / 2 + 1; |
| - width_middle = rect.height() / 2 + 1; |
| - } |
| + int width_middle = rect.width() / 2 + 1; |
| + int length_middle = rect.height() / 2 + 1; |
|
Evan Stade
2016/04/25 02:35:59
confusing var name -- why not height_middle?
Bret
2016/04/25 23:24:32
No reason, it was named that before I messed with
|
| SkPaint paint; |
| paint.setColor(color); |
| paint.setAntiAlias(false); |
| paint.setStyle(SkPaint::kFill_Style); |
| + int arrow_altitude; |
| + if (direction == kScrollbarUpArrow || direction == kScrollbarDownArrow) { |
| + arrow_altitude = length_middle / 2; |
| + } else { |
|
Evan Stade
2016/04/25 02:35:59
nit: no curlies
also ternary assignment is probab
Bret
2016/04/25 23:24:32
Replaced with ternary.
|
| + arrow_altitude = width_middle / 2; |
| + } |
| + int arrow_base_length = arrow_altitude * 2 - 1; |
|
Evan Stade
2016/04/25 02:35:59
seems a bit silly to divide by 2 then multiply by
Bret
2016/04/25 23:24:32
I guess it does look silly, but those are the valu
Evan Stade
2016/04/25 23:38:16
oops, this last bit of the comment was supposed to
|
| + |
| SkPath path; |
| - // The constants in this block of code are hand-tailored to produce good |
| + // The calculations in this block of code are hand-tailored to produce good |
| // looking arrows without anti-aliasing. |
| switch (direction) { |
|
Evan Stade
2016/04/25 02:35:59
what if you just calculated the path once (for an
Bret
2016/04/25 23:24:32
Didn't work. The arrows still need to be centered
|
| case kScrollbarUpArrow: |
| - path.moveTo(rect.x() + width_middle - 4, rect.y() + length_middle + 2); |
| - path.rLineTo(7, 0); |
| - path.rLineTo(-4, -4); |
| + path.moveTo(rect.x() + width_middle - arrow_altitude, |
| + rect.y() + length_middle + (arrow_altitude / 2)); |
|
Evan Stade
2016/04/25 02:35:59
the asymmetry here is weird. Why are you doing int
Bret
2016/04/25 23:24:32
I was making sure everything looked the same at 1x
|
| + path.rLineTo(arrow_base_length, 0); |
| + path.rLineTo(-arrow_altitude, -arrow_altitude); |
| break; |
| case kScrollbarDownArrow: |
| - path.moveTo(rect.x() + width_middle - 4, rect.y() + length_middle - 3); |
| - path.rLineTo(7, 0); |
| - path.rLineTo(-4, 4); |
| + path.moveTo(rect.x() + width_middle - arrow_altitude, |
| + rect.y() + length_middle - ceil(arrow_altitude / 2.0)); |
| + path.rLineTo(arrow_base_length, 0); |
| + path.rLineTo(-arrow_altitude, arrow_altitude); |
| break; |
| case kScrollbarRightArrow: |
| - path.moveTo(rect.x() + length_middle - 3, rect.y() + width_middle - 4); |
| - path.rLineTo(0, 7); |
| - path.rLineTo(4, -4); |
| + path.moveTo(rect.x() + width_middle - (arrow_altitude / 2), |
| + rect.y() + length_middle - arrow_altitude); |
| + path.rLineTo(0, arrow_base_length); |
| + path.rLineTo(arrow_altitude, -arrow_altitude); |
| break; |
| case kScrollbarLeftArrow: |
| - path.moveTo(rect.x() + length_middle + 1, rect.y() + width_middle - 5); |
| - path.rLineTo(0, 9); |
| - path.rLineTo(-4, -4); |
| + path.moveTo(rect.x() + width_middle + 1, |
| + rect.y() + length_middle - (arrow_altitude + 1)); |
| + path.rLineTo(0, arrow_base_length + 2); |
|
Evan Stade
2016/04/25 02:35:59
can you leave comments explaining the magic consta
Bret
2016/04/25 23:24:32
To be honest, I'm not really sure why these consta
Evan Stade
2016/04/25 23:38:16
The new code is even kookier than the old, and I s
|
| + path.rLineTo(-arrow_altitude, -arrow_altitude); |
| break; |
| default: |
| break; |