diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 32c3e5c7eaa..a7f4bb9e411 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -237,20 +237,20 @@ impl LayoutJS { /// on `Dom`. #[must_root] #[derive(JSTraceable)] -pub struct MutJS { +pub struct MutDom { val: UnsafeCell>, } -impl MutJS { - /// Create a new `MutJS`. - pub fn new(initial: &T) -> MutJS { +impl MutDom { + /// Create a new `MutDom`. + pub fn new(initial: &T) -> MutDom { debug_assert!(thread_state::get().is_script()); - MutJS { + MutDom { val: UnsafeCell::new(Dom::from_ref(initial)), } } - /// Set this `MutJS` to the given value. + /// Set this `MutDom` to the given value. pub fn set(&self, val: &T) { debug_assert!(thread_state::get().is_script()); unsafe { @@ -258,7 +258,7 @@ impl MutJS { } } - /// Get the value in this `MutJS`. + /// Get the value in this `MutDom`. pub fn get(&self) -> Root { debug_assert!(thread_state::get().is_script()); unsafe { @@ -267,14 +267,14 @@ impl MutJS { } } -impl HeapSizeOf for MutJS { +impl HeapSizeOf for MutDom { fn heap_size_of_children(&self) -> usize { // See comment on HeapSizeOf for Dom. 0 } } -impl PartialEq for MutJS { +impl PartialEq for MutDom { fn eq(&self, other: &Self) -> bool { unsafe { *self.val.get() == *other.val.get() @@ -282,7 +282,7 @@ impl PartialEq for MutJS { } } -impl PartialEq for MutJS { +impl PartialEq for MutDom { fn eq(&self, other: &T) -> bool { unsafe { **self.val.get() == *other diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 8020d832ab9..7c683edf9eb 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -33,7 +33,7 @@ //! the [`Root`](bindings/root/struct.Root.html) smart pointer; //! * tracing pointers in member fields: the [`Dom`](bindings/root/struct.Dom.html), //! [`MutNullableJS`](bindings/root/struct.MutNullableJS.html) and -//! [`MutJS`](bindings/root/struct.MutJS.html) smart pointers and +//! [`MutDom`](bindings/root/struct.MutDom.html) smart pointers and //! [the tracing implementation](bindings/trace/index.html); //! * rooting pointers from across thread boundaries or in channels: the //! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer; diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index 0ab8c54360b..ec18066a978 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::NodeIteratorBinding; use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods; use dom::bindings::error::Fallible; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::{Dom, MutJS, Root}; +use dom::bindings::root::{Dom, MutDom, Root}; use dom::document::Document; use dom::node::Node; use dom_struct::dom_struct; @@ -22,7 +22,7 @@ pub struct NodeIterator { reflector_: Reflector, root_node: Dom, #[ignore_heap_size_of = "Defined in rust-mozjs"] - reference_node: MutJS, + reference_node: MutDom, pointer_before_reference_node: Cell, what_to_show: u32, #[ignore_heap_size_of = "Can't measure due to #6870"] @@ -36,7 +36,7 @@ impl NodeIterator { NodeIterator { reflector_: Reflector::new(), root_node: Dom::from_ref(root_node), - reference_node: MutJS::new(root_node), + reference_node: MutDom::new(root_node), pointer_before_reference_node: Cell::new(true), what_to_show: what_to_show, filter: filter diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 1344f9c7a5c..79091beff55 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -14,7 +14,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::{Dom, MutJS, Root, RootedReference}; +use dom::bindings::root::{Dom, MutDom, Root, RootedReference}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::bindings::weakref::{WeakRef, WeakRefVec}; @@ -933,7 +933,7 @@ impl RangeMethods for Range { #[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] #[must_root] pub struct BoundaryPoint { - node: MutJS, + node: MutDom, offset: Cell, } @@ -942,7 +942,7 @@ impl BoundaryPoint { debug_assert!(!node.is_doctype()); debug_assert!(offset <= node.len()); BoundaryPoint { - node: MutJS::new(node), + node: MutDom::new(node), offset: Cell::new(offset), } } diff --git a/components/script/dom/touch.rs b/components/script/dom/touch.rs index d7920a2dd19..d526e607d8d 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::TouchBinding; use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::{MutJS, Root}; +use dom::bindings::root::{MutDom, Root}; use dom::eventtarget::EventTarget; use dom::window::Window; use dom_struct::dom_struct; @@ -15,7 +15,7 @@ use dom_struct::dom_struct; pub struct Touch { reflector_: Reflector, identifier: i32, - target: MutJS, + target: MutDom, screen_x: f64, screen_y: f64, client_x: f64, @@ -32,7 +32,7 @@ impl Touch { Touch { reflector_: Reflector::new(), identifier: identifier, - target: MutJS::new(target), + target: MutDom::new(target), screen_x: *screen_x, screen_y: *screen_y, client_x: *client_x, diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs index 4c29bc48445..92ff9bf0424 100644 --- a/components/script/dom/touchevent.rs +++ b/components/script/dom/touchevent.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::inheritance::Castable; use dom::bindings::reflector::reflect_dom_object; -use dom::bindings::root::{MutJS, Root}; +use dom::bindings::root::{MutDom, Root}; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; use dom::touchlist::TouchList; @@ -19,9 +19,9 @@ use std::cell::Cell; #[dom_struct] pub struct TouchEvent { uievent: UIEvent, - touches: MutJS, - target_touches: MutJS, - changed_touches: MutJS, + touches: MutDom, + target_touches: MutDom, + changed_touches: MutDom, alt_key: Cell, meta_key: Cell, ctrl_key: Cell, @@ -34,9 +34,9 @@ impl TouchEvent { target_touches: &TouchList) -> TouchEvent { TouchEvent { uievent: UIEvent::new_inherited(), - touches: MutJS::new(touches), - target_touches: MutJS::new(target_touches), - changed_touches: MutJS::new(changed_touches), + touches: MutDom::new(touches), + target_touches: MutDom::new(target_touches), + changed_touches: MutDom::new(changed_touches), ctrl_key: Cell::new(false), shift_key: Cell::new(false), alt_key: Cell::new(false), diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index bbb27c61541..61a085aaa53 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::TreeWalkerBinding; use dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods; use dom::bindings::error::Fallible; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::{Dom, MutJS, Root}; +use dom::bindings::root::{Dom, MutDom, Root}; use dom::document::Document; use dom::node::Node; use dom_struct::dom_struct; @@ -21,7 +21,7 @@ use std::rc::Rc; pub struct TreeWalker { reflector_: Reflector, root_node: Dom, - current_node: MutJS, + current_node: MutDom, what_to_show: u32, #[ignore_heap_size_of = "function pointers and Rc are hard"] filter: Filter @@ -34,7 +34,7 @@ impl TreeWalker { TreeWalker { reflector_: Reflector::new(), root_node: Dom::from_ref(root_node), - current_node: MutJS::new(root_node), + current_node: MutDom::new(root_node), what_to_show: what_to_show, filter: filter } diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index a17666e625e..d6e8d480c3d 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -18,7 +18,7 @@ use dom::bindings::inheritance::Castable; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; -use dom::bindings::root::{MutJS, MutNullableJS, Root}; +use dom::bindings::root::{MutDom, MutNullableJS, Root}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -51,9 +51,9 @@ pub struct VRDisplay { depth_near: Cell, depth_far: Cell, presenting: Cell, - left_eye_params: MutJS, - right_eye_params: MutJS, - capabilities: MutJS, + left_eye_params: MutDom, + right_eye_params: MutDom, + capabilities: MutDom, stage_params: MutNullableJS, #[ignore_heap_size_of = "Defined in rust-webvr"] frame_data: DOMRefCell, @@ -100,9 +100,9 @@ impl VRDisplay { depth_near: Cell::new(0.01), depth_far: Cell::new(10000.0), presenting: Cell::new(false), - left_eye_params: MutJS::new(&*VREyeParameters::new(display.left_eye_parameters.clone(), &global)), - right_eye_params: MutJS::new(&*VREyeParameters::new(display.right_eye_parameters.clone(), &global)), - capabilities: MutJS::new(&*VRDisplayCapabilities::new(display.capabilities.clone(), &global)), + left_eye_params: MutDom::new(&*VREyeParameters::new(display.left_eye_parameters.clone(), &global)), + right_eye_params: MutDom::new(&*VREyeParameters::new(display.right_eye_parameters.clone(), &global)), + capabilities: MutDom::new(&*VRDisplayCapabilities::new(display.capabilities.clone(), &global)), stage_params: MutNullableJS::new(stage.as_ref().map(|v| v.deref())), frame_data: DOMRefCell::new(Default::default()), layer: DOMRefCell::new(Default::default()), diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index cd4bf6feb97..d7c83ee8cee 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -575,10 +575,10 @@ def check_rust(file_name, lines): (r": &String", "use &str instead of &String", no_filter), # There should be any use of banned types: # Cell, Cell>, DOMRefCell>, DOMRefCell> - (r"(\s|:)+Cell", "Banned type Cell detected. Use MutJS instead", no_filter), - (r"(\s|:)+Cell>", "Banned type Cell> detected. Use MutJS instead", no_filter), - (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutJS instead", no_filter), - (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutJS instead", no_filter), + (r"(\s|:)+Cell", "Banned type Cell detected. Use MutDom instead", no_filter), + (r"(\s|:)+Cell>", "Banned type Cell> detected. Use MutDom instead", no_filter), + (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutDom instead", no_filter), + (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutDom instead", no_filter), # No benefit to using &Root (r": &Root<", "use &T instead of &Root", no_filter), (r"^&&", "operators should go at the end of the first line", no_filter), diff --git a/python/tidy/servo_tidy_tests/ban-domrefcell.rs b/python/tidy/servo_tidy_tests/ban-domrefcell.rs index f41358e7fa7..6d4e2b2fbc3 100644 --- a/python/tidy/servo_tidy_tests/ban-domrefcell.rs +++ b/python/tidy/servo_tidy_tests/ban-domrefcell.rs @@ -13,7 +13,7 @@ use script::test::Node; struct Foo { bar: DOMRefCell> - //~^ ERROR Banned type DOMRefCell> detected. Use MutJS instead + //~^ ERROR Banned type DOMRefCell> detected. Use MutDom instead } fn main() {} diff --git a/python/tidy/servo_tidy_tests/ban.rs b/python/tidy/servo_tidy_tests/ban.rs index f828053d289..fc5c600041a 100644 --- a/python/tidy/servo_tidy_tests/ban.rs +++ b/python/tidy/servo_tidy_tests/ban.rs @@ -13,7 +13,7 @@ use std::cell::UnsafeCell; struct Foo { bar: Cell, - //~^ ERROR Banned type Cell detected. Use MutJS instead + //~^ ERROR Banned type Cell detected. Use MutDom instead foo: UnsafeCell //~^ NOT AN ERROR } diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index ce9906f5549..3761975c62b 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -147,11 +147,11 @@ class CheckTidiness(unittest.TestCase): self.assertNoMoreErrors(feature_errors) ban_errors = tidy.collect_errors_for_files(iterFile('ban.rs'), [], [tidy.check_rust], print_text=False) - self.assertEqual('Banned type Cell detected. Use MutJS instead', ban_errors.next()[2]) + self.assertEqual('Banned type Cell detected. Use MutDom instead', ban_errors.next()[2]) self.assertNoMoreErrors(ban_errors) ban_errors = tidy.collect_errors_for_files(iterFile('ban-domrefcell.rs'), [], [tidy.check_rust], print_text=False) - self.assertEqual('Banned type DOMRefCell> detected. Use MutJS instead', ban_errors.next()[2]) + self.assertEqual('Banned type DOMRefCell> detected. Use MutDom instead', ban_errors.next()[2]) self.assertNoMoreErrors(ban_errors) def test_spec_link(self):