aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
Commit message (Collapse)AuthorAgeFilesLines
...
* script: Ensure `EventSource` field value is ignored if the null character ↵Keith Yeung2025-05-051-1/+3
| | | | | | | | | | | exists in the field name (#36854) Spec has updated so that any null characters in the `id` field name would result in the value being ignored. Testing: Covered by `tests/wpt/tests/eventsource/format-field-id-null.window.js` Signed-off-by: Keith Yeung <kungfukeith11@gmail.com>
* devtools: Allow highlighting elements from the inspector (#35822)Simon Wülker2025-05-054-0/+35
| | | | | | | | | | | | | | | | | | | | | | | This change connects the `HighlighterActor` from the devtools with the document, which will draw a blue rectangle over any highlighted dom node. https://github.com/user-attachments/assets/571b2dab-497f-4102-9e55-517cdcc040ba --- <!-- 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 we don't have devtools tests Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* script: Unconditionally send exit message during pipeline shutdown (#36808)Martin Robinson2025-05-051-8/+9
| | | | | | | | | | | | If a `WebView` is dropped immediately after creating it, the exit pipeline message can arrive to the `ScriptThread` before the `Document` is created for the pipeline. If this happens, we should still send a message to the `Constellation` informing it that the pipeline is closed, otherwise it will never know that this has happened properly. Testing: This change includes a new unit test. Fixes: #36807. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Remove unspecified early return in MessagePort::Close (#36836)Graham Lowe2025-05-051-4/+0
| | | | | | | | | | | | | | This change removes the early return in `MessagePort::Close` that occurred when the message port was detached. The [spec](https://html.spec.whatwg.org/multipage/web-messaging.html#dom-messageport-close) doesn't prescribe this behaviour for detached ports for this operation, so the early return was unnecessary. Testing: Runs ./mach test-wpt /webmessaging/ and ./mach test-wpt /streams/ Fixes: [servo-36765](https://github.com/servo/servo/issues/36765) Signed-off-by: Graham Lowe <graham.lowe@gmail.com> Co-authored-by: Graham Lowe <graham.lowe@gmail.com>
* Create new image cache per document (#36832)Tim van der Lippe2025-05-041-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Rather than sharing the full image cache in a script_thread, the image cache is now unique per document. This ensures that CSP factors no longer affect whether the image is retrieved from the cache incorrectly. To do so, the thread_pool is shared across all caches, but the store is fresh. Except for the place_holder{image,url}, which are cloned. That's because the `rippy_data` is only available in the constellation and no longer accessible at the point that we need to create the document in the script_thread. Contrary to the description in #36505, the script_thread still has an image_cache for this reason: so it has access to the store and thread_pool to clone it. With these changes, the two CSP tests no longer flake. Confirmed with running the following commmand: ``` ./mach test-wpt tests/wpt/tests/content-security-policy/generic/ --rerun=10 ``` Fixes #36505 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* Embed user agent stylesheets and media control resouces in libservo (#36803)webbeef2025-05-043-5/+485
| | | | | | | Embed user agent stylesheets and media control resouces in libservo as decided in https://github.com/servo/servo/pull/36788#issuecomment-2845332210 Signed-off-by: webbeef <me@webbeef.org>
* script: add `TaskSource` argument to `route_promise` (#36831)Gae242025-05-048-15/+46
| | | | | | | | | Added task_source argument to route_promise, enabling callers to pick the correct TaskSource. Testing: No testing required, straightforward refactor Fixes: #36825 Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* Implement Trusted types worker sinks (#36811)Tim van der Lippe2025-05-042-5/+35
| | | | | | | | | Part of #36258 Built on top of #36668 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* Implement Trusted types document write sinks (#36824)Tim van der Lippe2025-05-043-53/+136
| | | | | | | | | | Implements the Document.write algorithm covering Trusted HTML. Part of #36258 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* Propagate parent policy container to local iframes (#36710)Tim van der Lippe2025-05-033-2/+34
| | | | | | | | | | | | | | This follows the rules as defined in https://w3c.github.io/webappsec-csp/#security-inherit-csp where local iframes (about:blank and about:srcdoc) should initially start with the CSP rules of the parent. After that, all new CSP headers should only be set on the policy container of the iframe. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* Implement all trusted sinks in `HTMLScriptElement` (#36668)Tim van der Lippe2025-05-038-199/+312
| | | | | | | | | | | | | | | | | | | | | | | | As a follow-up to the recent introduction of `script.src` as trusted sink, this PR refactors machinery to also support `TrustedScript`. In doing so, all trusted sinks in `HTMLScriptElement` are now covered. Instead of calling the callbacks in `policy.createX`, we now have a `TrustedType` enum that specifies which callback to invoke. Unfortunately we still have the `USVString` vs `DOMString` problem, which is why we need to `.map` twice to retrieve the backing `String` and avoid two different types. Additionally, I saw that `script.text` should have called the "String replace all" algorithm rather than setting the child contents. So that's also now fixed. Part of #36258 Requires servo/html5ever#608 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* Check CSP for `javascript:` URLs (#36709)Tim van der Lippe2025-05-023-6/+45
| | | | | | | | | | Also update a WPT test to fail-fast if the iframe incorrectly evaluates the `eval`. Before, it would run into a timeout if the implementation is correct. Now we reject the promise when an exception is thrown. Requires servo/rust-content-security-policy#6 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* script: Move Window-only gamepad functionality out of GlobalScope (#36805)Josh Matthews2025-05-0213-236/+199
| | | | | | | | | | | | The only code that calls these methods is in the script thread, and the code is simpler when we can assume a Window global. Pulling this thread led to cleaning up a lot of constructors for Window-only WebXR code, too. Testing: Existing WPT coverage. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix build when `webgpu` feature is not enabled (#36804)webbeef2025-05-022-1/+4
| | | | | Fix winit_minimal build breakage Signed-off-by: webbeef <me@webbeef.org>
* Establish baseline webdriver conformance results (#35024)Josh Matthews2025-05-011-4/+4
| | | | | | | | | | | | | | | | https://github.com/web-platform-tests/wpt/pull/50041 allows us to start running the webdriver conformance tests in Servo, which will make it easier for us to track regressions/improvements in our webdriver server implementation. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes are part of #15274 - [x] There are tests for these changes --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Remove `HTMLCanvasDataSource` and `CanvasSource` (#36794)sagudev2025-05-017-22/+20
| | | | | | | All canvases return `Option<ImageKey>`. Testing: Just refactor without behavior changes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* feat: implement ShadowRoot::setHTMLUnsafe (#36240)Kelechi Ebiri2025-05-013-23/+40
| | | | | | | Implements #36166 --------- Signed-off-by: TG <ebiritg@gmail.com>
* script: Clamp table spans according to the HTML specification (#36703)Martin Robinson2025-05-013-22/+50
| | | | | | | | | | | | Previously, spans were partially clamped during layout, but this means that accessing and setting these properties via script wouldn't behave according to the HTML specification. In addition, the value wasn't floored in layout, so could lead to panics. This change improves clamping and moves it to script. Testing: This change includes a new WPT test. Fixes #36699. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Send info about the `DocumentType` node to the devtools inspector (#36787)Simon Wülker2025-05-011-0/+15
| | | | | | | | | | | | | | | | This makes the DOCTYPE tag show up correctly in the inspector. Before: ![image](https://github.com/user-attachments/assets/fd101337-95ce-45ee-8ac5-ae701109eb94) After: ![image](https://github.com/user-attachments/assets/4e80f4c0-6ae4-4c53-88ca-614803caa032) Testing: We don't have devtools tests Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Set cryptographic nonce metadata for module script fetch operations (#36776)Simon Wülker2025-04-301-2/+3
| | | | | | | This fixes a bunch of CSP errors on reddit.com --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Let (Offscreen)RenderingContext implement CanvasContext (#36712)sagudev2025-04-305-123/+258
| | | | | | | | | | this allows us to simplify canvas element/offscreen impl to only call CanvasContext implementations (no more match statements). This will help with impl more offscreen canvas contextl. Testing: WPT and rustc Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Include `ChildrenList::last_visited` in memory reports (#36772)Simon Wülker2025-04-301-1/+0
| | | | | | | `MutNullableDom<Node>` is not in fact defined in `mozjs`. Testing: This change compiles, so it works Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Remove macro impl_rare_data (#36771)Kingsley Yung2025-04-303-25/+26
| | | | | | | | | | | | | | | | | This macro does not hide any complex or unsafe implementation details, and, it's only used in two files (node.rs and element.rs). This patch removes the macro, and move the implementation in place. Moreover, the Element::rare_data_mut function in element.rs is called by other functions, so the #[allow(dead_code)] annotation is removed. The Node::rare_data_mut function in node.rs is not called anywhere, so it is removed. Testing: No test is needed for this cleaning up. Fixes: #36767 --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
* Don't explicitly restyle when updating `<details>` shadow tree (#36769)Simon Wülker2025-04-302-24/+30
| | | | | | | | | | | | | | | | | | | I'm not sure why I added these calls in the first place, but they don't seem to be necessary and seem to be the cause of crashes. This PR also adds some spec comments that I added while investigating the crash. Testing: Covered by existing WPT tests Fixes https://github.com/servo/servo/issues/36757 Fixes https://github.com/servo/servo/issues/36273 [try run](https://github.com/simonwuelker/servo/actions/runs/14753023662/job/41415889180) --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* MessagePort: implement disentanglement (#36654)Gregory Terzian2025-04-306-63/+198
| | | | | | | | | | | | | | | | | | | Implement [disentangle](https://html.spec.whatwg.org/multipage/#disentangle) Remove bespoke gc logic which now becomes unnecessary. Adds a wpt test that hits the "disentangle while in transfer" logic. Updates streams code, fixing an error where disentanglement is conditional on an error. Test coverage: there are existing tests in `/webmessaging/message-channels/close-event/explicitly-closed.tentative.window.js` for the no transfer case, and the simple completed transfer case, and this PR adds a test for the more complicated transfer in progress case. Fix https://github.com/servo/servo/issues/36465 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* Improve inter-document focus handling (#36649)Fuguo2025-04-307-116/+470
| | | | | | | | | | | | | | | *Describe the changes that this pull request makes here. This will be the commit message.* rewritten the PR #28571 Implement [Window#focus](https://html.spec.whatwg.org/multipage/#dom-window-focus), [Window#blur](https://html.spec.whatwg.org/multipage/#dom-window-blur) Testing: WPT Fixes: #8981 #9421 --------- Signed-off-by: kongbai1996 <1782765876@qq.com> Co-authored-by: yvt <i@yvt.jp>
* update doc for `ScriptThread::relative_mouse_down_point` (#36743)Euclid Ye2025-04-291-2/+1
| | | | | | | | update doc for `ScriptThread::relative_mouse_down_point` which was missing in #36619 Testing: No need as just updating docs Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* fix crash occurs when the focus element is adopted (#36608)Fuguo2025-04-291-1/+3
| | | | | | | | | | | | fix crash occurs when the focus element is adopted. Testing: wpt dom/nodes/insertion-removing-steps/blur-event.window.html not crash Fixes: #36607 #32972 --------- Signed-off-by: kongbai1996 <1782765876@qq.com>
* Fix BorrowMutError crash in form reset (#36726)Taym Haddadi2025-04-291-2/+8
| | | | | Fixes: #36724 Signed-off-by: Taym <haddadi.taym@gmail.com>
* canvas: Apply large size limitations (#36445)Andrei Volykhin2025-04-293-46/+79
| | | | | | | | | | | | | | | | | | | | | To prevent any potential crash/OOM issues with "canvas" element from "rogue" applications let's apply large size limitations for context canvas2d's draw target to Servo (similar approach in Firefox/Chromium - they limits width and height to 32767/65535 pixels). Fixes: #36155, #34117, #30164, #24710 -- - [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/html/canvas/element/canvas-host/2d.canvas.host.size.large.html tests/wpt/tests/html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.html tests/wpt/tests/html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.worker.js Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
* Devtools: Support worker scripts in `Debugger > Source` panel (#36562)atbrakhi2025-04-292-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for listing `worker scripts` in `debugger > source` panel For example: ``` <!-- test.html --> <!doctype html><meta charset=utf-8> <script> setTimeout(() => { console.log("inline classic"); new Worker("worker.js"); const blob = new Blob([`console.log("blob worker");`], { type: "text/javascript" }); const blobURL = URL.createObjectURL(blob); new Worker(blobURL); }, 2000); </script> ``` ``` // worker.js console.log("external classic worker"); ``` ``` ./mach run --devtools=6080 http://127.0.0.1:3000/test.html ``` ![file1](https://github.com/user-attachments/assets/84dd94b9-95d8-4087-b4bb-ab936fca0023) Another example: ``` ./mach run --devtools=6080 https://charming.daz.cat/ ``` ![blob](https://github.com/user-attachments/assets/a1341ee4-3a1c-4cca-ac04-658675cdcf39) - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes partially implement #36027 - [x] These changes require tests, but they are blocked on https://github.com/servo/servo/issues/36325 --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com>
* Start adding support for transforms in readable and writable streams (#36470)Taym Haddadi2025-04-2812-161/+390
| | | | Start adding support for transforms in readable and writable streams. Part of https://github.com/servo/servo/issues/34676
* Rewrite node insertion algorithm to match the spec (#35999)Xiaocheng Hu2025-04-281-38/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per [spec](https://dom.spec.whatwg.org/#concept-node-insert), adoption of new node should be done while inserting the node. This patch moves the call site of `adopt` to inside `insert` to match it. It also rewrites some existing code to better match the spec without any behavioral changes. --- <!-- 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 #___ (GitHub issue number if applicable) <!-- 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: Xiaocheng Hu <xiaochengh.work@gmail.com>
* htmlinputelement: Update radio group validity logic for disconnected trees ↵elomscansio2025-04-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36431) This PR updates the validity state revalidation behavior for radio input elements, ensuring consistent logic regardless of tree connectivity. --- **What’s changed:** - we now always update the validity state. - Handled more edge cases for disconnected trees, shadow roots, and cross-tree movement. - Ensured that radio group updates still trigger when a parent is moved into a different root. - Updated test expectations in `radio-disconnected-group-owner.html.ini`. --- **Why this matters:** The updated logic aligns better with the [HTML specification](https://html.spec.whatwg.org/multipage/input.html#radio-button-group), especially regarding radio group behavior in disconnected trees or shadow DOM. These changes improve validity propagation in scenarios like: - Appending inputs into a disconnected form - Shadow roots acting as radio group containers - Cross-tree movement of radio buttons --- **Tests:** - Modified `radio-disconnected-group-owner.html.ini` - Removed a test that now passes - Added a failing test expectation caused by a spec bug: the fragment parsing algorithm uses the connected tree for HTML set via `innerHTML`, affecting radio group computation --- **Spec reference:** https://html.spec.whatwg.org/multipage/input.html#radio-button-group --- <!-- 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 an errors - [ ] These changes fix # <!-- Either: --> - [X] There are tests for these changes Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
* script_thread: HTML parser doesn't set relevant option (#36622)elomscansio2025-04-272-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch ensures that the Servo HTML parser uses the appropriate `TreeBuilderOpts` settings as specified by the HTML specification. Changes: - **iframe_srcdoc:** Detect if the parsed document's URL scheme is `about:srcdoc`, and set the parser’s iframe_srcdoc option accordingly. - **quirks_mode:** Use the associated Document's quirks mode to set the parser’s quirks mode flag, improving fragment parsing behavior. - **scripting_enabled:** Add a `scripting_enabled` method to Document, based on whether it has a browsing context, and set this flag for the parser. These updates align Servo's parsing behavior more closely with the specification: https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode --- <!-- 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 #35478 <!-- Either: --> - [ ] There are tests for these changes Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
* Determine if ResizeTo is allowed (#36704)Taym Haddadi2025-04-271-1/+11
| | | | | | | | | Spec says to check If target is not an auxiliary browsing context before performing ResizeTo. Fixes: #36701 Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
* Use snapshot size instead of canvas size when converting canvas to blob (#36705)Simon Wülker2025-04-261-11/+19
| | | | | | | | | | | | | The blob data is encoded asynchronously, therefore the canvas size may have changed since it's data was saved to a snapshot. Using the canvas size confuses the encoder, because the provided data does not match the expected size anymore. Testing: This change includes a new web platform test Fixes https://github.com/servo/servo/issues/36702 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* layout: Use box tree `Fragment`s for offset parent queries (#36681)Martin Robinson2025-04-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | This change switches `offsetParent`, `offsetLeft`, etc queries to use the BoxTree fragments instead of walking the entire fragment tree. In addition, fragments are stored for columns and colgroups. In general, this greatly simplifies the flow of the query and prevents having to do expensive tree walks. Testing: This change is covered by newly passing WPT tests and three new failures: - /css/filter-effects/backdrop-filter-edge-clipping-2.html - /css/filter-effects/backdrop-filter-edge-mirror.html - /css/filter-effects/backdrop-filter-edge-pixels-2.html These failures are actually progressions, because now the references start to render properly whereas before they did not. Fixes: This is part of #36525 and #36665. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Support CSP report-only header (#36623)Tim van der Lippe2025-04-253-70/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this with `script-src-report-only-policy-works-with-external-hash-policy.html` which was blocking the script incorrectly. Turns out that there were multiple bugs in the CSP library, as well as a missing check in `fetch` to report violations. Additionally, in several locations we were manually reporting csp violations, instead of the new `global.report_csp_violations`. As a result of that, they would double report, since the report-only header would be appended as a policy and now would report twice. Now, all callsides use `global.report_csp_violations`. As a nice side-effect, I added the code to set source file information, since that was already present for the `eval` check, but nowhere else. Part of #36437 Requires servo/rust-content-security-policy#5 --------- Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
* layout: Implement node geometry queries against `BoxTree`'s `Fragment` (#36663)Martin Robinson2025-04-251-3/+9
| | | | | | | | | | | | | | | | | | This is a followup to #36629, continuing to implement script-based layout queries using the `Fragment`s attached to the `BoxTree`. In this change, geometry queris (apart from parent offset) are calculated using `Fragment`s hanging of the `BoxTree`. In order to make this work, all `Fragment`s for inlines split by blocks, need to be accessible in the `BoxTree`. This required some changes to the way that box tree items were stored in DOM `BoxSlot`s. Now every inline level item can have more than a single `BoxTree` item. These are carefully collected by the `InlineFormattingContextBuilder` -- currently a bit fragile, but with more documentation. Testing: There are tests for these changes. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Implement static Response.json (#36589)Sebastian C2025-04-251-97/+151
| | | | | | | | | | | Implements https://fetch.spec.whatwg.org/#dom-response-json Restructured the constructor to follow the spec more closely with a separate "initialize the response" algorithm. Testing: There are existing WPT tests for this. --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
* Report exceptions for async script executions to webdriver (#27041)Josh Matthews2025-04-253-30/+91
| | | | | | | | | | | | | | | | | | | | | Improving the accuracy of the async script execution for our webdriver implementation allows us to run many more webdriver tests without timeouts, which should help with https://github.com/web-platform-tests/wpt/issues/24257. Specification: * https://w3c.github.io/webdriver/#dfn-clone-an-object * https://w3c.github.io/webdriver/#execute-async-script --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #27036 and fix #27035 and fix #27031. - [x] There are tests for these changes (but we don't run them in CI yet) --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* compositor: Tick animations for an entire WebView at once (#36662)Martin Robinson2025-04-243-49/+6
| | | | | | | | | | | | | | | | | | | | | | | | Previously, when processing animations, the compositor would sent a tick message to each pipeline. This is an issue because now the `ScriptThread` always processes rendering updates for all `Document`s in order to ensure properly ordering. This change makes it so that tick messages are sent for an entire WebView. This means that each `ScriptThread` will always receive a single tick for every time that animations are processed, no matter how many frames are animating. This is the first step toward a refresh driver. In addition, we discard the idea of ticking animation only for animations and or only for request animation frame callbacks. The `ScriptThread` can no longer make this distinction due to the specification and the compositor shouldn't either. This should not really change observable behavior, but should make Servo more efficient when more than a single frame in a `ScriptThread` is animting at once. Testing: This is covered by existing WPT tests as it mainly just improve animation efficiency in a particular case. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout_image: Include missing request settings in layout-initiated image ↵elomscansio2025-04-241-1/+4
| | | | | | | | | | | | | | | | | | | | | | | loads (#36621) This PR updates the `fetch_image_for_layout` function to include missing security-related request settings: - `insecure_requests_policy` - `has_trustworthy_ancestor_origin` - `policy_container` --- <!-- 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 #36591 <!-- Either: --> - [X] There are tests for these changes Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
* script: Measure stored layout data memory usage. (#36664)Josh Matthews2025-04-242-3/+3
| | | | | | | | | | | | | | We previously ignored the opaque layout data field inside each node when measuring a DOM node's memory usage. While some of the reachable memory was accounted for by measuring the layout's box tree, measuring it via the node ensures that we don't miss anything. Since there are often Arc values involved, this means that the layout-thread box tree measurements now look quite small, while reported JS heap usage has increased. Testing: Manually compared about:memory for servo.org. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Implement CSSStyleSheet::replaceSync (#36586)webbeef2025-04-233-1/+36
| | | | | | | Implements the `replaceSync` method on CSSStyleSheet Testing: Covered by wpt tests. Expectations are updated. Signed-off-by: webbeef <me@webbeef.org>
* script: Add generic root storage to StructuredCloneReader. (#36640)Josh Matthews2025-04-2310-126/+73
| | | | | | | | | | | | | This reduces the boilerplate necessary for adding new serializable/transferable interfaces to the structured cloning code. We always need to root the deserialized objects when performing a read operation, but we don't actually need the concrete object types in the majority of cases. By storing a list of rooted JS object values, we can push generic reflector objects into it, and extract the types we need (MessagePort) at the very end. Testing: Existing WPT structured cloning tests will provide coverage. Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* layout: Add a new `FragmentTree` pass to calculate containing block ↵Martin Robinson2025-04-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | rectangles (#36629) When doing any kind of query, up until now, containing block rectangles were calculated by walking the `FragmentTree` until the node being queried was found. In order to make possible answering queries without walking the `FragmentTree`, `Fragment`s need to cache their cumulative containing block rectangles. This change adds a new `FragmentTree` pass (during construction) that takes care of calculating and caching these values. The new cached value is used during resolved style queries and also scrolling area queries (with the idea that all queries will eventually use them). In addition, extra `FragmentTree` walks used for cancelling animations for elements no longer in the `FragmentTree` are integrated into this new traversal. Testing: Covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Introduce snapshot concept of canvas (#36119)sagudev2025-04-2311-142/+136
| | | | | | | | | | | | | | | | | | Each canvas context returns snapshot instead of just raw bytes. This allows as to hold off conversions (BGRA <-> RGBA, (un)premultiply) to when/if they are actually needed. For example when loading snapshot into webgl we can load both RGBA and BGRA so no conversion is really needed. Currently whole thing is designed to be able to be extend on https://github.com/servo/ipc-channel/pull/356, to make less copies. Hence some commented out code. Fixes #35759 There are tests for these changes in WPT --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* chore: remove unnecessary `webrender_document` in script (#36648)Jason Tsai2025-04-222-18/+1
| | | | | | | | | remove `webrender_document` in script and constellation's pipeline Testing: `webrender_document` in script crate is not being referenced anywhere in the Servo, should be safe to remove. Fixes: https://github.com/servo/servo/issues/36647 Signed-off-by: Jason Tsai <git@pews.dev>