Bug 1494244 - Remove dead code in and around nsFrameLoader methods. r=nika

This was found with the help of code coverage results.
This commit is contained in:
Nicholas Nethercote 2018-10-03 13:09:26 +10:00
Родитель 034bf7870f
Коммит d0be881cf4
6 изменённых файлов: 0 добавлений и 161 удалений

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

@ -1046,10 +1046,6 @@ var SessionStoreInternal = {
this.resetEpoch(target);
}
break;
case "BrowserWillChangeProcess":
let promise = TabStateFlusher.flush(target);
target.frameLoader.addProcessChangeBlockingPromise(promise);
break;
case "BrowserChangedProcess":
let newEpoch = 1 + Math.max(this.getCurrentEpoch(target),
this.getCurrentEpoch(aEvent.otherBrowser));
@ -1125,7 +1121,6 @@ var SessionStoreInternal = {
// Keep track of a browser's latest frameLoader.
aWindow.gBrowser.addEventListener("XULFrameLoaderCreated", this);
aWindow.gBrowser.addEventListener("BrowserChangedProcess", this);
aWindow.gBrowser.addEventListener("BrowserWillChangeProcess", this);
},
/**
@ -1391,7 +1386,6 @@ var SessionStoreInternal = {
aWindow.gBrowser.removeEventListener("XULFrameLoaderCreated", this);
aWindow.gBrowser.removeEventListener("BrowserChangedProcess", this);
aWindow.gBrowser.removeEventListener("BrowserWillChangeProcess", this);
let winData = this._windows[aWindow.__SSi];

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

@ -95,7 +95,6 @@
#include "mozilla/WebBrowserPersistLocalDocument.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/GroupedHistoryEvent.h"
#include "mozilla/dom/ParentSHistory.h"
#include "mozilla/dom/ChildSHistory.h"
@ -166,7 +165,6 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, nsPIDOMWindowOuter* aOpener,
, mRemoteBrowser(nullptr)
, mChildID(0)
, mJSPluginID(aJSPluginID)
, mBrowserChangingProcessBlockers(nullptr)
, mDepthTooGreat(false)
, mIsTopLevelContent(false)
, mDestroyCalled(false)
@ -343,85 +341,6 @@ nsFrameLoader::LoadURI(nsIURI* aURI, nsIPrincipal* aTriggeringPrincipal,
return rv;
}
bool
nsFrameLoader::SwapBrowsersAndNotify(nsFrameLoader* aOther)
{
// Cache the owner content before calling SwapBrowsers, which will change
// these member variables.
RefPtr<mozilla::dom::Element> primaryContent = mOwnerContent;
RefPtr<mozilla::dom::Element> secondaryContent = aOther->mOwnerContent;
// Swap loaders through our owner, so the owner's listeners will be correctly
// setup.
nsCOMPtr<nsIBrowser> ourBrowser = do_QueryInterface(primaryContent);
nsCOMPtr<nsIBrowser> otherBrowser = do_QueryInterface(secondaryContent);
if (NS_WARN_IF(!ourBrowser || !otherBrowser)) {
return false;
}
nsresult rv = ourBrowser->SwapBrowsers(otherBrowser, nsIBrowser::SWAP_KEEP_PERMANENT_KEY);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
// Dispatch the BrowserChangedProcess event to tell JS that the process swap
// has occurred.
GroupedHistoryEventInit eventInit;
eventInit.mBubbles = true;
eventInit.mCancelable= false;
eventInit.mOtherBrowser = secondaryContent;
RefPtr<GroupedHistoryEvent> event =
GroupedHistoryEvent::Constructor(primaryContent,
NS_LITERAL_STRING("BrowserChangedProcess"),
eventInit);
event->SetTrusted(true);
primaryContent->DispatchEvent(*event);
return true;
}
already_AddRefed<Promise>
nsFrameLoader::FireWillChangeProcessEvent()
{
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mOwnerContent->GetOwnerGlobal()))) {
return nullptr;
}
JSContext* cx = jsapi.cx();
// Set our mBrowserChangingProcessBlockers property to refer to the blockers
// list. We will synchronously dispatch a DOM event to collect this list of
// blockers.
nsTArray<RefPtr<Promise>> blockers;
mBrowserChangingProcessBlockers = &blockers;
GroupedHistoryEventInit eventInit;
eventInit.mBubbles = true;
eventInit.mCancelable = false;
eventInit.mOtherBrowser = nullptr;
RefPtr<GroupedHistoryEvent> event =
GroupedHistoryEvent::Constructor(mOwnerContent,
NS_LITERAL_STRING("BrowserWillChangeProcess"),
eventInit);
event->SetTrusted(true);
mOwnerContent->DispatchEvent(*event);
mBrowserChangingProcessBlockers = nullptr;
ErrorResult rv;
RefPtr<Promise> allPromise = Promise::All(cx, blockers, rv);
return allPromise.forget();
}
void
nsFrameLoader::AddProcessChangeBlockingPromise(Promise& aPromise, ErrorResult& aRv)
{
if (NS_WARN_IF(!mBrowserChangingProcessBlockers)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
} else {
mBrowserChangingProcessBlockers->AppendElement(&aPromise);
}
}
nsresult
nsFrameLoader::ReallyStartLoading()
{
@ -3124,22 +3043,6 @@ nsFrameLoader::RequestNotifyAfterRemotePaint()
}
}
void
nsFrameLoader::RequestFrameLoaderClose(ErrorResult& aRv)
{
nsCOMPtr<nsIBrowser> browser = do_QueryInterface(mOwnerContent);
if (NS_WARN_IF(!browser)) {
// OwnerElement other than nsIBrowser is not supported yet.
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
}
nsresult rv = browser->CloseBrowser();
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
void
nsFrameLoader::RequestUpdatePosition(ErrorResult& aRv)
{

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

@ -139,8 +139,6 @@ public:
nsresult LoadURI(nsIURI* aURI, nsIPrincipal* aTriggeringPrincipal,
bool aOriginalSrc);
void AddProcessChangeBlockingPromise(mozilla::dom::Promise& aPromise, mozilla::ErrorResult& aRv);
/**
* Destroy the frame loader and everything inside it. This will
* clear the weak owner content reference.
@ -166,8 +164,6 @@ public:
void RequestNotifyAfterRemotePaint();
void RequestFrameLoaderClose(mozilla::ErrorResult& aRv);
void RequestUpdatePosition(mozilla::ErrorResult& aRv);
void Print(uint64_t aOuterWindowID,
@ -443,14 +439,6 @@ private:
nsresult
PopulateUserContextIdFromAttribute(mozilla::OriginAttributes& aAttr);
// Swap ourselves with the frameloader aOther, and notify chrome code with
// a BrowserChangedProcess event.
bool SwapBrowsersAndNotify(nsFrameLoader* aOther);
// Returns a promise which will be resolved once all of the blockers have
// resolved which were added during the BrowserWillChangeProcess event.
already_AddRefed<mozilla::dom::Promise> FireWillChangeProcessEvent();
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIURI> mURIToLoad;
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
@ -482,10 +470,6 @@ private:
// Holds the last known size of the frame.
mozilla::ScreenIntSize mLazySize;
// A stack-maintained reference to an array of promises which are blocking
// grouped history navigation
nsTArray<RefPtr<mozilla::dom::Promise>>* mBrowserChangingProcessBlockers;
RefPtr<mozilla::dom::ParentSHistory> mParentSHistory;
bool mDepthTooGreat : 1;

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

@ -39,14 +39,6 @@ interface FrameLoader {
*/
readonly attribute ParentSHistory? parentSHistory;
/**
* Adds a blocking promise for the current cross process navigation.
* This method can only be called while the "BrowserWillChangeProcess" event
* is being fired.
*/
[Throws]
void addProcessChangeBlockingPromise(Promise<any> aPromise);
/**
* Find out whether the loader's frame is at too great a depth in
* the frame tree. This can be used to decide what operations may
@ -97,12 +89,6 @@ interface FrameLoader {
*/
void requestNotifyAfterRemotePaint();
/**
* Close the window through the ownerElement.
*/
[Throws]
void requestFrameLoaderClose();
/**
* Force a remote browser to recompute its dimension and screen position.
*/
@ -129,13 +115,6 @@ interface FrameLoader {
*/
attribute boolean clipSubdocument;
/**
* If false, then the subdocument's scroll coordinates will not be clamped
* to their scroll boundaries.
* Defaults to true.
*/
attribute boolean clampScrollPosition;
/**
* The element which owns this frame loader.
*

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

@ -1,17 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[ChromeOnly,
Constructor(DOMString type, optional GroupedHistoryEventInit eventInitDict)]
interface GroupedHistoryEvent : Event
{
readonly attribute Element? otherBrowser;
};
dictionary GroupedHistoryEventInit : EventInit
{
Element? otherBrowser = null;
};

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

@ -133,9 +133,6 @@ with Files("GetUserMediaRequest.webidl"):
with Files("Grid.webidl"):
BUG_COMPONENT = ("Core", "CSS Parsing and Computation")
with Files("GroupedHistoryEvent.webidl"):
BUG_COMPONENT = ("Core", "Document Navigation")
with Files("HTML*"):
BUG_COMPONENT = ("Core", "DOM: Core & HTML")
@ -1052,7 +1049,6 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'GamepadAxisMoveEvent.webidl',
'GamepadButtonEvent.webidl',
'GamepadEvent.webidl',
'GroupedHistoryEvent.webidl',
'HashChangeEvent.webidl',
'HiddenPluginEvent.webidl',
'ImageCaptureErrorEvent.webidl',