Add accountable-refcell as optional build time feature

This commit is contained in:
Kunal Mohan 2020-01-07 13:27:19 +05:30
parent bd636b0e6c
commit 02c1612cb0
No known key found for this signature in database
GPG key ID: 2B475A4524237BAC
29 changed files with 69 additions and 44 deletions

11
Cargo.lock generated
View file

@ -1,5 +1,14 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "accountable-refcell"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9a97321189341ee9b728321237b564caf993ab578297fdf7af1172c9623ca4"
dependencies = [
"backtrace",
]
[[package]] [[package]]
name = "adler32" name = "adler32"
version = "1.0.3" version = "1.0.3"
@ -3134,6 +3143,7 @@ dependencies = [
name = "malloc_size_of" name = "malloc_size_of"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"accountable-refcell",
"app_units", "app_units",
"content-security-policy", "content-security-policy",
"crossbeam-channel", "crossbeam-channel",
@ -4452,6 +4462,7 @@ checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
name = "script" name = "script"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"accountable-refcell",
"app_units", "app_units",
"backtrace", "backtrace",
"base64", "base64",

View file

@ -22,10 +22,12 @@ servo = [
"webrender_api", "webrender_api",
"xml5ever", "xml5ever",
"content-security-policy", "content-security-policy",
"uuid" "uuid",
"accountable-refcell",
] ]
[dependencies] [dependencies]
accountable-refcell = { version = "0.2.0", optional = true }
app_units = "0.7" app_units = "0.7"
content-security-policy = {version = "0.3.0", features = ["serde"], optional = true} content-security-policy = {version = "0.3.0", features = ["serde"], optional = true}
crossbeam-channel = { version = "0.3", optional = true } crossbeam-channel = { version = "0.3", optional = true }

View file

@ -46,6 +46,7 @@
//! Note: WebRender has a reduced fork of this crate, so that we can avoid //! Note: WebRender has a reduced fork of this crate, so that we can avoid
//! publishing this crate on crates.io. //! publishing this crate on crates.io.
extern crate accountable_refcell;
extern crate app_units; extern crate app_units;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
extern crate content_security_policy; extern crate content_security_policy;
@ -970,3 +971,10 @@ impl<T: MallocSizeOf> DerefMut for Measurable<T> {
&mut self.0 &mut self.0
} }
} }
#[cfg(feature = "servo")]
impl<T: MallocSizeOf> MallocSizeOf for accountable_refcell::RefCell<T> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.borrow().size_of(ops)
}
}

View file

@ -19,6 +19,7 @@ unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"]
default = ["unrooted_must_root_lint"] default = ["unrooted_must_root_lint"]
webgl_backtrace = ["backtrace", "canvas_traits/webgl_backtrace"] webgl_backtrace = ["backtrace", "canvas_traits/webgl_backtrace"]
js_backtrace = ["backtrace"] js_backtrace = ["backtrace"]
refcell_backtrace = ["accountable-refcell"]
uwp = ["js/uwp"] uwp = ["js/uwp"]
vslatestinstalled = ["js/vslatestinstalled"] vslatestinstalled = ["js/vslatestinstalled"]
@ -31,6 +32,7 @@ serde_json = "1.0"
tinyfiledialogs = "3.0" tinyfiledialogs = "3.0"
[dependencies] [dependencies]
accountable-refcell = {version = "0.2.0", optional = true}
app_units = "0.7" app_units = "0.7"
backtrace = {version = "0.3", optional = true} backtrace = {version = "0.3", optional = true}
base64 = "0.10.1" base64 = "0.10.1"

View file

@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::compartments::{AlreadyInCompartment, InCompartment}; use crate::compartments::{AlreadyInCompartment, InCompartment};
use crate::dom::bindings::cell::Ref;
use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::reflector::DomObject;
@ -25,7 +26,6 @@ use js::rust::wrappers::JS_ParseJSON;
use js::typedarray::{ArrayBuffer, CreateWith}; use js::typedarray::{ArrayBuffer, CreateWith};
use mime::{self, Mime}; use mime::{self, Mime};
use script_traits::serializable::BlobImpl; use script_traits::serializable::BlobImpl;
use std::cell::Ref;
use std::ptr; use std::ptr;
use std::rc::Rc; use std::rc::Rc;
use std::str; use std::str;

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; use crate::dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
@ -19,7 +19,6 @@ use dom_struct::dom_struct;
use html5ever::{LocalName, Namespace, Prefix}; use html5ever::{LocalName, Namespace, Prefix};
use servo_atoms::Atom; use servo_atoms::Atom;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::Ref;
use std::mem; use std::mem;
use style::attr::{AttrIdentifier, AttrValue}; use style::attr::{AttrIdentifier, AttrValue};

View file

@ -4,7 +4,7 @@
use crate::compartments::enter_realm; use crate::compartments::enter_realm;
use crate::dom::audionode::MAX_CHANNEL_COUNT; use crate::dom::audionode::MAX_CHANNEL_COUNT;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{ use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{
self, AudioBufferMethods, AudioBufferOptions, self, AudioBufferMethods, AudioBufferOptions,
}; };
@ -21,7 +21,6 @@ use js::rust::wrappers::DetachArrayBuffer;
use js::rust::CustomAutoRooterGuard; use js::rust::CustomAutoRooterGuard;
use js::typedarray::{CreateWith, Float32Array}; use js::typedarray::{CreateWith, Float32Array};
use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer; use servo_media::audio::buffer_source_node::AudioBuffer as ServoMediaAudioBuffer;
use std::cell::Ref;
use std::cmp::min; use std::cmp::min;
use std::ptr::{self, NonNull}; use std::ptr::{self, NonNull};

View file

@ -4,7 +4,13 @@
//! A shareable mutable container for the DOM. //! A shareable mutable container for the DOM.
use std::cell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut}; #[cfg(feature = "refcell_backtrace")]
pub use accountable_refcell::{ref_filter_map, Ref, RefCell, RefMut};
#[cfg(not(feature = "refcell_backtrace"))]
pub use ref_filter_map::ref_filter_map;
use std::cell::{BorrowError, BorrowMutError};
#[cfg(not(feature = "refcell_backtrace"))]
pub use std::cell::{Ref, RefCell, RefMut};
use style::thread_state::{self, ThreadState}; use style::thread_state::{self, ThreadState};
/// A mutable field in the DOM. /// A mutable field in the DOM.

View file

@ -8,7 +8,7 @@ use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence}; use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence}; use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
use crate::compartments::{AlreadyInCompartment, InCompartment}; use crate::compartments::{AlreadyInCompartment, InCompartment};
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit}; use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit};
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions}; use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothLEScanFilterInit; use crate::dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothLEScanFilterInit;
@ -39,7 +39,6 @@ use js::conversions::ConversionResult;
use js::jsapi::JSObject; use js::jsapi::JSObject;
use js::jsval::{ObjectValue, UndefinedValue}; use js::jsval::{ObjectValue, UndefinedValue};
use profile_traits::ipc as ProfiledIpc; use profile_traits::ipc as ProfiledIpc;
use std::cell::Ref;
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr; use std::str::FromStr;

View file

@ -4,7 +4,7 @@
//! DOM bindings for `CharacterData`. //! DOM bindings for `CharacterData`.
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods; use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods;
@ -24,7 +24,6 @@ use crate::dom::processinginstruction::ProcessingInstruction;
use crate::dom::text::Text; use crate::dom::text::Text;
use crate::dom::virtualmethods::vtable_for; use crate::dom::virtualmethods::vtable_for;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use std::cell::Ref;
// https://dom.spec.whatwg.org/#characterdata // https://dom.spec.whatwg.org/#characterdata
#[dom_struct] #[dom_struct]

View file

@ -8,7 +8,7 @@ use crate::dom::activation::{synthetic_click_activation, ActivationSource};
use crate::dom::attr::Attr; use crate::dom::attr::Attr;
use crate::dom::beforeunloadevent::BeforeUnloadEvent; use crate::dom::beforeunloadevent::BeforeUnloadEvent;
use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut};
use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding; use crate::dom::bindings::codegen::Bindings::DocumentBinding;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
@ -133,7 +133,6 @@ use num_traits::ToPrimitive;
use percent_encoding::percent_decode; use percent_encoding::percent_decode;
use profile_traits::ipc as profile_ipc; use profile_traits::ipc as profile_ipc;
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType};
use ref_filter_map::ref_filter_map;
use ref_slice::ref_slice; use ref_slice::ref_slice;
use script_layout_interface::message::{Msg, ReflowGoal}; use script_layout_interface::message::{Msg, ReflowGoal};
use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType}; use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType};
@ -146,7 +145,7 @@ use servo_config::pref;
use servo_media::{ClientContextId, ServoMedia}; use servo_media::{ClientContextId, ServoMedia};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::{Cell, Ref, RefMut}; use std::cell::Cell;
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
use std::default::Default; use std::default::Default;

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods};
use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{ use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{
DOMMatrixReadOnlyMethods, Wrap, DOMMatrixReadOnlyMethods, Wrap,
@ -26,7 +26,7 @@ use js::jsapi::JSObject;
use js::rust::CustomAutoRooterGuard; use js::rust::CustomAutoRooterGuard;
use js::typedarray::CreateWith; use js::typedarray::CreateWith;
use js::typedarray::{Float32Array, Float64Array}; use js::typedarray::{Float32Array, Float64Array};
use std::cell::{Cell, Ref}; use std::cell::Cell;
use std::f64; use std::f64;
use std::ptr; use std::ptr;
use std::ptr::NonNull; use std::ptr::NonNull;

View file

@ -6,7 +6,7 @@
use crate::dom::activation::Activatable; use crate::dom::activation::Activatable;
use crate::dom::attr::{Attr, AttrHelpersForLayout}; use crate::dom::attr::{Attr, AttrHelpersForLayout};
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut};
use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use crate::dom::bindings::codegen::Bindings::ElementBinding; use crate::dom::bindings::codegen::Bindings::ElementBinding;
@ -98,7 +98,6 @@ use js::jsval::JSVal;
use msg::constellation_msg::InputMethodType; use msg::constellation_msg::InputMethodType;
use net_traits::request::CorsSettings; use net_traits::request::CorsSettings;
use net_traits::ReferrerPolicy; use net_traits::ReferrerPolicy;
use ref_filter_map::ref_filter_map;
use script_layout_interface::message::ReflowGoal; use script_layout_interface::message::ReflowGoal;
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::matching::{ElementSelectorFlags, MatchingContext};
@ -107,7 +106,7 @@ use selectors::Element as SelectorsElement;
use servo_arc::Arc; use servo_arc::Arc;
use servo_atoms::Atom; use servo_atoms::Atom;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::{Cell, Ref, RefMut}; use std::cell::Cell;
use std::default::Default; use std::default::Default;
use std::fmt; use std::fmt;
use std::mem; use std::mem;

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::attr::Attr; use crate::dom::attr::Attr;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{ use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{
HTMLCanvasElementMethods, RenderingContext, HTMLCanvasElementMethods, RenderingContext,
@ -44,7 +44,6 @@ use js::rust::HandleValue;
use profile_traits::ipc; use profile_traits::ipc;
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource}; use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource};
use servo_config::pref; use servo_config::pref;
use std::cell::Ref;
use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::attr::{AttrValue, LengthOrPercentageOrAuto};
const DEFAULT_WIDTH: u32 = 300; const DEFAULT_WIDTH: u32 = 300;
@ -192,7 +191,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
impl HTMLCanvasElement { impl HTMLCanvasElement {
pub fn context(&self) -> Option<Ref<CanvasContext>> { pub fn context(&self) -> Option<Ref<CanvasContext>> {
ref_filter_map::ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref()) ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref())
} }
fn get_or_init_2d_context(&self) -> Option<DomRoot<CanvasRenderingContext2D>> { fn get_or_init_2d_context(&self) -> Option<DomRoot<CanvasRenderingContext2D>> {

View file

@ -5,7 +5,7 @@
use crate::document_loader::{LoadBlocker, LoadType}; use crate::document_loader::{LoadBlocker, LoadType};
use crate::dom::activation::Activatable; use crate::dom::activation::Activatable;
use crate::dom::attr::Attr; use crate::dom::attr::Attr;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, RefMut};
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectBinding::DOMRectMethods;
use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding;
@ -67,7 +67,7 @@ use num_traits::ToPrimitive;
use servo_url::origin::ImmutableOrigin; use servo_url::origin::ImmutableOrigin;
use servo_url::origin::MutableOrigin; use servo_url::origin::MutableOrigin;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::cell::{Cell, RefMut}; use std::cell::Cell;
use std::char; use std::char;
use std::collections::HashSet; use std::collections::HashSet;
use std::default::Default; use std::default::Default;

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::{self, MediaStreamMethods}; use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::{self, MediaStreamMethods};
use crate::dom::bindings::error::Fallible; use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
@ -14,7 +14,6 @@ use crate::dom::mediastreamtrack::MediaStreamTrack;
use crate::dom::window::Window; use crate::dom::window::Window;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use servo_media::streams::MediaStreamType; use servo_media::streams::MediaStreamType;
use std::cell::Ref;
#[dom_struct] #[dom_struct]
pub struct MediaStream { pub struct MediaStream {

View file

@ -6,7 +6,7 @@
use crate::document_loader::DocumentLoader; use crate::document_loader::DocumentLoader;
use crate::dom::attr::Attr; use crate::dom::attr::Attr;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut};
use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
@ -86,7 +86,7 @@ use servo_arc::Arc;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::{Cell, Ref, RefMut, UnsafeCell}; use std::cell::{Cell, UnsafeCell};
use std::cmp; use std::cmp;
use std::default::Default; use std::default::Default;
use std::iter; use std::iter;

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{ use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{
OffscreenCanvasMethods, OffscreenRenderingContext, Wrap as OffscreenCanvasWrap, OffscreenCanvasMethods, OffscreenRenderingContext, Wrap as OffscreenCanvasWrap,
}; };
@ -22,9 +22,7 @@ use euclid::default::Size2D;
use ipc_channel::ipc::IpcSharedMemory; use ipc_channel::ipc::IpcSharedMemory;
use js::rust::HandleValue; use js::rust::HandleValue;
use profile_traits::ipc; use profile_traits::ipc;
use ref_filter_map;
use std::cell::Cell; use std::cell::Cell;
use std::cell::Ref;
#[unrooted_must_root_lint::must_root] #[unrooted_must_root_lint::must_root]
#[derive(Clone, JSTraceable, MallocSizeOf)] #[derive(Clone, JSTraceable, MallocSizeOf)]
@ -94,7 +92,7 @@ impl OffscreenCanvas {
} }
pub fn context(&self) -> Option<Ref<OffscreenCanvasContext>> { pub fn context(&self) -> Option<Ref<OffscreenCanvasContext>> {
ref_filter_map::ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref()) ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref())
} }
pub fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> { pub fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> {

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::body::{consume_body, BodyOperations, BodyType}; use crate::body::{consume_body, BodyOperations, BodyType};
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods};
use crate::dom::bindings::codegen::Bindings::RequestBinding; use crate::dom::bindings::codegen::Bindings::RequestBinding;
use crate::dom::bindings::codegen::Bindings::RequestBinding::ReferrerPolicy; use crate::dom::bindings::codegen::Bindings::RequestBinding::ReferrerPolicy;
@ -38,7 +38,7 @@ use net_traits::request::RequestMode as NetTraitsRequestMode;
use net_traits::request::{Origin, Window}; use net_traits::request::{Origin, Window};
use net_traits::ReferrerPolicy as MsgReferrerPolicy; use net_traits::ReferrerPolicy as MsgReferrerPolicy;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::cell::{Cell, Ref}; use std::cell::Cell;
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr; use std::str::FromStr;

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::body::{consume_body, consume_body_with_promise, BodyOperations, BodyType}; use crate::body::{consume_body, consume_body_with_promise, BodyOperations, BodyType};
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods};
use crate::dom::bindings::codegen::Bindings::ResponseBinding; use crate::dom::bindings::codegen::Bindings::ResponseBinding;
use crate::dom::bindings::codegen::Bindings::ResponseBinding::{ use crate::dom::bindings::codegen::Bindings::ResponseBinding::{
@ -26,7 +26,7 @@ use hyper::StatusCode;
use hyper_serde::Serde; use hyper_serde::Serde;
use net_traits::response::ResponseBody as NetTraitsResponseBody; use net_traits::response::ResponseBody as NetTraitsResponseBody;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::cell::{Cell, Ref}; use std::cell::Cell;
use std::mem; use std::mem;
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr; use std::str::FromStr;

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::WebGLProgramBinding; use crate::dom::bindings::codegen::Bindings::WebGLProgramBinding;
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::inheritance::Castable;
@ -19,7 +19,7 @@ use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult};
use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, WebGLCommand, WebGLError}; use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, WebGLCommand, WebGLError};
use dom_struct::dom_struct; use dom_struct::dom_struct;
use fnv::FnvHashSet; use fnv::FnvHashSet;
use std::cell::{Cell, Ref}; use std::cell::Cell;
#[dom_struct] #[dom_struct]
pub struct WebGLProgram { pub struct WebGLProgram {

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use crate::dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding; use crate::dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding;
use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::inheritance::Castable;
@ -15,8 +15,7 @@ use canvas_traits::webgl::{
ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVertexArrayId, ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVertexArrayId,
}; };
use dom_struct::dom_struct; use dom_struct::dom_struct;
use ref_filter_map::ref_filter_map; use std::cell::Cell;
use std::cell::{Cell, Ref};
#[dom_struct] #[dom_struct]
pub struct WebGLVertexArrayObjectOES { pub struct WebGLVertexArrayObjectOES {

View file

@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::compartments::InCompartment; use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::cell::{DomRefCell, Ref};
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit; use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
use crate::dom::bindings::codegen::Bindings::WorkerBinding::WorkerType; use crate::dom::bindings::codegen::Bindings::WorkerBinding::WorkerType;
use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods; use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
@ -52,7 +52,6 @@ use net_traits::request::{
use net_traits::IpcSend; use net_traits::IpcSend;
use script_traits::WorkerGlobalScopeInit; use script_traits::WorkerGlobalScopeInit;
use servo_url::{MutableOrigin, ServoUrl}; use servo_url::{MutableOrigin, ServoUrl};
use std::cell::Ref;
use std::default::Default; use std::default::Default;
use std::rc::Rc; use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};

View file

@ -125,6 +125,8 @@ fn is_unrooted_ty(sym: &Symbols, cx: &LateContext, ty: &ty::TyS, in_new_function
match_def_path(cx, did.did, &[sym::core, sym.cell, sym.RefMut]) || match_def_path(cx, did.did, &[sym::core, sym.cell, sym.RefMut]) ||
match_def_path(cx, did.did, &[sym::core, sym.slice, sym.Iter]) || match_def_path(cx, did.did, &[sym::core, sym.slice, sym.Iter]) ||
match_def_path(cx, did.did, &[sym::core, sym.slice, sym.IterMut]) || match_def_path(cx, did.did, &[sym::core, sym.slice, sym.IterMut]) ||
match_def_path(cx, did.did, &[sym.accountable_refcell, sym.Ref]) ||
match_def_path(cx, did.did, &[sym.accountable_refcell, sym.RefMut]) ||
match_def_path( match_def_path(
cx, cx,
did.did, did.did,
@ -175,6 +177,7 @@ fn is_unrooted_ty(sym: &Symbols, cx: &LateContext, ty: &ty::TyS, in_new_function
ty::Ref(..) => false, // don't recurse down &ptrs ty::Ref(..) => false, // don't recurse down &ptrs
ty::RawPtr(..) => false, // don't recurse down *ptrs ty::RawPtr(..) => false, // don't recurse down *ptrs
ty::FnDef(..) | ty::FnPtr(_) => false, ty::FnDef(..) | ty::FnPtr(_) => false,
_ => true, _ => true,
} }
}); });
@ -412,6 +415,7 @@ symbols! {
rc rc
Rc Rc
cell cell
accountable_refcell
Ref Ref
RefMut RefMut
slice slice

View file

@ -29,6 +29,7 @@ uwp = ["servo_config/uwp", "script/uwp"]
webrender_debugger = ["webrender/debugger"] webrender_debugger = ["webrender/debugger"]
no_static_freetype = ["webrender/no_static_freetype"] no_static_freetype = ["webrender/no_static_freetype"]
oculusvr = ["webvr/oculusvr"] oculusvr = ["webvr/oculusvr"]
refcell_backtrace = ["script/refcell_backtrace"]
webdriver = ["webdriver_server"] webdriver = ["webdriver_server"]
webgl_backtrace = [ webgl_backtrace = [
"script/webgl_backtrace", "script/webgl_backtrace",

View file

@ -206,7 +206,7 @@ def linux_tidy_unit():
python3 ./mach build --dev python3 ./mach build --dev
python3 ./mach test-unit python3 ./mach test-unit
python3 ./mach package --dev python3 ./mach package --dev
python3 ./mach build --dev --features canvas2d-raqote python3 ./mach build --dev --features refcell_backtrace
python3 ./mach build --dev --features layout-2020 python3 ./mach build --dev --features layout-2020
python3 ./mach build --dev --libsimpleservo python3 ./mach build --dev --libsimpleservo
python3 ./mach build --dev -p servo-gst-plugin python3 ./mach build --dev -p servo-gst-plugin

View file

@ -42,6 +42,7 @@ max_log_level = ["log/release_max_level_info"]
native-bluetooth = ["libservo/native-bluetooth"] native-bluetooth = ["libservo/native-bluetooth"]
no-wgl = ["libservo/no-wgl"] no-wgl = ["libservo/no-wgl"]
profilemozjs = ["libservo/profilemozjs"] profilemozjs = ["libservo/profilemozjs"]
refcell_backtrace = ["libservo/refcell_backtrace"]
webdriver = ["libservo/webdriver"] webdriver = ["libservo/webdriver"]
webgl_backtrace = ["libservo/webgl_backtrace"] webgl_backtrace = ["libservo/webgl_backtrace"]
webrender_debugger = ["libservo/webrender_debugger"] webrender_debugger = ["libservo/webrender_debugger"]

View file

@ -48,6 +48,7 @@ native-bluetooth = ["libservo/native-bluetooth"]
no_static_freetype = ["libservo/no_static_freetype"] no_static_freetype = ["libservo/no_static_freetype"]
no-wgl = ["libservo/no-wgl"] no-wgl = ["libservo/no-wgl"]
oculusvr = ["libservo/oculusvr"] oculusvr = ["libservo/oculusvr"]
refcell_backtrace = ["libservo/refcell_backtrace"]
webdriver = ["libservo/webdriver"] webdriver = ["libservo/webdriver"]
uwp = ["libservo/uwp", "webxr/openxr-api"] uwp = ["libservo/uwp", "webxr/openxr-api"]
webgl_backtrace = ["libservo/webgl_backtrace"] webgl_backtrace = ["libservo/webgl_backtrace"]

View file

@ -43,6 +43,7 @@ max_log_level = ["simpleservo/max_log_level"]
native-bluetooth = ["simpleservo/native-bluetooth"] native-bluetooth = ["simpleservo/native-bluetooth"]
no-wgl = ["simpleservo/no-wgl"] no-wgl = ["simpleservo/no-wgl"]
oculusvr = ["simpleservo/oculusvr"] oculusvr = ["simpleservo/oculusvr"]
refcell_backtrace = ["simpleservo/refcell_backtrace"]
uwp = ["simpleservo/uwp"] uwp = ["simpleservo/uwp"]
webdriver = ["simpleservo/webdriver"] webdriver = ["simpleservo/webdriver"]
webgl_backtrace = ["simpleservo/webgl_backtrace"] webgl_backtrace = ["simpleservo/webgl_backtrace"]