Commit graph

761 commits

Author SHA1 Message Date
Simon Wülker
6a2e37183c
Lay out the contents of slot elements (#35220)
* 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>
2025-02-02 20:49:42 +00:00
Simon Wülker
64b40ea700
Don't fire slotchange events when there's already a pending event for the same slot (#35222)
* Don't fire slotchange events if there is already a pending event for the same 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>
2025-01-30 13:57:04 +00:00
Simon Wülker
1ad45a776a
Potentially signal a slot change in Node::insert (#35221)
* Potentially signal a slot change in Node::insert

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>
2025-01-30 08:47:21 +00:00
Simon Wülker
859cc6ab9b
Fire slot change events when the slot content changes (#35137)
* Add the onslotchange attribute to ShadowRoot

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add spec comments to MutationObserver::queue_mutation_observer_microtask

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add DomRefCell::take

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add spec comments to notify_mutation_observers

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fire slotchange events when a slot changes

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* ./mach fmt

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix check for when to dispatch slot events

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Potentially fire slot change events in Node::remove

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* ./mach fmt

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Bump stylo

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Move "signal a slot change" into ScriptThread impl

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-01-27 14:13:22 +00:00
Simon Wülker
c070372d1e
Set descendant's attribute's owner document in Node::adopt (#35076)
* 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>
2025-01-19 23:06:28 +00:00
Simon Wülker
dabe162d44
Implement shadow dom slots (#35013)
* 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>
2025-01-19 14:05:05 +00:00
Josh Matthews
875e387004
script: Feature-gate all crown support. (#35055)
* 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>
2025-01-18 21:36:15 +00:00
Josh Matthews
c94d909a86
script: Limit public exports. (#34915)
* 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>
2025-01-10 08:19:19 +00:00
Simon Wülker
270df6e263
Consider shadow dom when dispatching events (#34788)
* Implement EventTarget::get_the_parent

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add spec steps to Event::init_event

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Rewrite Event::composedPath to be spec compliant

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Retarget EventTargets instead of Nodes

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Rewrite event dispatch/invocation to better match the spec

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add spec comments to Event struct

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Don't traverse shadow roots when calculating an events path

We can't do this correctly yet, and assuming that an events
composed flag is never set is correct 99% of the time.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix typo in event dispatch

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* fix comment

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* allow crown error

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* fmt

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reduce item visibility where possible

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Simplify code a bit

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix Step 5.10 of Event::invoke

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix renamed method calls

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-01-07 21:22:16 +00:00
Martin Robinson
e42b4b793d
script: Expose NodeTraits::owner_global / Window::as_global_scope (#34843)
Expose two new helpers and start using them as much as possible.

- `NodeTraits::owner_global`: which gets the `GlobalScope` that currenty
 owns a `Node`. This may be different than `.global()` in the case that
 the `Node` was adopted by a different `Document`.
- `Window::as_global_scope`: A helper to avoid having to cast so much
  when treating a `Window` like a `GlobalScope`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-07 09:56:02 +00:00
Simon Wülker
b6a5eaa3db
Add shadow tree flags to Bind/UnbindContext (#34863)
* 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>
2025-01-07 00:00:43 +00:00
Simon Wülker
1ab55e6b11
Fix IS_IN_SHADOW_TREE flag for descendants after Node::remove call (#34803)
* 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>
2025-01-03 23:27:43 +00:00
Martin Robinson
e8f75c9aea
script: Expose node helpers as NodeTraits and give more descriptive names (#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>
2025-01-03 18:55:01 +00:00
shanehandley
08a3e61bb4
Use spec-aligned process for resolving history handling during navigation (#34747)
Makes use of the is_initial_about_blank property on Document in order to
determine whether the navigation should create a history entry, or replace
the current history entry.

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
2024-12-27 02:45:53 +00:00
Josh Matthews
981616f918
Don't run scripts while DOM tree is undergoing mutations (#34505)
* script: Implement node insertion post-connection hook. Ensure script elements only run scripts when the DOM has stabilized.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Make iframe element use post-connection steps when handling initial document insertion.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Use a delayed task when running post-connection steps.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Add explanatory comment.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Tidy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-12-26 06:06:09 +00:00
Domenico Rizzo
1dfb44d7b8
Clone node on a shadow root should always throw an error (#34742)
* Corrected Node-prototype-cloneNode clone part test

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>

* Corrected node code

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>

* updated MANIFEST

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>

* removed fails expectations

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>

* Removed not legacy ini file

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>

---------

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2024-12-24 16:04:04 +00:00
Josh Matthews
a85241e635
Replace unsafe uses of HandleValueArray. (#34588)
* Replace unsafe uses of HandleValueArray.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy lint.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-12-13 23:21:55 +00:00
Martin Robinson
2bcee38e52
script: Remove note_rendering_opportunity and rendering_opportunity (#34575)
A rendering opportunity is now unconditionally triggered by handling IPC
messages in the `ScriptThread`, unless animations are running in which
case it's driven by the compositor. We can now remove calls to
`note_rendering_opportunity` and `rendering_opportunity`.

There is one tricky case, which is when a promise completion during a
microtask checkpoint dirties the page again. In this case we need to
trigger a new rendering opportunity, unless animations are running.  In
a followup change, when not driven by the compositor, rendering
opportunities will be driven by a timed task, meaning we can remove this
workaround.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-12-12 08:43:58 +00:00
Ville Lindholm
bc7fe41a02
Add XPath parser/evaluator (#34463)
* Add XPath parser/evaluator

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* Correctly annotate XPathEvaluator IDL

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: have bindings pass in `can_gc`

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: add docstrings

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: implement PartialEq for Value for readability

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: add docstrings for CoreFunctions

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: simplify node test code

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: add unit tests for string handling xpath functions

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* put xpath features behind dom.xpath.enabled pref

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review] remove rstest and insta dev-deps

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* update wpt test expectations

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* [PR review]: tweak metadata files

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

* update wpt test expectations AGAIN

Signed-off-by: Ville Lindholm <ville@lindholm.dev>

---------

Signed-off-by: Ville Lindholm <ville@lindholm.dev>
2024-12-08 02:01:50 +00:00
Simon Wülker
97e9841d47
Implement ShadowRoot.clonable attribute (#34514)
* 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>
2024-12-07 14:24:18 +00:00
Josh Matthews
4242ff9626
Make traverse_preorder follow shadow roots (#34503)
* 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>
2024-12-07 04:28:34 +00:00
Josh Matthews
e956f3124c
Generate a trait abstracting over all known DOM interfaces (#34357)
* script: Generate trait for all DOM interfaces and parameterize generated Methods traits over it.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Update trait implementations with new generic type.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-11-24 07:35:14 +00:00
Simon Wülker
1198b26ec9
Implement ShadowRoot.innerHtml attribute (#34335)
* Implement DocumentFragment::fragment_serialization_algorithm

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement ShadowRoot innerHtml attribute

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* cargo-clippy

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reuse existing serialization code and move helpers into Node

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix typo

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-11-22 17:07:01 +00:00
shanehandley
975e2ae859
Remove referrer policy from document (#34263)
* Remove the referrer policy from document and rely on its policy container

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* Make ReferrerPolicy non-optional, instead using a new enum value to represent the empty string case

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* Fix clippy issue

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* Fix usage of Option<ReferrerPolicy> in unit test

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

---------

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
2024-11-19 12:45:10 +00:00
eri
01820e2a8a
Improve how intrinsic sizes work for videos (#31746)
* feat: patch for video layout sizes

added rebase from main 2024/10/05

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: eri <epazos@igalia.com>

* feat: take width and height parameters if provided

Signed-off-by: eri <epazos@igalia.com>

* chore: tidy the code and update test expectations

Signed-off-by: eri <epazos@igalia.com>

* feat: handle removing poster

Signed-off-by: eri <epazos@igalia.com>

* chore: update test expectations and remove debug code

Signed-off-by: eri <epazos@igalia.com>

* fix: issues after rebasing to main

Signed-off-by: eri <epazos@igalia.com>

* feat: pass src remove test and tidy

Signed-off-by: eri <epazos@igalia.com>

* chore: clippy fixes

Signed-off-by: eri <epazos@igalia.com>

* chore: update passing test expectations

Signed-off-by: eri <epazos@igalia.com>

* fix object-position-svg test

Signed-off-by: eri <epazos@igalia.com>

* fix unintentional override of video size and resize events

Signed-off-by: eri <epazos@igalia.com>

* change how resize events are sent to better match the spec

Signed-off-by: eri <epazos@igalia.com>

* simplify poster mutation handling

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: eri <eri@inventati.org>

* improved handling of intrinsic sizes

- differentiate between natural size and css size
- presentational attributes
- fallback ratio for video element
- handle more cases where the src/poster are added/removed
- aspect ratio hints

Signed-off-by: eri <epazos@igalia.com>

* update test expectations

Signed-off-by: eri <epazos@igalia.com>

* fix cleaning current frame

Signed-off-by: eri <epazos@igalia.com>

* update test expectations

Signed-off-by: eri <epazos@igalia.com>

* Apply suggestions from code review

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: eri <eri@inventati.org>

* More code review suggestions

Signed-off-by: eri <epazos@igalia.com>

* Prevent aspect-ratio:auto from pulling the ratio from the default object size

As resolved in https://github.com/w3c/csswg-drafts/issues/7524#issuecomment-1204462924

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: eri <epazos@igalia.com>
Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-10-29 22:42:22 +00:00
chickenleaf
bb4932026c
cangc fixes in node.rs (#33984)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
2024-10-23 22:44:50 +00:00
chickenleaf
9acb25521e
CanGc changes from fontfaceset.rs (#33920)
* CanGc changes from fontfaceset.rs

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* Update components/script/dom/bindings/codegen/Bindings.conf

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: chickenleaf <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Signed-off-by: chickenleaf <lashwinib@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2024-10-21 12:28:56 +00:00
tanishka
65c866285f
Multiple CanGc fixes in components/script/dom (#33924)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
2024-10-20 16:07:15 +00:00
webbeef
2b71130a8a
Various CanGc fixes (#33800)
* CanGc fix for pagetransitionevent

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/node

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for gamepad

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for gpu

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/element

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for xhr

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/worker

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for rtcdatachannel

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for rtcerror

Signed-off-by: webbeef <me@webbeef.org>

* Address review comments

Signed-off-by: webbeef <me@webbeef.org>

---------

Signed-off-by: webbeef <me@webbeef.org>
2024-10-11 03:53:39 +00:00
Ben
dbd1666b17
Layout: Implement innerText/outerText (#33312)
* Implement outerText on HtmlElement

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* Fixed some innerText/outerText bugs

Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de>

* Unified innerText/outerText handling outside of Layout

Before these 2 were treated separately and only within
Layout would they end up calling the same method, now
they are already unified within HTMLElement

Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de>

* Address a few nits

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

* Added innerText support for `inline-flex`

Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de>

---------

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Shane Handley <shanehandley@fastmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-09-24 09:45:33 +00:00
Simon Wülker
7df30f3788
Replace .map_or(false with Option::is_some_and (#33468)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-09-16 10:03:52 +00:00
Oriol Brufau
ed908f3fd4
Fix rustdoc problems (#33458)
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-09-14 18:32:41 +00:00
Ali
ed6b1b5e6a
clippy: Fix suggestions in script, libservo, and servoshell (#33453)
* fix clone on copy warning in servoshell

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>

* Remove unecessary borrow in libservo

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>

* Ignore too many arguments warning on create_constellation()

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>

* fix explicit auto-deref warning

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>

* Autofix multiple clippy warnings in components/script

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>

---------

Signed-off-by: Ali Zein Yousuf <azy5030@gmail.com>
2024-09-14 08:41:13 +00:00
Oriol Brufau
a76daaf04c
Upgrade stylo to 2024-09-02 (#33370)
* Upgrade stylo to 2024-09-02

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Fixup for https://phabricator.services.mozilla.com/D217308

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Fixup for https://phabricator.services.mozilla.com/D217626

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Fixup for https://phabricator.services.mozilla.com/D218488

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Fixup for https://phabricator.services.mozilla.com/D219537

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Update test expectations

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-09-13 15:59:57 +00:00
Andriy Sultanov
e5150dbda1
Propagate CanGc from Document::new() (#33386)
* Add canGc as a parameter to autogenerated trait methods

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

* Propagate CanGc from Document::new()

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

---------

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
2024-09-09 22:38:01 +00:00
Nolan Lawson
67e2bb0ee6
script: fix querySelector returning the root (#33174)
Signed-off-by: Nolan Lawson <nolan@nolanlawson.com>
2024-08-25 09:16:26 +00:00
Josh Matthews
60ef6bc461
Start marking functions that can transitively trigger a GC (#33144)
* Mark JS reflector wrappers as CanGc.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from reflect_dom_object_with_proto.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Mark DOM constructors as GC operations.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-08-22 11:42:36 +00:00
Jose Monagas
a34920b605
fix(clippy): Clippy suggestions in components/script/dom/* (#33072)
Signed-off-by: Jose T. Monagas <josetmonagas@proton.me>
Co-authored-by: Jose T. Monagas <josetmonagas@proton.me>
2024-08-15 19:31:30 +00:00
Chocolate Pie
92866ab911
enhance: Add support for unsafe-eval and wasm-unsafe-eval (#32893)
Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
2024-08-01 17:26:44 +00:00
eri
c06a6a764e
DevTools: Inline text and clean whitespace (#32884)
* feat: inline text contents

Signed-off-by: eri <eri@inventati.org>

* feat: filter whitespace only nodes

Signed-off-by: eri <eri@inventati.org>

* chore: cleanup

Signed-off-by: eri <eri@inventati.org>

* fix: url fix

Signed-off-by: eri <eri@inventati.org>

* fix: review fixes

Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-30 10:18:21 +00:00
eri
902bf57331
DevTools: Show HTML tree (#32655)
* feat: watch root node

Signed-off-by: eri <eri@inventati.org>

* reafactor: divide inspector in components

Signed-off-by: eri <eri@inventati.org>

* feat: add css properties actor

Signed-off-by: eri <eri@inventati.org>

* feat: accesibility actor

Signed-off-by: eri <eri@inventati.org>

* feat: layout actor

Signed-off-by: eri <eri@inventati.org>

* feat: network parent and refactor

Signed-off-by: eri <eri@inventati.org>

* feat: progress on the inspector messages

Signed-off-by: eri <eri@inventati.org>

* feat: more progress on inspector

Signed-off-by: eri <eri@inventati.org>

* feat: try to fix nodes showing

Signed-off-by: eri <eri@inventati.org>

* feat: initial dom tree

Signed-off-by: eri <eri@inventati.org>

* feat: some more messages

Signed-off-by: eri <eri@inventati.org>

* feat: clean and add documentation

Signed-off-by: eri <eri@inventati.org>

* refactor: add more docs and clean

Signed-off-by: eri <eri@inventati.org>

* fix: restore deleted node attributes field

Signed-off-by: eri <eri@inventati.org>

* Apply suggestions from code review

Fix a few nits in comments

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-26 15:17:54 +00:00
eri
2888193cfe
DevTools: Replace camel case variable names (#32726)
* refactor: rename to snake case

* refactor: more renaming

* chore: format

* chore: clean
2024-07-08 11:18:35 +00:00
Gregory Terzian
3d78d60619
implement basic infra for ResizeObserver (#31108) 2024-06-17 16:44:07 +00:00
Mukilan Thiyagarajan
2af6fe0b30
compositor: Move WebRender-ish messages and types to webrender_traits (#32315)
* Move WebRender related types to `webrender_traits`

This refactor moves several WebRender related types
from `compositing_traits`, `script_traits` and `net_traits`
crates to the `webrender_traits` crate.

This change also moves the `Image` type and associated
function out of `net_traits` and into the `pixels` crate.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Move `script_traits::WebrenderIpcSender` to `webrender_traits::WebRenderScriptApi`

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-05-20 10:35:18 +00:00
Martin Robinson
3398fc017b
Move non-gfx things out of gfx_traits and create a base crate (#32296)
For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
2024-05-17 12:28:58 +00:00
Pi-Cla
160c7c0b0f
Fix some clippy warnings in components/gfx and components/script (#32215)
* clippy: Squish warnings and errors in gfx

warning: redundant closure (gfx/font.rs:415:18)

warning: useless conversion to the same type (gfx/font.rs:534:9)

warning: the following explicit lifetimes could be elided: 'a (gfx/font.rs:619:16)

error: this loop never actually loops (gfx/font_cache_thread.rs:112:9)

warning: this expression creates a reference which is immediately dereferenced by the compiler  (gfx/font_cache_thread.rs:229:51)

warning: redundant closure (gfx/font_cache_thread.rs:551:18)

3 instances of:
warning: casting integer literal to `f64` is unnecessary (gfx/platform/freetype/font_list.rs:271-273)

* clippy: methods called `from_*` usually take no `self`

It reports that by standard convention, from_* methods should not take any `&self` parameter

* clippy: you should consider adding a `Default` implementation

It reports that public types with a pub fn new() -> Self should have a Default implementation since they can be constructed without arguments

* clippy: casting to the same type is unnecessary (`f32` -> `f32`)

* clippy: use of `unwrap_or_else` to construct default value

* clippy: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self`

* clippy: manual `!RangeInclusive::contains` implementation

contains expresses the intent better and has less failure modes (such as fencepost errors or using || instead of &&)

* clippy: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`

* clippy: Fix some new warnings

warning: this `if` statement can be collapsed (gfx/font.rs:468:130)

warning: this lifetime isn't used in the impl (gfx/platform/freetype/font.rs:341:6)

warning: field assignment outside of initializer for an instance created with Default::default() (compositor.rs:881:17)
2024-05-02 20:02:21 +00:00
Martin Robinson
a0640c8524
Address issues uncovered by rust-1.78 beta (#32130)
This change makes changes to allow Servo to compile with the 1.78
version of Rust:

 - Dead code is removd (Rust seems to have gotten better at detecting
   it).
 - The `FlowRef` `DerefMut` is updated according to @SimonSapin's advice
   [^1].
 - The `imports.rs` now explicitly silences warnings about unused
   imports.

[^1]: https://github.com/servo/servo/issues/6503#issuecomment-2066088179

<!-- 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 should not change
behavior.

<!-- 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. -->
2024-04-22 18:20:47 +00:00
Martin Robinson
7d63c7607f
script_layout: Remove script to layout messages (#32081)
Instead of communicating with layout via messages, script can simply
call methods on the layout trait. This simplifies the way that script
communicates with layout and opens the path to sharing more data
structures between the two systems. This is part of a continuing 
series of cleanups after removing the layout thread.

<!-- 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 should not change
behavior.

<!-- 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. -->
2024-04-22 15:28:14 +00:00
Kitsu
67f239d1ba
clippy: fix several lint warns (#32126)
As seems #31500 still remain opened here's the next partial fix.

Fixed list: `unused_mut`, `clippy::needless_borrow`,
`clippy::match_ref_pats`, `clippy::borrow_deref_ref`, `clippy::ptr_eq`,
`clippy::unnecessary_cast`, `clippy::derivable_impls`,
`clippy::collapsible_match`, `clippy::extra_unused_lifetimes`,
`clippy::map_clone`, `clippy::manual_filter`.


- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes are part of #31500.
- [x] These changes do not require tests because are only cosmetic.
2024-04-22 06:45:39 +00:00
komuhangi
007a72fe4d
Fixed some clippy warnings in components (#32107)
* Fixed some clippy warnings in components

* Updated handling of NaN values in comparison

* Updated formatting using ./mach fmt
2024-04-19 08:48:01 +00:00