Bug 1285069 part 1 - Remove code around pending fullscreen request. r?smaug
This code is no longer needed as we are always granting pointerlock request.
MozReview-Commit-ID: 3HVo3CddqWY
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11874,37 +11874,21 @@ nsDocument::FullscreenElementReadyCheck(
return true;
}
FullscreenRequest::FullscreenRequest(Element* aElement)
: mElement(aElement)
, mDocument(static_cast<nsDocument*>(aElement->OwnerDoc()))
{
MOZ_COUNT_CTOR(FullscreenRequest);
- mDocument->mPendingFullscreenRequests++;
- if (MOZ_UNLIKELY(!mDocument->mPendingFullscreenRequests)) {
- NS_WARNING("Pending fullscreen request counter overflow");
- }
-}
-
-static void RedispatchPendingPointerLockRequest(nsIDocument* aDocument);
+}
FullscreenRequest::~FullscreenRequest()
{
MOZ_COUNT_DTOR(FullscreenRequest);
- if (MOZ_UNLIKELY(!mDocument->mPendingFullscreenRequests)) {
- NS_WARNING("Pending fullscreen request counter underflow");
- return;
- }
- mDocument->mPendingFullscreenRequests--;
- if (!mDocument->mPendingFullscreenRequests) {
- // There may be pointer lock request be blocked because of pending
- // fullscreen requests. Re-dispatch it to ensure it gets handled.
- RedispatchPendingPointerLockRequest(mDocument);
- }
}
// Any fullscreen request waiting for the widget to finish being full-
// screen is queued here. This is declared static instead of a member
// of nsDocument because in the majority of time, there would be at most
// one document requesting fullscreen. We shouldn't waste the space to
// hold for it in every document.
class PendingFullscreenRequestList
@@ -12346,21 +12330,16 @@ public:
if (!e || !d || gPendingPointerLockRequest != this ||
e->GetUncomposedDoc() != d) {
Handled();
DispatchPointerLockError(d);
return NS_OK;
}
nsDocument* doc = static_cast<nsDocument*>(d.get());
- if (doc->mPendingFullscreenRequests > 0) {
- // We're still entering fullscreen.
- return NS_OK;
- }
-
if (doc->GetFullscreenElement() || doc->mAllowRelocking) {
Allow(JS::UndefinedHandleValue);
return NS_OK;
}
// In non-fullscreen mode user input (or chrome caller) is required!
// Also, don't let the page to try to get the permission too many times.
if (!mUserInputOrChromeCaller ||
@@ -12506,45 +12485,16 @@ nsPointerLockPermissionRequest::GetReque
{
NS_ENSURE_ARG_POINTER(aRequester);
nsCOMPtr<nsIContentPermissionRequester> requester = mRequester;
requester.forget(aRequester);
return NS_OK;
}
-static void
-RedispatchPendingPointerLockRequest(nsIDocument* aDocument)
-{
- if (!gPendingPointerLockRequest) {
- return;
- }
- nsCOMPtr<nsIDocument> doc =
- do_QueryReferent(gPendingPointerLockRequest->mDocument);
- if (doc != aDocument) {
- return;
- }
- nsCOMPtr<Element> elem =
- do_QueryReferent(gPendingPointerLockRequest->mElement);
- if (!elem || elem->GetUncomposedDoc() != aDocument) {
- gPendingPointerLockRequest->Handled();
- return;
- }
-
- // We have a request pending on the document which may previously be
- // blocked for fullscreen change. Create a clone and re-dispatch it
- // to guarantee that Run() method gets called again.
- bool userInputOrChromeCaller =
- gPendingPointerLockRequest->mUserInputOrChromeCaller;
- gPendingPointerLockRequest->Handled();
- gPendingPointerLockRequest =
- new nsPointerLockPermissionRequest(elem, userInputOrChromeCaller);
- NS_DispatchToMainThread(gPendingPointerLockRequest);
-}
-
nsresult
nsDocument::Observe(nsISupports *aSubject,
const char *aTopic,
const char16_t *aData)
{
if (strcmp("app-theme-changed", aTopic) == 0) {
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()) &&
!IsUnstyledDocument()) {