Commit 0880dc1e authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

[Notifications] Avoid bad scaling from floating point truncation.

Suppose we have a notification with surface size 720x161. In
|UpdatePreferredSize|, we make sure the notification is of width
kNotificationWidth (360). While scaling, 161/2 is truncated to 80.
Later, in |Layout|, we use |contents_size| which holds the truncated 80
to compute the transform. This leads to the notification eventually
being displayed as 720x160. Instead, compute the scale factor based on
the surface width and kNotificationWidth.

BUG=754369

Change-Id: Ib2025bf7aac9d096085e0a641c20c6cc84689503
Reviewed-on: https://chromium-review.googlesource.com/625605Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496605}
parent 6806c559
......@@ -498,11 +498,11 @@ void ArcNotificationContentView::Layout() {
// Scale notification surface if necessary.
gfx::Transform transform;
const gfx::Size surface_size = surface_->GetSize();
const gfx::Size contents_size = contents_bounds.size();
if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) {
transform.Scale(
static_cast<float>(contents_size.width()) / surface_size.width(),
static_cast<float>(contents_size.height()) / surface_size.height());
if (!surface_size.IsEmpty()) {
const float factor =
static_cast<float>(message_center::kNotificationWidth) /
surface_size.width();
transform.Scale(factor, factor);
}
// Apply the transform to the surface content so that close button can
......
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