diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index b9c0459f1a56..46e9b7ad8ce2 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3584,9 +3584,7 @@ Element::RequestFullscreen(CallerType aCallerType, ErrorResult& aError) return; } - auto request = MakeUnique(this); - request->mIsCallerChrome = (aCallerType == CallerType::System); - + auto request = MakeUnique(this, aCallerType); OwnerDoc()->AsyncRequestFullscreen(std::move(request)); } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 647c56e2128b..40ce60365ceb 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -11094,8 +11094,8 @@ nsresult nsIDocument::RemoteFrameFullscreenChanged(Element* aFrameElement) // Ensure the frame element is the fullscreen element in this document. // If the frame element is already the fullscreen element in this document, // this has no effect. - auto request = MakeUnique(aFrameElement); - request->mIsCallerChrome = false; + auto request = MakeUnique(aFrameElement, + CallerType::NonSystem); request->mShouldNotifyNewOrigin = false; RequestFullscreen(std::move(request)); @@ -11128,10 +11128,10 @@ HasFullscreenSubDocument(nsIDocument* aDoc) // 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) +GetFullscreenError(nsIDocument* aDoc, CallerType aCallerType) { bool apiEnabled = nsContentUtils::IsFullscreenApiEnabled(); - if (apiEnabled && aCallerIsChrome) { + if (apiEnabled && aCallerType == CallerType::System) { // Chrome code can always use the fullscreen API, provided it's not // explicitly disabled. return nullptr; @@ -11152,7 +11152,7 @@ GetFullscreenError(nsIDocument* aDoc, bool aCallerIsChrome) bool nsIDocument::FullscreenElementReadyCheck(Element* aElement, - bool aWasCallerChrome) + CallerType aCallerType) { NS_ASSERTION(aElement, "Must pass non-null element to nsDocument::RequestFullscreen"); @@ -11171,7 +11171,7 @@ nsIDocument::FullscreenElementReadyCheck(Element* aElement, DispatchFullscreenError("FullscreenDeniedLostWindow"); return false; } - if (const char* msg = GetFullscreenError(this, aWasCallerChrome)) { + if (const char* msg = GetFullscreenError(this, aCallerType)) { DispatchFullscreenError(msg); return false; } @@ -11210,9 +11210,10 @@ nsIDocument::FullscreenElementReadyCheck(Element* aElement, return true; } -FullscreenRequest::FullscreenRequest(Element* aElement) +FullscreenRequest::FullscreenRequest(Element* aElement, CallerType aCallerType) : mElement(aElement) , mDocument(static_cast(aElement->OwnerDoc())) + , mCallerType(aCallerType) { MOZ_COUNT_CTOR(FullscreenRequest); } @@ -11389,7 +11390,7 @@ nsIDocument::RequestFullscreen(UniquePtr aRequest) // We don't need to check element ready before this point, because // if we called ApplyFullscreen, it would check that for us. - if (!FullscreenElementReadyCheck(elem, aRequest->mIsCallerChrome)) { + if (!FullscreenElementReadyCheck(elem, aRequest->mCallerType)) { return; } @@ -11436,7 +11437,7 @@ bool nsIDocument::ApplyFullscreen(const FullscreenRequest& aRequest) { Element* elem = aRequest.GetElement(); - if (!FullscreenElementReadyCheck(elem, aRequest.mIsCallerChrome)) { + if (!FullscreenElementReadyCheck(elem, aRequest.mCallerType)) { return false; } @@ -11534,7 +11535,7 @@ nsIDocument::ApplyFullscreen(const FullscreenRequest& aRequest) bool nsIDocument::FullscreenEnabled(CallerType aCallerType) { - return !GetFullscreenError(this, aCallerType == CallerType::System); + return !GetFullscreenError(this, aCallerType); } void diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 361a572c9e34..1bd9cb9a1c2d 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -88,7 +88,7 @@ class Performance; struct FullscreenRequest : public LinkedListElement { - explicit FullscreenRequest(Element* aElement); + FullscreenRequest(Element* aElement, CallerType aCallerType); FullscreenRequest(const FullscreenRequest&) = delete; ~FullscreenRequest(); @@ -101,8 +101,8 @@ private: public: // This value should be true if the fullscreen request is - // originated from chrome code. - bool mIsCallerChrome = false; + // originated from system code. + const CallerType mCallerType; // This value denotes whether we should trigger a NewOrigin event if // requesting fullscreen in its document causes the origin which is // fullscreen to change. We may want *not* to trigger that event if diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 785a8dab1b9d..77c48d247e0e 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -1756,7 +1756,8 @@ public: // Do the "fullscreen element ready check" from the fullscreen spec. // It returns true if the given element is allowed to go into fullscreen. - bool FullscreenElementReadyCheck(Element* aElement, bool aWasCallerChrome); + bool FullscreenElementReadyCheck(Element* aElement, + mozilla::dom::CallerType aCallerType); // This is called asynchronously by nsIDocument::AsyncRequestFullscreen() // to move this document into fullscreen mode if allowed.