Skip to content

Commit

Permalink
Backed out 7 changesets (bug 1075670) for e10s browser_586068-browser…
Browse files Browse the repository at this point in the history
…_state_interrupted.js crashes.

Backed out changeset 4ca74b217fe8 (bug 1075670)
Backed out changeset 83199cfc333f (bug 1075670)
Backed out changeset 065b859e6525 (bug 1075670)
Backed out changeset a3e8329610d9 (bug 1075670)
Backed out changeset ced9055e0bcc (bug 1075670)
Backed out changeset e6d6f0c11133 (bug 1075670)
Backed out changeset b823c6c95030 (bug 1075670)

CLOSED TREE
  • Loading branch information
rvandermeulen committed Feb 24, 2015
1 parent 59b700c commit ec8d751
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 146 deletions.
3 changes: 2 additions & 1 deletion browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,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": {
Expand Down
6 changes: 4 additions & 2 deletions dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions dom/base/nsFrameLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ class nsFrameLoader MOZ_FINAL : public nsIFrameLoader,
void ActivateUpdateHitRegion();
void DeactivateUpdateHitRegion();

// Properly retrieves documentSize of any subdocument type.
nsresult GetWindowDimensions(nsIntRect& aRect);

private:

void SetOwnerContent(mozilla::dom::Element* aContent);
Expand Down Expand Up @@ -285,6 +282,9 @@ class nsFrameLoader MOZ_FINAL : public nsIFrameLoader,
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);
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/TabChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,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<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
Expand Down
89 changes: 4 additions & 85 deletions dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
#include "nsICancelable.h"
#include "gfxPrefs.h"
#include "nsILoginManagerPrompter.h"
#include "nsPIWindowRoot.h"
#include <algorithm>

using namespace mozilla::dom;
Expand Down Expand Up @@ -322,27 +321,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<nsPIDOMWindow> window = mFrameElement->OwnerDoc()->GetWindow();
nsCOMPtr<EventTarget> 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<nsPIDOMWindow> window = mFrameElement->OwnerDoc()->GetWindow();
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
if (eventTarget) {
eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
this, false, false);
}
}

TryCacheDPIAndScale();
}

Expand Down Expand Up @@ -378,8 +357,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__().
Expand Down Expand Up @@ -906,36 +883,9 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags,
return false;
}

static nsIntPoint
GetChromeDisplacement(nsFrameLoader *aFrameLoader)
{
if (!aFrameLoader) {
return nsIntPoint();
}

// Calculate the displacement from the primary frame of the tab
// content to the top-level frame of the widget we are in.
nsIFrame* contentFrame = aFrameLoader->GetPrimaryFrameOfOwningContent();
nsIFrame* nextFrame = nsLayoutUtils::GetCrossDocParentFrame(contentFrame);
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 = contentFrame->GetOffsetToCrossDoc(rootFrame);
int32_t appUnitsPerDevPixel = rootFrame->PresContext()->AppUnitsPerDevPixel();
return nsIntPoint((int)(offset.x/appUnitsPerDevPixel),
(int)(offset.y/appUnitsPerDevPixel));
}

void
TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size)
TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size,
const nsIntPoint& aChromeDisp)
{
if (mIsDestroyed) {
return;
Expand All @@ -946,22 +896,12 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size)

if (!mUpdatedDimensions || mOrientation != orientation ||
mDimensions != size || !mRect.IsEqualEdges(rect)) {
nsCOMPtr<nsIWidget> 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;

nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
nsIntPoint chromeOffset = GetChromeDisplacement(frameLoader);

unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, chromeOffset);
unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, aChromeDisp);
}
}

Expand Down Expand Up @@ -2728,27 +2668,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<nsFrameLoader> 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,
Expand Down
10 changes: 3 additions & 7 deletions dom/ipc/TabParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "Units.h"
#include "WritingModes.h"
#include "js/TypeDecls.h"
#include "nsIDOMEventListener.h"

class nsFrameLoader;
class nsIFrameLoader;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -101,9 +99,6 @@ class TabParent : public PBrowserParent
mBrowserDOMWindow = aBrowserDOMWindow;
}

// nsIDOMEventListener interfaces
NS_DECL_NSIDOMEVENTLISTENER

already_AddRefed<nsILoadContext> GetLoadContext();

nsIXULBrowserWindow* GetXULBrowserWindow();
Expand Down Expand Up @@ -247,7 +242,8 @@ class TabParent : public PBrowserParent
// 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);
Expand Down
9 changes: 5 additions & 4 deletions dom/plugins/base/nsPluginInstanceOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) +
Expand All @@ -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;
Expand Down
12 changes: 3 additions & 9 deletions embedding/browser/nsDocShellTreeOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,15 +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,
tipText);
self->ShowTooltip(self->mMouseScreenX - screenDot.x,
self->mMouseScreenY - screenDot.y,
tipText);
}
}

Expand Down
21 changes: 21 additions & 0 deletions layout/generic/nsSubDocumentFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
2 changes: 2 additions & 0 deletions layout/generic/nsSubDocumentFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class nsSubDocumentFrame : public nsLeafFrame,
*/
bool PassPointerEventsToChildren();

nsIntPoint GetChromeDisplacement();

protected:
friend class AsyncFrameInit;

Expand Down
5 changes: 3 additions & 2 deletions toolkit/components/satchel/AutoCompleteE10S.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 21 additions & 1 deletion toolkit/content/widgets/browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,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":
Expand Down Expand Up @@ -1058,6 +1059,25 @@
</body>
</method>

<!--
For out-of-process code, event.screen[XY] is relative to the
left/top of the content view. For in-process code,
event.screen[XY] is relative to the left/top of the screen. We
use this method to map screen coordinates received from a
(possibly out-of-process) <browser> element to coordinates
that are relative to the screen. This code handles the
in-process case, where we return the coordinates unchanged.
-->
<method name="mapScreenCoordinatesFromContent">
<parameter name="aScreenX"/>
<parameter name="aScreenY"/>
<body>
<![CDATA[
return { x: aScreenX, y: aScreenY };
]]>
</body>
</method>

<method name="swapDocShells">
<parameter name="aOtherBrowser"/>
<body>
Expand Down
21 changes: 21 additions & 0 deletions toolkit/content/widgets/remote-browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,27 @@
]]></body>
</method>

<!--
For out-of-process code, event.screen[XY] is relative to the
left/top of the content view. For in-process code,
event.screen[XY] is relative to the left/top of the screen. We
use this method to map screen coordinates received from a
(possibly out-of-process) <browser> element to coordinates
that are relative to the screen. This code handles the
out-of-process case, where we need to translate by the screen
position of the <browser> element.
-->
<method name="mapScreenCoordinatesFromContent">
<parameter name="aScreenX"/>
<parameter name="aScreenY"/>
<body>
<![CDATA[
return { x: aScreenX + this.boxObject.screenX,
y: aScreenY + this.boxObject.screenY };
]]>
</body>
</method>

<method name="enableDisableCommands">
<parameter name="aAction"/>
<parameter name="aEnabledLength"/>
Expand Down
Loading

0 comments on commit ec8d751

Please sign in to comment.