mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rename MutJS<T> to MutDom<T>
This commit is contained in:
parent
7be32fb237
commit
d29335040d
12 changed files with 45 additions and 45 deletions
|
@ -237,20 +237,20 @@ impl LayoutJS<Node> {
|
|||
/// on `Dom<T>`.
|
||||
#[must_root]
|
||||
#[derive(JSTraceable)]
|
||||
pub struct MutJS<T: DomObject> {
|
||||
pub struct MutDom<T: DomObject> {
|
||||
val: UnsafeCell<Dom<T>>,
|
||||
}
|
||||
|
||||
impl<T: DomObject> MutJS<T> {
|
||||
/// Create a new `MutJS`.
|
||||
pub fn new(initial: &T) -> MutJS<T> {
|
||||
impl<T: DomObject> MutDom<T> {
|
||||
/// Create a new `MutDom`.
|
||||
pub fn new(initial: &T) -> MutDom<T> {
|
||||
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<T: DomObject> MutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the value in this `MutJS`.
|
||||
/// Get the value in this `MutDom`.
|
||||
pub fn get(&self) -> Root<T> {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
|
@ -267,14 +267,14 @@ impl<T: DomObject> MutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> HeapSizeOf for MutJS<T> {
|
||||
impl<T: DomObject> HeapSizeOf for MutDom<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
// See comment on HeapSizeOf for Dom<T>.
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> PartialEq for MutJS<T> {
|
||||
impl<T: DomObject> PartialEq for MutDom<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
unsafe {
|
||||
*self.val.get() == *other.val.get()
|
||||
|
@ -282,7 +282,7 @@ impl<T: DomObject> PartialEq for MutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject + PartialEq> PartialEq<T> for MutJS<T> {
|
||||
impl<T: DomObject + PartialEq> PartialEq<T> for MutDom<T> {
|
||||
fn eq(&self, other: &T) -> bool {
|
||||
unsafe {
|
||||
**self.val.get() == *other
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Node>,
|
||||
#[ignore_heap_size_of = "Defined in rust-mozjs"]
|
||||
reference_node: MutJS<Node>,
|
||||
reference_node: MutDom<Node>,
|
||||
pointer_before_reference_node: Cell<bool>,
|
||||
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
|
||||
|
|
|
@ -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>,
|
||||
node: MutDom<Node>,
|
||||
offset: Cell<u32>,
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<EventTarget>,
|
||||
target: MutDom<EventTarget>,
|
||||
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,
|
||||
|
|
|
@ -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<TouchList>,
|
||||
target_touches: MutJS<TouchList>,
|
||||
changed_touches: MutJS<TouchList>,
|
||||
touches: MutDom<TouchList>,
|
||||
target_touches: MutDom<TouchList>,
|
||||
changed_touches: MutDom<TouchList>,
|
||||
alt_key: Cell<bool>,
|
||||
meta_key: Cell<bool>,
|
||||
ctrl_key: Cell<bool>,
|
||||
|
@ -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),
|
||||
|
|
|
@ -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<Node>,
|
||||
current_node: MutJS<Node>,
|
||||
current_node: MutDom<Node>,
|
||||
what_to_show: u32,
|
||||
#[ignore_heap_size_of = "function pointers and Rc<T> 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
|
||||
}
|
||||
|
|
|
@ -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<f64>,
|
||||
depth_far: Cell<f64>,
|
||||
presenting: Cell<bool>,
|
||||
left_eye_params: MutJS<VREyeParameters>,
|
||||
right_eye_params: MutJS<VREyeParameters>,
|
||||
capabilities: MutJS<VRDisplayCapabilities>,
|
||||
left_eye_params: MutDom<VREyeParameters>,
|
||||
right_eye_params: MutDom<VREyeParameters>,
|
||||
capabilities: MutDom<VRDisplayCapabilities>,
|
||||
stage_params: MutNullableJS<VRStageParameters>,
|
||||
#[ignore_heap_size_of = "Defined in rust-webvr"]
|
||||
frame_data: DOMRefCell<WebVRFrameData>,
|
||||
|
@ -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()),
|
||||
|
|
|
@ -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<JSVal>, Cell<Dom<T>>, DOMRefCell<Dom<T>>, DOMRefCell<HEAP<T>>
|
||||
(r"(\s|:)+Cell<JSVal>", "Banned type Cell<JSVal> detected. Use MutJS<JSVal> instead", no_filter),
|
||||
(r"(\s|:)+Cell<Dom<.+>>", "Banned type Cell<Dom<T>> detected. Use MutJS<T> instead", no_filter),
|
||||
(r"DOMRefCell<Dom<.+>>", "Banned type DOMRefCell<Dom<T>> detected. Use MutJS<T> instead", no_filter),
|
||||
(r"DOMRefCell<Heap<.+>>", "Banned type DOMRefCell<Heap<T>> detected. Use MutJS<T> instead", no_filter),
|
||||
(r"(\s|:)+Cell<JSVal>", "Banned type Cell<JSVal> detected. Use MutDom<JSVal> instead", no_filter),
|
||||
(r"(\s|:)+Cell<Dom<.+>>", "Banned type Cell<Dom<T>> detected. Use MutDom<T> instead", no_filter),
|
||||
(r"DOMRefCell<Dom<.+>>", "Banned type DOMRefCell<Dom<T>> detected. Use MutDom<T> instead", no_filter),
|
||||
(r"DOMRefCell<Heap<.+>>", "Banned type DOMRefCell<Heap<T>> detected. Use MutDom<T> instead", no_filter),
|
||||
# No benefit to using &Root<T>
|
||||
(r": &Root<", "use &T instead of &Root<T>", no_filter),
|
||||
(r"^&&", "operators should go at the end of the first line", no_filter),
|
||||
|
|
|
@ -13,7 +13,7 @@ use script::test::Node;
|
|||
|
||||
struct Foo {
|
||||
bar: DOMRefCell<Dom<Node>>
|
||||
//~^ ERROR Banned type DOMRefCell<Dom<T>> detected. Use MutJS<T> instead
|
||||
//~^ ERROR Banned type DOMRefCell<Dom<T>> detected. Use MutDom<T> instead
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::UnsafeCell;
|
|||
|
||||
struct Foo {
|
||||
bar: Cell<JSVal>,
|
||||
//~^ ERROR Banned type Cell<JSVal> detected. Use MutJS<JSVal> instead
|
||||
//~^ ERROR Banned type Cell<JSVal> detected. Use MutDom<JSVal> instead
|
||||
foo: UnsafeCell<JSVal>
|
||||
//~^ NOT AN ERROR
|
||||
}
|
||||
|
|
|
@ -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<JSVal> detected. Use MutJS<JSVal> instead', ban_errors.next()[2])
|
||||
self.assertEqual('Banned type Cell<JSVal> detected. Use MutDom<JSVal> 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<Dom<T>> detected. Use MutJS<T> instead', ban_errors.next()[2])
|
||||
self.assertEqual('Banned type DOMRefCell<Dom<T>> detected. Use MutDom<T> instead', ban_errors.next()[2])
|
||||
self.assertNoMoreErrors(ban_errors)
|
||||
|
||||
def test_spec_link(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue