mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibWeb: Fix many bugs with the editing.
This commit is contained in:
parent
78558c9f30
commit
b3d7c5bfbc
2 changed files with 4 additions and 9 deletions
|
@ -40,11 +40,6 @@ namespace Web {
|
||||||
|
|
||||||
void EditEventHandler::handle_delete(DOM::Range range)
|
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() != range.end().node()) {
|
||||||
if (range.start().node()->parent() == range.end().node()->parent()) {
|
if (range.start().node()->parent() == range.end().node()->parent()) {
|
||||||
// Remove all intermediate nodes.
|
// 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,
|
// 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.
|
// this is the only way to get these to disappear.
|
||||||
m_frame.document()->force_layout();
|
m_frame.document()->force_layout();
|
||||||
|
|
||||||
dump_tree(*m_frame.document());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEventHandler::handle_insert(DOM::Position position, u32 code_point)
|
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()) {
|
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({});
|
m_frame.document()->layout_node()->set_selection({});
|
||||||
|
|
||||||
|
// FIXME: This doesn't work for some reason?
|
||||||
m_frame.set_cursor_position(range.start());
|
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()) {
|
if (range.start().node()->is_editable()) {
|
||||||
m_edit_event_handler->handle_delete(range);
|
m_edit_event_handler->handle_delete(range);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue