Immediate Layout

Overview

Some JavaScript methods require browsers to do an Immediate Layout to yield correct results. Gameface doesn’t do that by default as a layout is an expensive operation, but it is possible to enable the behavior on demand as third-party JavaScript libraries might depend on it.

What is affected

When Immediate Layout is enabled all getters from the list here execute a layout before returning a value.

Controlling the behavior

The default behavior is a view setting, so changing it affects all documents loaded in a view. It can be set by:

  1. Setting the ViewSettings::EnableImmediateLayout bool.
  2. By calling the engine.enableImmediateLayout and engine.isImmediateLayoutEnabled methods.
  3. By calling the View::EnableImmediateLayout and View::IsImmediateLayoutEnabled methods.

What is more, an immediate layout can be triggered on demand through the engine.executeImmediateLayoutSync method.

Workflow comparison

Enabling Immediate Layout will trigger a layout on each getter which might be rather expensive. This is the easiest way to test how a third-party library works.

A more optimal workflow would be to perform as many changes as possible, then doing a single engine.executeImmediateLayoutSync and then calling getters many times. With that flow, a single layout is executed and the performance of an application should improve.

Notes