Bug 1174966 part 5 - Re-dispatch pointer lock request after all fullscreen requests finish. r=smaug

--HG--
extra : source : e7c84940c5fc80eec70017381aad5e9a2c8375a3
This commit is contained in:
Xidorn Quan 2015-06-19 10:09:52 +10:00
Родитель 13e33b4858
Коммит e6f1b6fdb7
2 изменённых файлов: 38 добавлений и 19 удалений

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

@ -11592,6 +11592,8 @@ FullscreenRequest::FullscreenRequest(Element* aElement)
}
}
static void RedispatchPendingPointerLockRequest(nsIDocument* aDocument);
FullscreenRequest::~FullscreenRequest()
{
MOZ_COUNT_DTOR(FullscreenRequest);
@ -11600,6 +11602,11 @@ FullscreenRequest::~FullscreenRequest()
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-
@ -11965,6 +11972,7 @@ DispatchPointerLockError(nsIDocument* aTarget)
static const uint8_t kPointerLockRequestLimit = 2;
class nsPointerLockPermissionRequest;
mozilla::StaticRefPtr<nsPointerLockPermissionRequest> gPendingPointerLockRequest;
class nsPointerLockPermissionRequest : public nsRunnable,
@ -12165,6 +12173,35 @@ nsDocument::SetApprovedForFullscreen(bool aIsApproved)
mIsApprovedForFullscreen = aIsApproved;
}
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 approval. 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,
@ -12176,24 +12213,7 @@ nsDocument::Observe(nsISupports *aSubject,
return NS_OK;
}
SetApprovedForFullscreen(true);
if (gPendingPointerLockRequest) {
// We have a request pending. Create a clone of it and re-dispatch so that
// Run() method gets called again.
nsCOMPtr<Element> el =
do_QueryReferent(gPendingPointerLockRequest->mElement);
nsCOMPtr<nsIDocument> doc =
do_QueryReferent(gPendingPointerLockRequest->mDocument);
bool userInputOrChromeCaller =
gPendingPointerLockRequest->mUserInputOrChromeCaller;
gPendingPointerLockRequest->Handled();
if (doc == this && el && el->GetUncomposedDoc() == doc) {
nsPointerLockPermissionRequest* clone =
new nsPointerLockPermissionRequest(el, userInputOrChromeCaller);
gPendingPointerLockRequest = clone;
nsCOMPtr<nsIRunnable> r = gPendingPointerLockRequest.get();
NS_DispatchToMainThread(r);
}
}
RedispatchPendingPointerLockRequest(this);
} else if (strcmp("app-theme-changed", aTopic) == 0) {
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()) &&
!IsUnstyledDocument()) {

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

@ -86,7 +86,6 @@ class nsDOMNavigationTiming;
class nsWindowSizes;
class nsHtml5TreeOpExecutor;
class nsDocumentOnStack;
class nsPointerLockPermissionRequest;
class nsISecurityConsoleMessage;
class nsPIBoxObject;