LibWeb: Simplify empty string allocation in handle_delete()
This commit is contained in:
parent
bdaac6ce48
commit
fb23fd328b
Notes:
github-actions[bot]
2024-10-31 19:05:08 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/fb23fd328b0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2091 Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 3 additions and 3 deletions
|
@ -624,16 +624,16 @@ void FormAssociatedTextControlElement::handle_delete(DeleteDirection direction)
|
|||
if (selection_start == selection_end) {
|
||||
if (direction == DeleteDirection::Backward) {
|
||||
if (selection_start.value() > 0) {
|
||||
MUST(set_range_text(MUST(String::from_utf8(""sv)), selection_start.value() - 1, selection_end.value(), Bindings::SelectionMode::End));
|
||||
MUST(set_range_text(String {}, selection_start.value() - 1, selection_end.value(), Bindings::SelectionMode::End));
|
||||
}
|
||||
} else {
|
||||
if (selection_start.value() < text_node->data().code_points().length()) {
|
||||
MUST(set_range_text(MUST(String::from_utf8(""sv)), selection_start.value(), selection_end.value() + 1, Bindings::SelectionMode::End));
|
||||
MUST(set_range_text(String {}, selection_start.value(), selection_end.value() + 1, Bindings::SelectionMode::End));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
MUST(set_range_text(MUST(String::from_utf8(""sv)), selection_start.value(), selection_end.value(), Bindings::SelectionMode::End));
|
||||
MUST(set_range_text(String {}, selection_start.value(), selection_end.value(), Bindings::SelectionMode::End));
|
||||
}
|
||||
|
||||
void FormAssociatedTextControlElement::handle_return_key()
|
||||
|
|
Loading…
Add table
Reference in a new issue