Gecko:Fullscreen API
Jump to navigation
Jump to search
(WIP)
This page is for documenting our Fullscreen API implementation.
Resources
- Fullscreen API spec
- Fullscreen design from :Verdi also includes some background info
Basic Control Flow
The flow of how Fullscreen API works is a bit complicated because we want to change the state of the document after the window enters or leaves fullscreen, so that we can:
- provide a stable viewport size when we notify the content, and
- insert fullscreen transition there.
This flow is different for non-e10s, e10s, and the browser element, because we need to go across the process boundary in later cases.
Non-E10S
For entering fullscreen:
- the page calls Element.requestFullscreen() (Element::MozRequestFullScreen())
- (async) calls nsDocument::RequestFullscreen()
- calls nsGlobalWindow::SetFullScreenInternal()
- calls widget to enter fullscreen
- (async) calls nsGlobalWindow::FinishFullscreenChange() <-- triggers when the window enters fullscreen
- calls nsIDocument::HandlePendingFullscreenRequests()
- change the document state in nsDocument::ApplyFullscreen()
For exiting fullscreen by page:
- the page calls document.exitFullscreen() (nsDocument::MozCancelFullScreen())
- calls nsGlobalWindow::SetFullScreenInternal()
- calls widget to leave fullscreen
- (async) calls nsGlobalWindow::FinishFullscreenChange() <-- triggers when the window exits fullscreen
- calls nsIDocument::ExitFullscreenInDocTree() which changes the document state
For exiting fullscreen by user (via escape key):
- in PresShell::HandleEventInternal()
- calls nsIDocument::AsyncExitFullscreen()
- (async) calls nsGlobalWindow::SetFullscreenInternal()
- then same as above...
For exiting fullscreen unexpectedly (page closure / fullscreen element removal):
- in nsDocument::OnPageHide() (for page closure) / Element::UnbindFromTree() (for element removal)
- calls nsIDocument::ExitFullscreenInDocTree() which changes the document state
- (may async) calls nsGlobalWindow::SetFullscreenInternal()
- calls widget to leave fullscreen