Bug 1614462: Part 3b - Remove moribund DocShell FrameType/IsMozBrowser/IsInMozBrowser fields. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D70749
This commit is contained in:
Kris Maglione 2020-04-20 20:11:52 +00:00
Родитель f8eabd5b2a
Коммит a8a1c5767d
11 изменённых файлов: 17 добавлений и 218 удалений

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

@ -57,7 +57,7 @@
frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
SimpleTest.is(frame1.contentDocument.documentURI,
"about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/1&c=UTF-8&f=regular&d=pageTitle",
"about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/1&c=UTF-8&d=pageTitle",
"Correct about:tabcrashed displayed for page with title.");
errorPageReady = waitForErrorPage(frame2);
@ -66,7 +66,7 @@
await errorPageReady;
SimpleTest.is(frame2.contentDocument.documentURI,
"about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20",
"about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/2&c=UTF-8&d=%20",
"Correct about:tabcrashed displayed for page with no title.");
SimpleTest.finish();

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

@ -55,7 +55,7 @@
frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
SimpleTest.is(frame1.contentDocument.documentURI,
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/1&c=UTF-8&f=regular&d=%20",
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/1&c=UTF-8&d=%20",
"Correct about:restartrequired displayed for page with title.");
errorPageReady = waitForErrorPage(frame2);
@ -64,7 +64,7 @@
await errorPageReady;
SimpleTest.is(frame2.contentDocument.documentURI,
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20",
"about:restartrequired?e=restartrequired&u=http%3A//www.example.com/2&c=UTF-8&d=%20",
"Correct about:restartrequired displayed for page with no title.");
SimpleTest.finish();

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

@ -354,7 +354,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
mLoadType(0),
mDefaultLoadFlags(nsIRequest::LOAD_NORMAL),
mFailedLoadType(0),
mFrameType(FRAME_TYPE_REGULAR),
mDisplayMode(nsIDocShell::DISPLAY_MODE_BROWSER),
mJSRunToCompletionDepth(0),
mTouchEventsOverride(nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE),
@ -1847,21 +1846,6 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed) {
return parent->GetFullscreenAllowed(aFullscreenAllowed);
}
NS_IMETHODIMP
nsDocShell::SetFullscreenAllowed(bool aFullscreenAllowed) {
if (!nsIDocShell::GetIsMozBrowser()) {
// Only allow setting of fullscreenAllowed on content/process boundaries.
// At non-boundaries the fullscreenAllowed attribute is calculated based on
// whether all enclosing frames have the "mozFullscreenAllowed" attribute
// set to "true". fullscreenAllowed is set at the process boundaries to
// propagate the value of the parent's "mozFullscreenAllowed" attribute
// across process boundaries.
return NS_ERROR_UNEXPECTED;
}
mFullscreenAllowed = (aFullscreenAllowed ? PARENT_ALLOWS : PARENT_PROHIBITS);
return NS_OK;
}
hal::ScreenOrientation nsDocShell::OrientationLock() {
return mOrientationLock;
}
@ -2638,21 +2622,8 @@ void nsDocShell::MaybeClearStorageAccessFlag() {
NS_IMETHODIMP
nsDocShell::GetInProcessSameTypeParent(nsIDocShellTreeItem** aParent) {
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
if (nsIDocShell::GetIsMozBrowser()) {
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeItem> parent =
do_QueryInterface(GetAsSupports(mParent));
if (!parent) {
return NS_OK;
}
if (parent->ItemType() == mItemType) {
parent.swap(*aParent);
if (BrowsingContext* parentBC = mBrowsingContext->GetParent()) {
*aParent = do_AddRef(parentBC->GetDocShell()).take();
}
return NS_OK;
}
@ -3896,10 +3867,6 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
}
errorPageUrl.AppendLiteral("&c=UTF-8");
nsAutoCString frameType(FrameTypeToString(mFrameType));
errorPageUrl.AppendLiteral("&f=");
errorPageUrl.AppendASCII(frameType.get());
nsCOMPtr<nsICaptivePortalService> cps = do_GetService(NS_CAPTIVEPORTAL_CID);
int32_t cpsState;
if (cps && NS_SUCCEEDED(cps->GetState(&cpsState)) &&
@ -4723,10 +4690,8 @@ nsDocShell::SetIsActive(bool aIsActive) {
continue;
}
if (!docshell->GetIsMozBrowser()) {
docshell->SetIsActive(aIsActive);
}
}
// Restart or stop meta refresh timers if necessary
if (mDisableMetaRefreshWhenInactive) {
@ -9014,8 +8979,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
}
}
bool isTopLevelDoc =
mItemType == typeContent && (!IsFrame() || GetIsMozBrowser());
bool isTopLevelDoc = mBrowsingContext->IsTopContent();
OriginAttributes attrs = GetOriginAttributes();
attrs.SetFirstPartyDomain(isTopLevelDoc, aLoadState->URI());
@ -12395,46 +12359,6 @@ nsDocShell::GetCanExecuteScripts(bool* aResult) {
return NS_OK;
}
/* [infallible] */
NS_IMETHODIMP nsDocShell::SetFrameType(FrameType aFrameType) {
mFrameType = aFrameType;
return NS_OK;
}
/* [infallible] */
NS_IMETHODIMP nsDocShell::GetFrameType(FrameType* aFrameType) {
*aFrameType = mFrameType;
return NS_OK;
}
/* [infallible] */
NS_IMETHODIMP nsDocShell::GetIsMozBrowser(bool* aIsMozBrowser) {
*aIsMozBrowser = (mFrameType == FRAME_TYPE_BROWSER);
return NS_OK;
}
uint32_t nsDocShell::GetInheritedFrameType() {
if (mFrameType != FRAME_TYPE_REGULAR) {
return mFrameType;
}
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
GetInProcessSameTypeParent(getter_AddRefs(parentAsItem));
nsCOMPtr<nsIDocShell> parent = do_QueryInterface(parentAsItem);
if (!parent) {
return FRAME_TYPE_REGULAR;
}
return static_cast<nsDocShell*>(parent.get())->GetInheritedFrameType();
}
/* [infallible] */
NS_IMETHODIMP nsDocShell::GetIsInMozBrowser(bool* aIsInMozBrowser) {
*aIsInMozBrowser = (GetInheritedFrameType() == FRAME_TYPE_BROWSER);
return NS_OK;
}
/* [infallible] */
NS_IMETHODIMP nsDocShell::GetIsTopLevelContentDocShell(
bool* aIsTopLevelContentDocShell) {

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

@ -569,18 +569,6 @@ class nsDocShell final : public nsDocLoader,
return uint32_t(aTimeUsec / PR_USEC_PER_SEC);
}
static const nsCString FrameTypeToString(uint32_t aFrameType) {
switch (aFrameType) {
case FRAME_TYPE_BROWSER:
return NS_LITERAL_CSTRING("browser");
case FRAME_TYPE_REGULAR:
return NS_LITERAL_CSTRING("regular");
default:
NS_ERROR("Unknown frame type");
return EmptyCString();
}
}
virtual ~nsDocShell();
//
@ -1009,7 +997,6 @@ class nsDocShell final : public nsDocLoader,
bool IsPrintingOrPP(bool aDisplayErrorDialog = true);
bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true,
bool aCheckIfUnloadFired = true);
uint32_t GetInheritedFrameType();
nsIScrollableFrame* GetRootScrollFrame();
nsIChannel* GetCurrentDocChannel();
nsresult EnsureScriptEnvironment();
@ -1223,9 +1210,6 @@ class nsDocShell final : public nsDocLoader,
uint32_t mDefaultLoadFlags;
uint32_t mFailedLoadType;
// Are we a regular frame, a browser frame, or an app frame?
FrameType mFrameType;
// This represents the CSS display-mode we are currently using. This is mostly
// used for media queries.
DisplayMode mDisplayMode;

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

@ -684,32 +684,6 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[noscript] void notifyScrollObservers();
/**
* The type of iframe that this docshell lives.
*/
cenum FrameType : 8 {
FRAME_TYPE_REGULAR = 0,
FRAME_TYPE_BROWSER = 1,
};
[infallible] attribute nsIDocShell_FrameType frameType;
/**
* Returns true if this docshell corresponds to an <iframe mozbrowser>.
* <xul:browser> returns false here.
*/
[infallible] readonly attribute boolean isMozBrowser;
/**
* Returns true if this docshell corresponds to an <iframe mozbrowser>, or
* if this docshell is contained in an <iframe mozbrowser>. <xul:browser>
* returns false here.
*
* To compute this value, we walk up the docshell hierarchy. If we encounter
* a docshell with isMozBrowser before we hit the end of the hierarchy,
* we return true. Otherwise, we return false.
*/
[infallible] readonly attribute boolean isInMozBrowser;
/**
* Returns true if this docshell is the top level content docshell.
*/
@ -717,7 +691,7 @@ interface nsIDocShell : nsIDocShellTreeItem
/**
* Like nsIDocShellTreeItem::GetSameTypeParent, except this ignores <iframe
* mozbrowser> boundaries.
* mozbrowser> boundaries. Which no longer exist.
*
* @deprecated: Use `BrowsingContext::GetParent()` in the future.
*/
@ -779,8 +753,6 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[infallible] readonly attribute boolean fullscreenAllowed;
void setFullscreenAllowed(in boolean allowed);
[notxpcom] uint32_t orientationLock();
[notxpcom] void setOrientationLock(in uint32_t orientationLock);

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

@ -2144,13 +2144,9 @@ nsresult nsFrameLoader::MaybeCreateDocShell() {
NS_ENSURE_SUCCESS(rv, rv);
}
if (OwnerIsMozBrowserFrame()) {
docShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
}
// Apply sandbox flags even if our owner is not an iframe, as this copies
// flags from our owning content's owning document.
// Note: ApplySandboxFlags should be called after docShell->SetFrameType
// Note: ApplySandboxFlags should be called after docShell->SetIsFrame
// because we need to get the correct presentation URL in ApplySandboxFlags.
uint32_t sandboxFlags = 0;
HTMLIFrameElement* iframe = HTMLIFrameElement::FromNode(mOwnerContent);
@ -2165,10 +2161,6 @@ nsresult nsFrameLoader::MaybeCreateDocShell() {
if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
docShell->SetName(name);
}
docShell->SetFullscreenAllowed(
mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
mOwnerContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::mozallowfullscreen));
}
// Typically there will be a window, however for some cases such as printing
@ -2176,8 +2168,7 @@ nsresult nsFrameLoader::MaybeCreateDocShell() {
// that the window exists to ensure we don't try to gather ancestors for
// those cases.
nsCOMPtr<nsPIDOMWindowOuter> win = doc->GetWindow();
if (!docShell->GetIsMozBrowser() &&
parentDocShell->ItemType() == docShell->ItemType() &&
if (parentDocShell->ItemType() == docShell->ItemType() &&
!doc->IsStaticDocument() && win) {
// Propagate through the ancestor principals.
nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;

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

@ -3184,13 +3184,13 @@ nsPIDOMWindowOuter* nsGlobalWindowOuter::GetInProcessScriptableParent() {
return nullptr;
}
if (mDocShell->GetIsMozBrowser()) {
return this;
}
nsCOMPtr<nsPIDOMWindowOuter> parent = GetInProcessParent();
if (BrowsingContext* parentBC = GetBrowsingContext()->GetParent()) {
if (nsCOMPtr<nsPIDOMWindowOuter> parent = parentBC->GetDOMWindow()) {
return parent;
}
}
return this;
}
/**
* Behavies identically to GetInProcessScriptableParent extept that it returns
@ -3362,13 +3362,6 @@ already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowOuter::GetContentInternal(
return content.forget();
}
// If we're contained in <iframe mozbrowser>, then GetContent is the same as
// window.top.
if (mDocShell && mDocShell->GetIsInMozBrowser()) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow(GetInProcessScriptableTop());
return domWindow.forget();
}
nsCOMPtr<nsIDocShellTreeItem> primaryContent;
if (aCallerType != CallerType::System) {
if (mDoc) {
@ -5403,19 +5396,6 @@ nsresult nsGlobalWindowOuter::MoveBy(int32_t aXDif, int32_t aYDif) {
void nsGlobalWindowOuter::ResizeToOuter(int32_t aWidth, int32_t aHeight,
CallerType aCallerType,
ErrorResult& aError) {
/*
* If caller is a browser-element then dispatch a resize event to
* the embedder.
*/
if (mDocShell && mDocShell->GetIsMozBrowser()) {
CSSIntSize size(aWidth, aHeight);
if (!DispatchResizeEvent(size)) {
// The embedder chose to prevent the default action for this
// event, so let's not resize this window after all...
return;
}
}
/*
* If caller is not chrome and the user has not explicitly exempted the site,
* prevent window.resizeTo() by exiting early
@ -5444,26 +5424,6 @@ void nsGlobalWindowOuter::ResizeToOuter(int32_t aWidth, int32_t aHeight,
void nsGlobalWindowOuter::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
CallerType aCallerType,
ErrorResult& aError) {
/*
* If caller is a browser-element then dispatch a resize event to
* parent.
*/
if (mDocShell && mDocShell->GetIsMozBrowser()) {
CSSIntSize size;
if (NS_FAILED(GetInnerSize(size))) {
return;
}
size.width += aWidthDif;
size.height += aHeightDif;
if (!DispatchResizeEvent(size)) {
// The embedder chose to prevent the default action for this
// event, so let's not resize this window after all...
return;
}
}
/*
* If caller is not chrome and the user has not explicitly exempted the site,
* prevent window.resizeBy() by exiting early
@ -6131,8 +6091,7 @@ bool nsGlobalWindowOuter::CanClose() {
}
void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
if (!mDocShell || IsInModalState() ||
(IsFrame() && !mDocShell->GetIsMozBrowser())) {
if (!mDocShell || IsInModalState() || IsFrame()) {
// window.close() is called on a frame in a frameset, on a window
// that's already closed, or on a window for which there's
// currently a modal dialog open. Ignore such calls.

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

@ -596,24 +596,12 @@ void BrowserChild::NotifyTabContextUpdated() {
return;
}
UpdateFrameType();
// Set SANDBOXED_AUXILIARY_NAVIGATION flag if this is a receiver page.
if (!PresentationURL().IsEmpty()) {
mBrowsingContext->SetSandboxFlags(SANDBOXED_AUXILIARY_NAVIGATION);
}
}
void BrowserChild::UpdateFrameType() {
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
MOZ_ASSERT(docShell);
// TODO: Bug 1252794 - remove frameType from nsIDocShell.idl
docShell->SetFrameType(IsMozBrowserElement()
? nsIDocShell::FRAME_TYPE_BROWSER
: nsIDocShell::FRAME_TYPE_REGULAR);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(BrowserChild)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(BrowserChild)
@ -1096,9 +1084,6 @@ void BrowserChild::ApplyParentShowInfo(const ParentShowInfo& aInfo) {
mDidSetRealShowInfo = true;
}
if (nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation())) {
docShell->SetFullscreenAllowed(aInfo.fullscreenAllowed());
}
mIsTransparent = aInfo.isTransparent();
}
@ -2267,11 +2252,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvSwappedWithOtherRemoteLoader(
MOZ_CRASH("Update to TabContext after swap was denied.");
}
// Since mIsMozBrowserElement may change in UpdateTabContextAfterSwap, so we
// call UpdateFrameType here to make sure the frameType on the docshell is
// correct.
UpdateFrameType();
// Ignore previous value of mTriedBrowserInit since owner content has changed.
mTriedBrowserInit = true;
// Initialize the child side of the browser element machinery, if appropriate.

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

@ -770,9 +770,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
// call this during Init().
void NotifyTabContextUpdated();
// Update the frameType on our docshell.
void UpdateFrameType();
void ActorDestroy(ActorDestroyReason why) override;
bool InitBrowserChildMessageManager();

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

@ -124,7 +124,6 @@ bool Presentation::HasReceiverSupport() const {
}
if (!StaticPrefs::dom_presentation_testing_simulate_receiver() &&
!docShell->GetIsInMozBrowser() &&
!docShell->GetIsTopLevelContentDocShell()) {
return false;
}

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

@ -1980,13 +1980,6 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForParent(
chromeFlags = EnsureFlagsSafeForContent(chromeFlags, aChromeURL);
}
// Disable CHROME_OPENAS_DIALOG if the window is inside <iframe mozbrowser>.
// It's up to the embedder to interpret what dialog=1 means.
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
if (docshell && docshell->GetIsInMozBrowser()) {
chromeFlags &= ~nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
}
return chromeFlags;
}