Commit a95ea703 authored by wjmaclean's avatar wjmaclean Committed by Commit bot

Allow new zoom bubble to override current one.

At present, if a user changes zoom on OSX while the zoom bubble is
already being shown, the new zoom bubble (with the most up to date
information) is not shown. This CL changes this behaviour by allowing
a new zoom bubble to be created, and replace the existing one.

Example: load a PDF and repeatedly click the zoom +/- controls in the
lower-right corner of the viewer.

BUG=444995

Review URL: https://codereview.chromium.org/849693006

Cr-Commit-Position: refs/heads/master@{#313564}
parent 11c9dde5
......@@ -48,6 +48,8 @@ class ZoomBubbleControllerDelegate {
ui::ScopedCrTrackingArea trackingArea_;
}
@property(nonatomic) ZoomBubbleControllerDelegate* delegate;
// Creates the bubble for a parent window but does not show it.
- (id)initWithParentWindow:(NSWindow*)parentWindow
delegate:(ZoomBubbleControllerDelegate*)delegate;
......
......@@ -75,6 +75,8 @@ void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval) {
@implementation ZoomBubbleController
@synthesize delegate = delegate_;
- (id)initWithParentWindow:(NSWindow*)parentWindow
delegate:(ZoomBubbleControllerDelegate*)delegate {
base::scoped_nsobject<InfoBubbleWindow> window(
......
......@@ -33,6 +33,7 @@ class ZoomDecoration : public ImageDecoration,
// Shows the zoom bubble for this decoration. If |auto_close| is YES, then
// the bubble will automatically close after a fixed period of time.
// If a bubble is already showing, the |auto_close| timer is reset.
void ShowBubble(BOOL auto_close);
// Closes the zoom bubble.
......
......@@ -23,6 +23,7 @@ ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner)
ZoomDecoration::~ZoomDecoration() {
[bubble_ closeWithoutAnimation];
bubble_.delegate = nil;
}
bool ZoomDecoration::UpdateIfNecessary(
......@@ -48,8 +49,8 @@ bool ZoomDecoration::UpdateIfNecessary(
}
void ZoomDecoration::ShowBubble(BOOL auto_close) {
if (bubble_)
return;
ZoomBubbleController* old_bubble = bubble_;
old_bubble.delegate = nil;
content::WebContents* web_contents = owner_->GetWebContents();
if (!web_contents)
......@@ -68,6 +69,9 @@ void ZoomDecoration::ShowBubble(BOOL auto_close) {
bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window]
delegate:this];
[bubble_ showAnchoredAt:anchor autoClose:auto_close];
[old_bubble.window orderOut:nil];
[old_bubble closeWithoutAnimation];
}
void ZoomDecoration::CloseBubble() {
......@@ -138,6 +142,7 @@ content::WebContents* ZoomDecoration::GetWebContents() {
}
void ZoomDecoration::OnClose() {
bubble_.delegate = nil;
bubble_ = nil;
// If the page is at default zoom then hiding the zoom decoration
......
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