mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Rename Root::root_ref() to Root::r().
As it will be used much more widely after the upcoming changes, this limits the effort reading and writing the method calls.
This commit is contained in:
parent
1290c18794
commit
c9f26dfd59
9 changed files with 28 additions and 28 deletions
|
@ -2307,7 +2307,7 @@ class CGPerSignatureCall(CGThing):
|
||||||
def process(arg, i):
|
def process(arg, i):
|
||||||
argVal = "arg" + str(i)
|
argVal = "arg" + str(i)
|
||||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||||
argVal += ".root_ref()"
|
argVal += ".r()"
|
||||||
return argVal
|
return argVal
|
||||||
return [(a, process(a, i)) for (i, a) in enumerate(self.arguments)]
|
return [(a, process(a, i)) for (i, a) in enumerate(self.arguments)]
|
||||||
|
|
||||||
|
@ -3540,7 +3540,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
||||||
def process(arg):
|
def process(arg):
|
||||||
argVal = arg.identifier.name
|
argVal = arg.identifier.name
|
||||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||||
argVal += ".root_ref()"
|
argVal += ".r()"
|
||||||
return argVal
|
return argVal
|
||||||
args = [(a, process(a)) for a in self.arguments]
|
args = [(a, process(a)) for a in self.arguments]
|
||||||
if self.idlNode.isGetter():
|
if self.idlNode.isGetter():
|
||||||
|
|
|
@ -103,8 +103,8 @@ impl GlobalRoot {
|
||||||
/// lifetime of this root.
|
/// lifetime of this root.
|
||||||
pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> {
|
pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRoot::Window(ref window) => GlobalRef::Window(window.root_ref()),
|
GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()),
|
||||||
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.root_ref()),
|
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
//! Both `Temporary<T>` and `JS<T>` do not allow access to their inner value without explicitly
|
//! Both `Temporary<T>` and `JS<T>` do not allow access to their inner value without explicitly
|
||||||
//! creating a stack-based root via the `root` method. This returns a `Root<T>`, which causes
|
//! creating a stack-based root via the `root` method. This returns a `Root<T>`, which causes
|
||||||
//! the JS-owned value to be uncollectable for the duration of the `Root` object's lifetime.
|
//! the JS-owned value to be uncollectable for the duration of the `Root` object's lifetime.
|
||||||
//! A `JSRef<T>` can be obtained from a `Root<T>` either by dereferencing the `Root<T>` (`*rooted`)
|
//! A `JSRef<T>` can be obtained from a `Root<T>` by calling the `r` method. (Dereferencing the
|
||||||
//! or explicitly calling the `root_ref` method. These `JSRef<T>` values are not allowed to
|
//! object is still supported, but as it is unsafe, this is deprecated.) These `JSRef<T>` values
|
||||||
//! outlive their originating `Root<T>`, to ensure that all interactions with the enclosed value
|
//! are not allowed to outlive their originating `Root<T>`, to ensure that all interactions with
|
||||||
//! only occur when said value is uncollectable, and will cause static lifetime errors if
|
//! the enclosed value only occur when said value is uncollectable, and will cause static lifetime
|
||||||
//! misused.
|
//! errors if misused.
|
||||||
//!
|
//!
|
||||||
//! Other miscellaneous helper traits:
|
//! Other miscellaneous helper traits:
|
||||||
//!
|
//!
|
||||||
|
@ -307,23 +307,23 @@ impl<From, To> JS<From> {
|
||||||
|
|
||||||
/// Get an `Option<JSRef<T>>` out of an `Option<Root<T>>`
|
/// Get an `Option<JSRef<T>>` out of an `Option<Root<T>>`
|
||||||
pub trait RootedReference<T> {
|
pub trait RootedReference<T> {
|
||||||
fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>>;
|
fn r<'a>(&'a self) -> Option<JSRef<'a, T>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
|
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
|
||||||
fn root_ref<'a>(&'a self) -> Option<JSRef<'a, T>> {
|
fn r<'a>(&'a self) -> Option<JSRef<'a, T>> {
|
||||||
self.as_ref().map(|root| root.root_ref())
|
self.as_ref().map(|root| root.r())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an `Option<Option<JSRef<T>>>` out of an `Option<Option<Root<T>>>`
|
/// Get an `Option<Option<JSRef<T>>>` out of an `Option<Option<Root<T>>>`
|
||||||
pub trait OptionalRootedReference<T> {
|
pub trait OptionalRootedReference<T> {
|
||||||
fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>;
|
fn r<'a>(&'a self) -> Option<Option<JSRef<'a, T>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<T>>> {
|
impl<T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<T>>> {
|
||||||
fn root_ref<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> {
|
fn r<'a>(&'a self) -> Option<Option<JSRef<'a, T>>> {
|
||||||
self.as_ref().map(|inner| inner.root_ref())
|
self.as_ref().map(|inner| inner.r())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ impl<T: Reflectable> Root<T> {
|
||||||
|
|
||||||
/// Obtain a safe reference to the wrapped JS owned-value that cannot outlive
|
/// Obtain a safe reference to the wrapped JS owned-value that cannot outlive
|
||||||
/// the lifetime of this root.
|
/// the lifetime of this root.
|
||||||
pub fn root_ref<'b>(&'b self) -> JSRef<'b,T> {
|
pub fn r<'b>(&'b self) -> JSRef<'b, T> {
|
||||||
self.jsref.clone()
|
self.jsref.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl DOMStringMap {
|
||||||
pub fn new(element: JSRef<HTMLElement>) -> Temporary<DOMStringMap> {
|
pub fn new(element: JSRef<HTMLElement>) -> Temporary<DOMStringMap> {
|
||||||
let window = window_from_node(element).root();
|
let window = window_from_node(element).root();
|
||||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||||
GlobalRef::Window(window.root_ref()), DOMStringMapBinding::Wrap)
|
GlobalRef::Window(window.r()), DOMStringMapBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&
|
||||||
let mut iter = unsafe {
|
let mut iter = unsafe {
|
||||||
doc_node.query_selector_iter("input[type=radio]".into_string()).unwrap()
|
doc_node.query_selector_iter("input[type=radio]".into_string()).unwrap()
|
||||||
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
||||||
.filter(|&r| in_same_group(r, owner.root_ref(), group) && broadcaster != r)
|
.filter(|&r| in_same_group(r, owner.r(), group) && broadcaster != r)
|
||||||
};
|
};
|
||||||
for r in iter {
|
for r in iter {
|
||||||
if r.Checked() {
|
if r.Checked() {
|
||||||
|
@ -326,7 +326,7 @@ fn in_same_group<'a,'b>(other: JSRef<'a, HTMLInputElement>,
|
||||||
owner: Option<JSRef<'b, HTMLFormElement>>,
|
owner: Option<JSRef<'b, HTMLFormElement>>,
|
||||||
group: Option<&str>) -> bool {
|
group: Option<&str>) -> bool {
|
||||||
let other_owner = other.form_owner().root();
|
let other_owner = other.form_owner().root();
|
||||||
let other_owner = other_owner.root_ref();
|
let other_owner = other_owner.r();
|
||||||
other.input_type.get() == InputType::InputRadio &&
|
other.input_type.get() == InputType::InputRadio &&
|
||||||
// TODO Both a and b are in the same home subtree.
|
// TODO Both a and b are in the same home subtree.
|
||||||
other_owner.equals(owner) &&
|
other_owner.equals(owner) &&
|
||||||
|
@ -638,7 +638,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
|
||||||
let checked_member = unsafe {
|
let checked_member = unsafe {
|
||||||
doc_node.query_selector_iter("input[type=radio]".into_string()).unwrap()
|
doc_node.query_selector_iter("input[type=radio]".into_string()).unwrap()
|
||||||
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
.filter_map(|t| HTMLInputElementCast::to_ref(t))
|
||||||
.filter(|&r| in_same_group(r, owner.root_ref(),
|
.filter(|&r| in_same_group(r, owner.r(),
|
||||||
group.as_ref().map(|gr| gr.as_slice())))
|
group.as_ref().map(|gr| gr.as_slice())))
|
||||||
.find(|r| r.Checked())
|
.find(|r| r.Checked())
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,7 +101,7 @@ impl KeyboardEvent {
|
||||||
let event = KeyboardEvent::new(global.as_window(), type_,
|
let event = KeyboardEvent::new(global.as_window(), type_,
|
||||||
init.parent.parent.parent.bubbles,
|
init.parent.parent.parent.bubbles,
|
||||||
init.parent.parent.parent.cancelable,
|
init.parent.parent.parent.cancelable,
|
||||||
init.parent.parent.view.root_ref(),
|
init.parent.parent.view.r(),
|
||||||
init.parent.parent.detail,
|
init.parent.parent.detail,
|
||||||
init.key.clone(), init.code.clone(), init.location,
|
init.key.clone(), init.code.clone(), init.location,
|
||||||
init.repeat, init.isComposing, init.parent.ctrlKey,
|
init.repeat, init.isComposing, init.parent.ctrlKey,
|
||||||
|
|
|
@ -92,12 +92,12 @@ impl MouseEvent {
|
||||||
let event = MouseEvent::new(global.as_window(), type_,
|
let event = MouseEvent::new(global.as_window(), type_,
|
||||||
init.parent.parent.parent.bubbles,
|
init.parent.parent.parent.bubbles,
|
||||||
init.parent.parent.parent.cancelable,
|
init.parent.parent.parent.cancelable,
|
||||||
init.parent.parent.view.root_ref(),
|
init.parent.parent.view.r(),
|
||||||
init.parent.parent.detail,
|
init.parent.parent.detail,
|
||||||
init.screenX, init.screenY,
|
init.screenX, init.screenY,
|
||||||
init.clientX, init.clientY, init.parent.ctrlKey,
|
init.clientX, init.clientY, init.parent.ctrlKey,
|
||||||
init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
|
init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
|
||||||
init.button, init.relatedTarget.root_ref());
|
init.button, init.relatedTarget.r());
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,10 +307,10 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
||||||
assert!(new_child.next_sibling().is_none());
|
assert!(new_child.next_sibling().is_none());
|
||||||
match before {
|
match before {
|
||||||
Some(ref before) => {
|
Some(ref before) => {
|
||||||
assert!(before.parent_node().root().root_ref() == Some(self));
|
assert!(before.parent_node().root().r() == Some(self));
|
||||||
match before.prev_sibling().root() {
|
match before.prev_sibling().root() {
|
||||||
None => {
|
None => {
|
||||||
assert!(Some(*before) == self.first_child().root().root_ref());
|
assert!(Some(*before) == self.first_child().root().r());
|
||||||
self.first_child.assign(Some(new_child));
|
self.first_child.assign(Some(new_child));
|
||||||
},
|
},
|
||||||
Some(prev_sibling) => {
|
Some(prev_sibling) => {
|
||||||
|
@ -342,7 +342,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
||||||
///
|
///
|
||||||
/// Fails unless `child` is a child of this node.
|
/// Fails unless `child` is a child of this node.
|
||||||
fn remove_child(self, child: JSRef<Node>) {
|
fn remove_child(self, child: JSRef<Node>) {
|
||||||
assert!(child.parent_node().root().root_ref() == Some(self));
|
assert!(child.parent_node().root().r() == Some(self));
|
||||||
|
|
||||||
match child.prev_sibling.get().root() {
|
match child.prev_sibling.get().root() {
|
||||||
None => {
|
None => {
|
||||||
|
@ -1811,7 +1811,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
}.root();
|
}.root();
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Node::replace_all(node.root_ref(), self);
|
Node::replace_all(node.r(), self);
|
||||||
}
|
}
|
||||||
NodeTypeId::Comment |
|
NodeTypeId::Comment |
|
||||||
NodeTypeId::Text |
|
NodeTypeId::Text |
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl UIEvent {
|
||||||
init: &UIEventBinding::UIEventInit) -> Fallible<Temporary<UIEvent>> {
|
init: &UIEventBinding::UIEventInit) -> Fallible<Temporary<UIEvent>> {
|
||||||
let event = UIEvent::new(global.as_window(), type_,
|
let event = UIEvent::new(global.as_window(), type_,
|
||||||
init.parent.bubbles, init.parent.cancelable,
|
init.parent.bubbles, init.parent.cancelable,
|
||||||
init.view.root_ref(), init.detail);
|
init.view.r(), init.detail);
|
||||||
Ok(event)
|
Ok(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue