summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortapted <tapted@chromium.org>2014-09-10 19:03:13 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-11 03:07:09 +0000
commitf1d241a504fb4cdc18501ffb7b0369aa0135cc9d (patch)
tree10e7db237d64958575f8252135ebc7c5e0e034ec
parente970ae47a0490d1faafd7d6d1c7891a9c901266c (diff)
downloadchromium_src-f1d241a504fb4cdc18501ffb7b0369aa0135cc9d.zip
chromium_src-f1d241a504fb4cdc18501ffb7b0369aa0135cc9d.tar.gz
chromium_src-f1d241a504fb4cdc18501ffb7b0369aa0135cc9d.tar.bz2
MacViews: Ensure the RootView is in place before the first call to ReorderNativeViews
This gets 3 views_unittests passing: - ViewTargeterTest.HitTestCallsOnView, - ViewTest.CanProcessEventsWithinSubtree, - ViewTest.GetEventHandlerForRect. These were failing because the size of the RootView was being reset to the Widget size when first added. This happened because NativeWidgetMac was not ensuring the RootView was set up properly immediately after a call to Widget::Init() for all Widget types (i.e. those without a NonClientView). When there _is_ a NonClientView, Widget::Init() calls SetContentsView() which would eventually trickle down to NativeWidgetMac::ReorderNativeViews(), which is where NativeWidgetMac would set up the root view. BUG=378134 Review URL: https://codereview.chromium.org/559873002 Cr-Commit-Position: refs/heads/master@{#294296}
-rw-r--r--ui/views/widget/native_widget_mac.mm3
-rw-r--r--ui/views/widget/widget_unittest.cc21
2 files changed, 24 insertions, 0 deletions
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
index f40c2f4..ffe7cd3 100644
--- a/ui/views/widget/native_widget_mac.mm
+++ b/ui/views/widget/native_widget_mac.mm
@@ -118,6 +118,9 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
delegate_->OnNativeWidgetCreated(true);
bridge_->SetFocusManager(GetWidget()->GetFocusManager());
+
+ DCHECK(GetWidget()->GetRootView());
+ bridge_->SetRootView(GetWidget()->GetRootView());
}
NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() {
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index a31717d..962a7e5 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -3198,5 +3198,26 @@ TEST_F(WidgetTest, MouseEventTypesViaGenerator) {
widget->CloseNow();
}
+// Tests that the root view is correctly set up for Widget types that do not
+// require a non-client view, before any other views are added to the widget.
+// That is, before Widget::ReorderNativeViews() is called which, if called with
+// a root view not set, could cause the root view to get resized to the widget.
+TEST_F(WidgetTest, NonClientWindowValidAfterInit) {
+ Widget* widget = CreateTopLevelFramelessPlatformWidget();
+ View* root_view = widget->GetRootView();
+
+ // Size the root view to exceed the widget bounds.
+ const gfx::Rect test_rect(0, 0, 500, 500);
+ root_view->SetBoundsRect(test_rect);
+
+ EXPECT_NE(test_rect.size(), widget->GetWindowBoundsInScreen().size());
+
+ EXPECT_EQ(test_rect, root_view->bounds());
+ widget->ReorderNativeViews();
+ EXPECT_EQ(test_rect, root_view->bounds());
+
+ widget->CloseNow();
+}
+
} // namespace test
} // namespace views