mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1172889 - Remove unused nsFrameLoader::DestroyChild. r=smaug (36bbb4447) - Bug 1172889 - Remove unused nsFrameLoader::mContentParent. r=smaug (cee16d62f) - Bug 1172889 - Get current RenderFrameParent from TabParent directly. r=roc (b7090504e) - Bug 1176239, do tab navigation in the child when moving between the parent and child process, r=smaug (5c3d8213c) - Bug 1125325 followup: Add missing 'override' keyword to TabChild::GetInnerSize() and nsWindowRoot::AddBrowser(), RemoveBrowser(), EnumerateBrowsers(). rs=ehsan (3ea24684f) - reorder includes (d09953fd0) - Bug 1190245 - Separate mMessageManager creation and FrameScript loading. r=smaug (90eaa1612) - Bug 1177578 - Remove 'No docshells for remote frames' warning in nsFrameLoader::GetDocShell. r=smaug (de5770f1e) - Bug 1164616 - "nsFrameLoader::DelayedStartLoadingRunnable is unused". r=josh (2472ccba6) - Bug 1172889 - Rename nsFrameLoader::GetCurrentRemoteFrame to nsFrameLoader::GetCurrentRenderFrame. r=roc (8563de171) - Bug 1172889 - Reorder nsFrameLoader member declarations. r=smaug (535d6426d) - Bug 1190245 - Make the MaybeCreateDocShell using code path easier to follow. r=smaug (0d96f4663) - Bug 1190245 - Make frame script loading and browser-api initialization easier to follow. r=smaug (7993cfe00)
This commit is contained in:
+12
-12
@@ -2948,20 +2948,20 @@ nsFocusManager::GetNextTabbableContent(nsIPresShell* aPresShell,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If this is a remote child browser, call NavigateDocument to have
|
||||
// the child process continue the navigation. Return a special error
|
||||
// code to have the caller return early. If the child ends up not
|
||||
// being focusable in some way, the child process will call back
|
||||
// into document navigation again by calling MoveFocus.
|
||||
TabParent* remote = TabParent::GetFrom(currentContent);
|
||||
if (remote) {
|
||||
remote->NavigateByKey(aForward, aForDocumentNavigation);
|
||||
return NS_SUCCESS_DOM_NO_OPERATION;
|
||||
}
|
||||
|
||||
// Next, for document navigation, check if this a non-remote child document.
|
||||
bool checkSubDocument = true;
|
||||
if (aForDocumentNavigation) {
|
||||
// If this is a remote child browser, call NavigateDocument to have
|
||||
// the child process continue the navigation. Return a special error
|
||||
// code to have the caller return early. If the child ends up not
|
||||
// being focusable in some way, the child process will call back
|
||||
// into document navigation again by calling MoveFocus.
|
||||
TabParent* remote = TabParent::GetFrom(currentContent);
|
||||
if (remote) {
|
||||
remote->NavigateDocument(aForward);
|
||||
return NS_SUCCESS_DOM_NO_OPERATION;
|
||||
}
|
||||
|
||||
// Next, check if this a non-remote child document.
|
||||
nsIContent* docRoot = GetRootForChildDocument(currentContent);
|
||||
if (docRoot) {
|
||||
// If GetRootForChildDocument returned something then call
|
||||
|
||||
+139
-144
@@ -136,6 +136,9 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, bool aNetworkCreated)
|
||||
: mOwnerContent(aOwner)
|
||||
, mAppIdSentToPermissionManager(nsIScriptSecurityManager::NO_APP_ID)
|
||||
, mDetachedSubdocFrame(nullptr)
|
||||
, mRemoteBrowser(nullptr)
|
||||
, mChildID(0)
|
||||
, mEventMode(EVENT_MODE_NORMAL_DISPATCH)
|
||||
, mIsPrerendered(false)
|
||||
, mDepthTooGreat(false)
|
||||
, mIsTopLevelContent(false)
|
||||
@@ -151,12 +154,9 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, bool aNetworkCreated)
|
||||
, mClampScrollPosition(true)
|
||||
, mObservingOwnerContent(false)
|
||||
, mVisible(true)
|
||||
, mCurrentRemoteFrame(nullptr)
|
||||
, mRemoteBrowser(nullptr)
|
||||
, mChildID(0)
|
||||
, mEventMode(EVENT_MODE_NORMAL_DISPATCH)
|
||||
{
|
||||
ResetPermissionManagerStatus();
|
||||
mRemoteFrame = ShouldUseRemoteProcess();
|
||||
}
|
||||
|
||||
nsFrameLoader::~nsFrameLoader()
|
||||
@@ -294,37 +294,6 @@ nsFrameLoader::ReallyStartLoading()
|
||||
return rv;
|
||||
}
|
||||
|
||||
class DelayedStartLoadingRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
explicit DelayedStartLoadingRunnable(nsFrameLoader* aFrameLoader)
|
||||
: mFrameLoader(aFrameLoader)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
// Retry the request.
|
||||
mFrameLoader->ReallyStartLoading();
|
||||
|
||||
// We delayed nsFrameLoader::ReallyStartLoading() after the child process is
|
||||
// ready and might not be able to notify the remote browser in
|
||||
// UpdatePositionAndSize() when reflow finished. Retrigger reflow.
|
||||
nsIFrame* frame = mFrameLoader->GetPrimaryFrameOfOwningContent();
|
||||
if (!frame) {
|
||||
return NS_OK;
|
||||
}
|
||||
frame->InvalidateFrame();
|
||||
frame->PresContext()->PresShell()->
|
||||
FrameNeedsReflow(frame, nsIPresShell::eResize, NS_FRAME_IS_DIRTY);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsFrameLoader> mFrameLoader;
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::ReallyStartLoadingInternal()
|
||||
{
|
||||
@@ -333,20 +302,12 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
||||
PROFILER_LABEL("nsFrameLoader", "ReallyStartLoading",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (mRemoteFrame) {
|
||||
if (IsRemoteFrame()) {
|
||||
if (!mRemoteBrowser && !TryRemoteBrowser()) {
|
||||
NS_WARNING("Couldn't create child process for iframe.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Execute pending frame scripts before loading URL
|
||||
EnsureMessageManager();
|
||||
|
||||
// FIXME get error codes from child
|
||||
mRemoteBrowser->LoadURL(mURIToLoad);
|
||||
|
||||
@@ -357,6 +318,10 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ASSERTION(mDocShell,
|
||||
"MaybeCreateDocShell succeeded with a null mDocShell");
|
||||
|
||||
@@ -464,11 +429,7 @@ nsFrameLoader::CheckURILoad(nsIURI* aURI)
|
||||
}
|
||||
|
||||
// Bail out if this is an infinite recursion scenario
|
||||
rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (mRemoteFrame) {
|
||||
if (IsRemoteFrame()) {
|
||||
return NS_OK;
|
||||
}
|
||||
return CheckForRecursiveLoad(aURI);
|
||||
@@ -480,15 +441,16 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
|
||||
*aDocShell = nullptr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (IsRemoteFrame()) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If we have an owner, make sure we have a docshell and return
|
||||
// that. If not, we're most likely in the middle of being torn down,
|
||||
// then we just return null.
|
||||
if (mOwnerContent) {
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (mRemoteFrame) {
|
||||
NS_WARNING("No docshells for remote frames!");
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ASSERTION(mDocShell,
|
||||
@@ -646,42 +608,42 @@ nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
|
||||
AutoResetInShow resetInShow(this);
|
||||
mInShow = true;
|
||||
|
||||
ScreenIntSize size = frame->GetSubdocumentSize();
|
||||
if (IsRemoteFrame()) {
|
||||
return ShowRemoteFrame(size, frame);
|
||||
}
|
||||
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mRemoteFrame) {
|
||||
if (!mDocShell)
|
||||
return false;
|
||||
|
||||
mDocShell->SetMarginWidth(marginWidth);
|
||||
mDocShell->SetMarginHeight(marginHeight);
|
||||
|
||||
nsCOMPtr<nsIScrollable> sc = do_QueryInterface(mDocShell);
|
||||
if (sc) {
|
||||
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
|
||||
scrollbarPrefX);
|
||||
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
|
||||
scrollbarPrefY);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
|
||||
if (presShell) {
|
||||
// Ensure root scroll frame is reflowed in case scroll preferences or
|
||||
// margins have changed
|
||||
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
|
||||
if (rootScrollFrame) {
|
||||
presShell->FrameNeedsReflow(rootScrollFrame, nsIPresShell::eResize,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
NS_ASSERTION(mDocShell,
|
||||
"MaybeCreateDocShell succeeded, but null mDocShell");
|
||||
if (!mDocShell) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ScreenIntSize size = frame->GetSubdocumentSize();
|
||||
if (mRemoteFrame) {
|
||||
return ShowRemoteFrame(size, frame);
|
||||
mDocShell->SetMarginWidth(marginWidth);
|
||||
mDocShell->SetMarginHeight(marginHeight);
|
||||
|
||||
nsCOMPtr<nsIScrollable> sc = do_QueryInterface(mDocShell);
|
||||
if (sc) {
|
||||
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
|
||||
scrollbarPrefX);
|
||||
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
|
||||
scrollbarPrefY);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
|
||||
if (presShell) {
|
||||
// Ensure root scroll frame is reflowed in case scroll preferences or
|
||||
// margins have changed
|
||||
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
|
||||
if (rootScrollFrame) {
|
||||
presShell->FrameNeedsReflow(rootScrollFrame, nsIPresShell::eResize,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
nsView* view = frame->EnsureInnerView();
|
||||
@@ -703,7 +665,7 @@ nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
|
||||
// sub-document. This shouldn't be necessary, but given the way our
|
||||
// editor works, it is. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=284245
|
||||
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
|
||||
presShell = mDocShell->GetPresShell();
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDOMHTMLDocument> doc =
|
||||
do_QueryInterface(presShell->GetDocument());
|
||||
@@ -750,7 +712,7 @@ nsFrameLoader::MarginsChanged(uint32_t aMarginWidth,
|
||||
uint32_t aMarginHeight)
|
||||
{
|
||||
// We assume that the margins are always zero for remote frames.
|
||||
if (mRemoteFrame)
|
||||
if (IsRemoteFrame())
|
||||
return;
|
||||
|
||||
// If there's no docshell, we're probably not up and running yet.
|
||||
@@ -775,7 +737,7 @@ bool
|
||||
nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
|
||||
nsSubDocumentFrame *aFrame)
|
||||
{
|
||||
NS_ASSERTION(mRemoteFrame, "ShowRemote only makes sense on remote frames.");
|
||||
NS_ASSERTION(IsRemoteFrame(), "ShowRemote only makes sense on remote frames.");
|
||||
|
||||
if (!mRemoteBrowser && !TryRemoteBrowser()) {
|
||||
NS_ERROR("Couldn't create child process.");
|
||||
@@ -811,9 +773,6 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
|
||||
mRemoteBrowser->Show(size, parentIsActive);
|
||||
mRemoteBrowserShown = true;
|
||||
|
||||
EnsureMessageManager();
|
||||
|
||||
InitializeBrowserAPI();
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
|
||||
@@ -988,11 +947,11 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
"Swapping some sort of random loaders?");
|
||||
NS_ENSURE_STATE(!mInShow && !aOther->mInShow);
|
||||
|
||||
if (mRemoteFrame && aOther->mRemoteFrame) {
|
||||
if (IsRemoteFrame() && aOther->IsRemoteFrame()) {
|
||||
return SwapWithOtherRemoteLoader(aOther, aFirstToSwap, aSecondToSwap);
|
||||
}
|
||||
|
||||
if (mRemoteFrame || aOther->mRemoteFrame) {
|
||||
if (IsRemoteFrame() || aOther->IsRemoteFrame()) {
|
||||
NS_WARNING("Swapping remote and non-remote frames is not currently supported");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -1523,7 +1482,7 @@ nsFrameLoader::SetOwnerContent(Element* aContent)
|
||||
mOwnerContent->RemoveMutationObserver(this);
|
||||
}
|
||||
mOwnerContent = aContent;
|
||||
if (RenderFrameParent* rfp = GetCurrentRemoteFrame()) {
|
||||
if (RenderFrameParent* rfp = GetCurrentRenderFrame()) {
|
||||
rfp->OwnerContentChanged(aContent);
|
||||
}
|
||||
|
||||
@@ -1662,22 +1621,27 @@ nsFrameLoader::ShouldUseRemoteProcess()
|
||||
eCaseMatters);
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::IsRemoteFrame()
|
||||
{
|
||||
if (mRemoteFrame) {
|
||||
MOZ_ASSERT(!mDocShell, "Found a remote frame with a DocShell");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::MaybeCreateDocShell()
|
||||
{
|
||||
if (mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (mRemoteFrame) {
|
||||
if (IsRemoteFrame()) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ENSURE_STATE(!mDestroyCalled);
|
||||
|
||||
if (ShouldUseRemoteProcess()) {
|
||||
mRemoteFrame = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get our parent docshell off the document of mOwnerContent
|
||||
// XXXbz this is such a total hack.... We really need to have a
|
||||
// better setup for doing this.
|
||||
@@ -1810,8 +1774,6 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
webNav->SetSessionHistory(sessionHistory);
|
||||
}
|
||||
|
||||
EnsureMessageManager();
|
||||
|
||||
if (OwnerIsAppFrame()) {
|
||||
// You can't be both an app and a browser frame.
|
||||
MOZ_ASSERT(!OwnerIsBrowserFrame());
|
||||
@@ -1839,18 +1801,7 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
mDocShell->SetIsBrowserInsideApp(containingAppId);
|
||||
}
|
||||
|
||||
InitializeBrowserAPI();
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
|
||||
"inprocess-browser-shown", nullptr);
|
||||
}
|
||||
|
||||
if (OwnerIsBrowserOrAppFrame() && mMessageManager) {
|
||||
mMessageManager->LoadFrameScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
|
||||
/* allowDelayedLoad = */ true,
|
||||
/* aRunInGlobalScope */ true);
|
||||
if (OwnerIsBrowserOrAppFrame()) {
|
||||
// For inproc frames, set the docshell properties.
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
|
||||
nsAutoString name;
|
||||
@@ -1877,6 +1828,15 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
}
|
||||
}
|
||||
|
||||
ReallyLoadFrameScripts();
|
||||
InitializeBrowserAPI();
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
|
||||
"inprocess-browser-shown", nullptr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1897,13 +1857,16 @@ nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
MOZ_ASSERT(!IsRemoteFrame(),
|
||||
"Shouldn't call CheckForRecursiveLoad on remote frames.");
|
||||
|
||||
mDepthTooGreat = false;
|
||||
rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ASSERTION(!mRemoteFrame,
|
||||
"Shouldn't call CheckForRecursiveLoad on remote frames.");
|
||||
NS_ASSERTION(mDocShell,
|
||||
"MaybeCreateDocShell succeeded, but null mDocShell");
|
||||
if (!mDocShell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -2029,7 +1992,7 @@ nsFrameLoader::GetWindowDimensions(nsIntRect& aRect)
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame *aIFrame)
|
||||
{
|
||||
if (mRemoteFrame) {
|
||||
if (IsRemoteFrame()) {
|
||||
if (mRemoteBrowser) {
|
||||
ScreenIntSize size = aIFrame->GetSubdocumentSize();
|
||||
nsIntRect dimensions;
|
||||
@@ -2237,7 +2200,6 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
return false;
|
||||
}
|
||||
|
||||
mContentParent = mRemoteBrowser->Manager();
|
||||
mChildID = mRemoteBrowser->Manager()->ChildID();
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
@@ -2258,15 +2220,27 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
ReallyLoadFrameScripts();
|
||||
InitializeBrowserAPI();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
mozilla::dom::PBrowserParent*
|
||||
nsFrameLoader::GetRemoteBrowser()
|
||||
nsFrameLoader::GetRemoteBrowser() const
|
||||
{
|
||||
return mRemoteBrowser;
|
||||
}
|
||||
|
||||
RenderFrameParent*
|
||||
nsFrameLoader::GetCurrentRenderFrame() const
|
||||
{
|
||||
if (mRemoteBrowser) {
|
||||
return mRemoteBrowser->GetRenderFrame();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::ActivateRemoteFrame() {
|
||||
if (mRemoteBrowser) {
|
||||
@@ -2488,14 +2462,13 @@ nsFrameLoader::EnsureMessageManager()
|
||||
{
|
||||
NS_ENSURE_STATE(mOwnerContent);
|
||||
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
if (mMessageManager) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mIsTopLevelContent &&
|
||||
!OwnerIsBrowserOrAppFrame() &&
|
||||
!mRemoteFrame &&
|
||||
!IsRemoteFrame() &&
|
||||
!(mOwnerContent->IsXULElement() &&
|
||||
mOwnerContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::forcemessagemanager,
|
||||
@@ -2503,14 +2476,6 @@ nsFrameLoader::EnsureMessageManager()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool useRemoteProcess = ShouldUseRemoteProcess();
|
||||
if (mMessageManager) {
|
||||
if (useRemoteProcess && mRemoteBrowser) {
|
||||
mMessageManager->InitWithCallback(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
|
||||
do_QueryInterface(GetOwnerDoc()->GetWindow());
|
||||
nsCOMPtr<nsIMessageBroadcaster> parentManager;
|
||||
@@ -2529,18 +2494,33 @@ nsFrameLoader::EnsureMessageManager()
|
||||
}
|
||||
}
|
||||
|
||||
if (useRemoteProcess) {
|
||||
mMessageManager = new nsFrameMessageManager(mRemoteBrowser ? this : nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
MM_CHROME);
|
||||
} else {
|
||||
mMessageManager = new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
MM_CHROME);
|
||||
|
||||
mMessageManager = new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
MM_CHROME);
|
||||
if (!IsRemoteFrame()) {
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ASSERTION(mDocShell,
|
||||
"MaybeCreateDocShell succeeded, but null mDocShell");
|
||||
if (!mDocShell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mChildMessageManager =
|
||||
new nsInProcessTabChildGlobal(mDocShell, mOwnerContent, mMessageManager);
|
||||
// Force pending frame scripts to be loaded.
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::ReallyLoadFrameScripts()
|
||||
{
|
||||
nsresult rv = EnsureMessageManager();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (mMessageManager) {
|
||||
mMessageManager->InitWithCallback(this);
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -2571,10 +2551,11 @@ void
|
||||
nsFrameLoader::SetRemoteBrowser(nsITabParent* aTabParent)
|
||||
{
|
||||
MOZ_ASSERT(!mRemoteBrowser);
|
||||
MOZ_ASSERT(!mCurrentRemoteFrame);
|
||||
mRemoteFrame = true;
|
||||
mRemoteBrowser = TabParent::GetFrom(aTabParent);
|
||||
mChildID = mRemoteBrowser ? mRemoteBrowser->Manager()->ChildID() : 0;
|
||||
ReallyLoadFrameScripts();
|
||||
InitializeBrowserAPI();
|
||||
ShowRemoteFrame(ScreenIntSize(0, 0));
|
||||
}
|
||||
|
||||
@@ -2833,8 +2814,22 @@ nsFrameLoader::GetLoadContext(nsILoadContext** aLoadContext)
|
||||
void
|
||||
nsFrameLoader::InitializeBrowserAPI()
|
||||
{
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
if (browserFrame) {
|
||||
browserFrame->InitializeBrowserAPI();
|
||||
if (OwnerIsBrowserOrAppFrame()) {
|
||||
if (!IsRemoteFrame()) {
|
||||
nsresult rv = EnsureMessageManager();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
if (mMessageManager) {
|
||||
mMessageManager->LoadFrameScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
|
||||
/* allowDelayedLoad = */ true,
|
||||
/* aRunInGlobalScope */ true);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
if (browserFrame) {
|
||||
browserFrame->InitializeBrowserAPI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-42
@@ -23,8 +23,8 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "Units.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsSubDocumentFrame;
|
||||
@@ -62,11 +62,6 @@ class nsFrameLoader final : public nsIFrameLoader,
|
||||
typedef mozilla::dom::TabParent TabParent;
|
||||
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
|
||||
|
||||
protected:
|
||||
nsFrameLoader(mozilla::dom::Element* aOwner, bool aNetworkCreated);
|
||||
|
||||
~nsFrameLoader();
|
||||
|
||||
public:
|
||||
static nsFrameLoader* Create(mozilla::dom::Element* aOwner,
|
||||
bool aNetworkCreated);
|
||||
@@ -131,9 +126,6 @@ public:
|
||||
nsRefPtr<nsFrameLoader>& aFirstToSwap,
|
||||
nsRefPtr<nsFrameLoader>& aSecondToSwap);
|
||||
|
||||
// When IPC is enabled, destroy any associated child process.
|
||||
void DestroyChild();
|
||||
|
||||
/**
|
||||
* Return the primary frame for our owning content, or null if it
|
||||
* can't be found.
|
||||
@@ -150,7 +142,7 @@ public:
|
||||
nsIDocument* GetOwnerDoc() const
|
||||
{ return mOwnerContent ? mOwnerContent->OwnerDoc() : nullptr; }
|
||||
|
||||
PBrowserParent* GetRemoteBrowser();
|
||||
PBrowserParent* GetRemoteBrowser() const;
|
||||
|
||||
/**
|
||||
* The "current" render frame is the one on which the most recent
|
||||
@@ -166,20 +158,8 @@ public:
|
||||
* returned. (In-process <browser> behaves similarly, and this
|
||||
* behavior seems desirable.)
|
||||
*/
|
||||
RenderFrameParent* GetCurrentRemoteFrame() const
|
||||
{
|
||||
return mCurrentRemoteFrame;
|
||||
}
|
||||
RenderFrameParent* GetCurrentRenderFrame() const;
|
||||
|
||||
/**
|
||||
* |aFrame| can be null. If non-null, it must be the remote frame
|
||||
* on which the most recent layer transaction completed for this's
|
||||
* <browser>.
|
||||
*/
|
||||
void SetCurrentRemoteFrame(RenderFrameParent* aFrame)
|
||||
{
|
||||
mCurrentRemoteFrame = aFrame;
|
||||
}
|
||||
nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
|
||||
|
||||
mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; }
|
||||
@@ -190,10 +170,10 @@ public:
|
||||
/**
|
||||
* Tell this FrameLoader to use a particular remote browser.
|
||||
*
|
||||
* This will assert if mRemoteBrowser or mCurrentRemoteFrame is non-null. In
|
||||
* practice, this means you can't have successfully run TryRemoteBrowser() on
|
||||
* this object, which means you can't have called ShowRemoteFrame() or
|
||||
* ReallyStartLoading().
|
||||
* This will assert if mRemoteBrowser is non-null. In practice,
|
||||
* this means you can't have successfully run TryRemoteBrowser() on
|
||||
* this object, which means you can't have called ShowRemoteFrame()
|
||||
* or ReallyStartLoading().
|
||||
*/
|
||||
void SetRemoteBrowser(nsITabParent* aTabParent);
|
||||
|
||||
@@ -231,12 +211,23 @@ public:
|
||||
// Properly retrieves documentSize of any subdocument type.
|
||||
nsresult GetWindowDimensions(nsIntRect& aRect);
|
||||
|
||||
// public because a callback needs these.
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
|
||||
private:
|
||||
nsFrameLoader(mozilla::dom::Element* aOwner, bool aNetworkCreated);
|
||||
~nsFrameLoader();
|
||||
|
||||
void SetOwnerContent(mozilla::dom::Element* aContent);
|
||||
|
||||
bool ShouldUseRemoteProcess();
|
||||
|
||||
/**
|
||||
* Return true if the frame is a remote frame. Return false otherwise
|
||||
*/
|
||||
bool IsRemoteFrame();
|
||||
|
||||
/**
|
||||
* Is this a frameloader for a bona fide <iframe mozbrowser> or
|
||||
* <iframe mozapp>? (I.e., does the frame return true for
|
||||
@@ -285,6 +276,7 @@ private:
|
||||
*/
|
||||
nsresult MaybeCreateDocShell();
|
||||
nsresult EnsureMessageManager();
|
||||
nsresult ReallyLoadFrameScripts();
|
||||
|
||||
// Updates the subdocument position and size. This gets called only
|
||||
// when we have our own in-process DocShell.
|
||||
@@ -328,10 +320,6 @@ private:
|
||||
// Note: this variable must be modified only by ResetPermissionManagerStatus()
|
||||
uint32_t mAppIdSentToPermissionManager;
|
||||
|
||||
public:
|
||||
// public because a callback needs these.
|
||||
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
private:
|
||||
// Stores the root frame of the subdocument while the subdocument is being
|
||||
// reframed. Used to restore the presentation after reframing.
|
||||
@@ -343,6 +331,13 @@ private:
|
||||
// a reframe, so that we know not to restore the presentation.
|
||||
nsCOMPtr<nsIDocument> mContainerDocWhileDetached;
|
||||
|
||||
TabParent* mRemoteBrowser;
|
||||
uint64_t mChildID;
|
||||
|
||||
// See nsIFrameLoader.idl. EVENT_MODE_NORMAL_DISPATCH automatically
|
||||
// forwards some input events to out-of-process content.
|
||||
uint32_t mEventMode;
|
||||
|
||||
bool mIsPrerendered : 1;
|
||||
bool mDepthTooGreat : 1;
|
||||
bool mIsTopLevelContent : 1;
|
||||
@@ -366,17 +361,6 @@ private:
|
||||
// whether this frameloader's <iframe mozbrowser> is setVisible(true)'ed, and
|
||||
// doesn't necessarily correlate with docshell/document visibility.
|
||||
bool mVisible : 1;
|
||||
|
||||
// The ContentParent associated with mRemoteBrowser. This was added as a
|
||||
// strong ref in bug 545237, and we're not sure if we can get rid of it.
|
||||
nsRefPtr<mozilla::dom::nsIContentParent> mContentParent;
|
||||
RenderFrameParent* mCurrentRemoteFrame;
|
||||
TabParent* mRemoteBrowser;
|
||||
uint64_t mChildID;
|
||||
|
||||
// See nsIFrameLoader.idl. EVENT_MODE_NORMAL_DISPATCH automatically
|
||||
// forwards some input events to out-of-process content.
|
||||
uint32_t mEventMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,9 +69,9 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot,
|
||||
nsIDOMEventTarget)
|
||||
|
||||
virtual void AddBrowser(mozilla::dom::TabParent* aBrowser);
|
||||
virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser);
|
||||
virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void *aArg);
|
||||
virtual void AddBrowser(mozilla::dom::TabParent* aBrowser) override;
|
||||
virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser) override;
|
||||
virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void *aArg) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsWindowRoot();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(A10D887D-7FC2-48A2-ABC6-A2027423860C)]
|
||||
[scriptable, uuid(CE6F563B-BD77-4EF2-9D7C-A94C587353E4)]
|
||||
interface nsITabParent : nsISupports
|
||||
{
|
||||
void injectTouchEvent(in AString aType,
|
||||
@@ -28,10 +28,13 @@ interface nsITabParent : nsISupports
|
||||
readonly attribute uint64_t tabId;
|
||||
|
||||
/**
|
||||
* If aForward is true, navigate to the first focusable document.
|
||||
* If aForward is false, navigate to the last focusable document.
|
||||
* Navigate by key. If aForDocumentNavigation is true, navigate by document.
|
||||
* If aForDocumentNavigation is false, navigate by element.
|
||||
*
|
||||
* If aForward is true, navigate to the first focusable element or document.
|
||||
* If aForward is false, navigate to the last focusable element or document.
|
||||
*/
|
||||
void navigateDocument(in bool aForward);
|
||||
void navigateByKey(in bool aForward, in bool aForDocumentNavigation);
|
||||
|
||||
readonly attribute boolean hasContentOpener;
|
||||
};
|
||||
|
||||
@@ -680,9 +680,9 @@ child:
|
||||
SetIsDocShellActive(bool aIsActive);
|
||||
|
||||
/**
|
||||
* Navigate by document.
|
||||
* Navigate by key (Tab/Shift+Tab/F6/Shift+f6).
|
||||
*/
|
||||
NavigateDocument(bool aForward);
|
||||
NavigateByKey(bool aForward, bool aForDocumentNavigation);
|
||||
|
||||
/**
|
||||
* The parent (chrome thread) requests that the child inform it when
|
||||
|
||||
+14
-3
@@ -2917,7 +2917,7 @@ TabChild::RecvSetIsDocShellActive(const bool& aIsActive)
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::RecvNavigateDocument(const bool& aForward)
|
||||
TabChild::RecvNavigateByKey(const bool& aForward, const bool& aForDocumentNavigation)
|
||||
{
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
@@ -2925,9 +2925,20 @@ TabChild::RecvNavigateDocument(const bool& aForward)
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(WebNavigation());
|
||||
|
||||
// Move to the first or last document.
|
||||
fm->MoveFocus(window, nullptr, aForward ? nsIFocusManager::MOVEFOCUS_FIRSTDOC :
|
||||
nsIFocusManager::MOVEFOCUS_LASTDOC,
|
||||
uint32_t type = aForward ?
|
||||
(aForDocumentNavigation ? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_FIRSTDOC) :
|
||||
static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_ROOT)) :
|
||||
(aForDocumentNavigation ? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LASTDOC) :
|
||||
static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LAST));
|
||||
fm->MoveFocus(window, nullptr, type,
|
||||
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
|
||||
|
||||
// No valid root element was found, so move to the first focusable element.
|
||||
if (!result && aForward && !aForDocumentNavigation) {
|
||||
fm->MoveFocus(window, nullptr, nsIFocusManager::MOVEFOCUS_FIRST,
|
||||
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
|
||||
}
|
||||
|
||||
SendRequestFocus(false);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -515,7 +515,7 @@ public:
|
||||
}
|
||||
bool AsyncPanZoomEnabled() { return mAsyncPanZoomEnabled; }
|
||||
|
||||
virtual ScreenIntSize GetInnerSize();
|
||||
virtual ScreenIntSize GetInnerSize() override;
|
||||
|
||||
protected:
|
||||
virtual ~TabChild();
|
||||
@@ -525,7 +525,7 @@ protected:
|
||||
virtual bool RecvDestroy() override;
|
||||
virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) override;
|
||||
virtual bool RecvSetIsDocShellActive(const bool& aIsActive) override;
|
||||
virtual bool RecvNavigateDocument(const bool& aForward) override;
|
||||
virtual bool RecvNavigateByKey(const bool& aForward, const bool& aForDocumentNavigation) override;
|
||||
|
||||
virtual bool RecvRequestNotifyAfterRemotePaint() override;
|
||||
|
||||
|
||||
@@ -2893,9 +2893,9 @@ TabParent::SetHasContentOpener(bool aHasContentOpener)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabParent::NavigateDocument(bool aForward)
|
||||
TabParent::NavigateByKey(bool aForward, bool aForDocumentNavigation)
|
||||
{
|
||||
unused << SendNavigateDocument(aForward);
|
||||
unused << SendNavigateByKey(aForward, aForDocumentNavigation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -426,6 +426,7 @@ public:
|
||||
|
||||
void TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
|
||||
int32_t& aDragAreaX, int32_t& aDragAreaY);
|
||||
layout::RenderFrameParent* GetRenderFrame();
|
||||
protected:
|
||||
bool ReceiveMessage(const nsString& aMessage,
|
||||
bool aSync,
|
||||
@@ -478,7 +479,6 @@ protected:
|
||||
|
||||
private:
|
||||
already_AddRefed<nsFrameLoader> GetFrameLoader(bool aUseCachedFrameLoaderAfterDestroy = false) const;
|
||||
layout::RenderFrameParent* GetRenderFrame();
|
||||
nsRefPtr<nsIContentParent> mManager;
|
||||
void TryCacheDPIAndScale();
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
nsFrameLoader* frameLoader = FrameLoader();
|
||||
RenderFrameParent* rfp = nullptr;
|
||||
if (frameLoader) {
|
||||
rfp = frameLoader->GetCurrentRemoteFrame();
|
||||
rfp = frameLoader->GetCurrentRenderFrame();
|
||||
}
|
||||
|
||||
// If we are pointer-events:none then we don't need to HitTest background
|
||||
|
||||
@@ -329,8 +329,6 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
||||
mLayersId = *aId;
|
||||
CompositorChild::Get()->SendNotifyChildCreated(mLayersId);
|
||||
}
|
||||
// Set a default RenderFrameParent
|
||||
mFrameLoader->SetCurrentRemoteFrame(this);
|
||||
*aSuccess = true;
|
||||
}
|
||||
|
||||
@@ -445,15 +443,6 @@ RenderFrameParent::ActorDestroy(ActorDestroyReason why)
|
||||
}
|
||||
}
|
||||
|
||||
if (mFrameLoader && mFrameLoader->GetCurrentRemoteFrame() == this) {
|
||||
// XXX this might cause some weird issues ... we'll just not
|
||||
// redraw the part of the window covered by this until the "next"
|
||||
// remote frame has a layer-tree transaction. For
|
||||
// why==NormalShutdown, we'll definitely want to do something
|
||||
// better, especially as nothing guarantees another Update() from
|
||||
// the "next" remote layer tree.
|
||||
mFrameLoader->SetCurrentRemoteFrame(nullptr);
|
||||
}
|
||||
mFrameLoader = nullptr;
|
||||
}
|
||||
|
||||
@@ -481,8 +470,6 @@ RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion)
|
||||
void
|
||||
RenderFrameParent::TriggerRepaint()
|
||||
{
|
||||
mFrameLoader->SetCurrentRemoteFrame(this);
|
||||
|
||||
nsIFrame* docFrame = mFrameLoader->GetPrimaryFrameOfOwningContent();
|
||||
if (!docFrame) {
|
||||
// Bad, but nothing we can do about it (XXX/cjones: or is there?
|
||||
|
||||
Reference in New Issue
Block a user