summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 02:51:40 +0000
committerzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 02:51:40 +0000
commit9db038b4b858b5d2f9c1be9d4b38a3b2168769f0 (patch)
tree513f188a5c006b17a33df8e19c386986588efa22 /ui
parentc955a8d2084220f245f6ef5e78baef677691b23a (diff)
downloadchromium_src-9db038b4b858b5d2f9c1be9d4b38a3b2168769f0.zip
chromium_src-9db038b4b858b5d2f9c1be9d4b38a3b2168769f0.tar.gz
chromium_src-9db038b4b858b5d2f9c1be9d4b38a3b2168769f0.tar.bz2
Don't assume that widgets of TYPE_CONTROL are parented to the RootWindow.
This was causing the SadTabView to be drawn at the wrong origin. BUG=262051 Review URL: https://chromiumcodereview.appspot.com/21504003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_position_client.cc11
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc41
2 files changed, 45 insertions, 7 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
index 12be4cc..2ca556c 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
@@ -68,19 +68,16 @@ void DesktopScreenPositionClient::SetBounds(
const gfx::Rect& bounds,
const gfx::Display& display) {
// TODO: Use the 3rd parameter, |display|.
- gfx::Point origin = bounds.origin();
aura::RootWindow* root = window->GetRootWindow();
- aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
-
- if (window->type() == aura::client::WINDOW_TYPE_CONTROL) {
- window->SetBounds(gfx::Rect(origin, bounds.size()));
- return;
- }
if (PositionWindowInScreenCoordinates(window)) {
// The caller expects windows we consider "embedded" to be placed in the
// screen coordinate system. So we need to offset the root window's
// position (which is in screen coordinates) from these bounds.
+
+ gfx::Point origin = bounds.origin();
+ aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
+
gfx::Point host_origin = GetOrigin(root);
origin.Offset(-host_origin.x(), -host_origin.y());
window->SetBounds(gfx::Rect(origin, bounds.size()));
diff --git a/ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc b/ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc
index 196f6e4..47ba5dc 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_position_client_unittest.cc
@@ -34,4 +34,45 @@ TEST_F(DesktopScreenPositionClientTest, PositionDialog) {
EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString());
}
+// Verifies that setting the bounds of a control parented to something other
+// than the root window is positioned correctly.
+TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) {
+ Widget widget1;
+ Widget widget2;
+ Widget widget3;
+ gfx::Point origin = gfx::Point(16, 16);
+
+ // Create 3 windows. A root window, an arbitrary window parented to the root
+ // but NOT positioned at (0,0) relative to the root, and then a third window
+ // parented to the second, also not positioned at (0,0).
+ Widget::InitParams params1 =
+ CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params1.bounds = gfx::Rect(origin, gfx::Size(700, 600));
+ params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params1.native_widget = new DesktopNativeWidgetAura(&widget1);
+ widget1.Init(params1);
+
+ Widget::InitParams params2 =
+ CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params2.bounds = gfx::Rect(origin, gfx::Size(600, 500));
+ params2.parent = widget1.GetNativeView();
+ params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params2.child = true;
+ widget2.Init(params2);
+
+ Widget::InitParams params3 =
+ CreateParams(Widget::InitParams::TYPE_CONTROL);
+ params3.parent = widget2.GetNativeView();
+ params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params3.child = true;
+ params3.bounds = gfx::Rect(origin, gfx::Size(500, 400));
+ widget3.Init(params3);
+
+ // The origin of the 3rd window should be the sum of all parent origins.
+ gfx::Point expected_origin(origin.x() * 3, origin.y() * 3);
+ gfx::Rect expected_bounds(expected_origin, gfx::Size(500, 400));
+ gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen());
+ EXPECT_EQ(expected_bounds.ToString(), actual_bounds.ToString());
+}
+
} // namespace views