Commit graph

96 commits

Author SHA1 Message Date
marmeladema
88cacfb009 Modify *::get_cx methods to return a safe JSContext instead of a raw one 2019-07-24 09:53:10 +01:00
Peter Hall
8bfd4dc1e2 #8539 Config preferences backend restructure 2019-03-20 15:01:26 +00: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
Alan Jeffrey
d0cc9d2cd5 Updated to mozjs v0.7.1. 2018-05-30 14:44:47 -05:00
Gregory Terzian
427eaed535 beforeunload and unload infrastructure 2018-05-05 19:14:36 +08: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
f7c039516c Use unsafe Heap::handle wherever needed 2018-03-23 17:31:34 +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
Anthony Ramine
577370746e Rename DOMRefCell<T> to DomRefCell<T>
I don't want to do such a gratuitous rename, but with all the other types
now having "Dom" as part of their name, and especially with "DomOnceCell",
I feel like the other cell type that we already have should also follow
the convention. That argument loses weight though when we realise there
is still DOMString and other things.
2017-09-26 09:49:08 +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
Sadman Kazi
fa678992ff Use boxed slice instead of vec for FuntionTimerCallback 2017-07-11 14:07:40 -07:00
Nicolas Silva
8617320500 Bump euclid to 0.14. 2017-06-14 16:00:59 +02:00
Fernando Jiménez Moreno
fb878f33d1 Terminate timer scheduler thread during shutdown 2017-03-30 14:27:40 +02:00
Patrick Walton
4e7ac19380 script: Use a timer when rAF is used for non-animation purposes
After this patch, when the page calls `requestAnimationFrame()` too many
times in the row without actually mutating the DOM, further calls to
`rAF` will actually perform the moral equivalent of `setTimeout(16)`.
This saves a lot of CPU time compared to actually waiting for the
vertical blanking interval, because waiting for that requires us to draw
the page.

Reduces CPU usage drastically on nytimes.com, which has a perpetual
`requestAnimationFrame()` loop that checks whether ads are in view.
2017-03-03 23:25:29 +01:00
Anthony Ramine
8bcf36b9a5 Change #[privatize] into #[derive(DenyPublicFields)] 2017-02-15 10:24:01 +01:00
Alan Jeffrey
a43c842099 The constellation notifies the script thread about documents becoming inactive, active and fully active. 2017-01-27 12:39:43 -06:00
Ms2ger
e2c141179b Remove some unsound JSVal handling in JsTimerTask::invoke.
We were using Handles to *copies* of the traced values, rather than the
originals.
2017-01-05 17:49:01 +01:00
Alan Jeffrey
67bf23016e Added warnings for idempotent freeze/thaw. 2017-01-04 13:56:14 +00:00
Alan Jeffrey
78c87ea8d7 Implement discarding Document objects to reclaim space. 2017-01-04 11:29:31 +00:00
Alan Jeffrey
9be4fd56ce Removed util. 2016-12-14 18:04:37 -06:00
Corey Farwell
449f6337d4 Rename Reflectable to DomObject.
Fixes https://github.com/servo/servo/issues/8473.
2016-12-08 08:50:35 -10:00
Keith Yeung
a5c2c0ba4b Use a timer callback when re-establishing a connection 2016-11-11 14:52:20 -08:00
Anthony Ramine
d8e92bb271 Rename Reflectable::global_scope to global 2016-10-06 21:36:41 +02:00
Anthony Ramine
991801488c Move timers to GlobalScope 2016-10-06 21:35:51 +02:00
Anthony Ramine
9c04eb60bd Move JS evaluation functions to GlobalScope 2016-10-06 21:35:50 +02:00
Anthony Ramine
dd5c527689 Replace ScriptHelpers by GlobalRef methods 2016-10-03 11:42:21 +02:00
Josh Matthews
498ccd41e8 Support an equivalent of Trusted<T> for Rc<Promise> objects named TrustedPromise. 2016-09-22 16:16:59 -04:00
bors-servo
80cb0cf821 Auto merge of #11872 - eddyb:back-to-roots, r=Ms2ger
Replace return_address usage for rooting with stack guards and convenience macros.

The existing `Rooted` and `RootedVec` users were migrated the the following two macros:
```rust
let x = Rooted::new(cx, value);
// Was changed to:
rooted!(in(cx) let x = value);
// Which expands to:
let mut __root = Rooted::new_unrooted(value);
let x = RootedGuard::new(cx, &mut __root);
```
```rust
let mut v = RootedVec::new();
v.extend(iterator);
// Was changed to:
rooted_vec!(let v <- iterator);
// Which expands to:
let mut __root = RootableVec::new();
let v = RootedVec::new(&mut __root, iterator);
```

The `rooted!` macro depends on servo/rust-mozjs#272.
These APIs based on two types, a container to be rooted and a rooting guard, allow implementing both `Rooted`-style rooting and `Traceable`-based rooting in stable Rust, without abusing `return_address`.

Such macros may have been tried before, but in 1.9 their hygiene is broken, they work only since 1.10.

Sadly, `Rooted` is a FFI type and completely exposed, so I cannot prevent anyone from creating their own, although all fields but the value get overwritten by `RootedGuard::new` anyway.
`RootableVec` OTOH is *guaranteed* to be empty when not rooted, which makes it harmless AFAICT.

By fixing rust-lang/rust#34227, this PR enables Servo to build with `-Zorbit`.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix rust-lang/rust#34227
- [x] These changes do not require tests because they are not functional changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11872)
<!-- Reviewable:end -->
2016-07-04 11:03:35 -07:00
Eduard Burtescu
0db1faf876 Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
Corey Farwell
22928f50ac Refactor util::prefs operations to be methods on static struct. 2016-07-02 16:43:39 -04:00
bors-servo
d620ab71c4 Auto merge of #10225 - jmr0:visibility_api, r=jdm
Implement non-visible pipeline and iframe visibility methods

This addresses #9566 and a good part of #9751, specifically:

* Pipeline has a notion of visibility
* IFrame setVisible/getVisible interface with IFrame's pipeline visibility
* IFrame mozbrowservisibilitychange responds to changes in visibility
* Pipeline visibility is used to limit animations (requestAnimationFrame does not tick animations when hidden) and to increase timer intervals (currently set to a minimum of 1 second while hidden)

Absent for now are any changes to the Document API and general implementation of the Page Visibility API, since the more interesting parts require knowledge of whether the user agent is minimized, OS screen locked, etc.

cc @paulrouget @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10225)
<!-- Reviewable:end -->
2016-06-16 08:53:56 -05:00
jmr0
2bff131535 Implement non-visible pipeline and iframe visibility methods 2016-06-15 23:28:07 -04:00
Ms2ger
f695842df7 Remove an invalid assertion in fire_timer.
It's not clear to me if this is something we should expect to happen, but it
does indeed happen, so we should disable the assertion while we investigate.

Fixes #9984.
2016-06-10 09:49:58 +02:00
Josh Matthews
3cb8af20c2 Remove empty lines following braces. 2016-05-27 13:32:05 -04:00
Anthony Ramine
cdc7bca944 Move DOMString back to script
This entirely removes the 'non-geckolib' feature of the util crate.
2016-05-24 10:54:57 +02:00
Per Lundberg
2f7ed1d73e Removed unused imports
This fixes #11185.
2016-05-15 22:24:26 +03:00
Ms2ger
03d4bacc05 Use num-traits in script. 2016-04-20 15:23:43 +02:00
benshu
f2d4a7bbca Clean up of script timer code.
The code was split into the following two abstractions.
 - OneshotTimers can be used to schedule arbitrary oneshot timers, such
   as XHR-Timeouts.
 - JsTimers (`setTimeout` and `setInterval`) which use OneshotTimers to
   schedule individual callbacks.

With this change the implementation (of JsTimers in particular) is in
much closer alignment with the specification.
2016-02-20 22:43:16 +01:00
bors-servo
5505bf1de5 Auto merge of #9471 - peterkort:patch-1, r=jdm
fix #8461

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9471)
<!-- Reviewable:end -->
2016-02-06 02:51:21 +05:30
Anthony Ramine
cb5cd8d881 Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
peterkort
9181a52099 resume fn should set suspended_since back to None 2016-01-31 07:43:00 -08:00
Chad Kimes
ce6075825d Add global default method for Reflectable trait 2016-01-11 20:23:47 -05:00
rohan.prinja
1f02c4ebbb task -> thread 2016-01-10 17:58:13 +09:00
Aleksandr Likhanov
d891e75d9d fix intermittent Option::unwrap in timers
not allow to fire timers installed during another timer call
2015-12-04 20:16:43 +05:00
benshu
54e41fb22d Correct undisciplined rebase. (Closes #8583.) 2015-11-18 21:10:20 +01:00
Patrick Walton
1dc0d61c3c script: Make timer events e10s-safe.
Closes #8235.
2015-11-12 14:30:25 -05:00
Anthony Ramine
b290a3161d Clean up the conversion routines
Functions returning `Root<T>` are prefixed by "root_" and the ones returning
`*const T` by "native_".

Functions taking `*mut JSObject` are now suffixed by "_from_object" and the ones
taking `&T` by "_from_reflector".
2015-11-11 14:19:30 +01:00