aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/reflector.rs
Commit message (Collapse)AuthorAgeFilesLines
* Move generated bindings to script_bindings (#36323)Josh Matthews2025-04-041-63/+6
| | | | | | | | | | | | | | | | | | | | | This is the final step of #1799, where the majority of the generated code for the JS bindings is now compiled as part of the script_bindings build step. The remaining pieces in script must live there because they refer to concrete DOM types; all code in script_bindings is generic over the [DomTypes](https://doc.servo.org/script/dom/bindings/codegen/DomTypes/trait.DomTypes.html) trait. My testing with incremental builds shows me a 12 second reduction in build times on my 2024 M4 Macbook Pro when modifying code in the script crate after these changes. Before this PR those changes took 20 seconds to rebuild Servo, and now they take 8 seconds. Testing: Existing WPT tests ensure no regressions. Fixes: #1799 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Expose new methods for obtaining a global that require a realm. (#36116)Josh Matthews2025-03-261-2/+16
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-1/+1
| | | | | | | | | | | | | * 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: Refer to DOM interfaces with generic types in generated bindings. ↵Josh Matthews2025-02-211-20/+37
| | | | | (#35457) Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move various reflector types and traits to script_bindings (#35279)Josh Matthews2025-02-041-81/+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>
* script: Feature-gate all crown support. (#35055)Josh Matthews2025-01-181-3/+3
| | | | | | | | | | | | | * 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-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* script: Expose `NodeTraits::owner_global` / `Window::as_global_scope` (#34843)Martin Robinson2025-01-071-1/+3
| | | | | | | | | | | 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>
* Add CanGc argument to reflect_dom_object (#34606)Domenico Rizzo2024-12-131-10/+2
| | | | | | | | | | | | | | | | | | | | | * applied mach fmt Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com> Refinements Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com> Modified reflect_dom_object signature and all its calls Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com> * fix function calls when parameter is passed up Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com> --------- Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
* clippy: Fix warnings in `components/script/dom` (#33860)tanishka2024-10-161-0/+2
| | | | | | | | | | | | | * clippy: Fix warnings in components/script/dom Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Move allow to WRAP level Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* clippy: Add safety documentation and clean up unsafe methods (#33748)Martin Robinson2024-10-161-0/+8
| | | | | | | | | | | This change: 1. Adds safety documentation where it was missing. 2. Limits the scope of unsafe code in some cases to where it is actually unsafe. 3. Converts some free functions to associated functions and methods, thereby making them more likely to be called safely. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* 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>
* clippy: Fix a bunch of warnings in `script` (#32680)Martin Robinson2024-07-041-0/+2
| | | This is just a portion of the errors that are remaining to be fixed.
* Fix rustdoc errors in `components/script/dom` (#31617)Mucha Naibei2024-03-111-1/+1
| | | | | * Fix rustdoc errors in components/script/dom * Revert if to iff in audiobuffer.rs
* Replace script_plugins with a clippy like rustc driver (named crown) (#30508)Samson2023-12-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove script_plugins * Use crown instead of script_plugins * crown_is_not_used * Use crown in command base * bootstrap crown * tidy happy * disable sccache * Bring crown in tree * Install crown from tree * fix windows ci * fix warning * fix mac libscript_plugins.dylib is not available anymore * Update components/script/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> * Update for nightly-2023-03-18 Mostly just based off https://github.com/servo/servo/pull/30630 * Always install crown it's slow only when there is new version * Run crown test with `mach test-unit` * Small fixups; better trace_in_no_trace tests * Better doc * crown in config.toml * Fix tidy for real * no sccache on rustc_wrapper * document rustc overrides * fixup of compiletest * Make a few minor comment adjustments * Fix a typo in python/servo/platform/base.py Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com> * Proper test types * Ignore tidy on crown/tests --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-3/+5
| | | | | * strict imports formatting * Reformat all imports
* Rename reflect_dom_object2.Josh Matthews2023-05-311-1/+5
|
* Formatting.Josh Matthews2023-05-281-1/+6
|
* Support arbitrary protos when wrapping DOM objects with constructors.Josh Matthews2023-05-281-2/+2
|
* Support arbitrary protos when wrapping EventTarget objects.Josh Matthews2023-05-281-2/+12
|
* Make GlobalScope.get_cx a static method.Josh Matthews2023-05-201-2/+4
|
* Add trait DomObjectWrap to provide WRAP functionYUAN LYU2020-03-201-8/+22
|
* Introduce a new type MaybeUnreflectedDom<T> (fixes #25701)Anthony Ramine2020-02-171-4/+5
|
* Use `#![register_tool]` instead of `#![register_attr]`Simon Sapin2019-11-151-1/+1
| | | | CC https://github.com/rust-lang/rust/issues/66079
* Modify *::get_cx methods to return a safe JSContext instead of a raw onemarmeladema2019-07-241-9/+3
|
* Wrap(Global)Method now takes a SafeJSContext instead of a JSContextmarmeladema2019-07-241-3/+10
| | | | as first argument.
* Update MPL license to https (part 3)Jan Andre Ikenmeyer2018-11-191-1/+1
|
* Reorder importsPyfisch2018-11-061-1/+1
|
* `cargo fix --edition`Simon Sapin2018-11-061-3/+3
|
* Format script componentchansuke2018-09-191-9/+12
|
* Updated to mozjs v0.7.1.Alan Jeffrey2018-05-301-1/+1
|
* Adapt Servo for mozjs 0.6 and the changes introduced in servo/rust-mozjs#393Marcin Mielniczuk2018-03-281-1/+2
|
* Use unsafe Heap::handle wherever neededIgor Matuszewski2018-03-231-1/+2
|
* Replace all uses of the `heapsize` crate with `malloc_size_of`.Nicholas Nethercote2017-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`. `malloc_size_of` is better -- it handles various cases that `heapsize` does not -- so this patch changes Servo to use `malloc_size_of`. This patch makes the following changes to the `malloc_size_of` crate. - Adds `MallocSizeOf` trait implementations for numerous types, some built-in (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`). - Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't support that operation. - For `HashSet`/`HashMap`, falls back to a computed estimate when `enclosing_size_of_op` isn't available. - Adds an extern "C" `malloc_size_of` function that does the actual heap measurement; this is based on the same functions from the `heapsize` crate. This patch makes the following changes elsewhere. - Converts all the uses of `heapsize` to instead use `malloc_size_of`. - Disables the "heapsize"/"heap_size" feature for the external crates that provide it. - Removes the `HeapSizeOf` implementation from `hashglobe`. - Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of` doesn't derive those types, unlike `heapsize`.
* Make DomRoot<T> a type alias of a more general Root<T> typeAnthony Ramine2017-09-281-1/+1
| | | | | | | This Root<T> relies on the concept of a stable trace object, which doesn't move for the whole lifetime of the T value. For safety reasons, T must be 'static. The only implementor of StableTraceObject for now is Dom<T>.
* Rename Root<T> to DomRoot<T>Anthony Ramine2017-09-261-4/+4
| | | | | | | In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>, where Root<T> will be able to handle all the things that need to be rooted that have a stable traceable address that doesn't move for the whole lifetime of the root. Stay tuned.
* Rename dom::bindings::js to dom::bindings::rootAnthony Ramine2017-09-261-1/+1
|
* Replace inheritance_integrity by trait shenanigansAnthony Ramine2017-02-151-2/+1
| | | | | | | | | | | | | | | | | For each derived DomObject impl, we also generate a dummy trait ShouldNotImplDomObject that is implemented for all T: DomObject. We then try to implement it for each field type except the first one. If compilation succeed, this means that field type doesn't implement DomObject itself otherwise it would break coherence rules. error[E0119]: conflicting implementations of trait `dom::xmlhttprequest::_IMPL_DOMOBJECT_FOR_XMLHttpRequest::ShouldNotImplDomObject` for type `((), SomeFieldTypeThatShouldNotImplementDomObject)`: --> /Users/nox/src/servo/components/script/dom/xmlhttprequest.rs:120:1 | 120 | #[dom_struct] | ^^^^^^^^^^^^^ | | | first implementation here | conflicting implementation for `((), SomeFieldTypeThatShouldNotImplementDomObject)`
* Derive DomObject with a proc macroAnthony Ramine2017-02-141-0/+12
|
* Use Heap in DOM object reflector implementation to ensure GC barriers are used.Josh Matthews2017-01-201-15/+11
|
* Rename `Reflectable` to `DomObject`.Corey Farwell2016-12-081-4/+4
| | | | Fixes https://github.com/servo/servo/issues/8473.
* script creates methods taking '*mut JSContext' unsafeAbelardo E. Mendoza2016-11-141-2/+4
| | | | rebase + marked the necessary new code as unsafe
* Rename Reflectable::global_scope to globalAnthony Ramine2016-10-061-1/+1
|
* Remove GlobalRoot and GlobalRefAnthony Ramine2016-10-061-2/+1
|
* Remove Reflectable::globalAnthony Ramine2016-10-061-6/+1
|
* Remove global_root_from_reflectorAnthony Ramine2016-10-061-2/+2
|
* Introduce Reflectable::global_scopeAnthony Ramine2016-10-061-1/+6
|
* Make reflect_dom_object take a &GlobalScopeAnthony Ramine2016-10-061-6/+12
|
* Extract mutability out of Reflectable trait.Josh Matthews2016-09-071-2/+6
|
* Add global default method for Reflectable traitChad Kimes2016-01-111-1/+6
|