Bug 1157685 - Remove full-screen-api.content-only pref and its friends. r=smaug

--HG--
extra : source : 00be0263af62b29007d286d6d7dbac4ee4fdba01
This commit is contained in:
Xidorn Quan 2015-05-15 14:39:25 +12:00
Родитель fe240b1bf8
Коммит 3116f3bf53
10 изменённых файлов: 27 добавлений и 121 удалений

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

@ -3103,13 +3103,6 @@ Element::AttrValueToCORSMode(const nsAttrValue* aValue)
static const char*
GetFullScreenError(nsIDocument* aDoc)
{
// Block fullscreen requests in the chrome document when the fullscreen API
// is configured for content only.
if (nsContentUtils::IsFullscreenApiContentOnly() &&
nsContentUtils::IsChromeDoc(aDoc)) {
return "FullScreenDeniedContentOnly";
}
nsCOMPtr<nsPIDOMWindow> win = aDoc->GetWindow();
if (aDoc->NodePrincipal()->GetAppStatus() >= nsIPrincipal::APP_STATUS_INSTALLED) {
// Request is in a web app and in the same origin as the web app.

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

@ -247,7 +247,6 @@ nsString* nsContentUtils::sModifierSeparator = nullptr;
bool nsContentUtils::sInitialized = false;
bool nsContentUtils::sIsFullScreenApiEnabled = false;
bool nsContentUtils::sTrustedFullScreenOnly = true;
bool nsContentUtils::sFullscreenApiIsContentOnly = false;
bool nsContentUtils::sIsPerformanceTimingEnabled = false;
bool nsContentUtils::sIsResourceTimingEnabled = false;
bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
@ -512,12 +511,6 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sIsFullScreenApiEnabled,
"full-screen-api.enabled");
// Note: We deliberately read this pref here because this code runs
// before the profile loads, so users' changes to this pref in about:config
// won't have any effect on behaviour. We don't really want users messing
// with this pref, as it affects the security model of the fullscreen API.
sFullscreenApiIsContentOnly = Preferences::GetBool("full-screen-api.content-only", false);
Preferences::AddBoolVarCache(&sTrustedFullScreenOnly,
"full-screen-api.allow-trusted-requests-only");
@ -6635,13 +6628,6 @@ nsContentUtils::IsRequestFullScreenAllowed()
IsCallerChrome();
}
/* static */
bool
nsContentUtils::IsFullscreenApiContentOnly()
{
return sFullscreenApiIsContentOnly;
}
/* static */
bool
nsContentUtils::HaveEqualPrincipals(nsIDocument* aDoc1, nsIDocument* aDoc2)
@ -6752,16 +6738,16 @@ nsContentUtils::FireMutationEventsForDirectParsing(nsIDocument* aDoc,
/* static */
nsIDocument*
nsContentUtils::GetFullscreenAncestor(nsIDocument* aDoc)
nsContentUtils::GetRootDocument(nsIDocument* aDoc)
{
if (!aDoc) {
return nullptr;
}
nsIDocument* doc = aDoc;
while (doc) {
if (doc->IsFullScreenDoc()) {
return doc;
}
while (doc->GetParentDocument()) {
doc = doc->GetParentDocument();
}
return nullptr;
return doc;
}
/* static */

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

@ -1860,32 +1860,6 @@ public:
*/
static bool IsRequestFullScreenAllowed();
/**
* Returns true if the DOM fullscreen API is restricted to content only.
* This mirrors the pref "full-screen-api.content-only". If this is true,
* fullscreen requests in chrome are denied, and fullscreen requests in
* content stop percolating upwards before they reach chrome documents.
* That is, when an element in content requests fullscreen, only its
* containing frames that are in content are also made fullscreen, not
* the containing frame in the chrome document.
*
* Note if the fullscreen API is running in content only mode then multiple
* branches of a doctree can be fullscreen at the same time, but no fullscreen
* document will have a common ancestor with another fullscreen document
* that is also fullscreen (since the only common ancestor they can have
* is the chrome document, and that can't be fullscreen). i.e. multiple
* child documents of the chrome document can be fullscreen, but the chrome
* document won't be fullscreen.
*
* Making the fullscreen API content only is useful on platforms where we
* still want chrome to be visible or accessible while content is
* fullscreen.
*
* Note that if the fullscreen API is content only, chrome can still go
* fullscreen by setting the "fullScreen" attribute on its XUL window.
*/
static bool IsFullscreenApiContentOnly();
/*
* Returns true if the performance timing APIs are enabled.
*/
@ -1948,12 +1922,10 @@ public:
static bool HasPluginWithUncontrolledEventDispatch(nsIContent* aContent);
/**
* Returns the document that is the closest ancestor to aDoc that is
* fullscreen. If aDoc is fullscreen this returns aDoc. If aDoc is not
* fullscreen and none of aDoc's ancestors are fullscreen this returns
* nullptr.
* Returns the root document in a document hierarchy. Normally this
* will be the chrome document.
*/
static nsIDocument* GetFullscreenAncestor(nsIDocument* aDoc);
static nsIDocument* GetRootDocument(nsIDocument* aDoc);
/**
* Returns true if aWin and the current pointer lock document
@ -2452,7 +2424,6 @@ private:
static bool sAllowXULXBL_for_file;
static bool sIsFullScreenApiEnabled;
static bool sTrustedFullScreenOnly;
static bool sFullscreenApiIsContentOnly;
static uint32_t sHandlingInputTimeout;
static bool sIsPerformanceTimingEnabled;
static bool sIsResourceTimingEnabled;

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

@ -11051,35 +11051,17 @@ private:
nsRefPtr<gfx::VRHMDInfo> mHMD;
};
static nsIDocument*
GetFullscreenRootDocument(nsIDocument* aDoc)
{
if (!aDoc) {
return nullptr;
}
nsIDocument* doc = aDoc;
nsIDocument* parent;
while ((parent = doc->GetParentDocument()) &&
(!nsContentUtils::IsFullscreenApiContentOnly() ||
!nsContentUtils::IsChromeDoc(parent))) {
doc = parent;
}
return doc;
}
static void
SetWindowFullScreen(nsIDocument* aDoc, bool aValue, gfx::VRHMDInfo *aVRHMD = nullptr)
{
// Maintain list of fullscreen root documents.
nsCOMPtr<nsIDocument> root = GetFullscreenRootDocument(aDoc);
nsCOMPtr<nsIDocument> root = nsContentUtils::GetRootDocument(aDoc);
if (aValue) {
FullscreenRoots::Add(root);
} else {
FullscreenRoots::Remove(root);
}
if (!nsContentUtils::IsFullscreenApiContentOnly()) {
nsContentUtils::AddScriptRunner(new nsSetWindowFullScreen(aDoc, aValue, aVRHMD));
}
nsContentUtils::AddScriptRunner(new nsSetWindowFullScreen(aDoc, aValue, aVRHMD));
}
class nsCallExitFullscreen : public nsRunnable {
@ -11284,7 +11266,7 @@ GetFullscreenLeaf(nsIDocument* aDoc)
}
// Otherwise we could be either in a non-fullscreen doc tree, or we're
// below the fullscreen doc. Start the search from the root.
nsIDocument* root = GetFullscreenRootDocument(aDoc);
nsIDocument* root = nsContentUtils::GetRootDocument(aDoc);
// Check that the root is actually fullscreen so we don't waste time walking
// around its descendants.
if (!root->IsFullScreenDoc()) {
@ -11299,10 +11281,6 @@ nsDocument::RestorePreviousFullScreenState()
{
NS_ASSERTION(!IsFullScreenDoc() || !FullscreenRoots::IsEmpty(),
"Should have at least 1 fullscreen root when fullscreen!");
NS_ASSERTION(!nsContentUtils::IsFullscreenApiContentOnly() ||
!nsContentUtils::IsChromeDoc(this),
"Should not run RestorePreviousFullScreenState() on "
"chrome document when fullscreen is content only");
if (!IsFullScreenDoc() || !GetWindow() || FullscreenRoots::IsEmpty()) {
return;
@ -11377,7 +11355,7 @@ nsDocument::RestorePreviousFullScreenState()
// as necessary.
nsAutoString origin;
nsContentUtils::GetUTFOrigin(doc->NodePrincipal(), origin);
nsIDocument* root = GetFullscreenRootDocument(doc);
nsIDocument* root = nsContentUtils::GetRootDocument(doc);
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
os->NotifyObservers(root, "fullscreen-origin-change", origin.get());
}
@ -11389,8 +11367,8 @@ nsDocument::RestorePreviousFullScreenState()
if (doc == nullptr) {
// We moved all documents in this doctree out of fullscreen mode,
// move the top-level window out of fullscreen mode.
NS_ASSERTION(!GetFullscreenRootDocument(this)->IsFullScreenDoc(),
"Should have cleared all docs' stacks");
NS_ASSERTION(!nsContentUtils::GetRootDocument(this)->IsFullScreenDoc(),
"Should have cleared all docs' stacks");
nsRefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
this, NS_LITERAL_STRING("MozExitedDomFullscreen"), true, true);
asyncDispatcher->PostDOMEvent();
@ -11477,8 +11455,7 @@ LogFullScreenDenied(bool aLogFailure, const char* aMessage, nsIDocument* aDoc)
nsresult
nsDocument::AddFullscreenApprovedObserver()
{
if (mHasFullscreenApprovedObserver ||
!Preferences::GetBool("full-screen-api.approval-required")) {
if (mHasFullscreenApprovedObserver) {
return NS_OK;
}
@ -11666,7 +11643,7 @@ nsresult nsDocument::RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement,
// it can show a warning or approval UI.
if (!aOrigin.IsEmpty()) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
os->NotifyObservers(GetFullscreenRootDocument(this),
os->NotifyObservers(nsContentUtils::GetRootDocument(this),
"fullscreen-origin-change",
PromiseFlatString(aOrigin).get());
}
@ -11711,13 +11688,6 @@ nsDocument::RequestFullScreen(Element* aElement,
LogFullScreenDenied(true, "FullScreenDeniedLostWindow", this);
return;
}
if (nsContentUtils::IsFullscreenApiContentOnly() &&
nsContentUtils::IsChromeDoc(this)) {
// Block fullscreen requests in the chrome document when the fullscreen API
// is configured for content only.
LogFullScreenDenied(true, "FullScreenDeniedContentOnly", this);
return;
}
if (!IsFullScreenEnabled(aWasCallerChrome, true)) {
// IsFullScreenEnabled calls LogFullScreenDenied, no need to log.
return;
@ -11764,7 +11734,7 @@ nsDocument::RequestFullScreen(Element* aElement,
// Remember the root document, so that if a full-screen document is hidden
// we can reset full-screen state in the remaining visible full-screen documents.
nsIDocument* fullScreenRootDoc = GetFullscreenRootDocument(this);
nsIDocument* fullScreenRootDoc = nsContentUtils::GetRootDocument(this);
if (fullScreenRootDoc->IsFullScreenDoc()) {
// A document is already in fullscreen, unlock the mouse pointer
// before setting a new document to fullscreen
@ -11878,7 +11848,7 @@ nsDocument::RequestFullScreen(Element* aElement,
if (aNotifyOnOriginChange &&
!nsContentUtils::HaveEqualPrincipals(previousFullscreenDoc, this)) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
nsIDocument* root = GetFullscreenRootDocument(this);
nsIDocument* root = nsContentUtils::GetRootDocument(this);
nsAutoString origin;
nsContentUtils::GetUTFOrigin(NodePrincipal(), origin);
os->NotifyObservers(root, "fullscreen-origin-change", origin.get());

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

@ -1231,16 +1231,15 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
// key input if a windowed plugin is focused, so just exit fullscreen
// to guard against phishing.
#ifndef XP_MACOSX
nsIDocument* fullscreenAncestor;
if (contentToFocus &&
(fullscreenAncestor = nsContentUtils::GetFullscreenAncestor(contentToFocus->OwnerDoc())) &&
nsContentUtils::GetRootDocument(contentToFocus->OwnerDoc())->IsFullScreenDoc() &&
nsContentUtils::HasPluginWithUncontrolledEventDispatch(contentToFocus)) {
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM"),
contentToFocus->OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES,
"FocusedWindowedPluginWhileFullScreen");
nsIDocument::ExitFullscreen(fullscreenAncestor, /* async */ true);
nsIDocument::ExitFullscreen(contentToFocus->OwnerDoc(), /* async */ true);
}
#endif

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

@ -1161,10 +1161,7 @@ public:
*
* Note that the fullscreen leaf is the bottom-most document which is
* fullscreen, it may have non-fullscreen child documents. The fullscreen
* root is usually the chrome document, but if fullscreen is content-only,
* (see the comment in nsContentUtils.h on IsFullscreenApiContentOnly())
* the fullscreen root will be a direct child of the chrome document, and
* there may be other branches of the same doctree that are fullscreen.
* root is normally the chrome document.
*
* If aRunAsync is true, fullscreen is executed asynchronously.
*

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

@ -79,7 +79,6 @@ FullScreenDeniedLostWindow=Request for full-screen was denied because we no long
FullScreenDeniedSubDocFullScreen=Request for full-screen was denied because a subdocument of the document requesting full-screen is already full-screen.
FullScreenDeniedNotDescendant=Request for full-screen was denied because requesting element is not a descendant of the current full-screen element.
FullScreenDeniedNotFocusedTab=Request for full-screen was denied because requesting element is not in the currently focused tab.
FullScreenDeniedContentOnly=Request for full-screen was denied because requesting element is in the chrome document and the fullscreen API is configured for content only.
RemovedFullScreenElement=Exited full-screen because full-screen element was removed from document.
FocusedWindowedPluginWhileFullScreen=Exited full-screen because windowed plugin was focused.
HTMLSyncXHRWarning=HTML parsing in XMLHttpRequest is not supported in the synchronous mode.

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

@ -8035,10 +8035,10 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus)
case NS_KEY_UP: {
nsIDocument* doc = GetCurrentEventContent() ?
mCurrentEventContent->OwnerDoc() : nullptr;
nsIDocument* fullscreenAncestor = nullptr;
auto keyCode = aEvent->AsKeyboardEvent()->keyCode;
if (keyCode == NS_VK_ESCAPE) {
if ((fullscreenAncestor = nsContentUtils::GetFullscreenAncestor(doc))) {
nsIDocument* root = nsContentUtils::GetRootDocument(doc);
if (root && root->IsFullScreenDoc()) {
// Prevent default action on ESC key press when exiting
// DOM fullscreen mode. This prevents the browser ESC key
// handler from stopping all loads in the document, which
@ -8051,16 +8051,9 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus)
if (!mIsLastChromeOnlyEscapeKeyConsumed &&
aEvent->message == NS_KEY_UP) {
// ESC key released while in DOM fullscreen mode.
// If fullscreen is running in content-only mode, exit the target
// doctree branch from fullscreen, otherwise fully exit all
// browser windows and documents from fullscreen mode.
// Note: in the content-only fullscreen case, we pass the
// fullscreenAncestor since |doc| may not actually be fullscreen
// here, and ExitFullscreen() has no affect when passed a
// non-fullscreen document.
nsIDocument::ExitFullscreen(
nsContentUtils::IsFullscreenApiContentOnly() ? fullscreenAncestor : nullptr,
/* async */ true);
// Fully exit all browser windows and documents from
// fullscreen mode.
nsIDocument::ExitFullscreen(nullptr, /* async */ true);
}
}
nsCOMPtr<nsIDocument> pointerLockedDoc =

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

@ -4196,7 +4196,6 @@ pref("alerts.disableSlidingEffect", false);
// DOM full-screen API.
pref("full-screen-api.enabled", false);
pref("full-screen-api.allow-trusted-requests-only", true);
pref("full-screen-api.content-only", false);
pref("full-screen-api.pointer-lock.enabled", true);
// DOM idle observers API

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

@ -79,7 +79,6 @@ FullScreenDeniedLostWindow=Request for full-screen was denied because we no long
FullScreenDeniedSubDocFullScreen=Request for full-screen was denied because a subdocument of the document requesting full-screen is already full-screen.
FullScreenDeniedNotDescendant=Request for full-screen was denied because requesting element is not a descendant of the current full-screen element.
FullScreenDeniedNotFocusedTab=Request for full-screen was denied because requesting element is not in the currently focused tab.
FullScreenDeniedContentOnly=Request for full-screen was denied because requesting element is in the chrome document and the fullscreen API is configured for content only.
RemovedFullScreenElement=Exited full-screen because full-screen element was removed from document.
FocusedWindowedPluginWhileFullScreen=Exited full-screen because windowed plugin was focused.
HTMLSyncXHRWarning=HTML parsing in XMLHttpRequest is not supported in the synchronous mode.