Commit 1478d20b authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Ensure scaled separator fills entire bounds.

For some reason, separator logic didn't always fill the separator when
the resolution was not a multiple of 50%. It now fills the background.

Spearators will still be 1 DIP rather than 1px.

Bug: 1016760
Change-Id: I5cc8e9907c23d2db6ee519aa4298c2c99660cfb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880531Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709645}
parent d181b123
...@@ -55,21 +55,11 @@ gfx::Size Separator::CalculatePreferredSize() const { ...@@ -55,21 +55,11 @@ gfx::Size Separator::CalculatePreferredSize() const {
} }
void Separator::OnPaint(gfx::Canvas* canvas) { void Separator::OnPaint(gfx::Canvas* canvas) {
SkColor color = overridden_color_ const SkColor color = overridden_color_
? *overridden_color_ ? *overridden_color_
: GetNativeTheme()->GetSystemColor( : GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_SeparatorColor); ui::NativeTheme::kColorId_SeparatorColor);
canvas->DrawColor(color);
float dsf = canvas->UndoDeviceScaleFactor();
// The separator fills its bounds, but avoid filling partial pixels.
gfx::Rect aligned = gfx::ScaleToEnclosedRect(GetContentsBounds(), dsf, dsf);
// At least 1 pixel should be drawn to make the separator visible.
aligned.set_width(std::max(1, aligned.width()));
aligned.set_height(std::max(1, aligned.height()));
canvas->FillRect(aligned, color);
View::OnPaint(canvas); View::OnPaint(canvas);
} }
......
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