mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibWeb: Fix many bugs with the editing.
This commit is contained in:
parent
78558c9f30
commit
b3d7c5bfbc
Notes:
sideshowbarker
2024-07-19 00:57:07 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/b3d7c5bfbca Pull-request: https://github.com/SerenityOS/serenity/pull/4318 Reviewed-by: https://github.com/Lubrsi Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
2 changed files with 4 additions and 9 deletions
|
@ -40,11 +40,6 @@ namespace Web {
|
|||
|
||||
void EditEventHandler::handle_delete(DOM::Range range)
|
||||
{
|
||||
// FIXME: Deleting nodes seems to mess up the layout tree. Not sure if this is not entirely
|
||||
// my fault or not my fault at all.
|
||||
|
||||
dump_tree(*m_frame.document());
|
||||
|
||||
if (range.start().node() != range.end().node()) {
|
||||
if (range.start().node()->parent() == range.end().node()->parent()) {
|
||||
// Remove all intermediate nodes.
|
||||
|
@ -85,8 +80,6 @@ void EditEventHandler::handle_delete(DOM::Range range)
|
|||
// FIXME: We need to remove stale layout nodes when nodes are removed from the DOM. Currently,
|
||||
// this is the only way to get these to disappear.
|
||||
m_frame.document()->force_layout();
|
||||
|
||||
dump_tree(*m_frame.document());
|
||||
}
|
||||
|
||||
void EditEventHandler::handle_insert(DOM::Position position, u32 code_point)
|
||||
|
|
|
@ -346,12 +346,14 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
|
|||
}
|
||||
|
||||
if (layout_root()->selection().is_valid()) {
|
||||
auto range = layout_root()->selection().to_dom_range();
|
||||
auto range = layout_root()->selection().to_dom_range().normalized();
|
||||
|
||||
m_frame.document()->layout_node()->set_selection({});
|
||||
|
||||
// FIXME: This doesn't work for some reason?
|
||||
m_frame.set_cursor_position(range.start());
|
||||
|
||||
if (key == KeyCode::Key_Backspace) {
|
||||
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
|
||||
if (range.start().node()->is_editable()) {
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue