Commit 22ce0039 authored by calamity@chromium.org's avatar calamity@chromium.org

Make WebContents get the correct screen coordinates when initially added.

This CL fixes an issue where combobox dropdowns would render in the wrong
place for tabs that were created in the background. This was happening
because the native view and clipping windows weren't being added in the
right order, causing the incorrect screen space coordinates to get
passed around.

BUG=394715

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284913 0039d316-1c4b-4281-b951-d872f2087c98
parent 67074f88
......@@ -200,14 +200,14 @@ void NativeViewHostAura::AddClippingWindow() {
RemoveClippingWindow();
gfx::Rect bounds = host_->native_view()->bounds();
host_->native_view()->SetProperty(aura::client::kHostWindowKey,
host_->GetWidget()->GetNativeView());
Widget::ReparentNativeView(host_->native_view(),
&clipping_window_);
if (host_->GetWidget()->GetNativeView()) {
Widget::ReparentNativeView(&clipping_window_,
host_->GetWidget()->GetNativeView());
}
host_->native_view()->SetProperty(aura::client::kHostWindowKey,
host_->GetWidget()->GetNativeView());
Widget::ReparentNativeView(host_->native_view(),
&clipping_window_);
clipping_window_.SetBounds(bounds);
bounds.set_origin(gfx::Point(0, 0));
host_->native_view()->SetBounds(bounds);
......
......@@ -135,9 +135,10 @@ TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) {
test_view,
host));
#if defined(USE_AURA)
// One notification is generated from inserting the native view into the
// clipping window.
EXPECT_EQ(1, test_view->notification_count());
// Two notifications are generated from inserting the native view into the
// clipping window and then inserting the clipping window into the root
// window.
EXPECT_EQ(2, test_view->notification_count());
#else
EXPECT_EQ(0, test_view->notification_count());
#endif
......@@ -160,13 +161,14 @@ TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) {
// Attaching should send a NativeViewHierarchyChanged() notification and
// reset the parent.
host->Attach(child->GetNativeView());
EXPECT_EQ(1, test_view->notification_count());
#if defined(USE_AURA)
// There is a clipping window inserted above the native view that needs to be
// accounted for when looking at the relationship between the native views.
EXPECT_EQ(2, test_view->notification_count());
EXPECT_EQ(toplevel()->GetNativeView(),
GetNativeParent(GetNativeParent(child->GetNativeView())));
#else
EXPECT_EQ(1, test_view->notification_count());
EXPECT_EQ(toplevel()->GetNativeView(),
GetNativeParent(child->GetNativeView()));
#endif
......
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