aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
Commit message (Collapse)AuthorAgeFilesLines
* Implement trusted types url setter (#36596)Tim van der Lippe6 days1-1/+49
| | | | | | | | | | | | | | | | | | | | | | | | We now check the sink of script.src for trusted types. This is the first attribute that we check, other sinks will be implemented in follow-up changes. The algorithms currently hardcode various parts. That's because I need to refactor a couple of algorithms already present in TrustedTypePolicy. They use callbacks at the moment, which made sense for their initial use. However, for these new algorithms they don't work. Therefore, I will align them with the specification by taking in an enum. However, since that's a bigger refactoring, I left that out of this PR (which is already quite big). The other trusted types support (createScript and createHTML) will also be implemented separately. Part of #36258 --------- Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
* Use version of `markup5ever` with `web_atoms` crate (#36542)Nico Burns7 days1-3/+1
| | | | | | | | Upgrades `markup5ever` and fixes "unnecessary import" lints. See https://github.com/servo/html5ever/pull/599 And https://github.com/servo/stylo/pull/173 Signed-off-by: Nico Burns <nico@nicoburns.com>
* add CanGc as argument to methods in Element (#36464)Yerkebulan Tulibergenov2025-04-111-37/+44
| | | | | | | | add CanGc as argument to methods in Element Testing: These changes do not require tests because they are a refactor. Addresses part of https://github.com/servo/servo/issues/34573. Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* Add CanGc as arguments in methods in Attr and Node (#36371)Yerkebulan Tulibergenov2025-04-061-3/+6
| | | | | | | | | | | | | 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>
* constellation: Stop assuming that the viewport is shared by all WebViews ↵Martin Robinson2025-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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>
* Support single-value `<select>` elements (#35684)Simon Wülker2025-04-031-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Propagate CanGc arguments through HTMLCollection constructors (#36180)Kunga Derick Abongho2025-03-291-4/+9
| | | Signed-off-by: dericko681 <abonghoderick@gmail.com>
* resolve issue #36074 new_js_regex and matches_js_regex need a CanGc argument ↵Kunga Derick Abongho2025-03-291-58/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36111) * new_js_regex and matches_js_regex need a CanGc argument Signed-off-by: dericko681 <abonghoderick@gmail.com> * new_js_regex and matches_js_regex need a CanGc argument Signed-off-by: dericko681 <abonghoderick@gmail.com> * edit Propagate CanGc arguments through new_js_regex and matches_js_regex Signed-off-by: dericko681 <abonghoderick@gmail.com> * Propagate CanGc arguments through new_js_regex and matches_js_regex Signed-off-by: dericko681 <abonghoderick@gmail.com> * Propagate CanGc arguments through new_js_regex and matches_js_regex Signed-off-by: dericko681 <abonghoderick@gmail.com> * Propagate CanGc arguments through new_js_regex and matches_js_regex Signed-off-by: dericko681 <abonghoderick@gmail.com> --------- Signed-off-by: dericko681 <abonghoderick@gmail.com>
* script: Implement `Element::GetHTML` and `ShadowRoot::GetHTML` (#36106)Simon Wülker2025-03-231-5/+25
| | | | | | | | | | | | | | | | | | | | | * Serialize html fragments without going through html5ever Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement ShadowRoot::GetHtml / Element::GetHtml Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Propagate CanGc annotations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Don't clear children of declarative shadow hosts when imperatively attaching ↵Simon Wülker2025-03-231-2/+1
| | | | | | | | | | | | | | | | | another shadow root (#36104) * Don't remove a declarative shadow hosts children when attaching an imperative shadow root Instead we should remove all children of the shadowroot. 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>
* Make Element::attach_shadow() and ShadowRoot closer to spec (#36024)batu_hoang2025-03-191-9/+60
| | | Signed-off-by: batu_hoang <longvatrong111@gmail.com>
* dom: Implement minimal IntersectionObserver workflow (#35551)Steven Novaryo2025-03-181-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add very rough implemnentation of observation steps Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix entry reflection and propagate can_gc Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix BorrowError and add fragment find descendant Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Implement is descendant in containing block path correctly Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix unrooted error and tidy issues Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix comments Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Remove is descendant of other node query I suppose these changes is better separated to other PRs. Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix intersection and refactor registration Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Use AppUnit more and propagate GlobalScope better Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update WPT expectations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Revert delay changes Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Align compute intersection algo to other browser actual behavior Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Align processing documents and note several issues Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update WPT Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Minor lint Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix top level browsing context Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Make Registration rootable Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Avoid reflow inside observation step algo Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Using borrow for iterating registration Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix document disconnect Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update WPT Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Address comments and minor quality suggestions Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Root the observer before nofifying any of it Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Tidy docs Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Account not found element and refactor observation step Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix documentations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Ignore position of document viewport Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Refactor root intersection rectangle Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Add can GC note to the callback Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix top-level browsing context term Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix minor comments Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* Implement declarative shadow dom (#34964)batu_hoang2025-03-171-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement declarative shadow dom Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Set allowDeclarativeShadowRoots false for innerHTML Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Enable allowDeclarativeShadowRoots for Document Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Expose HTMLTemplateElement to js Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Implemenet setHTMLUnsafe and add more test cases Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Declarative shadow dom: minor updates and expected test result update Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Shadow-dom: add more test cases Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Update comments according to the spec Signed-off-by: batu_hoang <longvatrong111@gmail.com> * Bump html5ever version Signed-off-by: batu_hoang <longvatrong111@gmail.com> --------- Signed-off-by: batu_hoang <longvatrong111@gmail.com>
* Check whether an element is custom in the spec-compliant way (#35960)Xiaocheng Hu2025-03-131-5/+12
| | | | | | | | | | | | | * Check whether element is custom in spec-compliant way Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> * Update tests Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> --------- Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
* Hide servo internal shadow roots from the inspector by default (#35958)Simon Wülker2025-03-131-0/+1
| | | Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Migrate to the 2024 edition (#35755)Simon Wülker2025-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | * Migrate to 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow unsafe_op_in_unsafe_fn lint This lint warns by default in the 2024 edition, but is *way* too noisy for servo. We might enable it in the future, but not now. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Compile using the 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Set `is` value when constructing custom elements with the `new` operator ↵Simon Wülker2025-03-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | (#35930) * Add doc comments throughout the code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Set is-value for elements constructed with the "new" operator Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow custom elements to extend <slot> 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>
* Implement `ElementInternals::shadowRoot` (#35923)Simon Wülker2025-03-121-0/+10
| | | | | | | | | | | | | * Implement ElementInternals::shadowRoot 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>
* Use new stylo crate renames (#35898)Nico Burns2025-03-121-2/+2
| | | Signed-off-by: Nico Burns <nico@nicoburns.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-23/+27
| | | | | | | | | | | | | * 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>
* layout: Implement a non-recursive version of CSS `quotes` (#34770)Xiaocheng Hu2025-02-271-7/+24
| | | | | | | | | | | | | | | | | * Squash and don't explicitly use noto-cjk in tests Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> * Mark quotes-034.html.ini failure Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> * Address review comments Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> --------- Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
* Allow the `<details>` element to be opened and closed (#35261)Simon Wülker2025-02-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement the <summary> element Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement UA shadow root for <details> Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Invalidate style when display is opened or closed Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fix /_mozilla/mozilla/duplicated_scroll_ids.html This test previously assumed that <details> elements would not be rendered. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement implicit summary elements Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Remove test for duplicated scroll IDs See https://github.com/servo/servo/pull/35261#discussion_r1969328725 for reasoning. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Use Iterator::find to find implicit summary element Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* refactor: add CanGc as argument to Promise::reject_error (#35646)Yerkebulan Tulibergenov2025-02-251-1/+4
| | | Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* refactor: add CanGc as argument to Promise::resolve (#35616)Yerkebulan Tulibergenov2025-02-231-2/+2
| | | Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* refactor: propagate CanGc arguments through callers (#35591)Auguste Baum2025-02-231-1/+3
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Move more bindings code to script_bindings (#35578)Josh Matthews2025-02-221-20/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move JSContext wrapper to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move webidl constant bindings to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move CanGc to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move Dom<T> and Root<T> types to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Extra docs for new traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Support the `<meter>` element (#35524)Simon Wülker2025-02-211-4/+6
| | | | | | | | | | | | | | | | | | | | | * Allow attaching UA shadow roots to any element Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement a UA shadow tree for the <meter> element Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add UA styles for the meter element Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Include spec text when computing meter state Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Allow resetting multiple flags at once in Element::set_state (#35580)Simon Wülker2025-02-211-5/+9
| | | | | | | Previously, the code would incorrectly return without updating the flags if the caller tried to reset multiple flags at once and the not all of them were true. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Propagate `CanGc` arguments through callers in constructors (#35541)Auguste Baum2025-02-201-3/+4
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Ensure that qualified-name segments start with a valid start character (#35530)Simon Wülker2025-02-191-7/+7
| | | | | | | | | | | | | | | | | * Add spec comments to various methods Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Ensure that qualified-name segments start with a valid start character 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>
* dom: IntersectionObserver initialization (#35314)Steven Novaryo2025-02-131-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add internal slot definition Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Add initialization for new IntersectionObserver Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Move observer initialization Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update WPT tests Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Make a copy of style IntersectionObserverRootMargin Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Move initialization to account for rooted expression Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix some fields typing Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Impl rest of IntersectionObserver interface Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix tidy issue Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Apply types logic and tidy fix from suggestions Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Add allow unrooted for add registration to element Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* Implement ServoLayoutNode::traversal_parent (#35338)Simon Wülker2025-02-071-52/+0
| | | | | | | | | | | | | | | | | | | | | 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>
* script: delay Mutation initialization (#35291)Euclid Ye2025-02-051-5/+5
| | | Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* Lay out the contents of slot elements (#35220)Simon Wülker2025-02-021-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make Slottable match layout/alignment of NonNull<Node> Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement ServoLayoutElement::slotted_nodes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Bump mozjs Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Layout the contents of slot elements Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Implement ServoLayoutElement::assigned_slot Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * implement ServoLayoutElement::traversal_parent Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Simplify slottable name update Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Don't iterate over children of shadow hosts Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Recompute slot style when contents change Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Change match_slottable to a function instead of a macro Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fix crown errors Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reset a slottable's assigned slot when it's removed from the slot Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Use "slot" attribute for slottable name (#35191)Simon Wülker2025-01-291-1/+12
| | | | | | | | | | | | | | | | | * Implement Element::slot attribute Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Simplify slottable name update 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>
* Set descendant's attribute's owner document in Node::adopt (#35076)Simon Wülker2025-01-191-0/+1
| | | | | | | | | | | | | * Set descendant's attribute's owner document in Node::adopt Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add test that adopting an element into a new doc updates the attribute' owner docs Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Implement shadow dom slots (#35013)Simon Wülker2025-01-191-3/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: Feature-gate all crown support. (#35055)Josh Matthews2025-01-181-2/+2
| | | | | | | | | | | | | * script: Feature-gate all crown support. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use cfg(crown) instead of a cargo feature. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-129/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 shadow tree flags to Bind/UnbindContext (#34863)Simon Wülker2025-01-071-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Rename IS_IN_DOC flag to IS_IN_A_DOCUMENT_TREE Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add BindContext::is_in_a_shadow_tree Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add UnbindContext::tree_is_in_shadow_tree Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach fmt Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update test expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * fix build after rebasing Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Ensure Element ID modifications inside disconnected shadow roots are ↵Simon Wülker2025-01-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | registered (#34834) * Add test for modifying element IDs in disconnected shadow roots Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Register element ID modifications inside disconnected shadow roots Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Don't crash when registering named elements in disconnected shadow roots Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fix test title Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Fix IS_IN_SHADOW_TREE flag for descendants after Node::remove call (#34803)Simon Wülker2025-01-031-1/+5
| | | | | | | | | | | | | | | | | * Consider a UnbindContext to be tree-connected if its in a shadow root Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Properly track whether a node is in a shadow tree after removing subtree 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: Expose node helpers as `NodeTraits` and give more descriptive names ↵Martin Robinson2025-01-031-38/+35
| | | | | | | | | | | | | (#34832) This puts a few commonly used `Node` helpers into a trait (`NodeTraits`) and gives them more descriptive names and documentation. The renames: - `document_from_node` -> `NodeTraits::owner_document` - `window_from_node` -> `NodeTraits::owner_window` - `stylesheets_owner_from_node<T:` -> `NodeTraits::stylesheet_list_owner` - `containing_shadow_root` -> `NodeTraits::containing_shadow_root` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Elide lifetimes where possible after rustup (#34824)Martin Robinson2025-01-031-2/+2
| | | | | | | | | The new version of rust allows us to elide some lifetimes and clippy is now complaining about this. This change elides them where possible and removes the clippy exceptions. Fixes #34804. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Add check for valid custom element name in element::attach_shadow (#34749)Steven Novaryo2024-12-241-23/+47
| | | | | | | | | | | | | * Add valid custom element name check Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update wpt test expectation Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* layout: Lay out Shadow DOM elements (#34701)Martin Robinson2024-12-191-8/+13
| | | | | | | | | | | When an element is a shadow root, lay out the shadow root elements instead of the non-shadow children. This fixes some tests and introduces some failures, due to bugs in the Shadow DOM implementation. In general, this is very low impact as the Shadow DOM is still disabled by default. At least this gets elements rendering when the preference is turned on though. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: No longer do explicit reflows for display (#34599)Martin Robinson2024-12-131-14/+0
| | | | | | | | | | | | | | | | | | | | | | | These all happen now in *update the rendering*, typically after the message that triggered this code is processed, though in two cases reflow needs to be triggered explicitly. This makes `ReflowReason` redundant though perhaps `ReflowCondition` can be expanded later to give more insight into why the page is dirty. - Handling of the "reflow timer" concept has been explained a bit more via data structures and rustdoc comments. - Theme changes are cleaned up a little to simplify what happens during reflow and to avoid unecessary reflows when the theme doesn't change. Notably, layout queries and scrolling still trigger normal reflows and don't update the rendering. This needs more investigation as it's unclear to me currently whether or not they should update the rendering and simply delay event dispatch or only reflow. In general, this is a simplfication of the code. Fixes #31871. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* traverse Shadow DOM boundaries when determining element lang (#34529)Ville Lindholm2024-12-081-1/+1
| | | Signed-off-by: Ville Lindholm <ville@lindholm.dev>
* Implement `ShadowRoot.clonable` attribute (#34514)Simon Wülker2024-12-071-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | * Implement ShadowRoot clonable attribute Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach test-tidy fixes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * fix clippy warnings Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Make traverse_preorder follow shadow roots (#34503)Josh Matthews2024-12-071-7/+9
| | | | | | | | | | | | | | | | | * script: Ensure shadow-inclusve preorder traversals follow hosted shadow roots. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Handle unregistering element id/name values inside of a shadow root. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Merge shadow root tree iteration logic. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>