Commit 54574a88 authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

MD downloads: Fix an issue that might incorrectly leave room for status text under the filename.

A few times, I've seen the a download complete exceptionally quickly and
leave the filename positioned as if there's status text, but there
isn't. I can't reproduce it consistently, but one possibility is that
`statusTextView_.hidden` is a bad signal for whether the layout needs to
change (it can be hidden for other reasons, like a dangerous download).

This change stops using `hidden` to decide whether to change states,
which is an improvement either way.

Bug: 589943
Change-Id: I491c06f57860315068fa719f046032353cb2db1e
Reviewed-on: https://chromium-review.googlesource.com/664137Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501391}
parent 4ee33134
......@@ -51,6 +51,7 @@ constexpr CGFloat kDangerViewYInset = 10;
constexpr CGFloat kTextX = 45;
constexpr CGFloat kFilenameY = 16;
constexpr CGFloat kFilenameWithStatusY = 23;
constexpr CGFloat kStatusTextY = 9;
constexpr CGFloat kMenuButtonSpacing = 8;
......@@ -450,9 +451,10 @@ NSTextField* MakeLabel(
NSString* statusString =
base::SysUTF16ToNSString(downloadModel->GetStatusText());
const BOOL hadStatusBefore = statusTextView_.stringValue.length > 0;
const BOOL hasStatus = statusString.length > 0;
statusTextView_.stringValue = statusString;
BOOL hasStatus = statusString.length != 0;
if (hasStatus == statusTextView_.hidden) {
if (hasStatus != hadStatusBefore) {
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
context.duration = 0.25;
context.timingFunction =
......@@ -463,7 +465,8 @@ NSTextField* MakeLabel(
addAnimation:[CABasicAnimation animationWithKeyPath:@"position.y"]
forKey:nil];
[filenameView_ setFrameOrigin:NSMakePoint(NSMinX(filenameView_.frame),
hasStatus ? 23 : 16)];
hasStatus ? kFilenameWithStatusY
: kFilenameY)];
statusTextView_.animator.hidden = !hasStatus;
}
completionHandler:nil];
......
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