aboutsummaryrefslogtreecommitdiffstats
path: root/components
Commit message (Collapse)AuthorAgeFilesLines
* Add a tokenizer for URLPatterns (#36362)Simon Wülker2025-04-071-4/+543
| | | | | | | | | | | | Not a lot of new tests start to pass because the actual parser is still missing, so we're only passing tests for invalid inputs. The parser will be added in the next PR. This is part 3 of upstreaming the changes in https://github.com/simonwuelker/servo/tree/urlpattern --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* dom: Implement `ClipboardItem` (#36336)Gae242025-04-065-0/+214
| | | | | | | | | | | implement the `ClipboardItem` interface Testing: covered by existing wpt tests part of #36084 --------- Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* Add CanGc as arguments in methods in devtools.rs, CharacterData, ↵Yerkebulan Tulibergenov2025-04-066-30/+42
| | | | | | | | | | | | | CSSStyleRule, CSSStyleSheet (#36375) Add CanGc as arguments in methods in devtools.rs, CharacterData, CSSStyleRule, CSSStyleSheet Testing: These changes do not require tests because they are a refactor. Addressed part of https://github.com/servo/servo/issues/34573. --------- Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* Fix radio group validity update when removing or selecting an input (#36252)elomscansio2025-04-064-38/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR fixes an issue where radio inputs in the same group failed to correctly update their `validity.valueMissing` state when: - A **checked radio button was removed** from the DOM. - A **different radio button was selected** by user interaction. This behavior caused mismatches with how browsers like Firefox handle radio group validation. --- ### Changes in This PR #### Radio group revalidation on DOM removal - Updated `unbind_from_tree()` to revalidate other radio buttons in the same group when a checked input is removed. - Uses `UnbindContext::parent` as the DOM root to ensure the correct context is used during traversal. #### New helper: `find_related_radios()` - Encapsulates logic for finding other inputs in the same group. - Used during both removal and attribute changes for consistency. #### Validation on `checked`/`value` updates - Introduced `update_related_validity_states()` to revalidate all group members when a radio's `checked` or `value` is changed. #### Web Platform Test (WPT) coverage - Created a new WPT file: `radio-group-valueMissing.html`. - Tests follow recommended `test()` pattern: - **Precondition**: Assert initial `valueMissing`. - **Action**: Remove or select a radio. - **Postcondition**: Assert expected `valueMissing`. #### Manifest updated - The WPT manifest now includes the new test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #36110 <!-- Either: --> - [X] There are tests for these changes Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
* `compositing`: Combine `webrender_traits` and `compositing_traits` (#36372)Martin Robinson2025-04-0653-596/+561
| | | | | | | | | | | | | | | These two traits both exposed different parts of the compositing API, but now that the compositor doesn't depend directly on `script` any longer and the `script_traits` crate has been split into the `constellation_traits` crate, this can be finally be cleaned up without causing circular dependencies. In addition, some unit tests for the `IOPCompositor`'s scroll node tree are also moved into `compositing_traits` as well. Testing: This just combines two crates, so no new tests are necessary. Fixes: #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Remove unsafe from cross_origin_property_fallback (#36373)Usman Yahaya Baba2025-04-061-2/+2
| | | | | | | | | | | | Remove unsafe from cross_origin_property_fallback - Refactors `cross_origin_property_fallback` to remove the `unsafe` annotation from the function signature, as it now uses safe wrappers instead of raw pointers - Adds an `unsafe` block around `MutableHandle::from_raw` Testing: Changes does not require test Fixes: https://github.com/servo/servo/issues/36359 Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Process colorSchemeSimulation in TargetConfigurationActor (#36297)Usman Yahaya Baba2025-04-063-7/+44
| | | | | | | | | | | | | | | | Implements Steps 1,4&6 of https://github.com/servo/servo/issues/35867: - Adds `pub simulate_color_scheme` to `BrowsingContextActor` using `script_chan`. - Processes `colorSchemeSimulation` flag in `TargetConfigurationActor`’s `updateConfiguration`. - Routes `colorSchemeSimulation` from `RootActor` via `TabDescriptorActor` to `BrowsingContextActor`. Testing: Compiles and lints clean. Fixes: https://github.com/servo/servo/issues/35867 --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Remove unsafe from maybe_cross_origin_get_prototype (#36366)Usman Yahaya Baba2025-04-061-8/+6
| | | | | | | | | | | | | Remove unsafe from maybe_cross_origin_get_prototype -Refactors `maybe_cross_origin_get_prototype` to remove the `unsafe` annotation from the function signature and `get_proto_object` argument -Adds `unsafe` blocks around calls `D::GlobalScope::from_context` and `MutableHandleObject::from_raw` Testing: Changes does not require test Fixes: https://github.com/servo/servo/issues/36357 Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Add CanGc as arguments in methods in Attr and Node (#36371)Yerkebulan Tulibergenov2025-04-0620-111/+137
| | | | | | | | | | | | | Add CanGc as argument to methods in `Attr` and `Node`. Addressed part of https://github.com/servo/servo/issues/34573. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are a refactor. Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* Fix: Add support for stylesheet MIME type quirk in quirks mode (#36338)saku2025-04-061-1/+11
| | | | | | | | | | | | | | | | | This PR implements the HTML spec quirk for stylesheets: https://html.spec.whatwg.org/multipage/#link-type-stylesheet The implementation adds a check in `stylesheet_loader.rs` to handle this quirk condition correctly, and adds a new WPT test to verify that same-origin non-CSS MIME type resources are properly treated as CSS in quirks mode. Testing: Added a new WPT test (`quirk-origin-check-positive.html`) that verifies the positive case for this quirk. Fixes: https://github.com/servo/servo/issues/36324 --------- Signed-off-by: saku-1101 <sakupi1101@outlook.jp>
* Move `ScriptToConstellationMsg` to `constellation_traits` (#36364)Martin Robinson2025-04-0576-1212/+1212
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last big change necessary to create the `constellation_traits` crate. This moves the data structure for messages that originate from the `ScriptThread` and are sent to the `Contellation` to `constellation_traits`, effectively splitting `script_traits` in half. Before, `script_traits` was responsible for exposing the API of both the `ScriptThread` and the `Constellation` to the rest of Servo. - Data structures that are used by `ScriptToConstellationMsg` are moved to `constellation_traits`. The dependency graph looks a bit like this: `script_layout_interface` depends on `script_traits` depends on `constellation_traits` depends on `embedder_traits`. - Data structures that are used in the embedding layer (`UntrustedNodeAddress`, `CompositorHitTestResult`, `TouchEventResult` and `AnimationState`) are moved to embedder_traits, to avoid a dependency cycle between `webrender_traits` and `constellation_traits`. - Types dealing with MessagePorts and serialization are moved to `constellation_traits::message_port`. Testing: This is covered by existing tests as it just moves types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Refactor:Refactors report_cross_origin_denial method to use unsafe block ↵kaushikashok452025-04-051-5/+7
| | | | | | | | | | | | | | | | (#36365) The method report_cross_origin_denial was marked as unsafe, have instead moved the unsafe code within the method into an unsafe block within the method and removed the unsafe marking for the method. Testing: No testing needed Fixes: This PR resolves #36356. Signed-off-by : Ashok Kaushik kaushikashok45@gmail.com --------- Signed-off-by: ashok.kaushik <ashok.kaushik@zohocorp.com> Co-authored-by: ashok.kaushik <ashok.kaushik@zohocorp.com>
* Stub out Trusted Types interfaces (#36355)Tim van der Lippe2025-04-0517-2/+516
| | | | | | | | | | | | Some methods are implemented fully, while others are implemented partly. With these implementations, there are no observed crashes when running the trusted-types web-platform-tests. Most notably, the tests/wpt/tests/trusted-types/idlharness.window.js is now fully passing. Part of #36258 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* structuredclone::read throws a DataClone error on failure (#36361)Kingsley Yung2025-04-051-10/+8
| | | | | | | | | In the structured clone writing API, the read function should throw a DataClone error on failure, just like the write function. Testing: It doesn't require tests. Fixes: #36217 Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
* Make the memory reporting multi-process aware (#35863)webbeef2025-04-0513-359/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | So far the memory reporter aggregates reports from all processes, and runs the system reporter only in the main process. Instead it is desirable to have per-process reports. We do so by: - creating a ProcessReports struct that holds includes the pid in addition to the reports themselves. - running the system memory reporter also in content processes. - updating the about:memory page to create one report per process, and add useful information like the pid and the urls loaded in a given process. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors ![image](https://github.com/user-attachments/assets/0bafe140-539d-4d6a-8316-639309a22d4a) Signed-off-by: webbeef <me@webbeef.org>
* Check all ancestor navigable trustworthiness for mixed content (#36157)Sebastian C2025-04-0536-48/+287
| | | | | | | | | | | | | | | | | | | | | | | | | | Propagate through documents a flag that represents if any of the ancestor navigables has a potentially trustworthy origin. The "potentially trustworthy origin" concept appears to have gotten confused in a couple of places and we were instead testing if a URL had "potentially trustworthy" properties. The main test for the ancestor navigables is [mixed-content/nested-iframes](https://github.com/web-platform-tests/wpt/blob/master/mixed-content/nested-iframes.window.js) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #36108 <!-- Either: --> - [X] There are tests for these changes --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
* script: Implement input preprocessing for URLPatterns (#36225)Simon Wülker2025-04-042-52/+686
| | | | | | | | | | | | Implements https://urlpattern.spec.whatwg.org/#process-a-urlpatterninit and the component canonicalization functions. These handle percent-encoding and such for the components of a `URLPattern`. No new tests pass, because the tokenizer and parser are still missing. This is part 2 of upstreaming the changes in https://github.com/simonwuelker/servo/tree/urlpattern Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* constellation: Only return focused browsing contexts that exist. (#36330)Josh Matthews2025-04-041-1/+9
| | | | | | | | | | | | | | | | | | The webdriver server relies on the constellation to report which browsing context is focused, and assumes that a focused context is ready for interaction. However, new browsing contexts exist in a weird state where they are not tracked by the constellation until the initial load is complete, which leads to the constellation rejecting attempts to navigate a browsing context right after it's created. These changes ensure the constellation does not report a browsing context as focused until it's actually created and ready for interaction. Testing: Run `./mach test-wpt --product servodriver tests/wpt/mozilla/tests/mozilla/DOMParser.html`, which now runs to completion. Fixes: #34551 Fixes: #36328 Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Implement TestUtils (#36301)Sebastian C2025-04-044-0/+63
| | | | | | | | | | | | | | | | Implement the TestUtils namespace from https://testutils.spec.whatwg.org/. This should make the `js/builtins/weakrefs` tests run faster and more consistently. This change will enable other WPT tests but no tests exist currently for TestUtils itself. Fixes: #36290 --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com> Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: sagudev <16504129+sagudev@users.noreply.github.com>
* constellation: Rename messages sent to the `Constellation` (#36341)Martin Robinson2025-04-0436-363/+414
| | | | | | | | | | | | | | | | | | | | Messages that are sent to the `Constellation` have pretty ambiguous names. This change does two renames: - `ConstellationMsg` → `EmbedderToConstellationMessage` - `ScriptMsg` → `ScriptToConstellationMessage` This naming reflects that the `Constellation` stands in between the embedding layer and the script layer and can receive messages from both. Soon both of these message types will live in `constellation_traits`, reflecting the idea that the `_traits` variant for a crate is responsible for exposing the API for that crate. Testing: No new tests are necessary here as this just renames two enums. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Prevent zombie processes in multi-process mode. (#36329)webbeef2025-04-046-44/+177
| | | | | | | | | | | | | This introduces a process manager that holds for each process a "lifeline": this is the receiving end of a ipc channel that is not used to send anything, but only to monitor the process presence. We turn that ipc receiver into a crossbeam one to integrate the monitoring into the constellation run loop. The sender side is made part of the initial "UnprivilegedContent" data structure sent to the new process, both for content and for service worker processes. When a process dies we currently wait() on it to let the OS do a clean shutdown. Signed-off-by: webbeef <me@webbeef.org>
* script: Remove code dealing with `CompositorUntrustedNode` (#36343)Martin Robinson2025-04-042-36/+5
| | | | | | | | | | | | There used to be two kinds of untrusted nodes, but these have been unified, so the duplicate methods dealing with them in `script` can be removed. Testing: This is covered by existing tests as it shouldn't change any behavior. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Stop assuming that the viewport is shared by all WebViews ↵Martin Robinson2025-04-0425-256/+271
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36312) The `Constellation` previously held a `window_size` member, but this assumes that all `WebView`s have the same size. This change removes that assumption as well as making sure that all `WebView`s pass their size and HiDIP scaling to the `Constellation` when they are created. In addition - `WindowSizeData` is renamed to `ViewportDetails`, as it was holding more than just the size and it didn't necessarily correspond to a "window." It's used for tracking viewport data, whether for an `<iframe>` or the main `WebView` viewport. - `ViewportDetails` is stored more consistently so that conceptually an `<iframe>` can also have its own HiDPI scaling. This isn't something we necessarily want, but it makes everything conceptually simpler. The goal with this change is to work toward allowing per-`WebView` HiDPI scaling and sizing. There are still some corresponding changes in the compositor to make that happen, but they will in a subsequent change. Testing: This is covered by existing tests. There should be no behavior changes. Fixes: This is part of #36232. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Remove dependency on `webgpu` (#36332)Martin Robinson2025-04-0423-346/+351
| | | | | | | | | | | | | After #36320, `script` only depends on `webgpu` for its type aliases to `wgpu_core` and `wgpu_types`. This change removes the dependency on `webgpu` in favor of depending directly on the upstream crates. This makes it so that you can change `webgpu` without recompiling `script`. Testing: This change is covered by existing WebGPU tests and is mainly just changing the way dependencies are accessed. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Restrict stretch alignment to flex items with computed auto size ↵Oriol Brufau2025-04-044-64/+64
| | | | | | | | | | | | | | | | | | | | (#36288) We were allowing `align-self: stretch` to stretch flex items whose cross size behaves as `auto`, including cyclic percentages. However, https://github.com/w3c/csswg-drafts/issues/4525 resolved that stretching should only happen when the cross size computes to `auto`. So this patch exposes this information in `ContentBoxSizesAndPBM`, and refactors the flexbox stretching logic. Fixes: #36285 Testing: - `/css/css-flexbox/quirks-auto-block-size-with-percentage-item.html` - `/css/css-flexbox/stretch-requires-computed-auto-size.html` Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* webgpu: Add a `webgpu_traits` crate (#36320)Martin Robinson2025-04-0450-565/+618
| | | | | | | | | | | | | | | This breaks the `script_traits` dependency on `webgpu`. In general, the `traits` crates shouldn't depend on Servo non-`traits` crates. This is necessary to move "script to constellation" messages to the `constellation_traits` crate, making it the entire API for talking to the constellation. This will break a circular dependency when that happens. Testing: Successfully building is enough of a test for this one as it is mainly moving types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Separate `WebviewManager` from `Webview` in `compositor` and `constellation` ↵Shubham Gupta2025-04-047-239/+253
| | | | | | | | | (#36302) Create a separate file for `WebviewManager` to improve clarity. Testing: This change is just a refactor, so no new tests are needed. Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
* Move generated bindings to script_bindings (#36323)Josh Matthews2025-04-0443-1826/+1923
| | | | | | | | | | | | | | | | | | | | | This is the final step of #1799, where the majority of the generated code for the JS bindings is now compiled as part of the script_bindings build step. The remaining pieces in script must live there because they refer to concrete DOM types; all code in script_bindings is generic over the [DomTypes](https://doc.servo.org/script/dom/bindings/codegen/DomTypes/trait.DomTypes.html) trait. My testing with incremental builds shows me a 12 second reduction in build times on my 2024 M4 Macbook Pro when modifying code in the script crate after these changes. Before this PR those changes took 20 seconds to rebuild Servo, and now they take 8 seconds. Testing: Existing WPT tests ensure no regressions. Fixes: #1799 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Webdriver delete cookie (#36306)Euclid Ye2025-04-047-4/+65
| | | | | | | | | | 1. Implement `WebDriverCommand::DeleteCookie` 2. Remove unnecessary clone for `WebDriverCommand::GetNamedCookie` Fixes: #36287 --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* Fix: `display: inline-grid` considered an atomic inline (#36298)Barigbue Nbira2025-04-032-1/+8
| | | | | | | | | | | | | | | | | | This change ensures that `display: inline-grid` is considered an atomic inline - Add `is_atomic_inline_level()` logic to `box_fragment.rs` to improve accuracy. - Update `stacking_context.rs` to use the new `is_atomic_inline_level()` method instead of the one from stylo. - Update `repeat-auto-fill-005.html` test expectation. - Remove .ini expectations for tests that are no longer failing. Testing: covered by WPT Fixes: #35310 --------- Signed-off-by: Barigbue <barigbuenbira@gmail.com>
* fix: root element not establishing stacking context (#35390) (#36174)Michael Rees2025-04-035-0/+23
| | | | | | | | | | | | | | | | | - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #35390 - [X] There are tests for these changes [Successful WPT run](https://github.com/reesmichael1/servo/actions/runs/14097679625) (which includes the new test files) (I didn't make the formatting changes intentionally--those came from `mach format` following `mach test-tidy`.) --------- Signed-off-by: Michael Rees <mrees@noeontheend.com>
* script: Implement deprecated CSSStyleSheet members (#36313)Oriol Brufau2025-04-032-3/+57
| | | | | | | | | | | | | | | | | | | | | | | Implements `rules`, `addRule()` and `removeRule()` for `CSSStyleSheet`. https://drafts.csswg.org/cssom/#legacy-css-style-sheet-members This is part of #36162 Testing: - `/css/css-cascade/at-scope-parsing.html` - `/css/css-conditional/at-supports-whitespace.html` - `/css/css-nesting/invalidation-004.html` - `/css/css-nesting/parsing.html` - `/css/css-nesting/serialize-group-rules-with-decls.html` - `/css/css-syntax/custom-property-rule-ambiguity.html` - `/css/css-syntax/invalid-nested-rules.html` - `/css/css-syntax/trailing-braces.html` - `/css/css-syntax/var-with-blocks.html` - `/css/css-transitions/parsing/starting-style-parsing.html` - `/css/cssom/CSSStyleSheet.html` - `/css/cssom/idlharness.html` - `/css/cssom/insertRule-across-context.html` Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Improve style conversion for Taffy (#36311)Oriol Brufau2025-04-031-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | This imports the following changes from Blitz: - Map position:sticky to relative rather than absolute position https://github.com/DioxusLabs/blitz/commit/16a7c1654455bee62e83854f83304a2931b29a0d - Map left and right alignment from Stylo https://github.com/DioxusLabs/blitz/commit/c71cc681d8c877dbd30853b3c4a2a7449c6450e4 - Improve mapping of align-items/self https://github.com/DioxusLabs/blitz/commit/7bf2a25e756c1310a9e4603b4757e20548b961e2 Fixes: #35998 Testing: - `/css/css-grid/alignment/grid-align-justify-margin-border-padding.html` - `/css/css-grid/alignment/grid-align.html` - `/css/css-grid/alignment/grid-column-axis-alignment-sticky-positioned-items-001.html` - `/css/css-grid/alignment/grid-gutters-and-alignment.html` - `/css/css-grid/alignment/grid-item-alignment-with-orthogonal-flows.html` - `/css/css-grid/alignment/grid-row-axis-alignment-sticky-positioned-items-001.html` - `/css/css-grid/alignment/grid-self-alignment.html` Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Support single-value `<select>` elements (#35684)Simon Wülker2025-04-0311-95/+456
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/user-attachments/assets/9aba75ff-4190-4a85-89ed-d3f3aa53d3b0 Among other things this adds a new `EmbedderMsg::ShowSelectElementMenu` to tell the embedder to display a select popup at the given location. This is a draft because some small style adjustments need to be made: * the select element should always have the width of the largest option * the border should be part of the shadow tree Apart from that, it's mostly ready for review. <details><summary>HTML for demo video</summary> ```html <html> <body> <select id="c" name="choice"> <option value="first">First Value</option> <option value="second">Second Value</option> <option value="third">Third Value</option> </select> </body> </html> ``` </details> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] Part of https://github.com/servo/servo/issues/3551 - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Use Window in new methods instead of GlobalScope for interfaces with … ↵Richard Dushime2025-04-0240-240/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36133) …Window-only constructors <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #36118 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: richarddushime <mudaherarich@gmail.com> Signed-off-by: Richard Dushime <45734838+richarddushime@users.noreply.github.com>
* script: Create `CSSStyleOwner::Null` for `getComputedStyle` (#36272)Martin Robinson2025-04-022-3/+68
| | | | | | | | | | | | | | | | | | | | This new `CSSStyleOwner` variant is used when the pseudo-element argument fails to parse properly or is for some unknown or unsupported pseudo-element. Testing: There are tests for this change. Various tests start to pass and some start to fail. New failures are due to partial or fully missing support for pseudo-elements such as: - `::selection` - `::first-letter` and `::first-line` - `::marker` Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Allow collapsing bottom margins with any indefinite block size (#36278)Oriol Brufau2025-04-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to CSS2, the bottom margin of a block container can collapse with the bottom margin of its last in-flow child if `height` computes to `auto`. However, according to CSS Sizing, that was "legacy spec prose" and should be interpreted as "behaves as `auto`". Therefore, cyclic percentages and intrinsic keywords like `min-content` shouldn't prevent margin collapse, because they behave as `auto`. This change aligns Servo with Gecko and Blink, but diverges from WebKit. https://www.w3.org/TR/CSS22/box.html#collapsing-margins https://www.w3.org/TR/css-sizing/#behave-auto Testing: - `tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-001.html` - `tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-002.html` - `tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-003.html` - `tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-004.html` - `tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-005.html` Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* dom: Firing "click" event as synthetic pointer event (#36274)Andrei Volykhin2025-04-025-53/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to specification https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-click-event "Firing a click event at target means firing a synthetic pointer event named click at target" So need to replace synthetic mouse event with "click" type to pointer event. https://w3c.github.io/pointerevents/#the-click-auxclick-and-contextmenu-events https://www.w3.org/TR/uievents/#event-type-click Firing "click" event could be triggered from script or by UA: - element.click() (https://html.spec.whatwg.org/multipage/interaction.html#dom-click) - form implicit submission (https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission) - keyboard activation (space) --- - [x] ./mach build -d does not report any errors - [x] ./mach test-tidy does not report any errors - [x] There are tests for these changes tests/wpt/tests/shadow-dom/event-composed.html tests/wpt/tests/uievents/interface/click-event.htm Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
* libservo: Start moving `WindowMethods` to `WebViewDelegate` (#36223)Martin Robinson2025-04-0211-117/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `WindowMethods` is used by the embedding layer to get information from the embedder. This change moves the functionality for getting screen size and `WebView` offsets to `WebViewDelegate`. This is important because `WebView`s might be on different screens or have different offsets on the screen itself, so it makes sense for this to be per-`WebView` and not global to the embedder. HiDPI and animation state functionality will move to the embedder in subsequent changes. Signed-off-by: Martin Robinson <mrobinson@igalia.com> <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they just modify the `WebView` API surface a bit. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Fix broken unit-test of webview (#36238)Shubham Gupta2025-04-021-9/+10
| | | | | | | | | | | This PR fixes the broken unit-test after [#35662](https://github.com/servo/servo/pull/35662) Testing: Verified locally and CI confirms too. Fixes: Migrate the test to use new API cc: @xiaochengh Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
* libservo: Remove a couple `EmbedderMethods` (#36276)Martin Robinson2025-04-0122-195/+95
| | | | | | | | | | | | | | | | | | | | | | | - Remove `EmbedderMethods::get_user_agent_string`. This is now part of the `Preferences` data structure, which should allow it to be per-`WebView` in the future. - Remove `EmbedderMethods::get_version_string`. This was used to include some data along with WebRender captures about the Servo version. This isn't really necessary and it was done to replace code in the past that output the WebRender version, so also isn't what the original code did. I think we can just remove this entirely. The idea with these changes is that `EmbedderMethods` can be removed in a followup and the rest of the methods can be added to `ServoDelegate`. These two methods are ones that cannot be added to a delegate as they are used during `Servo` initialization. Testing: There is currently no testing for libservo. These changes are meant as preparation for adding a suite of `WebView` unit tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Turn `CSSStyleRule` into a `CSSGroupingRule` subclass (#36254)Oriol Brufau2025-04-016-43/+83
| | | | | | | | | | | | | | | Note that `StyleRule` may not have the `CssRules` readily available, they may need to be created. So the previous approach of providing `CSSGroupingRule` with the `CssRules` is no good: it would require writing them in advance, just in case they end up being used. Therefore, this removes the `CSSGroupingRule::rules` field. Instead, they are lazily obtained in `CSSGroupingRule::rulelist()` by downcasting and calling the appropriate method for the subclass. Testing: covered by WPT Fixes: #36245 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* canvas: Implement line dash setters and getters (#36257)Steven Novaryo2025-04-019-3/+144
| | | | | | | | | | | Implement `setLineDash`, `getLineDash`, and `lineDashOffset` from `CanvasPathDrawingStyles` mixin, according to the spec https://html.spec.whatwg.org/multipage/canvas.html#canvaspathdrawingstyles. Testing: Existing WPT. --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* Implement CSSNestedDeclarations (#36248)Oriol Brufau2025-04-015-1/+118
| | | | | | | | | | | This is the CSSOM interface that represents a nested declarations rule. https://drafts.csswg.org/css-nesting/#the-cssnestrule Testing: `/_mozilla/mozilla/interfaces.https.html`. And once `CSSStyleRule` becomes a `CSSGroupingRule` subclass, this will be further covered by `/css/css-nestting/`. This is part of #36245 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* devtools: Fix id collisions by using incrementing counters (#35971)Delan Azabani2025-04-017-33/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Devtools clients need a `browserId`, `browsingContextID`, and `outerWindowID`, which correspond to WebViewId, BrowsingContextId, and PipelineId in Servo. These u32 values were previously derived from our sharded (u32,u32) id values by taking only the `index` (second u32) and ignoring the `namespace_id` (first u32), leading to collisions. This patch fixes that by mapping those Servo ids to sequential u32 values. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #35954 <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Fix null realm assertion when activating a service worker (#36256)Josh Matthews2025-04-011-3/+3
| | | | | | | | | | | Ensure there is an active realm when dispatching the `activation` DOM event to the ServiceWorker global. Testing: Existing WPT coverage. Fixes: #36114 Fixes: #36235 Fixes: #36231 Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Use `RegExpFlag_UnicodeSets` when validating regular expressions in ↵MDCODE2472025-04-011-3/+3
| | | | | | | | | | | | | | | `HTMLInputElement` (#36236) Changed `RegExpFlag_Unicode` to `RegExpFlag_UnicodeSets` in all instances. Testing: Ran `./mach test-wpt tests/wpt/tests/html/semantics/forms/constraints/form-validation-validity-patternMismatch.html` and all tests passed successfully. Fixes: #36075 --------- Signed-off-by: MDCODE247 <ammedabubakard500@gmail.com>
* Add SimulateColorScheme command and script thread handling (#36253)Usman Yahaya Baba2025-04-013-0/+12
| | | | | | | | | | | | | | | | Implements Steps 2-3 of #35867: - Adds `SimulateColorScheme` to `DevtoolScriptControlMsg` for light/dark mode simulation. - Handles it in `ScriptThread` with `handle_theme_change` to toggle themes. Testing: This PR does not require testing because it only adds infrastructure (command and handler) but doesn’t yet integrate with devtools actors. Fixes: Part of #35867 (https://github.com/servo/servo/issues/35867) --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Remove ServoParser::do_parse_sync (#36255)Simon Wülker2025-04-011-8/+0
| | | | | | The indirection through ServoParser::parse_sync does nothing, so the method can simply be called directly. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Track the active tab and browsing context for devtools (#36168)Usman Yahaya Baba2025-03-313-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Please describe your changes on the following line: --> ---Part of #35867, per Step 5 suggestion. This PR: - Adds active_tab (via RefCell) to RootActor, updated in get_tab_msg_by_browser_id. - Adds browsing_context() helper to TabDescriptorActor. - Adds actor()`getter to TabDescriptorActorMsg for access in root.rs. -Creates the chain (Root - Tab - BrowsingContext) for routing colorSchemeSimulation. <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X ] `./mach build -d` does not report any errors - [X ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they’re structural setup for the actor chain and don’t change the system's behavior yet. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>