Bug 1606660 - Move allowfullscreen checks to the browsing context. r=nika
So that they work properly on fission iframes. Differential Revision: https://phabricator.services.mozilla.com/D78702
This commit is contained in:
@@ -1743,74 +1743,6 @@ nsDocShell::SetAllowContentRetargetingOnChildren(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed) {
|
||||
NS_ENSURE_ARG_POINTER(aFullscreenAllowed);
|
||||
|
||||
// Assume false until we determine otherwise...
|
||||
*aFullscreenAllowed = false;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// FIXME(emilio, bug 1606660): What makes this work in fission?
|
||||
if (nsCOMPtr<Element> frameElement = win->GetFrameElementInternal()) {
|
||||
if (frameElement->IsXULElement()) {
|
||||
if (frameElement->HasAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::disablefullscreen)) {
|
||||
// Document inside this frame is explicitly disabled.
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
// We do not allow document inside any containing element other
|
||||
// than iframe to enter fullscreen.
|
||||
if (auto* iframe = HTMLIFrameElement::FromNode(*frameElement)) {
|
||||
// If any ancestor iframe does not have allowfullscreen attribute
|
||||
// set, then fullscreen is not allowed.
|
||||
if (!iframe->AllowFullscreen()) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (frameElement->IsHTMLElement(nsGkAtoms::embed)) {
|
||||
// Respect allowfullscreen only if this is a rewritten YouTube embed.
|
||||
nsCOMPtr<nsIObjectLoadingContent> objectLoadingContent =
|
||||
do_QueryInterface(frameElement);
|
||||
if (!objectLoadingContent) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsObjectLoadingContent* olc =
|
||||
static_cast<nsObjectLoadingContent*>(objectLoadingContent.get());
|
||||
if (!olc->IsRewrittenYoutubeEmbed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
// We don't have to check prefixed attributes because Flash does not
|
||||
// support them.
|
||||
if (!frameElement->HasAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::allowfullscreen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
// neither iframe nor embed
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we have no parent then we're the root docshell; no ancestor of the
|
||||
// original docshell doesn't have a allowfullscreen attribute, so
|
||||
// report fullscreen as allowed.
|
||||
RefPtr<nsDocShell> parent = GetInProcessParentDocshell();
|
||||
if (!parent) {
|
||||
*aFullscreenAllowed = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, we have a parent, continue the checking for
|
||||
// mozFullscreenAllowed in the parent docshell's ancestors.
|
||||
return parent->GetFullscreenAllowed(aFullscreenAllowed);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetMayEnableCharacterEncodingMenu(
|
||||
bool* aMayEnableCharacterEncodingMenu) {
|
||||
|
||||
Reference in New Issue
Block a user