Bug 1003848 - Don't use sync messaging during BrowserElementChild initialization r=smaug

This commit is contained in:
Fabrice Desré 2014-11-24 11:05:35 -08:00
parent 75e88f7137
commit 10b2fef7f6
8 changed files with 84 additions and 26 deletions

View File

@ -52,6 +52,7 @@
#include "nsIPermissionManager.h"
#include "nsISHistory.h"
#include "nsNullPrincipal.h"
#include "nsIScriptError.h"
#include "nsLayoutUtils.h"
#include "nsView.h"
@ -1762,6 +1763,30 @@ nsFrameLoader::MaybeCreateDocShell()
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
/* allowDelayedLoad = */ true,
/* aRunInGlobalScope */ true);
// For inproc frames, set the docshell properties.
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
nsAutoString name;
if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
item->SetName(name);
}
mDocShell->SetFullscreenAllowed(
mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen));
bool isPrivate = mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing);
if (isPrivate) {
bool nonBlank;
mDocShell->GetHasLoadedNonBlankURI(&nonBlank);
if (nonBlank) {
nsContentUtils::ReportToConsoleNonLocalized(
NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."),
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("mozprivatebrowsing"),
nullptr);
} else {
nsCOMPtr<nsILoadContext> context = do_GetInterface(mDocShell);
context->SetUsePrivateBrowsing(true);
}
}
}
return NS_OK;

View File

@ -52,14 +52,5 @@ if (!('BrowserElementIsPreloaded' in this)) {
var BrowserElementIsReady = true;
let infos = sendSyncMessage('browser-element-api:call',
{ 'msg_name': 'hello' })[0];
docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name;
docShell.setFullscreenAllowed(infos.fullscreenAllowed);
if (infos.isPrivate) {
if (docShell.hasLoadedNonBlankURI) {
Cu.reportError("We should not switch to Private Browsing after loading a document.");
} else {
docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
}
}
sendAsyncMessage('browser-element-api:call', { 'msg_name': 'hello' });

View File

@ -325,14 +325,6 @@ BrowserElementParent.prototype = {
this._domRequestReady = true;
this._runPendingAPICall();
}
return {
name: this._frameElement.getAttribute('name'),
fullscreenAllowed:
this._frameElement.hasAttribute('allowfullscreen') ||
this._frameElement.hasAttribute('mozallowfullscreen'),
isPrivate: this._frameElement.hasAttribute('mozprivatebrowsing')
};
},
_fireCtxMenuEvent: function(data) {

View File

@ -15,10 +15,6 @@ iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
}, 0);
}, 0);
}
else {
// Pass the message up to our parent.
alert(e.detail.message);
}
});
document.body.appendChild(iframe);

View File

@ -69,6 +69,13 @@ union MaybeNativeKeyBinding
void_t;
};
struct ShowInfo
{
nsString name;
bool fullscreenAllowed;
bool isPrivate;
};
prio(normal upto urgent) intr protocol PBrowser
{
manager PContent or PContentBridge;
@ -411,6 +418,7 @@ child:
* point.
*/
Show(nsIntSize size,
ShowInfo info,
ScrollingBehavior scrolling,
TextureFactoryIdentifier textureFactoryIdentifier,
uint64_t layersId,

View File

@ -90,6 +90,7 @@
#include "nsIAppsService.h"
#include "nsNetUtil.h"
#include "nsIPermissionManager.h"
#include "nsIScriptError.h"
#define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
@ -1881,10 +1882,36 @@ TabChild::DoFakeShow(const ScrollingBehavior& aScrolling,
const uint64_t& aLayersId,
PRenderFrameChild* aRenderFrame)
{
RecvShow(nsIntSize(0, 0), aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame);
ShowInfo info(EmptyString(), false, false);
RecvShow(nsIntSize(0, 0), info, aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame);
mDidFakeShow = true;
}
void
TabChild::ApplyShowInfo(const ShowInfo& aInfo)
{
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
if (docShell) {
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
item->SetName(aInfo.name());
docShell->SetFullscreenAllowed(aInfo.fullscreenAllowed());
if (aInfo.isPrivate()) {
bool nonBlank;
docShell->GetHasLoadedNonBlankURI(&nonBlank);
if (nonBlank) {
nsContentUtils::ReportToConsoleNonLocalized(
NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."),
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("mozprivatebrowsing"),
nullptr);
} else {
nsCOMPtr<nsILoadContext> context = do_GetInterface(docShell);
context->SetUsePrivateBrowsing(true);
}
}
}
}
#ifdef MOZ_WIDGET_GONK
void
TabChild::MaybeRequestPreinitCamera()
@ -1945,6 +1972,7 @@ TabChild::MaybeRequestPreinitCamera()
bool
TabChild::RecvShow(const nsIntSize& aSize,
const ShowInfo& aInfo,
const ScrollingBehavior& aScrolling,
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
const uint64_t& aLayersId,
@ -1953,6 +1981,7 @@ TabChild::RecvShow(const nsIntSize& aSize,
MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame));
if (mDidFakeShow) {
ApplyShowInfo(aInfo);
return true;
}
@ -1976,7 +2005,9 @@ TabChild::RecvShow(const nsIntSize& aSize,
MaybeRequestPreinitCamera();
#endif
return InitTabChildGlobal();
bool res = InitTabChildGlobal();
ApplyShowInfo(aInfo);
return res;
}
bool

View File

@ -317,6 +317,7 @@ public:
const FileDescriptor& aFileDescriptor)
MOZ_OVERRIDE;
virtual bool RecvShow(const nsIntSize& aSize,
const ShowInfo& aInfo,
const ScrollingBehavior& aScrolling,
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
const uint64_t& aLayersId,
@ -552,6 +553,8 @@ private:
const uint64_t& aLayersId,
PRenderFrameChild* aRenderFrame);
void ApplyShowInfo(const ShowInfo& aInfo);
// These methods are used for tracking synthetic mouse events
// dispatched for compatibility. On each touch event, we
// UpdateTapState(). If we've detected that the current gesture

View File

@ -600,7 +600,19 @@ TabParent::Show(const nsIntSize& size)
unused << SendPRenderFrameConstructor(renderFrame);
}
}
unused << SendShow(size, scrolling, textureFactoryIdentifier, layersId, renderFrame);
ShowInfo info(EmptyString(), false, false);
if (mFrameElement) {
nsAutoString name;
mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
bool allowFullscreen =
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen);
bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing);
info = ShowInfo(name, allowFullscreen, isPrivate);
}
unused << SendShow(size, info, scrolling, textureFactoryIdentifier, layersId, renderFrame);
}
void