From 75b7fa4b986034c967aec20d543d61be544808fe Mon Sep 17 00:00:00 2001 From: David Parks Date: Wed, 4 Feb 2015 04:00:28 -0800 Subject: [PATCH] Bug 1075670 - [e10s] event.screenX and event.screenY is wrong Change the PuppetWidget from defining screen coordinates from tab-content-relative to being based on actual screen geometry. PuppetWidgets can have position. In the parent process, the widget has a position and a separate client position (that includes OS window chrome... on Linux and Windows as others have no chrome). In the child process, the widget (non-origin) position, whose calculation compensates for the OS window decoration. --- dom/ipc/TabChild.cpp | 2 +- dom/ipc/TabParent.cpp | 9 ++++++++- widget/PuppetWidget.cpp | 7 +++++++ widget/PuppetWidget.h | 12 ++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index b74ce4bffeb..63d7ccf8d83 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2051,7 +2051,7 @@ TabChild::RecvUpdateDimensions(const nsIntRect& rect, const nsIntSize& size, ScreenIntSize oldScreenSize = mInnerSize; mInnerSize = ScreenIntSize::FromUnknownSize( gfx::IntSize(size.width, size.height)); - mWidget->Resize(0, 0, size.width, size.height, + mWidget->Resize(rect.x + chromeDisp.x, rect.y + chromeDisp.y, size.width, size.height, true); nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 39dc1c5b4d5..794a955f4b3 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -896,8 +896,15 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size) if (!mUpdatedDimensions || mOrientation != orientation || mDimensions != size || !mRect.IsEqualEdges(rect)) { + nsCOMPtr widget = GetWidget(); + nsIntRect contentRect = rect; + if (widget) { + contentRect.x += widget->GetClientOffset().x; + contentRect.y += widget->GetClientOffset().y; + } + mUpdatedDimensions = true; - mRect = rect; + mRect = contentRect; mDimensions = size; mOrientation = orientation; diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index d1194ff8c7f..f8555773db8 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -960,6 +960,13 @@ PuppetWidget::GetWindowPosition() return nsIntPoint(winX, winY); } +NS_METHOD +PuppetWidget::GetScreenBounds(nsIntRect &aRect) { + aRect.MoveTo(WidgetToScreenOffset()); + aRect.SizeTo(mBounds.Size()); + return NS_OK; +} + PuppetScreen::PuppetScreen(void *nativeScreen) { } diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 45c64ca18af..629876e3645 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -92,8 +92,14 @@ public: double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE - // Widget position is controlled by the parent process via TabChild. - { return Resize(aWidth, aHeight, aRepaint); } + { + if (mBounds.x != aX || mBounds.y != aY) { + NotifyWindowMoved(aX, aY); + } + mBounds.x = aX; + mBounds.y = aY; + return Resize(aWidth, aHeight, aRepaint); + } // XXX/cjones: copying gtk behavior here; unclear what disabling a // widget is supposed to entail @@ -197,6 +203,8 @@ public: // Get the screen position of the application window. nsIntPoint GetWindowPosition(); + NS_IMETHOD GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE; + protected: bool mEnabled; bool mVisible;