From MozillaWiki
Jump to: navigation, search

See Gecko:FullScreenAPI.

Firefox Requirements

  • Integrate scripted fullscreen with user-chosen fullscreen

Gecko Implementation

Initially we won't support fullscreening of IFRAMEs.

We store the following state:

  • a boolean on the toplevel window indicating whether the toplevel window is in fullscreen state (nsGlobalWindow::mFullScreen)
  • a boolean in the toplevel window indicating if keyboard input is disabled (nsGlobalWindow::mFullScreenKeysDisabled)
  • in each document, the fullscreen element (if any)


  • A window is in the fullscreen state if the toplevel chrome window for the window has mFullScreen set and the window is the toplevel chrome window or a toplevel content window
  • A window is in the "keys disabled" state if the toplevel chrome window for the window has mFullScreenKeysDisabled set

For styling, Documents whose (inner) windows are in the fullscreen state will have NS_DOCUMENT_STATE_FULL_SCREEN set on them. Elements that are the fullscreen element would have the NS_EVENT_STATE_FULL_SCREEN state bit set on them. nsEventStateManager::SetContentState needs a big cleanup...


  • nsGlobalWindow::GetFullScreen returns the fullscreen state of the window
  • nsGlobalWindow::SetFullScreen(KeysEnabled), when called by chrome, will put the toplevel window in the fullscreen state, or take it out of the fullscreen state, and set the keys-enabled state.
  • A FullScreenRequested event that gets fired at the chrome event listener if fullscreen is requested (and we should not ignore it --- e.g. request in inactive tab). Pass a reference to the element and window in the event. The event also contains a flag to indicate if keys-disabled was requested.
  • A FullScreenCanceled event that gets fired if a window wants to cancel fullscreen. The event contains a reference to the element that had been requested and the window.

Chrome's policy code could work like this:

  • The user has ultimate control: the user can request fullscreen at any time (F11), as now.
  • Chrome can store a "current fullscreen request" for each <browser>, including a flag to indicate whether it wanted to disable keys.
  • Each FullScreenRequested events received sets the current fullscreen request for that <browser>.
  • Each FullScreenCanceled event clears the current fullscreen request for that <browser>. If that <browser> is the active tab, exit fullscreen mode.
  • Whenever a request is approved (it might be approved instantly), call SetFullScreen on the chrome window to make everything fullscreen.


  • Part 1: Implement fullscreen window state, content events and styling
    • Basic fullscreen stuff should work if the user manually enters fullscreen
  • Part 2: Implement request APIs and dispatching of chrome events
  • Part 3: Implement key disabling
  • Part 4: Implement extended nsGlobalWindow API to enter fullscreen mode with optional key disabling
  • Part 5: Hook up chrome events to prototype browser UI and trigger fullscreen
  • Part 6: Extend to support fullscreening of subdocuments