summaryrefslogtreecommitdiffstats
path: root/ui/views/bubble
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 10:38:40 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 10:38:40 +0000
commit40b3a86be34556a8e6f50ed64891a6e3100990ed (patch)
tree679854d5a870368c1bf958aea2190dd7b1e4f383 /ui/views/bubble
parent0f94a39733b76f21524554450f7e8ee02dd61ce4 (diff)
downloadchromium_src-40b3a86be34556a8e6f50ed64891a6e3100990ed.zip
chromium_src-40b3a86be34556a8e6f50ed64891a6e3100990ed.tar.gz
chromium_src-40b3a86be34556a8e6f50ed64891a6e3100990ed.tar.bz2
Close bubble widget when its anchor widget bounds has changed and move_with_anchor is false.
The bookmark bubble will close when the browser window size changes with this CL. We already close it when the browser window moves, so this is more consistent with that behavior. BUG=321034 TEST=BubbleDelegateTest.CloseWhenAnchorWidgetBoundsChanged. manual. see bug for repro step. Review URL: https://codereview.chromium.org/89503003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/bubble')
-rw-r--r--ui/views/bubble/bubble_delegate.cc8
-rw-r--r--ui/views/bubble/bubble_delegate_unittest.cc14
-rw-r--r--ui/views/bubble/tray_bubble_view.cc1
3 files changed, 21 insertions, 2 deletions
diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index 8c305c8..515c400 100644
--- a/ui/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
@@ -174,8 +174,12 @@ void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget,
void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget,
const gfx::Rect& new_bounds) {
- if (move_with_anchor() && anchor_widget() == widget)
- SizeToContents();
+ if (anchor_widget() == widget) {
+ if (move_with_anchor())
+ SizeToContents();
+ else
+ GetWidget()->Close();
+ }
}
View* BubbleDelegateView::GetAnchorView() const {
diff --git a/ui/views/bubble/bubble_delegate_unittest.cc b/ui/views/bubble/bubble_delegate_unittest.cc
index 4c72088..9104900 100644
--- a/ui/views/bubble/bubble_delegate_unittest.cc
+++ b/ui/views/bubble/bubble_delegate_unittest.cc
@@ -244,6 +244,20 @@ TEST_F(BubbleDelegateTest, NonClientHitTest) {
}
}
+TEST_F(BubbleDelegateTest, CloseWhenAnchorWidgetBoundsChanged) {
+ scoped_ptr<Widget> anchor_widget(CreateTestWidget());
+ BubbleDelegateView* bubble_delegate = new BubbleDelegateView(
+ anchor_widget->GetContentsView(), BubbleBorder::NONE);
+ Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_delegate);
+ test::TestWidgetObserver bubble_observer(bubble_widget);
+ EXPECT_FALSE(bubble_observer.widget_closed());
+
+ bubble_widget->Show();
+ EXPECT_TRUE(bubble_widget->IsVisible());
+ anchor_widget->SetBounds(gfx::Rect(10, 10, 100, 100));
+ EXPECT_FALSE(bubble_widget->IsVisible());
+}
+
// This class provides functionality to verify that the BubbleView shows up
// when we call BubbleDelegateView::StartFade(true) and is destroyed when we
// call BubbleDelegateView::StartFade(false).
diff --git a/ui/views/bubble/tray_bubble_view.cc b/ui/views/bubble/tray_bubble_view.cc
index cab704f..3f947ab 100644
--- a/ui/views/bubble/tray_bubble_view.cc
+++ b/ui/views/bubble/tray_bubble_view.cc
@@ -325,6 +325,7 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window,
mouse_actively_entered_(false) {
set_parent_window(parent_window);
set_notify_enter_exit_on_child(true);
+ set_move_with_anchor(true);
set_close_on_deactivate(init_params.close_on_deactivate);
set_margins(gfx::Insets());
bubble_border_ = new TrayBubbleBorder(this, GetAnchorView(), params_);