Bug 1285069 part 1 - Remove code around pending fullscreen request. r?smaug draft
authorXidorn Quan <me@upsuper.org>
Mon, 11 Jul 2016 09:42:15 +1000
changeset 386053 49f8ae12f5957f8a1da7926091fa32464217f234
parent 386052 09489f5e56c6f65233479361ae21e0420f08f2a9
child 386054 8d0c3dda8c7c756c21d5a195c5465ab957a035dd
child 386056 6bdf59cc71948d89e124c5e18d0b9c911f7d3bf3
child 386486 7077f46e08c649db8d3de696af6084132cdbe63c
push id22608
push userxquan@mozilla.com
push dateMon, 11 Jul 2016 00:18:03 +0000
reviewerssmaug
bugs1285069
milestone50.0a1
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
dom/base/nsDocument.cpp
--- 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()) {