Commit graph

167 commits

Author SHA1 Message Date
Josh Matthews
b4079b3ff3
Move generated bindings to script_bindings (#36323)
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>
2025-04-04 06:45:08 +00:00
Josh Matthews
c30ad5a30e
Miscellaneous script splitting preparation changes (#36216)
* script: Move num module to script_bindings.

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

* script: Make JS reflector creation generic over DOM trait.

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

* script: Move bindings-specific lock to script_bindings.

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

* script: Move DOM proto array code to script_bindings.

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

* script: Move finalizer implementations to script_bindings.

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

* script: Move some error routines to script_bindings.

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

* script: Move some DOM interface conversion routines to script_bindings.

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

* script: Make is_array_like generic over DOM trait.

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

* script: Use generic interfaces for conditional exposure functions.

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

* script: Move a bunch of routines used by codegen to script_bindings.

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>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-03-29 08:11:27 +00:00
Josh Matthews
c8d8787959
Move CustomTraceable to script_bindings. (#35988)
* script: Move CustomTraceable to script_bindings.

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

* script: Move record binding support to script_bindings.

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

* Address clippy warnings.

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

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-03-16 14:08:22 +00:00
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* 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>
2025-03-03 11:26:53 +00:00
Josh Matthews
35f21e426b
Move more bindings code to script_bindings (#35578)
* 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>
2025-02-22 04:46:56 +00:00
Josh Matthews
1192ae32b0
script: Refer to DOM interfaces with generic types in generated bindings. (#35457)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-02-21 11:10:00 +00:00
Josh Matthews
c0cef69108
Move more foundational types to script_bindings (#35280)
* script: Move DOMClass to script_bindings.

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

* script: Move DOMJSClass and get_dom_class to script_bindings.

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

* script: Move Castable/DerivedFrom/IDLInterface to script_bindings.

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

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-02-04 10:36:30 +00:00
Josh Matthews
c94ac5bccb
Move various reflector types and traits to script_bindings (#35279)
* 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>
2025-02-04 06:58:08 +00:00
Josh Matthews
a6218b42ea
bindings: Move string-related bindings code to script_bindings. (#35172)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-01-29 07:40:25 +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
Andriy Sultanov
aadc212b95
jsstring_to_str should accept a NonNull argument for the JS string (#33306)
Instead of asserting the raw pointer is not null, force callers to
produce a NonNull pointer.

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
2024-09-05 03:25:49 +00:00
Josh Matthews
3829e91662
Handle failed string conversions in console.log. (#33085)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-08-16 16:49:56 +00:00
Rosemary Ajayi
bb7778774d
clippy:Fix clippy problems in components/scripts/binding (#31893)
* constants have by default a static lifetime

* constants have by default a static lifetime

* unneeded unit expression

* unneeded unit expression

* Box of default value

* casting raw pointers

* casting raw pointers
2024-03-27 12:32:04 +00:00
Oluwatobi Sofela
bae77671f8
clippy: Fix unnecessary_cast warnings in components/script (#31823)
* clippy: Fix unnecessary cast warnings

* clippy: Replace redundant field names with their shorthand alternatives

* clippy: Delete struct pattern dereferencings
2024-03-22 13:48:03 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
59d134133f
Use MozTools 4 and update mozjs (#30326)
* Update mozjs

* moztools4 in bootstrap

* no autoconf

* tidy

* switch to servo-build-deps

* update mozjs for real

* glue mozjs

* fmt

* move to servo/mozjs
2023-09-11 08:23:05 +00:00
Martin Robinson
dc192172ad Clean up debug options 2023-05-01 14:09:28 +02:00
Josh Matthews
bd77a4043c Changes for spidermomkey upgrade. 2022-11-23 10:04:50 -05:00
Josh Matthews
5c4939599e Update mozjs. 2021-02-18 09:35:45 -05:00
Josh Matthews
6dc4488bc7 Remove unnecessary generic from private_from_proto_check. 2020-06-04 20:54:36 -04:00
Josh Matthews
96698779cc dom: Remove unnecessary generic from private_from_proto_check_static. 2020-06-02 15:36:54 -04:00
bors-servo
e5689df6b4
Auto merge of #24694 - servo:rustup, r=jdm
Remove use of on_unimplemented

It errors in today’s Nightly:

```rust
error[E0557]: feature has been removed
 --> components/script/lib.rs:9:12
  |
9 | #![feature(on_unimplemented)]
  |            ^^^^^^^^^^^^^^^^ feature has been removed

error[E0658]: this is an internal attribute that will never be stable
  --> components/script/dom/bindings/conversions.rs:77:1
   |
77 | #[rustc_on_unimplemented(message = "The IDL interface `{Self}` is not derived from `{T}`.")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/29642
   = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error: aborting due to 2 previous errors
```
2019-11-09 10:15:30 -05:00
Simon Sapin
f2e7b4ec8c Remove use of on_unimplemented
It errors in today’s Nightly:

```rust
error[E0557]: feature has been removed
 --> components/script/lib.rs:9:12
  |
9 | #![feature(on_unimplemented)]
  |            ^^^^^^^^^^^^^^^^ feature has been removed

error[E0658]: this is an internal attribute that will never be stable
  --> components/script/dom/bindings/conversions.rs:77:1
   |
77 | #[rustc_on_unimplemented(message = "The IDL interface `{Self}` is not derived from `{T}`.")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/29642
   = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error: aborting due to 2 previous errors
```
2019-11-08 11:38:24 +01:00
Kagami Sascha Rosylight
f8b61c0315 Use MessageEventSource on MessageEvent IDL 2019-11-04 23:12:52 +09:00
George Roman
ef7b58f0cd Check existence of property in get_property_jsval 2019-07-23 10:00:19 +03:00
bors-servo
29097d15d0
Auto merge of #23669 - georgeroman:more_array_like_types, r=ferjm
Add support for more array-like types in is_array_like

<!-- 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

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23669)
<!-- Reviewable:end -->
2019-07-04 08:18:52 -04:00
George Roman
b26aa3ec19 Add support for more array-like types in is_array_like 2019-07-02 00:47:41 +03:00
Simon Sapin
bddfe9a468 Remove default-except-unstable
… and use remaining unstable features unconditionally.
This doesn’t actually change the set of crates that can build on the Stable channel.
2019-07-01 15:43:24 +02:00
Josh Matthews
63714c90fb Upgrade to Spidermonkey 67. 2019-06-26 18:10:46 -04:00
Simon Sapin
99b898753f Upgrade to rustc 1.34.0-nightly (0ea22717a 2019-03-02) 2019-03-03 19:32:42 +01:00
Jan Andre Ikenmeyer
a1a14459c1
Update MPL license to https (part 3) 2018-11-19 14:47:12 +01:00
Simon Sapin
9f977c5287 Remove useless use crate_name; imports.
A `crate_name::foo` path always works in 2018
2018-11-08 09:29:52 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Simon Sapin
45f7199eee cargo fix --edition 2018-11-06 15:26:02 +01:00
chansuke
c37a345dc9 Format script component 2018-09-19 17:40:47 -04:00
Alan Jeffrey
74c1e00d81 Upgraded to SM 60 2018-08-20 18:22:29 -04:00
Marcin Mielniczuk
356c57e628 Adapt Servo for mozjs 0.6 and the changes introduced in servo/rust-mozjs#393 2018-03-28 21:28:30 +02:00
Igor Matuszewski
64dc0c4b9e Root any members in dictionaries 2018-03-16 16:53:38 +01:00
Simon Sapin
52eda6082f Replace NonNullJSObjectPtr with std::ptr::NonNull<JSObject> 2018-01-22 17:41:25 +01:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Simon Sapin
bffec1c1a1 Make usage of unstable feature on_unimplemented optional. 2017-10-16 20:20:18 +02:00
Simon Sapin
e2fafd2dfc Replace NonZero<*mut JSObject> with a wrapper to enable local trait impls. 2017-10-16 20:19:56 +02:00
Anthony Ramine
f87c2a8d76 Rename Root<T> to DomRoot<T>
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.
2017-09-26 09:49:10 +02:00
Anthony Ramine
0e3c54c191 Rename dom::bindings::js to dom::bindings::root 2017-09-26 02:19:05 +02:00
Josh Matthews
b169689f32 Store rootable dictionary members of dictionaries in RootedTraceableBox. 2017-09-25 16:10:58 -04:00
Emilio Cobos Álvarez
6edefb829c
script: remove unused function. 2017-09-18 09:15:13 +02:00
Emilio Cobos Álvarez
5281fc1a44
script: Add a comment about some conversion that looks fishy. 2017-09-17 18:42:24 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Alan Jeffrey
3db4761767 Implemented paint worklets invoking worklet scripts. 2017-06-29 17:32:21 -05:00
Simon Sapin
7af5a7fd54 Untry script 2017-06-18 13:21:49 +02:00