mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 743198 part 3 - Refactor nsDocument::IsFullScreenEnabled to be static local function GetFullscreenError. r=smaug
This commit is contained in:
parent
6536557784
commit
6c40e9925c
@ -11558,6 +11558,48 @@ ReleaseVRDeviceProxyRef(void *, nsIAtom*, void *aPropertyValue, void *)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
HasFullScreenSubDocument(nsIDocument* aDoc)
|
||||
{
|
||||
uint32_t count = CountFullscreenSubDocuments(aDoc);
|
||||
NS_ASSERTION(count <= 1, "Fullscreen docs should have at most 1 fullscreen child!");
|
||||
return count >= 1;
|
||||
}
|
||||
|
||||
// Returns nullptr if a request for Fullscreen API is currently enabled
|
||||
// in the given document. Returns a static string indicates the reason
|
||||
// why it is not enabled otherwise.
|
||||
static const char*
|
||||
GetFullscreenError(nsIDocument* aDoc, bool aCallerIsChrome)
|
||||
{
|
||||
if (nsContentUtils::IsFullScreenApiEnabled() && aCallerIsChrome) {
|
||||
// Chrome code can always use the full-screen API, provided it's not
|
||||
// explicitly disabled. Note IsCallerChrome() returns true when running
|
||||
// in an nsRunnable, so don't use GetMozFullScreenEnabled() from an
|
||||
// nsRunnable!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled()) {
|
||||
return "FullScreenDeniedDisabled";
|
||||
}
|
||||
if (!aDoc->IsVisible()) {
|
||||
return "FullScreenDeniedHidden";
|
||||
}
|
||||
if (HasFullScreenSubDocument(aDoc)) {
|
||||
return "FullScreenDeniedSubDocFullScreen";
|
||||
}
|
||||
|
||||
// Ensure that all containing elements are <iframe> and have
|
||||
// allowfullscreen attribute set.
|
||||
nsCOMPtr<nsIDocShell> docShell(aDoc->GetDocShell());
|
||||
if (!docShell || !docShell->GetFullscreenAllowed()) {
|
||||
return "FullScreenDeniedContainerNotAllowed";
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::FullscreenElementReadyCheck(Element* aElement,
|
||||
bool aWasCallerChrome)
|
||||
@ -11579,8 +11621,8 @@ nsDocument::FullscreenElementReadyCheck(Element* aElement,
|
||||
LogFullScreenDenied(true, "FullScreenDeniedLostWindow", this);
|
||||
return false;
|
||||
}
|
||||
if (!IsFullScreenEnabled(aWasCallerChrome, true)) {
|
||||
// IsFullScreenEnabled calls LogFullScreenDenied, no need to log.
|
||||
if (const char* msg = GetFullscreenError(this, aWasCallerChrome)) {
|
||||
LogFullScreenDenied(true, msg, this);
|
||||
return false;
|
||||
}
|
||||
if (GetFullscreenElement() &&
|
||||
@ -11989,50 +12031,7 @@ nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
|
||||
bool
|
||||
nsDocument::FullscreenEnabled()
|
||||
{
|
||||
return IsFullScreenEnabled(nsContentUtils::IsCallerChrome(), false);
|
||||
}
|
||||
|
||||
static bool
|
||||
HasFullScreenSubDocument(nsIDocument* aDoc)
|
||||
{
|
||||
uint32_t count = CountFullscreenSubDocuments(aDoc);
|
||||
NS_ASSERTION(count <= 1, "Fullscreen docs should have at most 1 fullscreen child!");
|
||||
return count >= 1;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsFullScreenEnabled(bool aCallerIsChrome, bool aLogFailure)
|
||||
{
|
||||
if (nsContentUtils::IsFullScreenApiEnabled() && aCallerIsChrome) {
|
||||
// Chrome code can always use the full-screen API, provided it's not
|
||||
// explicitly disabled. Note IsCallerChrome() returns true when running
|
||||
// in an nsRunnable, so don't use GetMozFullScreenEnabled() from an
|
||||
// nsRunnable!
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled()) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedDisabled", this);
|
||||
return false;
|
||||
}
|
||||
if (!IsVisible()) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedHidden", this);
|
||||
return false;
|
||||
}
|
||||
if (HasFullScreenSubDocument(this)) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedSubDocFullScreen", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure that all containing elements are <iframe> and have
|
||||
// allowfullscreen attribute set.
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
|
||||
if (!docShell || !docShell->GetFullscreenAllowed()) {
|
||||
LogFullScreenDenied(aLogFailure, "FullScreenDeniedContainerNotAllowed", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !GetFullscreenError(this, nsContentUtils::IsCallerChrome());
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
@ -1418,15 +1418,6 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if a request for DOM full-screen is currently enabled in
|
||||
// this document. This returns true if there are no windowed plugins in this
|
||||
// doc tree, and if the document is visible, and if the api is not
|
||||
// disabled by pref. aIsCallerChrome must contain the return value of
|
||||
// nsContentUtils::IsCallerChrome() from the context we're checking.
|
||||
// If aLogFailure is true, an appropriate warning message is logged to the
|
||||
// console, and a "mozfullscreenerror" event is dispatched to this document.
|
||||
bool IsFullScreenEnabled(bool aIsCallerChrome, bool aLogFailure);
|
||||
|
||||
/**
|
||||
* Check that aId is not empty and log a message to the console
|
||||
* service if it is.
|
||||
|
Loading…
Reference in New Issue
Block a user