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

MD downloads: Fix layout of dangerous download views.

The old logic wasn't prepared to lay out a dangerous download when when the
button was too small to contain it, which happens when a download animates in.
This change lays out the dangerous download view like other views in the
download item (other than the menu button): give it its final frame and anchor
it to the leading edge of the button. That way, it's gracefully uncovered as
the button's width animates up from zero.

Bug: 805647
Change-Id: Ic7c75cfc0675674e15694670858b6673c5f4b39b
Reviewed-on: https://chromium-review.googlesource.com/884442Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531716}
parent 4edc316d
......@@ -347,8 +347,8 @@ NSTextField* MakeLabel(
- (CGFloat)preferredWidth {
if (dangerView_) {
CGFloat delta = [dangerView_ preferredWidth] - NSWidth(dangerView_.frame);
return NSWidth(self.frame) + delta;
return NSWidth(dangerView_.frame) + kMenuButtonSpacing + kMenuButtonSize +
kMenuButtonTrailingMargin;
} else {
return kNormalSize.width;
}
......@@ -461,22 +461,19 @@ NSTextField* MakeLabel(
for (NSView* view in [self normalViews]) {
view.hidden = YES;
}
NSRect dangerViewRect =
NSMakeRect(0, 0,
NSWidth(self.bounds) - NSWidth(menuButton_.frame) -
kMenuButtonSpacing - kMenuButtonTrailingMargin,
NSHeight(self.bounds));
base::scoped_nsobject<MDDownloadItemDangerView> dangerView(
[[MDDownloadItemDangerView alloc]
initWithFrame:[self cr_localizedRect:dangerViewRect]]);
initWithFrame:NSMakeRect(0, 0, 0, NSHeight(self.bounds))]);
dangerView_ = dangerView;
dangerView_.autoresizingMask =
[NSView cr_localizedAutoresizingMask:NSViewWidthSizable];
[NSView cr_localizedAutoresizingMask:NSViewMaxXMargin];
dangerView_.button.target = controller_;
dangerView_.button.action = @selector(discardDownload:);
[self addSubview:dangerView_];
}
[dangerView_ setStateFromDownload:downloadModel];
[dangerView_ setFrameSize:NSMakeSize(dangerView_.preferredWidth,
NSHeight(dangerView_.frame))];
return;
} else if (dangerView_) {
for (NSView* view in [self normalViews]) {
......
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