LibWeb: Don't force relayout after every keyboard input event

Instead, just rely on the invalidation and lazy relayout that happens as
a consequence of mutating the DOM.

This allows multiple keystrokes to coalesce into a single relayout if
necessary, dramatically improving performance when typing text into
form fields on complex pages.
This commit is contained in:
Andreas Kling 2024-03-17 19:15:20 +01:00
parent c51a4cc007
commit a7d7c5b7b4
Notes: sideshowbarker 2024-07-18 08:59:31 +09:00

View File

@ -33,11 +33,6 @@ void EditEventHandler::handle_delete_character_after(JS::NonnullGCPtr<DOM::Posit
builder.append(text.bytes_as_string_view().substring_view(*next_grapheme_offset));
node.set_data(MUST(builder.to_string()));
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance.
m_browsing_context->active_document()->force_layout();
m_browsing_context->did_edit({});
}
@ -94,11 +89,6 @@ void EditEventHandler::handle_delete(DOM::Range& range)
end->remove();
}
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance.
m_browsing_context->active_document()->force_layout();
m_browsing_context->did_edit({});
}
@ -131,11 +121,6 @@ void EditEventHandler::handle_insert(JS::NonnullGCPtr<DOM::Position> position, u
position->set_offset(1);
}
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance.
m_browsing_context->active_document()->force_layout();
m_browsing_context->did_edit({});
}
}