Backed out changeset 05a5f9d8249f (bug 1343728)

This commit is contained in:
Sebastian Hengst 2017-06-16 22:20:37 +02:00
Родитель e8cca2e7cf
Коммит 7e1b1cf069
9 изменённых файлов: 117 добавлений и 186 удалений

Просмотреть файл

@ -857,17 +857,6 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
uint32_t maxTouchPoints = 0; uint32_t maxTouchPoints = 0;
DimensionInfo dimensionInfo; DimensionInfo dimensionInfo;
nsCOMPtr<nsPIDOMWindowInner> parentTopInnerWindow;
if (aParent) {
nsCOMPtr<nsPIDOMWindowOuter> parentTopWindow =
nsPIDOMWindowOuter::From(aParent)->GetTop();
if (parentTopWindow) {
parentTopInnerWindow = parentTopWindow->GetCurrentInnerWindow();
}
}
// Send down the request to open the window.
RefPtr<CreateWindowPromise> windowCreated;
if (aIframeMoz) { if (aIframeMoz) {
MOZ_ASSERT(aTabOpener); MOZ_ASSERT(aTabOpener);
nsAutoCString url; nsAutoCString url;
@ -880,11 +869,10 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
url.SetIsVoid(true); url.SetIsVoid(true);
} }
// NOTE: BrowserFrameOpenWindowPromise is the same type as newChild->SendBrowserFrameOpenWindow(aTabOpener, renderFrame, NS_ConvertUTF8toUTF16(url),
// CreateWindowPromise, and this code depends on that fact. name, NS_ConvertUTF8toUTF16(features),
windowCreated = aWindowIsNew, &textureFactoryIdentifier,
newChild->SendBrowserFrameOpenWindow(aTabOpener, renderFrame, NS_ConvertUTF8toUTF16(url), &layersId, &compositorOptions, &maxTouchPoints);
name, NS_ConvertUTF8toUTF16(features));
} else { } else {
nsAutoCString baseURIString; nsAutoCString baseURIString;
float fullZoom; float fullZoom;
@ -893,89 +881,30 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
return rv; return rv;
} }
windowCreated = if (!SendCreateWindow(aTabOpener, newChild, renderFrame,
SendCreateWindow(aTabOpener, newChild, renderFrame, aChromeFlags, aCalledFromJS, aPositionSpecified,
aChromeFlags, aCalledFromJS, aPositionSpecified, aSizeSpecified,
aSizeSpecified, features,
features, baseURIString,
baseURIString, fullZoom,
fullZoom); &rv,
} aWindowIsNew,
&frameScripts,
// Await the promise being resolved. When the promise is resolved, we'll set &urlToLoad,
// the `ready` local variable, which will cause us to exit our nested event &textureFactoryIdentifier,
// loop. &layersId,
bool ready = false; &compositorOptions,
windowCreated->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__, &maxTouchPoints,
[&] (const CreatedWindowInfo& info) { &dimensionInfo)) {
rv = info.rv(); PRenderFrameChild::Send__delete__(renderFrame);
*aWindowIsNew = info.windowOpened(); return NS_ERROR_NOT_AVAILABLE;
frameScripts = info.frameScripts();
urlToLoad = info.urlToLoad();
textureFactoryIdentifier = info.textureFactoryIdentifier();
layersId = info.layersId();
compositorOptions = info.compositorOptions();
maxTouchPoints = info.maxTouchPoints();
dimensionInfo = info.dimensions();
ready = true;
},
[&] (const CreateWindowPromise::RejectValueType aReason) {
NS_WARNING("windowCreated promise rejected");
rv = NS_ERROR_NOT_AVAILABLE;
ready = true;
});
// =======================
// Begin Nested Event Loop
// =======================
// We have to wait for a response from either SendCreateWindow or
// SendBrowserFrameOpenWindow with information we're going to need to return
// from this function, So we spin a nested event loop until they get back to
// us.
// Prevent the docshell from becoming active while the nested event loop is
// spinning.
newChild->AddPendingDocShellBlocker();
auto removePendingDocShellBlocker = MakeScopeExit([&] {
if (newChild) {
newChild->RemovePendingDocShellBlocker();
} }
});
// Suspend our window if we have one to make sure we don't re-enter it. if (NS_FAILED(rv)) {
if (parentTopInnerWindow) { PRenderFrameChild::Send__delete__(renderFrame);
parentTopInnerWindow->Suspend(); return rv;
}
} }
{
AutoNoJSAPI nojsapi;
// Spin the event loop until we get a response. Callers of this function
// already have to guard against an inner event loop spinning in the
// non-e10s case because of the need to spin one to create a new chrome
// window.
SpinEventLoopUntil([&] () { return ready; });
MOZ_RELEASE_ASSERT(ready,
"We are on the main thread, so we should not exit this "
"loop without ready being true.");
}
if (parentTopInnerWindow) {
parentTopInnerWindow->Resume();
}
// =====================
// End Nested Event Loop
// =====================
// Handle the error which we got back from the parent process, if we got
// one.
if (NS_FAILED(rv)) {
PRenderFrameChild::Send__delete__(renderFrame);
return rv;
}
if (!*aWindowIsNew) { if (!*aWindowIsNew) {
PRenderFrameChild::Send__delete__(renderFrame); PRenderFrameChild::Send__delete__(renderFrame);
return NS_ERROR_ABORT; return NS_ERROR_ABORT;

Просмотреть файл

@ -4630,28 +4630,25 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const float& aFullZoom, const float& aFullZoom,
CreateWindowResolver&& aResolve) nsresult* aResult,
bool* aWindowIsNew,
InfallibleTArray<FrameScriptInfo>* aFrameScripts,
nsCString* aURLToLoad,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId,
CompositorOptions* aCompositorOptions,
uint32_t* aMaxTouchPoints,
DimensionInfo* aDimensions)
{ {
nsresult rv = NS_OK;
CreatedWindowInfo cwi;
// We always expect to open a new window here. If we don't, it's an error. // We always expect to open a new window here. If we don't, it's an error.
cwi.windowOpened() = true; *aWindowIsNew = true;
*aResult = NS_OK;
// Make sure to resolve the resolver when this function exits, even if we
// failed to generate a valid response.
auto resolveOnExit = MakeScopeExit([&] {
// Copy over the nsresult, and then resolve.
cwi.rv() = rv;
aResolve(cwi);
});
TabParent* newTab = TabParent::GetFrom(aNewTab); TabParent* newTab = TabParent::GetFrom(aNewTab);
MOZ_ASSERT(newTab); MOZ_ASSERT(newTab);
auto destroyNewTabOnError = MakeScopeExit([&] { auto destroyNewTabOnError = MakeScopeExit([&] {
// We always expect to open a new window here. If we don't, it's an error. if (!*aWindowIsNew || NS_FAILED(*aResult)) {
if (!cwi.windowOpened() || NS_FAILED(rv)) {
if (newTab) { if (newTab) {
newTab->Destroy(); newTab->Destroy();
} }
@ -4662,7 +4659,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
// we must have an opener. // we must have an opener.
newTab->SetHasContentOpener(true); newTab->SetHasContentOpener(true);
TabParent::AutoUseNewTab aunt(newTab, &cwi.urlToLoad()); TabParent::AutoUseNewTab aunt(newTab, aURLToLoad);
const uint64_t nextTabParentId = ++sNextTabParentId; const uint64_t nextTabParentId = ++sNextTabParentId;
sNextTabParents.Put(nextTabParentId, newTab); sNextTabParents.Put(nextTabParentId, newTab);
@ -4671,35 +4668,35 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
CommonCreateWindow(aThisTab, /* aSetOpener = */ true, aChromeFlags, CommonCreateWindow(aThisTab, /* aSetOpener = */ true, aChromeFlags,
aCalledFromJS, aPositionSpecified, aSizeSpecified, aCalledFromJS, aPositionSpecified, aSizeSpecified,
nullptr, aFeatures, aBaseURI, aFullZoom, nullptr, aFeatures, aBaseURI, aFullZoom,
nextTabParentId, NullString(), rv, nextTabParentId, NullString(), *aResult,
newRemoteTab, &cwi.windowOpened()); newRemoteTab, aWindowIsNew);
if (!ipcResult) { if (!ipcResult) {
return ipcResult; return ipcResult;
} }
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(*aResult))) {
return IPC_OK(); return IPC_OK();
} }
if (sNextTabParents.GetAndRemove(nextTabParentId).valueOr(nullptr)) { if (sNextTabParents.GetAndRemove(nextTabParentId).valueOr(nullptr)) {
cwi.windowOpened() = false; *aWindowIsNew = false;
} }
MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab); MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab);
newTab->SwapFrameScriptsFrom(cwi.frameScripts()); newTab->SwapFrameScriptsFrom(*aFrameScripts);
RenderFrameParent* rfp = static_cast<RenderFrameParent*>(aRenderFrame); RenderFrameParent* rfp = static_cast<RenderFrameParent*>(aRenderFrame);
if (!newTab->SetRenderFrame(rfp) || if (!newTab->SetRenderFrame(rfp) ||
!newTab->GetRenderFrameInfo(&cwi.textureFactoryIdentifier(), &cwi.layersId())) { !newTab->GetRenderFrameInfo(aTextureFactoryIdentifier, aLayersId)) {
rv = NS_ERROR_FAILURE; *aResult = NS_ERROR_FAILURE;
} }
cwi.compositorOptions() = rfp->GetCompositorOptions(); *aCompositorOptions = rfp->GetCompositorOptions();
nsCOMPtr<nsIWidget> widget = newTab->GetWidget(); nsCOMPtr<nsIWidget> widget = newTab->GetWidget();
if (widget) { *aMaxTouchPoints = widget ? widget->GetMaxTouchPoints() : 0;
cwi.maxTouchPoints() = widget->GetMaxTouchPoints();
cwi.dimensions() = newTab->GetDimensionInfo(); // NOTE: widget must be set for this to return a meaningful value.
} *aDimensions = widget ? newTab->GetDimensionInfo() : DimensionInfo();
return IPC_OK(); return IPC_OK();
} }

Просмотреть файл

@ -536,7 +536,15 @@ public:
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const float& aFullZoom, const float& aFullZoom,
CreateWindowResolver&& aResolve) override; nsresult* aResult,
bool* aWindowIsNew,
InfallibleTArray<FrameScriptInfo>* aFrameScripts,
nsCString* aURLToLoad,
layers::TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId,
mozilla::layers::CompositorOptions* aCompositorOptions,
uint32_t* aMaxTouchPoints,
DimensionInfo* aDimensions) override;
virtual mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess( virtual mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess(
PBrowserParent* aThisTab, PBrowserParent* aThisTab,

Просмотреть файл

@ -22,8 +22,6 @@ using CSSRect from "Units.h";
using CSSSize from "Units.h"; using CSSSize from "Units.h";
using mozilla::LayoutDeviceIntPoint from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h";
using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h"; using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -98,27 +96,5 @@ struct DimensionInfo
LayoutDeviceIntPoint chromeDisp; LayoutDeviceIntPoint chromeDisp;
}; };
struct FrameScriptInfo
{
nsString url;
bool runInGlobalScope;
};
/**
* The information required to complete a window creation request.
*/
struct CreatedWindowInfo
{
nsresult rv;
bool windowOpened;
FrameScriptInfo[] frameScripts;
nsCString urlToLoad;
TextureFactoryIdentifier textureFactoryIdentifier;
uint64_t layersId;
CompositorOptions compositorOptions;
uint32_t maxTouchPoints;
DimensionInfo dimensions;
};
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -459,9 +459,13 @@ parent:
* *
* @param opener the PBrowser whose content called window.open. * @param opener the PBrowser whose content called window.open.
*/ */
async BrowserFrameOpenWindow(PBrowser opener, PRenderFrame renderFrame, sync BrowserFrameOpenWindow(PBrowser opener, PRenderFrame renderFrame,
nsString aURL, nsString aName, nsString aFeatures) nsString aURL, nsString aName, nsString aFeatures)
returns (CreatedWindowInfo window); returns (bool windowOpened,
TextureFactoryIdentifier textureFactoryIdentifier,
uint64_t layersId,
CompositorOptions compositorOptions,
uint32_t maxTouchPoints);
/** /**
* Tells the containing widget whether the given input block results in a * Tells the containing widget whether the given input block results in a

Просмотреть файл

@ -176,6 +176,14 @@ struct DomainPolicyClone
URIParams[] superWhitelist; URIParams[] superWhitelist;
}; };
struct FrameScriptInfo
{
nsString url;
bool runInGlobalScope;
};
struct AndroidSystemInfo struct AndroidSystemInfo
{ {
nsString device; nsString device;
@ -979,17 +987,25 @@ parent:
sync GetGraphicsDeviceInitData() sync GetGraphicsDeviceInitData()
returns (ContentDeviceData aData); returns (ContentDeviceData aData);
async CreateWindow(nullable PBrowser aThisTab, sync CreateWindow(nullable PBrowser aThisTab,
PBrowser aNewTab, PBrowser aNewTab,
PRenderFrame aRenderFrame, PRenderFrame aRenderFrame,
uint32_t aChromeFlags, uint32_t aChromeFlags,
bool aCalledFromJS, bool aCalledFromJS,
bool aPositionSpecified, bool aPositionSpecified,
bool aSizeSpecified, bool aSizeSpecified,
nsCString aFeatures, nsCString aFeatures,
nsCString aBaseURI, nsCString aBaseURI,
float aFullZoom) float aFullZoom)
returns (CreatedWindowInfo window); returns (nsresult rv,
bool windowOpened,
FrameScriptInfo[] frameScripts,
nsCString urlToLoad,
TextureFactoryIdentifier textureFactoryIdentifier,
uint64_t layersId,
CompositorOptions compositorOptions,
uint32_t maxTouchPoints,
DimensionInfo dimensions);
async CreateWindowInDifferentProcess( async CreateWindowInDifferentProcess(
PBrowser aThisTab, PBrowser aThisTab,

Просмотреть файл

@ -2583,27 +2583,21 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
const nsString& aURL, const nsString& aURL,
const nsString& aName, const nsString& aName,
const nsString& aFeatures, const nsString& aFeatures,
BrowserFrameOpenWindowResolver&& aResolve) bool* aOutWindowOpened,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId,
CompositorOptions* aCompositorOptions,
uint32_t* aMaxTouchPoints)
{ {
CreatedWindowInfo cwi;
BrowserElementParent::OpenWindowResult opened = BrowserElementParent::OpenWindowResult opened =
BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener), BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener),
this, aRenderFrame, aURL, aName, aFeatures, this, aRenderFrame, aURL, aName, aFeatures,
&cwi.textureFactoryIdentifier(), aTextureFactoryIdentifier, aLayersId);
&cwi.layersId()); *aCompositorOptions = static_cast<RenderFrameParent*>(aRenderFrame)->GetCompositorOptions();
cwi.compositorOptions() = *aOutWindowOpened = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
static_cast<RenderFrameParent*>(aRenderFrame)->GetCompositorOptions();
cwi.windowOpened() = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
nsCOMPtr<nsIWidget> widget = GetWidget(); nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget) { *aMaxTouchPoints = widget ? widget->GetMaxTouchPoints() : 0;
cwi.maxTouchPoints() = widget->GetMaxTouchPoints(); if (!*aOutWindowOpened) {
cwi.dimensions() = GetDimensionInfo();
}
// Resolve the request with the information we collected.
aResolve(cwi);
if (!cwi.windowOpened()) {
Destroy(); Destroy();
} }
return IPC_OK(); return IPC_OK();

Просмотреть файл

@ -165,13 +165,16 @@ public:
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvSetHasBeforeUnload(const bool& aHasBeforeUnload) override; RecvSetHasBeforeUnload(const bool& aHasBeforeUnload) override;
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, PRenderFrameParent* aRenderFrame,
PRenderFrameParent* aRenderFrame, const nsString& aURL,
const nsString& aURL, const nsString& aName,
const nsString& aName, const nsString& aFeatures,
const nsString& aFeatures, bool* aOutWindowOpened,
BrowserFrameOpenWindowResolver&& aResolve) override; TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId,
CompositorOptions* aCompositorOptions,
uint32_t* aMaxTouchPoints) override;
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvSyncMessage(const nsString& aMessage, RecvSyncMessage(const nsString& aMessage,

Просмотреть файл

@ -839,6 +839,8 @@ description =
description = description =
[PBrowser::GetWidgetRounding] [PBrowser::GetWidgetRounding]
description = description =
[PBrowser::BrowserFrameOpenWindow]
description =
[PBrowser::RequestNativeKeyBindings] [PBrowser::RequestNativeKeyBindings]
description = description =
[PBrowser::GetTabCount] [PBrowser::GetTabCount]
@ -907,6 +909,8 @@ description =
description = description =
[PContent::GetGraphicsDeviceInitData] [PContent::GetGraphicsDeviceInitData]
description = description =
[PContent::CreateWindow]
description =
[PContent::GetAndroidSystemInfo] [PContent::GetAndroidSystemInfo]
description = description =
[PContent::UngrabPointer] [PContent::UngrabPointer]