mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #14473 - nox:raf-safety, r=Ms2ger
Clean up JSTraceable and how we use it <!-- 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/14473) <!-- Reviewable:end -->
This commit is contained in:
commit
32c121b6ff
22 changed files with 389 additions and 234 deletions
|
@ -41,10 +41,11 @@ fn expand_string(input: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
let tokens = quote! {
|
let tokens = quote! {
|
||||||
impl #impl_generics ::dom::bindings::trace::JSTraceable for #name #ty_generics #where_clause {
|
#[allow(unsafe_code)]
|
||||||
|
unsafe impl #impl_generics ::dom::bindings::trace::JSTraceable for #name #ty_generics #where_clause {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unused_variables, unused_imports)]
|
#[allow(unused_variables, unused_imports)]
|
||||||
fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
|
unsafe fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
|
||||||
use ::dom::bindings::trace::JSTraceable;
|
use ::dom::bindings::trace::JSTraceable;
|
||||||
match *self {
|
match *self {
|
||||||
#match_body
|
#match_body
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use devtools_traits::{AutoMargins, CONSOLE_API, CachedConsoleMessage, CachedConsoleMessageTypes};
|
use devtools_traits::{AutoMargins, CONSOLE_API, CachedConsoleMessage, CachedConsoleMessageTypes};
|
||||||
use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError};
|
||||||
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, PAGE_ERROR, TimelineMarker};
|
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, PAGE_ERROR, TimelineMarker};
|
||||||
use devtools_traits::TimelineMarkerType;
|
use devtools_traits::TimelineMarkerType;
|
||||||
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||||
|
@ -17,6 +17,7 @@ use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
|
use dom::document::AnimationFrameCallback;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::node::{Node, window_from_node};
|
use dom::node::{Node, window_from_node};
|
||||||
|
@ -253,11 +254,7 @@ pub fn handle_request_animation_frame(documents: &Documents,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
actor_name: String) {
|
actor_name: String) {
|
||||||
if let Some(doc) = documents.find_document(id) {
|
if let Some(doc) = documents.find_document(id) {
|
||||||
let devtools_sender = doc.window().upcast::<GlobalScope>().devtools_chan().unwrap().clone();
|
doc.request_animation_frame(AnimationFrameCallback::DevtoolsFramerateTick { actor_name });
|
||||||
doc.request_animation_frame(box move |time| {
|
|
||||||
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
|
||||||
devtools_sender.send(msg).unwrap();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ which has an area, and the trait provides a way to get that object's area.
|
||||||
Now let's look at the `JSTraceable` trait, which we use for tracing:
|
Now let's look at the `JSTraceable` trait, which we use for tracing:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
pub trait JSTraceable {
|
pub unsafe trait JSTraceable {
|
||||||
fn trace(&self, trc: *mut JSTracer);
|
unsafe fn trace(&self, trc: *mut JSTracer);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> JSTraceable for JS<T> {
|
impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
trace_reflector(trc, "", unsafe { (**self.ptr).reflector() });
|
trace_reflector(trc, "", unsafe { (**self.ptr).reflector() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
use dom::abstractworker::WorkerScriptMsg;
|
use dom::abstractworker::WorkerScriptMsg;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
use dom::bindings::trace::JSTraceable;
|
||||||
use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort};
|
use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort};
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ pub struct SendableWorkerScriptChan<T: Reflectable> {
|
||||||
pub worker: Trusted<T>,
|
pub worker: Trusted<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable + 'static> ScriptChan for SendableWorkerScriptChan<T> {
|
impl<T: JSTraceable + Reflectable + 'static> ScriptChan for SendableWorkerScriptChan<T> {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
self.sender.send((self.worker.clone(), msg)).map_err(|_| ())
|
self.sender.send((self.worker.clone(), msg)).map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
@ -39,7 +40,7 @@ pub struct WorkerThreadWorkerChan<T: Reflectable> {
|
||||||
pub worker: Trusted<T>,
|
pub worker: Trusted<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable + 'static> ScriptChan for WorkerThreadWorkerChan<T> {
|
impl<T: JSTraceable + Reflectable + 'static> ScriptChan for WorkerThreadWorkerChan<T> {
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
|
||||||
self.sender
|
self.sender
|
||||||
.send((self.worker.clone(), WorkerScriptMsg::Common(msg)))
|
.send((self.worker.clone(), WorkerScriptMsg::Common(msg)))
|
||||||
|
|
|
@ -105,10 +105,10 @@ impl<T: Reflectable> Deref for JS<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> JSTraceable for JS<T> {
|
unsafe impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let trace_str = format!("for {} on heap", unsafe { type_name::<T>() });
|
let trace_str = format!("for {} on heap", type_name::<T>());
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let trace_info = &trace_str[..];
|
let trace_info = &trace_str[..];
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
|
@ -116,7 +116,7 @@ impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
|
|
||||||
trace_reflector(trc,
|
trace_reflector(trc,
|
||||||
trace_info,
|
trace_info,
|
||||||
unsafe { (**self.ptr).reflector() });
|
(**self.ptr).reflector());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
//! This is typically derived via a `#[dom_struct]`
|
//! This is typically derived via a `#[dom_struct]`
|
||||||
//! (implies `#[derive(JSTraceable)]`) annotation.
|
//! (implies `#[derive(JSTraceable)]`) annotation.
|
||||||
//! Non-JS-managed types have an empty inline `trace()` method,
|
//! Non-JS-managed types have an empty inline `trace()` method,
|
||||||
//! achieved via `no_jsmanaged_fields!` or similar.
|
//! achieved via `unsafe_no_jsmanaged_fields!` or similar.
|
||||||
//! 3. For all fields, `Foo::trace()`
|
//! 3. For all fields, `Foo::trace()`
|
||||||
//! calls `trace()` on the field.
|
//! calls `trace()` on the field.
|
||||||
//! For example, for fields of type `JS<T>`, `JS<T>::trace()` calls
|
//! For example, for fields of type `JS<T>`, `JS<T>::trace()` calls
|
||||||
|
@ -26,14 +26,14 @@
|
||||||
//! 5. When the GC finishes tracing, it [`finalizes`](../index.html#destruction)
|
//! 5. When the GC finishes tracing, it [`finalizes`](../index.html#destruction)
|
||||||
//! any reflectors that were not reachable.
|
//! any reflectors that were not reachable.
|
||||||
//!
|
//!
|
||||||
//! The `no_jsmanaged_fields!()` macro adds an empty implementation of `JSTraceable` to
|
//! The `unsafe_no_jsmanaged_fields!()` macro adds an empty implementation of
|
||||||
//! a datatype.
|
//! `JSTraceable` to a datatype.
|
||||||
|
|
||||||
|
use app_units::Au;
|
||||||
use canvas_traits::{CanvasGradientStop, LinearGradientStyle, RadialGradientStyle};
|
use canvas_traits::{CanvasGradientStop, LinearGradientStyle, RadialGradientStyle};
|
||||||
use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle};
|
use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle};
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use devtools_traits::CSSError;
|
use devtools_traits::{CSSError, TimelineMarkerType, WorkerId};
|
||||||
use devtools_traits::WorkerId;
|
|
||||||
use dom::abstractworker::SharedRt;
|
use dom::abstractworker::SharedRt;
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
|
@ -70,35 +70,38 @@ use net_traits::response::{Response, ResponseBody};
|
||||||
use net_traits::response::HttpsState;
|
use net_traits::response::HttpsState;
|
||||||
use net_traits::storage_thread::StorageType;
|
use net_traits::storage_thread::StorageType;
|
||||||
use offscreen_gl_context::GLLimits;
|
use offscreen_gl_context::GLLimits;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||||
use script_layout_interface::OpaqueStyleAndLayoutData;
|
use script_layout_interface::OpaqueStyleAndLayoutData;
|
||||||
use script_layout_interface::reporter::CSSErrorReporter;
|
use script_layout_interface::reporter::CSSErrorReporter;
|
||||||
use script_layout_interface::rpc::LayoutRPC;
|
use script_layout_interface::rpc::LayoutRPC;
|
||||||
use script_runtime::ScriptChan;
|
|
||||||
use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase};
|
use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase};
|
||||||
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::boxed::FnBox;
|
|
||||||
use std::cell::{Cell, UnsafeCell};
|
use std::cell::{Cell, UnsafeCell};
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||||
use std::hash::{BuildHasher, Hash};
|
use std::hash::{BuildHasher, Hash};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, Mutex};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use std::time::{SystemTime, Instant};
|
use std::time::{SystemTime, Instant};
|
||||||
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
|
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
|
||||||
use style::element_state::*;
|
use style::element_state::*;
|
||||||
|
use style::font_face::FontFaceRule;
|
||||||
|
use style::keyframes::Keyframe;
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::properties::PropertyDeclarationBlock;
|
use style::properties::PropertyDeclarationBlock;
|
||||||
use style::selector_parser::{PseudoElement, Snapshot};
|
use style::selector_parser::{PseudoElement, Snapshot};
|
||||||
|
use style::stylesheets::{CssRules, KeyframesRule, MediaRule, NamespaceRule, StyleRule};
|
||||||
use style::values::specified::Length;
|
use style::values::specified::Length;
|
||||||
|
use style::viewport::ViewportRule;
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
use url::Origin as UrlOrigin;
|
use url::Origin as UrlOrigin;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -106,18 +109,18 @@ use webrender_traits::{WebGLBufferId, WebGLError, WebGLFramebufferId, WebGLProgr
|
||||||
use webrender_traits::{WebGLRenderbufferId, WebGLShaderId, WebGLTextureId};
|
use webrender_traits::{WebGLRenderbufferId, WebGLShaderId, WebGLTextureId};
|
||||||
|
|
||||||
/// A trait to allow tracing (only) DOM objects.
|
/// A trait to allow tracing (only) DOM objects.
|
||||||
pub trait JSTraceable {
|
pub unsafe trait JSTraceable {
|
||||||
/// Trace `self`.
|
/// Trace `self`.
|
||||||
fn trace(&self, trc: *mut JSTracer);
|
unsafe fn trace(&self, trc: *mut JSTracer);
|
||||||
}
|
}
|
||||||
|
|
||||||
no_jsmanaged_fields!(CSSError);
|
unsafe_no_jsmanaged_fields!(CSSError);
|
||||||
|
|
||||||
no_jsmanaged_fields!(EncodingRef);
|
unsafe_no_jsmanaged_fields!(EncodingRef);
|
||||||
|
|
||||||
no_jsmanaged_fields!(Reflector);
|
unsafe_no_jsmanaged_fields!(Reflector);
|
||||||
|
|
||||||
no_jsmanaged_fields!(Duration);
|
unsafe_no_jsmanaged_fields!(Duration);
|
||||||
|
|
||||||
/// Trace a `JSVal`.
|
/// Trace a `JSVal`.
|
||||||
pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) {
|
pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) {
|
||||||
|
@ -154,40 +157,44 @@ pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for Rc<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for Rc<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
(**self).trace(trc)
|
(**self).trace(trc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable + ?Sized> JSTraceable for Box<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for Arc<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
(**self).trace(trc)
|
(**self).trace(trc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable + Copy> JSTraceable for Cell<T> {
|
unsafe impl<T: JSTraceable + ?Sized> JSTraceable for Box<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
|
(**self).trace(trc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<T: JSTraceable + Copy> JSTraceable for Cell<T> {
|
||||||
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
self.get().trace(trc)
|
self.get().trace(trc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for UnsafeCell<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for UnsafeCell<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
unsafe { (*self.get()).trace(trc) }
|
(*self.get()).trace(trc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for DOMRefCell<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for DOMRefCell<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
unsafe {
|
(*self).borrow_for_gc_trace().trace(trc)
|
||||||
(*self).borrow_for_gc_trace().trace(trc)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for Heap<*mut JSObject> {
|
unsafe impl JSTraceable for Heap<*mut JSObject> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
if self.get().is_null() {
|
if self.get().is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -195,34 +202,34 @@ impl JSTraceable for Heap<*mut JSObject> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for Heap<JSVal> {
|
unsafe impl JSTraceable for Heap<JSVal> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
trace_jsval(trc, "heap value", self);
|
trace_jsval(trc, "heap value", self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXXManishearth Check if the following three are optimized to no-ops
|
// XXXManishearth Check if the following three are optimized to no-ops
|
||||||
// if e.trace() is a no-op (e.g it is an no_jsmanaged_fields type)
|
// if e.trace() is a no-op (e.g it is an unsafe_no_jsmanaged_fields type)
|
||||||
impl<T: JSTraceable> JSTraceable for Vec<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for Vec<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
for e in &*self {
|
for e in &*self {
|
||||||
e.trace(trc);
|
e.trace(trc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for VecDeque<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for VecDeque<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
for e in &*self {
|
for e in &*self {
|
||||||
e.trace(trc);
|
e.trace(trc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for (T, T, T, T) {
|
unsafe impl<T: JSTraceable> JSTraceable for (T, T, T, T) {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
self.0.trace(trc);
|
self.0.trace(trc);
|
||||||
self.1.trace(trc);
|
self.1.trace(trc);
|
||||||
self.2.trace(trc);
|
self.2.trace(trc);
|
||||||
|
@ -231,26 +238,26 @@ impl<T: JSTraceable> JSTraceable for (T, T, T, T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXXManishearth Check if the following three are optimized to no-ops
|
// XXXManishearth Check if the following three are optimized to no-ops
|
||||||
// if e.trace() is a no-op (e.g it is an no_jsmanaged_fields type)
|
// if e.trace() is a no-op (e.g it is an unsafe_no_jsmanaged_fields type)
|
||||||
impl<T: JSTraceable + 'static> JSTraceable for SmallVec<[T; 1]> {
|
unsafe impl<T: JSTraceable + 'static> JSTraceable for SmallVec<[T; 1]> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
for e in self.iter() {
|
for e in self.iter() {
|
||||||
e.trace(trc);
|
e.trace(trc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for Option<T> {
|
unsafe impl<T: JSTraceable> JSTraceable for Option<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
self.as_ref().map(|e| e.trace(trc));
|
self.as_ref().map(|e| e.trace(trc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: JSTraceable, U: JSTraceable> JSTraceable for Result<T, U> {
|
unsafe impl<T: JSTraceable, U: JSTraceable> JSTraceable for Result<T, U> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
match *self {
|
match *self {
|
||||||
Ok(ref inner) => inner.trace(trc),
|
Ok(ref inner) => inner.trace(trc),
|
||||||
Err(ref inner) => inner.trace(trc),
|
Err(ref inner) => inner.trace(trc),
|
||||||
|
@ -258,13 +265,13 @@ impl<T: JSTraceable, U: JSTraceable> JSTraceable for Result<T, U> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K, V, S> JSTraceable for HashMap<K, V, S>
|
unsafe impl<K, V, S> JSTraceable for HashMap<K, V, S>
|
||||||
where K: Hash + Eq + JSTraceable,
|
where K: Hash + Eq + JSTraceable,
|
||||||
V: JSTraceable,
|
V: JSTraceable,
|
||||||
S: BuildHasher
|
S: BuildHasher
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
for (k, v) in &*self {
|
for (k, v) in &*self {
|
||||||
k.trace(trc);
|
k.trace(trc);
|
||||||
v.trace(trc);
|
v.trace(trc);
|
||||||
|
@ -272,9 +279,21 @@ impl<K, V, S> JSTraceable for HashMap<K, V, S>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Ord + JSTraceable, V: JSTraceable> JSTraceable for BTreeMap<K, V> {
|
unsafe impl<T, S> JSTraceable for HashSet<T, S>
|
||||||
|
where T: Hash + Eq + JSTraceable,
|
||||||
|
S: BuildHasher
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
|
for v in &*self {
|
||||||
|
v.trace(trc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<K: Ord + JSTraceable, V: JSTraceable> JSTraceable for BTreeMap<K, V> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
for (k, v) in self {
|
for (k, v) in self {
|
||||||
k.trace(trc);
|
k.trace(trc);
|
||||||
v.trace(trc);
|
v.trace(trc);
|
||||||
|
@ -282,18 +301,18 @@ impl<K: Ord + JSTraceable, V: JSTraceable> JSTraceable for BTreeMap<K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
|
unsafe impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
let (ref a, ref b) = *self;
|
let (ref a, ref b) = *self;
|
||||||
a.trace(trc);
|
a.trace(trc);
|
||||||
b.trace(trc);
|
b.trace(trc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: JSTraceable, B: JSTraceable, C: JSTraceable> JSTraceable for (A, B, C) {
|
unsafe impl<A: JSTraceable, B: JSTraceable, C: JSTraceable> JSTraceable for (A, B, C) {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
let (ref a, ref b, ref c) = *self;
|
let (ref a, ref b, ref c) = *self;
|
||||||
a.trace(trc);
|
a.trace(trc);
|
||||||
b.trace(trc);
|
b.trace(trc);
|
||||||
|
@ -301,139 +320,258 @@ impl<A: JSTraceable, B: JSTraceable, C: JSTraceable> JSTraceable for (A, B, C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
no_jsmanaged_fields!(bool, f32, f64, String, ServoUrl, AtomicBool, AtomicUsize, UrlOrigin, Uuid, char);
|
unsafe_no_jsmanaged_fields!(bool, f32, f64, String, ServoUrl, AtomicBool, AtomicUsize, UrlOrigin, Uuid, char);
|
||||||
no_jsmanaged_fields!(usize, u8, u16, u32, u64);
|
unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64);
|
||||||
no_jsmanaged_fields!(isize, i8, i16, i32, i64);
|
unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64);
|
||||||
no_jsmanaged_fields!(Sender<T>);
|
unsafe_no_jsmanaged_fields!(Image, ImageMetadata, ImageCacheChan, ImageCacheThread);
|
||||||
no_jsmanaged_fields!(Receiver<T>);
|
unsafe_no_jsmanaged_fields!(Metadata);
|
||||||
no_jsmanaged_fields!(Point2D<T>);
|
unsafe_no_jsmanaged_fields!(NetworkError);
|
||||||
no_jsmanaged_fields!(Rect<T>);
|
unsafe_no_jsmanaged_fields!(Atom, Prefix, LocalName, Namespace, QualName);
|
||||||
no_jsmanaged_fields!(Size2D<T>);
|
unsafe_no_jsmanaged_fields!(TrustedPromise);
|
||||||
no_jsmanaged_fields!(Arc<T>);
|
unsafe_no_jsmanaged_fields!(PropertyDeclarationBlock);
|
||||||
no_jsmanaged_fields!(Image, ImageMetadata, ImageCacheChan, ImageCacheThread);
|
|
||||||
no_jsmanaged_fields!(Metadata);
|
|
||||||
no_jsmanaged_fields!(NetworkError);
|
|
||||||
no_jsmanaged_fields!(Atom, Prefix, LocalName, Namespace, QualName);
|
|
||||||
no_jsmanaged_fields!(Trusted<T: Reflectable>);
|
|
||||||
no_jsmanaged_fields!(TrustedPromise);
|
|
||||||
no_jsmanaged_fields!(PropertyDeclarationBlock);
|
|
||||||
no_jsmanaged_fields!(HashSet<T>);
|
|
||||||
// These three are interdependent, if you plan to put jsmanaged data
|
// These three are interdependent, if you plan to put jsmanaged data
|
||||||
// in one of these make sure it is propagated properly to containing structs
|
// in one of these make sure it is propagated properly to containing structs
|
||||||
no_jsmanaged_fields!(FrameId, FrameType, WindowSizeData, WindowSizeType, PipelineId);
|
unsafe_no_jsmanaged_fields!(FrameId, FrameType, WindowSizeData, WindowSizeType, PipelineId);
|
||||||
no_jsmanaged_fields!(TimerEventId, TimerSource);
|
unsafe_no_jsmanaged_fields!(TimerEventId, TimerSource);
|
||||||
no_jsmanaged_fields!(WorkerId);
|
unsafe_no_jsmanaged_fields!(TimelineMarkerType);
|
||||||
no_jsmanaged_fields!(BufferQueue, QuirksMode);
|
unsafe_no_jsmanaged_fields!(WorkerId);
|
||||||
no_jsmanaged_fields!(Runtime);
|
unsafe_no_jsmanaged_fields!(BufferQueue, QuirksMode);
|
||||||
no_jsmanaged_fields!(Headers, Method);
|
unsafe_no_jsmanaged_fields!(Runtime);
|
||||||
no_jsmanaged_fields!(WindowProxyHandler);
|
unsafe_no_jsmanaged_fields!(Headers, Method);
|
||||||
no_jsmanaged_fields!(UntrustedNodeAddress);
|
unsafe_no_jsmanaged_fields!(WindowProxyHandler);
|
||||||
no_jsmanaged_fields!(LengthOrPercentageOrAuto);
|
unsafe_no_jsmanaged_fields!(UntrustedNodeAddress);
|
||||||
no_jsmanaged_fields!(RGBA);
|
unsafe_no_jsmanaged_fields!(LengthOrPercentageOrAuto);
|
||||||
no_jsmanaged_fields!(EuclidLength<Unit, T>);
|
unsafe_no_jsmanaged_fields!(RGBA);
|
||||||
no_jsmanaged_fields!(Matrix2D<T>);
|
unsafe_no_jsmanaged_fields!(StorageType);
|
||||||
no_jsmanaged_fields!(Matrix4D<T>);
|
unsafe_no_jsmanaged_fields!(CanvasGradientStop, LinearGradientStyle, RadialGradientStyle);
|
||||||
no_jsmanaged_fields!(StorageType);
|
unsafe_no_jsmanaged_fields!(LineCapStyle, LineJoinStyle, CompositionOrBlending);
|
||||||
no_jsmanaged_fields!(CanvasGradientStop, LinearGradientStyle, RadialGradientStyle);
|
unsafe_no_jsmanaged_fields!(RepetitionStyle);
|
||||||
no_jsmanaged_fields!(LineCapStyle, LineJoinStyle, CompositionOrBlending);
|
unsafe_no_jsmanaged_fields!(WebGLError, GLLimits);
|
||||||
no_jsmanaged_fields!(RepetitionStyle);
|
unsafe_no_jsmanaged_fields!(TimeProfilerChan);
|
||||||
no_jsmanaged_fields!(WebGLError, GLLimits);
|
unsafe_no_jsmanaged_fields!(MemProfilerChan);
|
||||||
no_jsmanaged_fields!(TimeProfilerChan);
|
unsafe_no_jsmanaged_fields!(PseudoElement);
|
||||||
no_jsmanaged_fields!(MemProfilerChan);
|
unsafe_no_jsmanaged_fields!(Length);
|
||||||
no_jsmanaged_fields!(PseudoElement);
|
unsafe_no_jsmanaged_fields!(ElementState);
|
||||||
no_jsmanaged_fields!(Length);
|
unsafe_no_jsmanaged_fields!(DOMString);
|
||||||
no_jsmanaged_fields!(ElementState);
|
unsafe_no_jsmanaged_fields!(Mime);
|
||||||
no_jsmanaged_fields!(DOMString);
|
unsafe_no_jsmanaged_fields!(AttrIdentifier);
|
||||||
no_jsmanaged_fields!(Mime);
|
unsafe_no_jsmanaged_fields!(AttrValue);
|
||||||
no_jsmanaged_fields!(AttrIdentifier);
|
unsafe_no_jsmanaged_fields!(Snapshot);
|
||||||
no_jsmanaged_fields!(AttrValue);
|
unsafe_no_jsmanaged_fields!(PendingRestyle);
|
||||||
no_jsmanaged_fields!(Snapshot);
|
unsafe_no_jsmanaged_fields!(HttpsState);
|
||||||
no_jsmanaged_fields!(PendingRestyle);
|
unsafe_no_jsmanaged_fields!(Request);
|
||||||
no_jsmanaged_fields!(HttpsState);
|
unsafe_no_jsmanaged_fields!(RequestInit);
|
||||||
no_jsmanaged_fields!(Request);
|
unsafe_no_jsmanaged_fields!(SharedRt);
|
||||||
no_jsmanaged_fields!(RequestInit);
|
unsafe_no_jsmanaged_fields!(TouchpadPressurePhase);
|
||||||
no_jsmanaged_fields!(SharedRt);
|
unsafe_no_jsmanaged_fields!(USVString);
|
||||||
no_jsmanaged_fields!(TouchpadPressurePhase);
|
unsafe_no_jsmanaged_fields!(ReferrerPolicy);
|
||||||
no_jsmanaged_fields!(USVString);
|
unsafe_no_jsmanaged_fields!(Response);
|
||||||
no_jsmanaged_fields!(ReferrerPolicy);
|
unsafe_no_jsmanaged_fields!(ResponseBody);
|
||||||
no_jsmanaged_fields!(Response);
|
unsafe_no_jsmanaged_fields!(ResourceThreads);
|
||||||
no_jsmanaged_fields!(ResponseBody);
|
unsafe_no_jsmanaged_fields!(StatusCode);
|
||||||
no_jsmanaged_fields!(ResourceThreads);
|
unsafe_no_jsmanaged_fields!(SystemTime);
|
||||||
no_jsmanaged_fields!(StatusCode);
|
unsafe_no_jsmanaged_fields!(Instant);
|
||||||
no_jsmanaged_fields!(SystemTime);
|
unsafe_no_jsmanaged_fields!(RelativePos);
|
||||||
no_jsmanaged_fields!(Instant);
|
unsafe_no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
||||||
no_jsmanaged_fields!(RelativePos);
|
unsafe_no_jsmanaged_fields!(PathBuf);
|
||||||
no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
unsafe_no_jsmanaged_fields!(CSSErrorReporter);
|
||||||
no_jsmanaged_fields!(PathBuf);
|
unsafe_no_jsmanaged_fields!(WebGLBufferId);
|
||||||
no_jsmanaged_fields!(CSSErrorReporter);
|
unsafe_no_jsmanaged_fields!(WebGLFramebufferId);
|
||||||
no_jsmanaged_fields!(WebGLBufferId);
|
unsafe_no_jsmanaged_fields!(WebGLProgramId);
|
||||||
no_jsmanaged_fields!(WebGLFramebufferId);
|
unsafe_no_jsmanaged_fields!(WebGLRenderbufferId);
|
||||||
no_jsmanaged_fields!(WebGLProgramId);
|
unsafe_no_jsmanaged_fields!(WebGLShaderId);
|
||||||
no_jsmanaged_fields!(WebGLRenderbufferId);
|
unsafe_no_jsmanaged_fields!(WebGLTextureId);
|
||||||
no_jsmanaged_fields!(WebGLShaderId);
|
unsafe_no_jsmanaged_fields!(MediaList);
|
||||||
no_jsmanaged_fields!(WebGLTextureId);
|
|
||||||
no_jsmanaged_fields!(MediaList);
|
|
||||||
|
|
||||||
impl JSTraceable for Box<ScriptChan + Send> {
|
unsafe impl<'a> JSTraceable for &'a str {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _trc: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for Box<FnBox(f64, )> {
|
unsafe impl<A, B> JSTraceable for fn(A) -> B {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _trc: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> JSTraceable for &'a str {
|
unsafe impl<T> JSTraceable for IpcSender<T> where T: Deserialize + Serialize {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B> JSTraceable for fn(A) -> B {
|
// Safe thanks to the Send bound.
|
||||||
|
unsafe impl JSTraceable for Box<LayoutRPC + Send + 'static> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> JSTraceable for IpcSender<T> where T: Deserialize + Serialize {
|
unsafe impl JSTraceable for () {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for Box<LayoutRPC + 'static> {
|
unsafe impl<T> JSTraceable for IpcReceiver<T> where T: Deserialize + Serialize {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for () {
|
unsafe impl<T: Reflectable> JSTraceable for Trusted<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> JSTraceable for IpcReceiver<T> where T: Deserialize + Serialize {
|
unsafe impl<T: Send> JSTraceable for Receiver<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl<T: Send> JSTraceable for Sender<T> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Matrix2D<f32> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Matrix4D<f64> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Point2D<f32> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<T> JSTraceable for EuclidLength<u64, T> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Rect<Au> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Rect<f32> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Size2D<i32> {
|
||||||
|
#[inline]
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for Mutex<Option<SharedRt>> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<FontFaceRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<CssRules> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<Keyframe> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<KeyframesRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<MediaRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<NamespaceRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<StyleRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<ViewportRule> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<PropertyDeclarationBlock> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<SharedRt> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl JSTraceable for RwLock<MediaList> {
|
||||||
|
unsafe fn trace(&self, _trc: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Homemade trait object for JSTraceable things
|
/// Homemade trait object for JSTraceable things
|
||||||
struct TraceableInfo {
|
struct TraceableInfo {
|
||||||
pub ptr: *const libc::c_void,
|
pub ptr: *const libc::c_void,
|
||||||
pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
|
pub trace: unsafe fn(obj: *const libc::c_void, tracer: *mut JSTracer),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds a set of JSTraceables that need to be rooted
|
/// Holds a set of JSTraceables that need to be rooted
|
||||||
|
@ -474,8 +612,8 @@ impl RootedTraceableSet {
|
||||||
|
|
||||||
unsafe fn add<T: JSTraceable>(traceable: &T) {
|
unsafe fn add<T: JSTraceable>(traceable: &T) {
|
||||||
ROOTED_TRACEABLES.with(|ref traceables| {
|
ROOTED_TRACEABLES.with(|ref traceables| {
|
||||||
fn trace<T: JSTraceable>(obj: *const libc::c_void, tracer: *mut JSTracer) {
|
unsafe fn trace<T: JSTraceable>(obj: *const libc::c_void, tracer: *mut JSTracer) {
|
||||||
let obj: &T = unsafe { &*(obj as *const T) };
|
let obj: &T = &*(obj as *const T);
|
||||||
obj.trace(tracer);
|
obj.trace(tracer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,11 @@ impl<T: WeakReferenceable> PartialEq<T> for WeakRef<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
no_jsmanaged_fields!(WeakRef<T: WeakReferenceable>);
|
unsafe impl<T: WeakReferenceable> JSTraceable for WeakRef<T> {
|
||||||
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: WeakReferenceable> Drop for WeakRef<T> {
|
impl<T: WeakReferenceable> Drop for WeakRef<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
@ -188,17 +192,15 @@ impl<T: WeakReferenceable> HeapSizeOf for MutableWeakRef<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> {
|
unsafe impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> {
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
let ptr = self.cell.get();
|
let ptr = self.cell.get();
|
||||||
unsafe {
|
let should_drop = match *ptr {
|
||||||
let should_drop = match *ptr {
|
Some(ref value) => !value.is_alive(),
|
||||||
Some(ref value) => !value.is_alive(),
|
None => false,
|
||||||
None => false,
|
};
|
||||||
};
|
if should_drop {
|
||||||
if should_drop {
|
mem::drop((*ptr).take().unwrap());
|
||||||
mem::drop((*ptr).take().unwrap());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use js::jsapi::{JSContext, JSObject};
|
||||||
use js::jsapi::{JS_GetArrayBufferViewType, Type};
|
use js::jsapi::{JS_GetArrayBufferViewType, Type};
|
||||||
use rand::{OsRng, Rng};
|
use rand::{OsRng, Rng};
|
||||||
|
|
||||||
no_jsmanaged_fields!(OsRng);
|
unsafe_no_jsmanaged_fields!(OsRng);
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto
|
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
|
|
@ -16,8 +16,10 @@ use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::stylesheets::{CssRules, KeyframesRule, RulesMutateError};
|
use style::stylesheets::{CssRules, KeyframesRule, RulesMutateError};
|
||||||
|
|
||||||
no_jsmanaged_fields!(RulesSource);
|
#[allow(unsafe_code)]
|
||||||
no_jsmanaged_fields!(CssRules);
|
unsafe_no_jsmanaged_fields!(RulesSource);
|
||||||
|
|
||||||
|
unsafe_no_jsmanaged_fields!(CssRules);
|
||||||
|
|
||||||
impl From<RulesMutateError> for Error {
|
impl From<RulesMutateError> for Error {
|
||||||
fn from(other: RulesMutateError) -> Self {
|
fn from(other: RulesMutateError) -> Self {
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use core::nonzero::NonZero;
|
use core::nonzero::NonZero;
|
||||||
|
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||||
use document_loader::{DocumentLoader, LoadType};
|
use document_loader::{DocumentLoader, LoadType};
|
||||||
use dom::activation::{ActivationSource, synthetic_click_activation};
|
use dom::activation::{ActivationSource, synthetic_click_activation};
|
||||||
use dom::attr::Attr;
|
use dom::attr::Attr;
|
||||||
|
use dom::bindings::callback::ExceptionHandling;
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding;
|
use dom::bindings::codegen::Bindings::DocumentBinding;
|
||||||
|
@ -18,7 +20,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
||||||
use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods;
|
use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods;
|
||||||
use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods;
|
use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, WindowMethods};
|
use dom::bindings::codegen::Bindings::WindowBinding::{FrameRequestCallback, ScrollBehavior, WindowMethods};
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
|
@ -112,7 +114,6 @@ use servo_atoms::Atom;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::boxed::FnBox;
|
|
||||||
use std::cell::{Cell, Ref, RefMut};
|
use std::cell::{Cell, Ref, RefMut};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
|
@ -233,8 +234,7 @@ pub struct Document {
|
||||||
animation_frame_ident: Cell<u32>,
|
animation_frame_ident: Cell<u32>,
|
||||||
/// https://html.spec.whatwg.org/multipage/#list-of-animation-frame-callbacks
|
/// https://html.spec.whatwg.org/multipage/#list-of-animation-frame-callbacks
|
||||||
/// List of animation frame callbacks
|
/// List of animation frame callbacks
|
||||||
#[ignore_heap_size_of = "closures are hard"]
|
animation_frame_list: DOMRefCell<Vec<(u32, Option<AnimationFrameCallback>)>>,
|
||||||
animation_frame_list: DOMRefCell<Vec<(u32, Option<Box<FnBox(f64)>>)>>,
|
|
||||||
/// Whether we're in the process of running animation callbacks.
|
/// Whether we're in the process of running animation callbacks.
|
||||||
///
|
///
|
||||||
/// Tracking this is not necessary for correctness. Instead, it is an optimization to avoid
|
/// Tracking this is not necessary for correctness. Instead, it is an optimization to avoid
|
||||||
|
@ -1461,7 +1461,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||||
pub fn request_animation_frame(&self, callback: Box<FnBox(f64)>) -> u32 {
|
pub fn request_animation_frame(&self, callback: AnimationFrameCallback) -> u32 {
|
||||||
let ident = self.animation_frame_ident.get() + 1;
|
let ident = self.animation_frame_ident.get() + 1;
|
||||||
|
|
||||||
self.animation_frame_ident.set(ident);
|
self.animation_frame_ident.set(ident);
|
||||||
|
@ -1502,7 +1502,7 @@ impl Document {
|
||||||
|
|
||||||
for (_, callback) in animation_frame_list.drain(..) {
|
for (_, callback) in animation_frame_list.drain(..) {
|
||||||
if let Some(callback) = callback {
|
if let Some(callback) = callback {
|
||||||
callback(*timing);
|
callback.call(self, *timing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3182,3 +3182,29 @@ pub enum FocusEventType {
|
||||||
Focus, // Element gained focus. Doesn't bubble.
|
Focus, // Element gained focus. Doesn't bubble.
|
||||||
Blur, // Element lost focus. Doesn't bubble.
|
Blur, // Element lost focus. Doesn't bubble.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(HeapSizeOf, JSTraceable)]
|
||||||
|
pub enum AnimationFrameCallback {
|
||||||
|
DevtoolsFramerateTick { actor_name: String },
|
||||||
|
FrameRequestCallback {
|
||||||
|
#[ignore_heap_size_of = "Rc is hard"]
|
||||||
|
callback: Rc<FrameRequestCallback>
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AnimationFrameCallback {
|
||||||
|
fn call(&self, document: &Document, now: f64) {
|
||||||
|
match *self {
|
||||||
|
AnimationFrameCallback::DevtoolsFramerateTick { ref actor_name } => {
|
||||||
|
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name.clone(), now);
|
||||||
|
let devtools_sender = document.window().upcast::<GlobalScope>().devtools_chan().unwrap();
|
||||||
|
devtools_sender.send(msg).unwrap();
|
||||||
|
}
|
||||||
|
AnimationFrameCallback::FrameRequestCallback { ref callback } => {
|
||||||
|
// TODO(jdm): The spec says that any exceptions should be suppressed:
|
||||||
|
// https://github.com/servo/servo/issues/6928
|
||||||
|
let _ = callback.Call__(Finite::wrap(now), ExceptionHandling::Report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ use style::parser::ParserContextExtraData;
|
||||||
use style::str::HTML_SPACE_CHARACTERS;
|
use style::str::HTML_SPACE_CHARACTERS;
|
||||||
use style::stylesheets::{Stylesheet, Origin};
|
use style::stylesheets::{Stylesheet, Origin};
|
||||||
|
|
||||||
no_jsmanaged_fields!(Stylesheet);
|
unsafe_no_jsmanaged_fields!(Stylesheet);
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLLinkElement {
|
pub struct HTMLLinkElement {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
no_jsmanaged_fields!(Key);
|
unsafe_no_jsmanaged_fields!(Key);
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct KeyboardEvent {
|
pub struct KeyboardEvent {
|
||||||
|
|
|
@ -302,38 +302,31 @@ macro_rules! make_nonzero_dimension_setter(
|
||||||
|
|
||||||
/// For use on non-jsmanaged types
|
/// For use on non-jsmanaged types
|
||||||
/// Use #[derive(JSTraceable)] on JS managed types
|
/// Use #[derive(JSTraceable)] on JS managed types
|
||||||
macro_rules! no_jsmanaged_fields(
|
macro_rules! unsafe_no_jsmanaged_fields(
|
||||||
([$ty:ident; $count:expr]) => (
|
|
||||||
impl $crate::dom::bindings::trace::JSTraceable for [$ty; $count] {
|
|
||||||
#[inline]
|
|
||||||
fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
($($ty:ident),+) => (
|
($($ty:ident),+) => (
|
||||||
$(
|
$(
|
||||||
impl $crate::dom::bindings::trace::JSTraceable for $ty {
|
#[allow(unsafe_code)]
|
||||||
|
unsafe impl $crate::dom::bindings::trace::JSTraceable for $ty {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
|
unsafe fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
);
|
);
|
||||||
($ty:ident<$($gen:ident),+>) => (
|
);
|
||||||
impl<$($gen),+> $crate::dom::bindings::trace::JSTraceable for $ty<$($gen),+> {
|
|
||||||
|
macro_rules! jsmanaged_array(
|
||||||
|
($count:expr) => (
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
unsafe impl<T> $crate::dom::bindings::trace::JSTraceable for [T; $count]
|
||||||
|
where T: $crate::dom::bindings::trace::JSTraceable
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
|
unsafe fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
|
||||||
// Do nothing
|
for v in self.iter() {
|
||||||
}
|
v.trace(tracer);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
($ty:ident<$($gen:ident: $bound:ident),+>) => (
|
|
||||||
impl<$($gen: $bound),+> $crate::dom::bindings::trace::JSTraceable for $ty<$($gen),+> {
|
|
||||||
#[inline]
|
|
||||||
fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -143,8 +143,9 @@ impl WeakMediaQueryListVec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for WeakMediaQueryListVec {
|
#[allow(unsafe_code)]
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe impl JSTraceable for WeakMediaQueryListVec {
|
||||||
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
self.cell.borrow_mut().retain_alive()
|
self.cell.borrow_mut().retain_alive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2566,7 +2566,7 @@ struct UniqueId {
|
||||||
cell: UnsafeCell<Option<Box<Uuid>>>,
|
cell: UnsafeCell<Option<Box<Uuid>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
no_jsmanaged_fields!(UniqueId);
|
unsafe_no_jsmanaged_fields!(UniqueId);
|
||||||
|
|
||||||
impl HeapSizeOf for UniqueId {
|
impl HeapSizeOf for UniqueId {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
|
@ -1262,8 +1262,8 @@ impl HeapSizeOf for WeakRangeVec {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
impl JSTraceable for WeakRangeVec {
|
unsafe impl JSTraceable for WeakRangeVec {
|
||||||
fn trace(&self, _: *mut JSTracer) {
|
unsafe fn trace(&self, _: *mut JSTracer) {
|
||||||
unsafe { (*self.cell.get()).retain_alive() }
|
(*self.cell.get()).retain_alive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,9 @@ impl Tokenizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> {
|
#[allow(unsafe_code)]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> {
|
||||||
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
struct Tracer(*mut JSTracer);
|
struct Tracer(*mut JSTracer);
|
||||||
let tracer = Tracer(trc);
|
let tracer = Tracer(trc);
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> {
|
||||||
type Handle = JS<Node>;
|
type Handle = JS<Node>;
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn trace_handle(&self, node: &JS<Node>) {
|
fn trace_handle(&self, node: &JS<Node>) {
|
||||||
node.trace(self.0);
|
unsafe { node.trace(self.0); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,9 @@ impl Tokenizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> {
|
#[allow(unsafe_code)]
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> {
|
||||||
|
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||||
struct Tracer(*mut JSTracer);
|
struct Tracer(*mut JSTracer);
|
||||||
let tracer = Tracer(trc);
|
let tracer = Tracer(trc);
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> {
|
||||||
type Handle = JS<Node>;
|
type Handle = JS<Node>;
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn trace_handle(&self, node: JS<Node>) {
|
fn trace_handle(&self, node: JS<Node>) {
|
||||||
node.trace(self.0);
|
unsafe { node.trace(self.0); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub enum TexParameterValue {
|
||||||
const MAX_LEVEL_COUNT: usize = 31;
|
const MAX_LEVEL_COUNT: usize = 31;
|
||||||
const MAX_FACE_COUNT: usize = 6;
|
const MAX_FACE_COUNT: usize = 6;
|
||||||
|
|
||||||
no_jsmanaged_fields!([ImageInfo; MAX_LEVEL_COUNT * MAX_FACE_COUNT]);
|
jsmanaged_array!(MAX_LEVEL_COUNT * MAX_FACE_COUNT);
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct WebGLTexture {
|
pub struct WebGLTexture {
|
||||||
|
|
|
@ -6,7 +6,6 @@ use app_units::Au;
|
||||||
use bluetooth_traits::BluetoothRequest;
|
use bluetooth_traits::BluetoothRequest;
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
||||||
use dom::bindings::callback::ExceptionHandling;
|
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
|
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
|
@ -30,7 +29,7 @@ use dom::bindings::utils::{GlobalStaticData, WindowProxyHandler};
|
||||||
use dom::browsingcontext::BrowsingContext;
|
use dom::browsingcontext::BrowsingContext;
|
||||||
use dom::crypto::Crypto;
|
use dom::crypto::Crypto;
|
||||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
||||||
use dom::document::Document;
|
use dom::document::{AnimationFrameCallback, Document};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
|
@ -199,7 +198,7 @@ pub struct Window {
|
||||||
|
|
||||||
/// A handle to perform RPC calls into the layout, quickly.
|
/// A handle to perform RPC calls into the layout, quickly.
|
||||||
#[ignore_heap_size_of = "trait objects are hard"]
|
#[ignore_heap_size_of = "trait objects are hard"]
|
||||||
layout_rpc: Box<LayoutRPC + 'static>,
|
layout_rpc: Box<LayoutRPC + Send + 'static>,
|
||||||
|
|
||||||
/// The current size of the window, in pixels.
|
/// The current size of the window, in pixels.
|
||||||
window_size: Cell<Option<WindowSizeData>>,
|
window_size: Cell<Option<WindowSizeData>>,
|
||||||
|
@ -601,15 +600,8 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||||
fn RequestAnimationFrame(&self, callback: Rc<FrameRequestCallback>) -> u32 {
|
fn RequestAnimationFrame(&self, callback: Rc<FrameRequestCallback>) -> u32 {
|
||||||
let doc = self.Document();
|
self.Document()
|
||||||
|
.request_animation_frame(AnimationFrameCallback::FrameRequestCallback { callback })
|
||||||
let callback = move |now: f64| {
|
|
||||||
// TODO: @jdm The spec says that any exceptions should be suppressed;
|
|
||||||
// https://github.com/servo/servo/issues/6928
|
|
||||||
let _ = callback.Call__(Finite::wrap(now), ExceptionHandling::Report);
|
|
||||||
};
|
|
||||||
|
|
||||||
doc.request_animation_frame(Box::new(callback))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||||
|
@ -1568,7 +1560,7 @@ impl Window {
|
||||||
parent_info: Option<(PipelineId, FrameType)>,
|
parent_info: Option<(PipelineId, FrameType)>,
|
||||||
window_size: Option<WindowSizeData>)
|
window_size: Option<WindowSizeData>)
|
||||||
-> Root<Window> {
|
-> Root<Window> {
|
||||||
let layout_rpc: Box<LayoutRPC> = {
|
let layout_rpc: Box<LayoutRPC + Send> = {
|
||||||
let (rpc_send, rpc_recv) = channel();
|
let (rpc_send, rpc_recv) = channel();
|
||||||
layout_chan.send(Msg::GetRPC(rpc_send)).unwrap();
|
layout_chan.send(Msg::GetRPC(rpc_send)).unwrap();
|
||||||
rpc_recv.recv().unwrap()
|
rpc_recv.recv().unwrap()
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(fnbox)]
|
#![feature(field_init_shorthand)]
|
||||||
#![feature(mpsc_select)]
|
#![feature(mpsc_select)]
|
||||||
#![feature(nonzero)]
|
#![feature(nonzero)]
|
||||||
#![feature(on_unimplemented)]
|
#![feature(on_unimplemented)]
|
||||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
|
use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
|
||||||
use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots};
|
use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots};
|
||||||
use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects};
|
use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects};
|
||||||
use dom::bindings::trace::trace_traceables;
|
use dom::bindings::trace::{JSTraceable, trace_traceables};
|
||||||
use dom::bindings::utils::DOM_CALLBACKS;
|
use dom::bindings::utils::DOM_CALLBACKS;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use js::glue::CollectServoSizes;
|
use js::glue::CollectServoSizes;
|
||||||
|
@ -48,7 +48,7 @@ pub enum CommonScriptMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A cloneable interface for communicating with an event loop.
|
/// A cloneable interface for communicating with an event loop.
|
||||||
pub trait ScriptChan {
|
pub trait ScriptChan: JSTraceable {
|
||||||
/// Send a message to the associated event loop.
|
/// Send a message to the associated event loop.
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>;
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>;
|
||||||
/// Clone this handle.
|
/// Clone this handle.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue