From 27cd4c3c96c3ac903d182eb11503e95048de653b Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Wed, 11 Feb 2015 16:03:06 +0100 Subject: [PATCH] Backed out 6 changesets (bug 1075670) for bustage on a CLOSED TREE Backed out changeset 4d68750b4e28 (bug 1075670) Backed out changeset 4d34eb58c46d (bug 1075670) Backed out changeset d3ac4fd82311 (bug 1075670) Backed out changeset 8b72b1201661 (bug 1075670) Backed out changeset cd6cf15b27cc (bug 1075670) Backed out changeset bf710daef92b (bug 1075670) --- browser/base/content/tabbrowser.xml | 3 +- dom/base/nsFrameLoader.cpp | 6 +- dom/base/nsFrameLoader.h | 6 +- dom/ipc/TabChild.cpp | 2 +- dom/ipc/TabParent.cpp | 59 ++----------------- dom/ipc/TabParent.h | 10 +--- dom/plugins/base/nsPluginInstanceOwner.cpp | 9 +-- embedding/browser/nsDocShellTreeOwner.cpp | 11 +--- layout/generic/nsSubDocumentFrame.cpp | 21 +++++++ layout/generic/nsSubDocumentFrame.h | 2 + .../components/satchel/AutoCompleteE10S.jsm | 5 +- toolkit/content/widgets/browser.xml | 22 ++++++- toolkit/content/widgets/remote-browser.xml | 21 +++++++ toolkit/modules/SelectParentHelper.jsm | 3 +- widget/PuppetWidget.cpp | 7 --- widget/PuppetWidget.h | 17 ++---- xpfe/appshell/nsWebShellWindow.cpp | 11 ---- 17 files changed, 100 insertions(+), 115 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 018a7ef7943..b8c7c374626 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -3202,7 +3202,8 @@ addonInfo: aMessage.data.addonInfo }; let popup = browser.ownerDocument.getElementById("contentAreaContextMenu"); let event = gContextMenuContentData.event; - popup.openPopupAtScreen(event.screenX, event.screenY, true); + let pos = browser.mapScreenCoordinatesFromContent(event.screenX, event.screenY); + popup.openPopupAtScreen(pos.x, pos.y, true); break; } case "DOMWebNotificationClicked": { diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index f99bec98150..172a5745222 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -914,7 +914,8 @@ nsFrameLoader::ShowRemoteFrame(const nsIntSize& size, // Don't show remote iframe if we are waiting for the completion of reflow. if (!aFrame || !(aFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { - mRemoteBrowser->UpdateDimensions(dimensions, size); + nsIntPoint chromeDisp = aFrame->GetChromeDisplacement(); + mRemoteBrowser->UpdateDimensions(dimensions, size, chromeDisp); } } @@ -1959,7 +1960,8 @@ nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame *aIFrame) nsIntSize size = aIFrame->GetSubdocumentSize(); nsIntRect dimensions; NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE); - mRemoteBrowser->UpdateDimensions(dimensions, size); + nsIntPoint chromeDisp = aIFrame->GetChromeDisplacement(); + mRemoteBrowser->UpdateDimensions(dimensions, size, chromeDisp); } return NS_OK; } diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index 71ce9fb37f0..43b3acdab6f 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -227,9 +227,6 @@ public: void ActivateUpdateHitRegion(); void DeactivateUpdateHitRegion(); - // Properly retrieves documentSize of any subdocument type. - nsresult GetWindowDimensions(nsIntRect& aRect); - private: void SetOwnerContent(mozilla::dom::Element* aContent); @@ -285,6 +282,9 @@ private: nsresult MaybeCreateDocShell(); nsresult EnsureMessageManager(); + // Properly retrieves documentSize of any subdocument type. + nsresult GetWindowDimensions(nsIntRect& aRect); + // Updates the subdocument position and size. This gets called only // when we have our own in-process DocShell. void UpdateBaseWindowPositionAndSize(nsSubDocumentFrame *aIFrame); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 63d7ccf8d83..b74ce4bffeb 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(rect.x + chromeDisp.x, rect.y + chromeDisp.y, size.width, size.height, + mWidget->Resize(0, 0, size.width, size.height, true); nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 794a955f4b3..062aa8744e1 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -78,7 +78,6 @@ #include "nsICancelable.h" #include "gfxPrefs.h" #include "nsILoginManagerPrompter.h" -#include "nsPIWindowRoot.h" #include using namespace mozilla::dom; @@ -319,27 +318,7 @@ TabParent::RemoveTabParentFromTable(uint64_t aLayersId) void TabParent::SetOwnerElement(Element* aElement) { - // If we held previous content then unregister for its events. - if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) { - nsCOMPtr window = mFrameElement->OwnerDoc()->GetWindow(); - nsCOMPtr eventTarget = window->GetTopWindowRoot(); - if (eventTarget) { - eventTarget->RemoveEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"), - this, false); - } - } - - // Update to the new content, and register to listen for events from it. mFrameElement = aElement; - if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) { - nsCOMPtr window = mFrameElement->OwnerDoc()->GetWindow(); - nsCOMPtr eventTarget = window->GetTopWindowRoot(); - if (eventTarget) { - eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"), - this, false, false); - } - } - TryCacheDPIAndScale(); } @@ -375,8 +354,6 @@ TabParent::Destroy() return; } - SetOwnerElement(nullptr); - // If this fails, it's most likely due to a content-process crash, // and auto-cleanup will kick in. Otherwise, the child side will // destroy itself and send back __delete__(). @@ -885,7 +862,8 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags, } void -TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size) +TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size, + const nsIntPoint& aChromeDisp) { if (mIsDestroyed) { return; @@ -896,20 +874,12 @@ 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 = contentRect; + mRect = rect; mDimensions = size; mOrientation = orientation; - nsIntPoint chromeOffset = -GetChildProcessOffset(); - unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, chromeOffset); + unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, aChromeDisp); } } @@ -2672,27 +2642,6 @@ TabParent::DeallocPPluginWidgetParent(mozilla::plugins::PPluginWidgetParent* aAc return true; } -nsresult -TabParent::HandleEvent(nsIDOMEvent* aEvent) -{ - nsAutoString eventType; - aEvent->GetType(eventType); - - if (eventType.EqualsLiteral("MozUpdateWindowPos")) { - // This event is sent when the widget moved. Therefore we only update - // the position. - nsRefPtr frameLoader = GetFrameLoader(); - if (!frameLoader) { - return NS_OK; - } - nsIntRect windowDims; - NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE); - UpdateDimensions(windowDims, mDimensions); - return NS_OK; - } - return NS_OK; -} - class FakeChannel MOZ_FINAL : public nsIChannel, public nsIAuthPromptCallback, public nsIInterfaceRequestor, diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 295ef45ee9e..55b69835ad5 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -22,7 +22,6 @@ #include "Units.h" #include "WritingModes.h" #include "js/TypeDecls.h" -#include "nsIDOMEventListener.h" class nsFrameLoader; class nsIFrameLoader; @@ -59,8 +58,7 @@ class nsIContentParent; class Element; struct StructuredCloneData; -class TabParent : public PBrowserParent - , public nsIDOMEventListener +class TabParent : public PBrowserParent , public nsITabParent , public nsIAuthPromptProvider , public nsISecureBrowserUI @@ -101,9 +99,6 @@ public: mBrowserDOMWindow = aBrowserDOMWindow; } - // nsIDOMEventListener interfaces - NS_DECL_NSIDOMEVENTLISTENER - already_AddRefed GetLoadContext(); nsIXULBrowserWindow* GetXULBrowserWindow(); @@ -241,7 +236,8 @@ public: // message-sending functions under a layer of indirection and // eating the return values void Show(const nsIntSize& size, bool aParentIsActive); - void UpdateDimensions(const nsIntRect& rect, const nsIntSize& size); + void UpdateDimensions(const nsIntRect& rect, const nsIntSize& size, + const nsIntPoint& chromeDisp); void UpdateFrame(const layers::FrameMetrics& aFrameMetrics); void UIResolutionChanged(); void AcknowledgeScrollUpdate(const ViewID& aScrollId, const uint32_t& aScrollGeneration); diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index a1416b6a935..53020b03efd 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -789,6 +789,7 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget, tabContentBounds.ScaleInverseRoundOut(scaleFactor); int32_t windowH = tabContentBounds.height + int(chromeSize.y); + // This is actually relative to window-chrome. nsPoint pluginPosition = AsNsPoint(pluginFrame->GetScreenRect().TopLeft()); // Convert (sourceX, sourceY) to 'real' (not PuppetWidget) screen space. @@ -798,8 +799,8 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget, nsPoint screenPoint; switch (sourceSpace) { case NPCoordinateSpacePlugin: - screenPoint = sourcePoint + pluginPosition + - pluginFrame->GetContentRectRelativeToSelf().TopLeft() / nsPresContext::AppUnitsPerCSSPixel(); + screenPoint = sourcePoint + pluginFrame->GetContentRectRelativeToSelf().TopLeft() + + chromeSize + pluginPosition + windowPosition; break; case NPCoordinateSpaceWindow: screenPoint = nsPoint(sourcePoint.x, windowH-sourcePoint.y) + @@ -822,8 +823,8 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget, nsPoint destPoint; switch (destSpace) { case NPCoordinateSpacePlugin: - destPoint = screenPoint - pluginPosition - - pluginFrame->GetContentRectRelativeToSelf().TopLeft() / nsPresContext::AppUnitsPerCSSPixel(); + destPoint = screenPoint - pluginFrame->GetContentRectRelativeToSelf().TopLeft() - + chromeSize - pluginPosition - windowPosition; break; case NPCoordinateSpaceWindow: destPoint = screenPoint - windowPosition; diff --git a/embedding/browser/nsDocShellTreeOwner.cpp b/embedding/browser/nsDocShellTreeOwner.cpp index d4096c12d1b..4787a2c2408 100644 --- a/embedding/browser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/nsDocShellTreeOwner.cpp @@ -1453,14 +1453,9 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, if (textFound) { nsString tipText(tooltipText); LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset(); - double scaleFactor = 1.0; - if (shell->GetPresContext()) { - scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/ - shell->GetPresContext()->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom(); - } - // ShowTooltip expects widget-relative position. - self->ShowTooltip(self->mMouseScreenX - screenDot.x / scaleFactor, - self->mMouseScreenY - screenDot.y / scaleFactor, + self->ShowTooltip(self->mMouseScreenX - screenDot.x, + self->mMouseScreenY - screenDot.y, + tipText); } } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index a470a66b952..4a74295513a 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -1274,3 +1274,24 @@ nsSubDocumentFrame::ObtainIntrinsicSizeFrame() } return nullptr; } + +nsIntPoint +nsSubDocumentFrame::GetChromeDisplacement() +{ + nsIFrame* nextFrame = nsLayoutUtils::GetCrossDocParentFrame(this); + if (!nextFrame) { + NS_WARNING("Couldn't find window chrome to calculate displacement to."); + return nsIntPoint(); + } + + nsIFrame* rootFrame = nextFrame; + while (nextFrame) { + rootFrame = nextFrame; + nextFrame = nsLayoutUtils::GetCrossDocParentFrame(rootFrame); + } + + nsPoint offset = GetOffsetToCrossDoc(rootFrame); + int32_t appUnitsPerDevPixel = rootFrame->PresContext()->AppUnitsPerDevPixel(); + return nsIntPoint((int)(offset.x/appUnitsPerDevPixel), + (int)(offset.y/appUnitsPerDevPixel)); +} diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index f409f3bd475..788e4d8d9b6 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -127,6 +127,8 @@ public: */ bool PassPointerEventsToChildren(); + nsIntPoint GetChromeDisplacement(); + protected: friend class AsyncFrameInit; diff --git a/toolkit/components/satchel/AutoCompleteE10S.jsm b/toolkit/components/satchel/AutoCompleteE10S.jsm index 1e506fd97b2..3928b273dec 100644 --- a/toolkit/components/satchel/AutoCompleteE10S.jsm +++ b/toolkit/components/satchel/AutoCompleteE10S.jsm @@ -81,8 +81,9 @@ this.AutoCompleteE10S = { this.popup.hidden = false; this.popup.setAttribute("width", rect.width); - this.x = rect.left; - this.y = rect.top + rect.height; + let {x, y} = this.browser.mapScreenCoordinatesFromContent(rect.left, rect.top + rect.height); + this.x = x; + this.y = y; }, _showPopup: function(results) { diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 9b172878861..67f449409c8 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -868,7 +868,8 @@ if (!this.autoscrollEnabled) { return false; } - this.startScroll(data.scrolldir, data.screenX, data.screenY); + let pos = this.mapScreenCoordinatesFromContent(data.screenX, data.screenY); + this.startScroll(data.scrolldir, pos.x, pos.y); return true; } case "Autoscroll:Cancel": @@ -1049,6 +1050,25 @@ + + + + + + + + + diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index 9b0d4300401..45eb3ca2b8a 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -385,6 +385,27 @@ ]]> + + + + + + + + + diff --git a/toolkit/modules/SelectParentHelper.jsm b/toolkit/modules/SelectParentHelper.jsm index 60a179fa023..5d6b8742508 100644 --- a/toolkit/modules/SelectParentHelper.jsm +++ b/toolkit/modules/SelectParentHelper.jsm @@ -28,7 +28,8 @@ this.SelectParentHelper = { currentBrowser = browser; this._registerListeners(menulist.menupopup); - menulist.menupopup.openPopupAtScreen(rect.left, rect.top + rect.height); + let {x, y} = browser.mapScreenCoordinatesFromContent(rect.left, rect.top + rect.height); + menulist.menupopup.openPopupAtScreen(x, y); menulist.selectedItem.scrollIntoView(); }, diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index f8555773db8..d1194ff8c7f 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -960,13 +960,6 @@ 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 629876e3645..fd2689002f1 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -80,7 +80,7 @@ public: int32_t* aY) MOZ_OVERRIDE { *aX = kMaxDimension; *aY = kMaxDimension; return NS_OK; } - // Widget position is controlled by the parent process via TabChild. + // We're always at <0, 0>, and so ignore move requests. NS_IMETHOD Move(double aX, double aY) MOZ_OVERRIDE { return NS_OK; } @@ -92,14 +92,8 @@ public: double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE - { - if (mBounds.x != aX || mBounds.y != aY) { - NotifyWindowMoved(aX, aY); - } - mBounds.x = aX; - mBounds.y = aY; - return Resize(aWidth, aHeight, aRepaint); - } + // (we're always at <0, 0>) + { return Resize(aWidth, aHeight, aRepaint); } // XXX/cjones: copying gtk behavior here; unclear what disabling a // widget is supposed to entail @@ -129,8 +123,9 @@ public: NS_IMETHOD SetTitle(const nsAString& aTitle) MOZ_OVERRIDE { return NS_ERROR_UNEXPECTED; } + // PuppetWidgets are always at <0, 0>. virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE - { return GetWindowPosition() + GetChromeDimensions(); } + { return mozilla::LayoutDeviceIntPoint(0, 0); } void InitEvent(WidgetGUIEvent& aEvent, nsIntPoint* aPoint = nullptr); @@ -203,8 +198,6 @@ public: // Get the screen position of the application window. nsIntPoint GetWindowPosition(); - NS_IMETHOD GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE; - protected: bool mEnabled; bool mVisible; diff --git a/xpfe/appshell/nsWebShellWindow.cpp b/xpfe/appshell/nsWebShellWindow.cpp index 65acc462a74..2f42e8aa565 100644 --- a/xpfe/appshell/nsWebShellWindow.cpp +++ b/xpfe/appshell/nsWebShellWindow.cpp @@ -71,8 +71,6 @@ #include "mozilla/DebugOnly.h" #include "mozilla/MouseEvents.h" -#include "nsPIWindowRoot.h" - #ifdef XP_MACOSX #include "nsINativeMenuService.h" #define USE_NATIVE_MENUS @@ -259,15 +257,6 @@ nsWebShellWindow::WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) pm->AdjustPopupsOnWindowChange(window); } - // Notify all tabs that the widget moved. - if (mDocShell && mDocShell->GetWindow()) { - nsCOMPtr eventTarget = mDocShell->GetWindow()->GetTopWindowRoot(); - nsContentUtils::DispatchChromeEvent(mDocShell->GetDocument(), - eventTarget, - NS_LITERAL_STRING("MozUpdateWindowPos"), - false, false, nullptr); - } - // Persist position, but not immediately, in case this OS is firing // repeated move events as the user drags the window SetPersistenceTimer(PAD_POSITION);