aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/script
Commit message (Collapse)AuthorAgeFilesLines
* Fix Backspace deleting entire previous line in `<textarea>` (#36112)elomscansio2025-03-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-033-12/+12
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* dom: Move child_list to rare data (#35592)webbeef2025-02-221-7/+7
| | | | | | This is only created when calling the ChildNodes method. Gecko also stores it in their similar data structure at https://searchfox.org/mozilla-central/rev/155d514d72473453492a822e97dc1c68cf49d110/dom/base/nsINode.h#1464 Signed-off-by: webbeef <me@webbeef.org>
* dom: move node ranges to raredata (#35554)webbeef2025-02-211-7/+7
| | | Signed-off-by: webbeef <me@webbeef.org>
* libservo: Add a `ClipboardDelegate` and a default implementation (#35297)Martin Robinson2025-02-071-3/+3
| | | | | | | | | | | | | | | | | Add a `ClipboardDelegate` to the `WebView` API and a default implementation in libservo for this delegate that works on Mac, Windows, and Linux. Support for Android will be added in the future. This means that embedders do not need to do anything special to get clipboard support, but can choose to override it or implement it for other platforms. In addition, this adds support for handling fetches of clipboard contents and renames things to reflect that eventually other types of clipboard content will be supported. Part of this is removing the string argument from the `ClipboardEventType::Paste` enum because script will need to get other types of content from the clipboard than just a string. It now talks to the embedder to get this information directly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Implement ServoLayoutNode::traversal_parent (#35338)Simon Wülker2025-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | This fixes common crash related to slottables, currently present on wpt.fyi. Previously, the traversal parent of `Text` nodes was incorrectly assumed to always be the parent or shadow host. That caused crashes inside stylo's bloom filter. Now the traversal parent is the slot that the node is assigned to, if any, and the parent/shadow host otherwise. The slottable data for Text/Element nodes is now stored in NodeRareData. This is very cheap, because NodeRareData will already be instantiated for assigned slottables anyways, because the containing_shadow_root field will be set (since assigned slottables are always in a shadow tree). This change is necessary because we need to hand out references to the assigned slot to stylo and that is not possible to do (without unsafe code) if we need to downcast the node first. As a side effect, this reduces the size of `Text` from 256 to 232 bytes, because the slottable data is no longer stored there. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Implement shadow dom slots (#35013)Simon Wülker2025-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement slot-related algorithms Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Hook up slot elements to DOM creation logic Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Set a slot assignment mode for servo-internal shadow roots Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Assign slots when a slottable's slot attribute changes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Properly compute slot name Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach test-tidy Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update <slot> name when name attribute changes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement fast path for Node::assign_slottables_for_a_tree assign_slottables_for_a_tree traverses all descendants of the node and is potentially very expensive. If the node is not a shadow root then assigning slottables to it won't have any effect, so we take a fast path out. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Move slottable data into ElementRareData This shrinks all element descendants back to their original size. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Address review comments Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Restrict reexport visibility of DOM types. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Mass pub->pub(crate) conversion. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Hide existing dead code warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix unit tests. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * More formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Add `rust-version` to all `Cargo.toml` files (#33483)Martin Robinson2024-09-171-0/+1
| | | | | | | This is another step preparing for building Servo without `mach`. Fixes #33430. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Fix panic in `htmlimageelement.rs` using `str::find()` to find ↵Kopanov Anton2024-08-241-23/+23
| | | | | | | | | | | | | | | | | | | | | character boundaries. (#32980) * fix loop with chars().enumerate() by using find() Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru> * Add documentation to parser and fix some small issues - Rename the properties of `Descriptor` so that they are full words - Use the Rust-parser to parse doubles - Add documentation and restructure parser to be more readable Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Use workspace definitions for all crates and update to the 2021 edition (#32544)Martin Robinson2024-06-181-4/+5
|
* Fixed some clippy warning by adding default implementations (#31989)komuhangi2024-04-041-6/+6
| | | | | | | | | | | * Fixed some clippy warning by adding default implementations * Updated PR that adds default implementation of structs * Clean up and extend `Default` implementations --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* script: Split style and layout data in DOM nodes (#31985)Martin Robinson2024-04-041-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change splits the style and layout data in DOM nodes that is populated by style and layout passes. This makes Servo's data design more like Gecko's. This allows: 1. Removing the various `StyleAndLayout` data structures used by layout. 2. Removing the `GetStyleAndLayoutData` and `GetStyleAndOpaqueLayoutData` traits. Accessing style and layout data are now just functions on the `LayoutNode` and `ThreadSafeLayoutNode` traits. 3. Styling now doesn't populate layout data. This is is postponed until layout itself. 4. Allows the DOM wrappers to no longer have to be generic over the layout data. This data was already stored using `std::any::Any` and the new code just makes layout responsible for downcasting. Cleaning up the generic type parameter in the DOM wrappers can happen in a followup change. The main benefit to all of this is that we should be able to remove unsafe creation of `ServoLayoutNode` in layout and `TrustedLayoutNodeAddress` entirely, because `ServoLayoutNode` will be able to be passed directly from script to layout. In addition, this removes one more abstraction layer from the layout DOM wrappers, making the code a lot more understandable. Note: This increases the measured size of DOM types, but the same data is stored. It's simply that before that data was stored behind a heap pointer.
* Start the transition to workspace dependenciesMartin Robinson2023-05-171-2/+2
| | | | | | | This will ultimately make it simpler to update crate dependencies and reduce duplicate when specifying requirements. Generally, this change does not touch dependencies that are only used by a single crate. We could consider moving them to workspace dependencies in the future.
* Bump euclid to 0.22Martin Robinson2023-01-261-1/+1
| | | | | | | | | | | | | - Also updates raqote to latest with an upgrade of font-kit to 0.11 applied on as a patch - Update lyon_geom to the latest version Major change: - All matrices are now stored in row major order. This means that parameters to rotation functions no longer should be negated. - `post_...()` functions are now named `then()`. `pre_transform()` is removed, so `then()` is used and the order of operations changed.
* Update keyboard-types.Josh Matthews2022-04-011-1/+1
|
* Upgrade to rustc 1.48.0-nightly (623fb90b5 2020-09-26)Simon Sapin2021-01-261-8/+8
|
* update keyboard-types cratePaul Rouget2020-06-291-1/+1
|
* Make Node::style_and_layout_data be a DomRefCell<T>Anthony Ramine2020-05-191-7/+7
| | | | That way we can use borrow_mut_for_layout and borrow_mut.
* Make OpaqueLayoutAndStyleData just a bit less opaqueAnthony Ramine2020-04-041-7/+7
| | | | It now stores a NonNull<dyn Any>.
* Allow deletion from overflowed textinputteapotd2020-01-101-0/+22
|
* Update rand to 0.7 (fixes #24448)Anthony Ramine2019-10-231-4/+4
|
* ISSUE-23995: lazily generate unique_id for nodeThomas Delacour2019-09-241-7/+7
|
* Update euclid.Emilio Cobos Álvarez2019-07-231-1/+1
| | | | | | | | There are a few canvas2d-related dependencies that haven't updated, but they only use euclid internally so that's not blocking landing the rest of the changes. Given the size of this patch, I think it's useful to get this landed as-is.
* Restore DummyClipboardContext for textinput.rs testsMichal Mieczkowski2019-06-151-1/+22
|
* ISSUE-20455: introduce stronger types for textinput indexingThomas Delacour2019-05-161-135/+236
|
* Make Node and Element rare_data an OptionFernando Jiménez Moreno2019-04-261-8/+7
|
* Update size of tests after *RareData changesFernando Jiménez Moreno2019-04-261-7/+8
|
* Update size of tests with shadow root sizeFernando Jiménez Moreno2019-04-261-7/+7
|
* Upgrade to rustc 1.36.0-nightly (e305df184 2019-04-24)Simon Sapin2019-04-251-8/+8
| | | | | | | | | | | | | | | | | This includes a `size_of` regression for a few DOM types, due to https://github.com/rust-lang/rust/pull/58623 which replaces the implementation of `HashMap` in the standard library to Hashbrown. Although `size_of<HashMap>` grows, it’s not obvious how total memory usage is going to be impacted: Hashbrown only has one `u8` instead of one `usize` of overhead per hash table bucket for storing (part of) a hash, and so might allocate less memory itself. Hashbrown also typically has better run time performance: https://github.com/rust-lang/hashbrown#performance Still, I’ve filed https://github.com/rust-lang/hashbrown/issues/69 about potentially reducing the `size_of<HashMap>` regression.
* Fixed bug in textinput::adjust_vertical concerning selection_origin updateDenis Merigoux2018-12-221-0/+4
| | | | | | | | This bug was discovered using the F* formal verification framework. Style changes (match -> if let) Replace if let Some(_) by .is_some()
* Update MPL license to https (part 5)Jan Andre Ikenmeyer2018-11-276-6/+6
|
* Use keyboard-types::webdriver::send_keysPyfisch2018-11-111-1/+1
| | | | | | | | This improves the quality of KeyboardEvents sent by WebDriver. Now key, code, location and modifiers are set according to spec. CompositionEvents are discarded as servo does not handle them at all.
* `cargo fix --edition-idioms`Simon Sapin2018-11-081-9/+0
|
* Correct select allPyfisch2018-11-071-0/+10
| | | | | Fixes assertion failure. Set selection direction forward on select all.
* Reorder importsPyfisch2018-11-063-3/+3
|
* Format remaining filesPyfisch2018-11-066-123/+359
|
* Switch most crates to the 2018 editionSimon Sapin2018-11-061-0/+1
|
* Implement TimeRanges interfaceFernando Jiménez Moreno2018-10-312-0/+89
|
* Minor keyboard updatesPyfisch2018-10-131-1/+1
| | | | | | Support combined character input from winit. Make use of utility methods from keyboard-types. Remove prinatable attribute of KeyboardEvent.
* Use keyboard-types cratePyfisch2018-10-073-15/+14
| | | | | | | | | | | | | Have embedders send DOM keys to servo and use a strongly typed KeyboardEvent from the W3C UI Events spec. All keyboard handling now uses the new types. Introduce a ShortcutMatcher to recognize key bindings. Shortcuts are now recognized in a uniform way. Updated the winit port. Updated webdriver integration. part of #20331
* WR updatePaul Rouget2018-08-061-1/+1
|
* Update euclid to 0.18Bastien Orivel2018-07-181-1/+1
|
* Remove unused code for parsing a `sizes` attribute.Emilio Cobos Álvarez2018-07-013-99/+0
| | | | | | We have `SourceSizeList` in components/style/values/specified/source_size_list.rs which does the job and is tested via WPT in Gecko.
* Bump euclid to 0.17Bastien Orivel2018-02-281-1/+1
|
* Correct default selectionStart and selectionEndpaavininanda2018-02-231-1/+6
|
* Revert "Correct default Selectionstart and SelectionEnd"paavininanda2018-02-231-6/+2
| | | | This reverts commit b2c1f89b932a72f9e0110c17adde33647e84c902.
* Disallow mutating the internals of TextInputJon Leighton2018-02-161-117/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | The TextInput::assert_ok_selection() method is meant to ensure that we are not getting into a state where a selection refers to a location in the control's contents which doesn't exist. However, before this change we could have a situation where the internals of the TextInput are changed by another part of the code, without using its public API. This could lead to us having an invalid selection. I did manage to trigger such a situation (see the test added in this commit) although it is quite contrived. There may be others that I didn't think of, and it's also possible that future changes could introduce new cases. (Including ones which trigger panics, if indexing is used on the assumption that the selection indices are always valid.) The current HTML specification doesn't explicitly say that selectionStart/End must remain within the length of the content, but that does seems to be the consensus reached in a discussion of this: https://github.com/whatwg/html/issues/2424 The test case I've added here is currently undefined in the spec which is why I've added it in tests/wpt/mozilla.
* Correct default Selectionstart and SelectionEndpaavininanda2018-02-101-3/+7
|
* Changed offset_to_text_point function and added unit tests for the samepaavininanda2018-02-071-0/+28
|