Commit 40b3a86b authored by oshima@chromium.org's avatar oshima@chromium.org

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
parent 0f94a397
...@@ -174,8 +174,12 @@ void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, ...@@ -174,8 +174,12 @@ void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget,
void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget, void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget,
const gfx::Rect& new_bounds) { const gfx::Rect& new_bounds) {
if (move_with_anchor() && anchor_widget() == widget) if (anchor_widget() == widget) {
SizeToContents(); if (move_with_anchor())
SizeToContents();
else
GetWidget()->Close();
}
} }
View* BubbleDelegateView::GetAnchorView() const { View* BubbleDelegateView::GetAnchorView() const {
......
...@@ -244,6 +244,20 @@ TEST_F(BubbleDelegateTest, NonClientHitTest) { ...@@ -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 // This class provides functionality to verify that the BubbleView shows up
// when we call BubbleDelegateView::StartFade(true) and is destroyed when we // when we call BubbleDelegateView::StartFade(true) and is destroyed when we
// call BubbleDelegateView::StartFade(false). // call BubbleDelegateView::StartFade(false).
......
...@@ -325,6 +325,7 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window, ...@@ -325,6 +325,7 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window,
mouse_actively_entered_(false) { mouse_actively_entered_(false) {
set_parent_window(parent_window); set_parent_window(parent_window);
set_notify_enter_exit_on_child(true); set_notify_enter_exit_on_child(true);
set_move_with_anchor(true);
set_close_on_deactivate(init_params.close_on_deactivate); set_close_on_deactivate(init_params.close_on_deactivate);
set_margins(gfx::Insets()); set_margins(gfx::Insets());
bubble_border_ = new TrayBubbleBorder(this, GetAnchorView(), params_); bubble_border_ = new TrayBubbleBorder(this, GetAnchorView(), params_);
......
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