Commit graph

45 commits

Author SHA1 Message Date
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
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
Domenico Rizzo
0e9746fbbe
Add CanGc argument to reflect_dom_object (#34606)
* 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>
2024-12-13 15:51:59 +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
RustAndMetal
f6a975fc58
clippy: Fix several warnings (#31710)
Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
2024-03-18 08:33:43 +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
Josh Matthews
0e8ac3fdac Formatting. 2023-05-28 23:54:02 -04:00
Josh Matthews
d9600ff50f Support arbitrary protos when wrapping EventTarget objects. 2023-05-28 23:23:12 -04:00
YUAN LYU
3ea6d87bcc
Add trait DomObjectWrap to provide WRAP function 2020-03-20 22:16:56 -04:00
marmeladema
ce3778afcc Remove some usage of unsafe code in iterator.rs 2019-08-09 00:02:09 +01:00
marmeladema
2c5d0a6ebc Convert CGTraitInterface to use safe JSContext instead of raw JSContext 2019-07-24 08:24:50 +01:00
marmeladema
35dc5320ab Wrap(Global)Method now takes a SafeJSContext instead of a JSContext
as first argument.
2019-07-24 08:18:21 +01:00
Jan Andre Ikenmeyer
a1a14459c1
Update MPL license to https (part 3) 2018-11-19 14:47:12 +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
Manish Goregaokar
cceaede96a Make (dictionary)::empty() safe
It currently works by constructing from null (which will throw a runtime
error if there are non-defaultable members).

This changes it so that we no longer need a JSContext to construct this,
so it can be safely constructed. In the case of non-defaultable members,
this method simply does not exist.
2018-07-06 13:10:56 -07: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
b78ac6ba6a Use safe NonZero constructor instead of an explicit null check 2018-01-22 17:41:26 +01:00
Simon Sapin
52eda6082f Replace NonNullJSObjectPtr with std::ptr::NonNull<JSObject> 2018-01-22 17:41:25 +01:00
Simon Sapin
4d459bce32 Fix tyvar_behind_raw_pointer warnings
https://github.com/rust-lang/rust/issues/46906
2018-01-10 20:54:35 +01:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
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`.
2017-10-18 22:20:37 +11:00
Simon Sapin
e2fafd2dfc Replace NonZero<*mut JSObject> with a wrapper to enable local trait impls. 2017-10-16 20:19:56 +02:00
Simon Sapin
aa15dc269f Remove use of unstable box syntax.
http://www.robohornet.org gives a score of 101.36 on master,
and 102.68 with this PR. The latter is slightly better,
but probably within noise level.
So it looks like this PR does not affect DOM performance.

This is expected since `Box::new` is defined as:

```rust
impl<T> Box<T> {
    #[inline(always)]
    pub fn new(x: T) -> Box<T> {
        box x
    }
}
```

With inlining, it should compile to the same as box syntax.
2017-10-16 17:16:20 +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
7be32fb237 Rename JS<T> to Dom<T> 2017-09-26 09:48:55 +02:00
Anthony Ramine
0e3c54c191 Rename dom::bindings::js to dom::bindings::root 2017-09-26 02:19:05 +02:00
Josh Matthews
77b3e911c1 Remove almost all uses of Heap::new. 2017-09-25 16:11:49 -04:00
Josh Matthews
b169689f32 Store rootable dictionary members of dictionaries in RootedTraceableBox. 2017-09-25 16:10:58 -04:00
Josh Matthews
da65698c5c Be more conservative about safety of dictionary and union values.
Mark dictionaries containing GC values as must_root, and wrap them in
RootedTraceableBox in automatically-generated APIs. To accommodate
union variants that are now flagged as unsafe, add RootedTraceableBox
to union variants that need to be rooted, rather than wrapping the
entire union value.
2017-09-25 16:10:58 -04: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
Simon Sapin
a205c82264 Upgrade to rustc 1.21.0-nightly (599be0d18 2017-07-26) 2017-07-27 02:21:01 +02:00
Anthony Ramine
31e9d81c0f Make #[dom_struct] a proc_macro attribute 2017-02-24 01:50:51 +01:00
Ms2ger
8ce9ca6243 Use Heap for dictionary and union members. 2017-02-16 11:03:21 +01:00
Anthony Ramine
be000d3833 Use #[dom_struct] on IterableIterator<T> (fixes #12811) 2017-02-15 10:24:02 +01:00
Anthony Ramine
8bcf36b9a5 Change #[privatize] into #[derive(DenyPublicFields)] 2017-02-15 10:24:01 +01:00
Corey Farwell
449f6337d4 Rename Reflectable to DomObject.
Fixes https://github.com/servo/servo/issues/8473.
2016-12-08 08:50:35 -10:00
Abelardo E. Mendoza
b372e7c98f script creates methods taking '*mut JSContext' unsafe
rebase + marked the necessary new code as unsafe
2016-11-14 11:06:17 +01:00
Anthony Ramine
d8e92bb271 Rename Reflectable::global_scope to global 2016-10-06 21:36:41 +02:00
Anthony Ramine
ae6af5172b Introduce Reflectable::global_scope 2016-10-06 21:35:38 +02:00
Anthony Ramine
fcb59d3057 Make reflect_dom_object take a &GlobalScope 2016-10-06 20:59:09 +02:00
Josh Matthews
8653450b6e Extract mutability out of Reflectable trait. 2016-09-07 10:40:13 +02:00
Anthony Ramine
6e1523f4ae Compile WebIDL return type "object" to NonZero<*mut JSObject> 2016-08-30 19:07:13 +02:00
Josh Matthews
812a761abf Implement pair iterators in WebIDL interfaces. 2016-08-24 11:26:01 -04:00