From 4877e7593cdc4748585d1ed393faf7878115a021 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Fri, 18 Feb 2022 23:14:52 +0100 Subject: [PATCH] LibWeb: Refresh text- contents when pressing backspace or delete Make sure to refresh the contents of text- when pressing backspace or delete key. The methods 'handle_insert()' and 'handle_delete()' already had the call to 'm_browsing_context.active_document()->force_layout()' so let us also add it to 'handle_delete_character_after()'. --- Userland/Libraries/LibWeb/Page/EditEventHandler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp index 4579140eae..b5b411b009 100644 --- a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp @@ -33,6 +33,11 @@ void EditEventHandler::handle_delete_character_after(const DOM::Position& cursor builder.append(text.substring_view(cursor_position.offset() + code_point_length)); node.set_data(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({}); }