aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/eventtarget.rs
Commit message (Collapse)AuthorAgeFilesLines
* Check CSP for inline event handlers (#36510)Tim van der Lippe10 days1-2/+19
| | | | | | | | | | | | This also ensures that document now reports all violations and we set the correct directive. With these changes, all `script-src-attr-elem` WPT tests pass. Part of #36437 Requires servo/rust-content-security-policy#3 to land first Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
* dom: Track "removed" event listener status (#36163)Andrei Volykhin2025-03-281-67/+72
| | | | | | | | | | | | | | | | | The DOM event listener "removed" status should be supported to track the following situations (with immediate effect of listener removal): - Removing a later event listener while an earlier listener for the same event is running - Nested usage (recursively dispatch another event) of "once" listeners https://dom.spec.whatwg.org/#event-listener-removed During event dispatching requires to clone event listeners list on "invoke" step https://dom.spec.whatwg.org/#concept-event-listener-invoke and the lowercase "event listener" concept in Servo is EventListenerEntry https://dom.spec.whatwg.org/#concept-event-listener Bug: #25479, #25090 Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
* Cleanups for future script crate split (#35987)Josh Matthews2025-03-161-11/+12
| | | | | | | | | | | | | | | | | * script: Avoid direct impl blocks on generated dicts and unions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Remove references to codegen-specific import module. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Use new stylo crate renames (#35898)Nico Burns2025-03-121-1/+1
| | | Signed-off-by: Nico Burns <nico@nicoburns.com>
* script: use passive event listener option on AddEventListenerOptions (#35877)shanehandley2025-03-101-1/+56
| | | Signed-off-by: Shane Handley <shanehandley@fastmail.com>
* script: Mark callback methods with CanGc. (#35753)Josh Matthews2025-03-031-6/+17
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-4/+4
| | | | | | | | | | | | | * 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>
* script: Make callbacks generic over DOM interfaces. (#35459)Josh Matthews2025-02-211-5/+5
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* make report_pending_exception safe and adjust callers (#35351)Nolen Scaife2025-02-081-5/+3
| | | Signed-off-by: Nolen Scaife <nolen@scaife.org>
* Implement ServoLayoutNode::traversal_parent (#35338)Simon Wülker2025-02-071-21/+1
| | | | | | | | | | | | | | | | | | | | | This fixes common crash related to slottables, currently present on wpt.fyi. Previously, the traversal parent of `Text` nodes was incorrectly assumed to always be the parent or shadow host. That caused crashes inside stylo's bloom filter. Now the traversal parent is the slot that the node is assigned to, if any, and the parent/shadow host otherwise. The slottable data for Text/Element nodes is now stored in NodeRareData. This is very cheap, because NodeRareData will already be instantiated for assigned slottables anyways, because the containing_shadow_root field will be set (since assigned slottables are always in a shadow tree). This change is necessary because we need to hand out references to the assigned slot to stylo and that is not possible to do (without unsafe code) if we need to downcast the node first. As a side effect, this reduces the size of `Text` from 256 to 232 bytes, because the slottable data is no longer stored there. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Move various reflector types and traits to script_bindings (#35279)Josh Matthews2025-02-041-1/+3
| | | | | | | | | | | | | * script: Move Reflector to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Extract global() helper from DomObject into new trait. Move DomObject and related traits to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Propagate events from slottables to their assigned slot instead of their ↵Simon Wülker2025-01-271-3/+26
| | | | | | | | | | | | | | | parent (#35177) * Propagate events from slottables to their assigned slot instead of their parent 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 Event propagation across shadow roots (#34884)Simon Wülker2025-01-221-5/+7
| | | | | | | | | | | | | | | | | * Implement Event.composed flag Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow composed events to pass shadow boundaries Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-25/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Consider shadow dom when dispatching events (#34788)Simon Wülker2025-01-071-2/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* script: Expose node helpers as `NodeTraits` and give more descriptive names ↵Martin Robinson2025-01-031-2/+2
| | | | | | | | | | | | | (#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>
* Generate a trait abstracting over all known DOM interfaces (#34357)Josh Matthews2024-11-241-1/+1
| | | | | | | | | | | | | | | | | * 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>
* Use out parameter for generated methods returning JSVal (#34087)Josh Matthews2024-11-051-9/+19
| | | | | | | | | | | | | | | | | | | | | * Make generated bindings that return a WebIDL `any` value use out parameters. Returning raw JSVal values makes it easier to create GC hazards in code that calls these methods. Accepting a MutableHandle argument instead ensures that the values are rooted by the caller. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update mozjs. 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>
* Remove GC hazard when compiling inline event listeners. (#33965)Josh Matthews2024-10-281-42/+42
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* cangc fixes in several files + event.rs + rtcpeerconnection.rs (#34002)chickenleaf2024-10-251-1/+1
| | | Signed-off-by: L Ashwin B <lashwinib@gmail.com>
* CanGc fixes from EventTarget::fire_event (#33985)tanishka2024-10-231-2/+2
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* CanGc fixes from eventtarget.rs (#33973)tanishka2024-10-221-6/+19
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* CanGc fixes in `errorevent.rs` (#33960)tanishka2024-10-221-2/+2
| | | | | | | | | | | | | * CanGc fixes in errorevent.rs Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Allow too_many_arguments to avoid lint error Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* Mark CompileFunction as a potential GC operation. (#33937)Josh Matthews2024-10-211-9/+21
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Multiple CanGc fixes in components/script/dom (#33924)tanishka2024-10-201-4/+4
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* More CanGc fixes: Range, Event, gpu error, Header (#33774)webbeef2024-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Propagate CanGc parameter in Range Signed-off-by: webbeef <me@webbeef.org> * Propagate CanGc parameter in gpu code and dependencies Signed-off-by: webbeef <me@webbeef.org> * Propagate CanGc parameter in Header and dependencies Signed-off-by: webbeef <me@webbeef.org> * Propagate CanGc parameter in Event and dependencies Signed-off-by: webbeef <me@webbeef.org> * Propagate CanGc parameter in rtcdatachannel Signed-off-by: webbeef <me@webbeef.org> * Propagate CanGc parameter in servoparser Signed-off-by: webbeef <me@webbeef.org> --------- Signed-off-by: webbeef <me@webbeef.org>
* Fixed some clippy warnings in components/script/dom (#33757)komuhangi2024-10-101-0/+1
| | | | | | | | | | | | | * Fixed some clippy warnings in components/script/dom Signed-off-by: jahielkomu <ktumuhairwe24@gmail.com> * Incorporated review suggestions Signed-off-by: jahielkomu <ktumuhairwe24@gmail.com> --------- Signed-off-by: jahielkomu <ktumuhairwe24@gmail.com>
* script: Include constructors and static methods in generated DOM traits (#33665)Josh Matthews2024-10-081-9/+9
| | | | | | | | | | | | | | | | | * Add all constructors, special operations, and static methods to generated DOM interface traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move all constructors and static methods defined in bare impl blocks inside FooMethods trait impls. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Add missing doc links. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Start marking functions that can transitively trigger a GC (#33144)Josh Matthews2024-08-221-3/+14
| | | | | | | | | | | | | | | | | * 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>
* Support HTML parser reentrancy (#32820)Josh Matthews2024-08-161-5/+0
| | | | | | | | | | | | | | | | | | | | | * Update parser interface for reentrancy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Remove assertions around invoking scripts with active parser. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Add regression test. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Run test with normal and async html parser. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Replace null-byte terminated string literals with C-string literals (#32716)Bumsoo Kim2024-07-061-6/+6
| | | | | | | | | | | | | * simple conversion from byte string to c-string Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * convert byte strings to c-strings to c_char ptr Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> --------- Signed-off-by: Bum Kim <bumcrystlbum@gmail.com>
* clippy: Fix a bunch of warnings in `script` (#32680)Martin Robinson2024-07-041-11/+7
| | | This is just a portion of the errors that are remaining to be fixed.
* Revert "script: implement AbortController (#31361)" (#32243)Samson2024-05-071-12/+2
| | | This reverts commit 7fce850cffb72a6fbcf763a40164a9b35b7fa833.
* script: implement AbortController (#31361)Smitty2024-05-041-2/+12
| | | | | | | | | | | | | | | | | | | | | * Implement AbortController Signed-off-by: syvb <me@iter.ca> * Update WPT tests Signed-off-by: syvb <me@iter.ca> * Address review comments * Fix duplicate import generation * Update WPT test expectations * Change expectation to FAIL for flaky test --------- Signed-off-by: syvb <me@iter.ca>
* clippy: Fix `toplevel_ref_arg` warning in `components/script` (#31984)Oluwatobi Sofela2024-04-031-3/+2
| | | | | * clippy: Fix toplevel_ref_arg warnings * refactor: Make the let binding more idiomatic
* clippy: Fix another set of clippy problems in `components/script/dom` (#31909)Rosemary Ajayi2024-03-281-4/+4
| | | | | | | | | * a reference to a reference * length comparison to zero * length comparison to zero * length comparison to zero
* clippy: Fix collapsible_else_if warnings (#31853)Oluwatobi Sofela2024-03-261-9/+7
|
* fixes dereferencing on an immutable reference (#31864)Aarya Khandelwal2024-03-261-2/+2
|
* changed `match` to 'matches!' (#31850)Aarya Khandelwal2024-03-251-7/+6
|
* clippy: Fix redundant field names warnings (#31793)Oluwatobi Sofela2024-03-201-7/+3
|
* Remove usage of `drain_filter` (#30742)Martin Robinson2023-11-171-1/+1
| | | This is a step on the way toward supporting stable rust.
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-28/+30
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-0/+1
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* No tracing of nop traceable fields (#29926)Samson2023-08-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `no_trace` option to JSTraceable derive * NoTrace wrapper * Port some types to no_trace schematics * Fixing my unsafe mistakes (not tracing traceables) * Add docs & safety guards for no_trace Safety guards (trait shenanigans) guarantees safety usage of `no_trace` * Port canvas_traits to no_trace * Port servo_media to no_trace * Port net_traits to no_trace * Port style to no_trace * Port webgpu to no_trace * Port script_traits to no_trace * Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace * unrooted_must_root lint in seperate file * Add trace_in_no_trace_lint as script_plugin * Composable types in must_not_have_traceable * Introduced HashMapTracedValues wrapper * `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>` * Port rest of servo's types to no_trace * Port html5ever, euclid, mime and http to no_trace * Port remaining externals to no_trace * Port webxr and Arc<Mutex<_>> * Fix spelling in notrace doc
* make the concept of has_listeners_for follow other implementations (#21044)Gregory Terzian2023-07-191-0/+2
| | | Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
* Rename reflect_dom_object2.Josh Matthews2023-05-311-2/+2
|
* Formatting.Josh Matthews2023-05-281-2/+5
|
* Support arbitrary protos when wrapping DOM objects with constructors.Josh Matthews2023-05-281-5/+5
|
* Support arbitrary protos when wrapping EventTarget objects.Josh Matthews2023-05-281-4/+4
|
* Make GlobalScope.get_cx a static method.Josh Matthews2023-05-201-7/+7
|