Skip to content

Instantly share code, notes, and snippets.

@alivedise
Last active August 29, 2015 13:59
Show Gist options
  • Save alivedise/10627348 to your computer and use it in GitHub Desktop.
Save alivedise/10627348 to your computer and use it in GitHub Desktop.
FxOS Window Management 201

FirefoxOS Window Management 201

Window classes

  • AppWindow
  • HomescreenWindow
  • ActivityWindow
  • LockscreenWindow
  • SecureWindow
  • PopupWindow
  • SearchWindow
  • (AttentionWindow)
  • (TrustedWindow)
  • (KeyboardWindow)

Multiple dimensional layouting

  • Bottom<->Top
  • Top window is rendered inside the bottom window.
  • All events propagation in inner window should be stopped.
  • Previous<->Next

Factory/Manager pattern

  • Factory is creating new instances.
  • Manager is managing instnaces by the events generated by the instances.
  • Q: Who should keep the list of living instances?

Child Window

If an appWindow instance is created to service another appWindow we call it child window.

  • window.open
  • new MozActivity

BaseWindow is responsible to manage its child windows.

Base Window

The window which is rendered under #windows. All of them is instance of AppWindow and managed by AppWindowManager.

Currently there's only one child window for one dimension on mobile devices. But if we are heading for multiple windows, we will have a list of child windows.

Transition control

  • Each app window has a state machine for managing transition state changes.
  • Transition state change will trigger many things.
  • orientation control
  • size control
  • visibility control
  • Load state

Inner events & outer events

  • '_' prefixed event is inner event.
  • No '_' is outer event.
  • AppWindow will trigger inner event before any outer events.
  • An event is triggered on dom element the controller owns.
  • Event is also prefixed by the type of the window.

Suspended apps

  • Suspended app is an app being killed by gecko, usually by LMK.
  • We are keeping at most 10 suspended apps for now for performance issues.
  • If there's more than 10 suspended apps, SuspendingAppManager will kill the oldest suspended app.
  • AppWindow will resume itself by re-creating the mozbrowser iframe with the latest URL when it's opened from task managero or homescreen (mozApps launch).

Future plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment