public void onUpdate(EditorUpdateEvent event) {
// Check isEditing to prevent code from running during session teardown.
if (isEditing() && event.selectionCoordsChanged()) {
// First use a non-invasive approach for discovering the focus location.
// This query does not mutate the DOM, so will not force a layout cycle.
IntRange r = NativeSelectionUtil.getFocusBounds();
if (r != null) {
double focusStartInScreen = r.getFirst();
double focusEndInScreen = r.getSecond();
double viewportStartInScreen = measurer.top(null, viewport);
double viewportEndInScreen = measurer.bottom(null, viewport);
if (viewportStartInScreen < focusStartInScreen - PAD_PX
&& focusEndInScreen + PAD_PX < viewportEndInScreen) {
// All ok.