servo/components/script
elomscansio 30a2a89d16
Fix Backspace deleting entire previous line in <textarea> (#36112)
* test(textinput): Add test for backspace at beginning of line in textarea

Introduce a test to reproduce and verify the fix for backspacing at the
beginning of a line in a multiline textarea. This ensures that pressing
Backspace when the cursor is at the start of a line correctly removes the
newline without deleting the entire previous line’s content.

Related to: #27523

Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>

* fix(textinput): Preserve selection origin when adjusting vertical position

Fixes an issue where pressing Backspace at the beginning of a line in a
textarea incorrectly deleted the entire previous line's content. This happened
because `self.adjust_vertical(-1, select)` modified `selection_origin` and
`edit_point`, but `selection_origin` was not restored before performing the
horizontal adjustment. As a result, `self.selection_start()` and
`self.selection_end()` were inconsistent, leading to `replace_operation`
erasing the entire line.

Now, we temporarily store `selection_origin` before adjusting vertical
position and restore it afterward to ensure proper cursor and selection
behavior.

Fixes: #27523
Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>

---------

Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-03-26 18:37:48 +00:00
..
docs Update branch name to main (#30877) 2023-12-16 09:32:20 +00:00
dom Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
layout_dom script: Eliminate PseudoElementType (#36146) 2025-03-26 08:33:12 +00:00
svgpath Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
xpath Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
animation_timeline.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
animations.rs Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
body.rs Use read all bytes when consuming body (#36048) 2025-03-26 11:01:18 +00:00
build.rs script: Move code generation and webidl files to new script_bindings crate. (#35157) 2025-01-24 20:47:43 +00:00
canvas_context.rs Cleanups for future script crate split (#35987) 2025-03-16 13:46:14 +00:00
canvas_state.rs Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
Cargo.toml Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
clipboard_provider.rs libservo: Add a ClipboardDelegate and a default implementation (#35297) 2025-02-07 10:43:46 +00:00
conversions.rs suppress build warnings when disabling webgpu and webxr (#35379) 2025-02-08 08:16:21 +00:00
devtools.rs Hide servo internal shadow roots from the inspector by default (#35958) 2025-03-13 13:08:24 +00:00
document_collection.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
document_loader.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
drag_data_store.rs DataTransferItem: improve spec compliance (#35418) 2025-02-16 18:53:35 +00:00
fetch.rs Implement nonce attribute to pass more CSP checks (#35876) 2025-03-10 09:25:34 +00:00
iframe_collection.rs Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
init.rs Make generated bindings generic over DOM types (#35169) 2025-01-25 05:08:49 +00:00
layout_image.rs Move various reflector types and traits to script_bindings (#35279) 2025-02-04 06:58:08 +00:00
lib.rs Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
links.rs script: Allow opening links in a new WebView (#35017) 2025-03-23 10:59:19 +00:00
mem.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
messaging.rs metrics: Simplify ProgressiveWebMetrics (#35985) 2025-03-21 14:55:00 +00:00
microtask.rs script: Mark callback methods with CanGc. (#35753) 2025-03-03 12:17:25 +00:00
navigation.rs Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
network_listener.rs Propagate CanGc arguments through callers in constructors (#35541) 2025-02-20 16:17:45 +00:00
realms.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
routed_promise.rs webgpu: leverage routed_promise in calls returning promises (#35859) 2025-03-23 18:52:46 +00:00
script_module.rs Use explicit reborrows with mozjs::MutableHandle (#35892) 2025-03-23 01:23:52 +00:00
script_runtime.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
script_thread.rs compositor: Remove the script channel from the compositor (#36089) 2025-03-23 11:19:27 +00:00
security_manager.rs Cleanups for future script crate split (#35987) 2025-03-16 13:46:14 +00:00
serviceworker_manager.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
stylesheet_loader.rs Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00
stylesheet_set.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
task.rs Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00
task_manager.rs dom: Implement minimal IntersectionObserver workflow (#35551) 2025-03-18 11:09:44 +00:00
task_queue.rs Use strum to iterate through enum variants and get their names (#35933) 2025-03-13 12:00:31 +00:00
task_source.rs dom: Implement minimal IntersectionObserver workflow (#35551) 2025-03-18 11:09:44 +00:00
test.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
textinput.rs Fix Backspace deleting entire previous line in <textarea> (#36112) 2025-03-26 18:37:48 +00:00
timers.rs script: Mark callback methods with CanGc. (#35753) 2025-03-03 12:17:25 +00:00
unminify.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
webdriver_handlers.rs script: Implement Element::GetHTML and ShadowRoot::GetHTML (#36106) 2025-03-23 19:04:23 +00:00
window_named_properties.rs Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00