mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove most RootedReference uses
We can replace all uses of RootedReference for Option<T> by Option::deref calls.
This commit is contained in:
parent
7bdfad92a5
commit
5fe5e5d6de
34 changed files with 186 additions and 185 deletions
|
@ -6,7 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
|
|||
use crate::dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::customelementregistry::CallbackReaction;
|
||||
use crate::dom::element::{AttributeMutation, Element};
|
||||
|
@ -194,7 +194,7 @@ impl Attr {
|
|||
ScriptThread::enqueue_callback_reaction(owner, reaction, None);
|
||||
}
|
||||
|
||||
assert_eq!(Some(owner), self.owner().r());
|
||||
assert_eq!(Some(owner), self.owner().deref());
|
||||
owner.will_mutate_attr(self);
|
||||
self.swap_value(&mut value);
|
||||
if self.identifier.namespace == ns!() {
|
||||
|
@ -227,7 +227,7 @@ impl Attr {
|
|||
match (self.owner(), owner) {
|
||||
(Some(old), None) => {
|
||||
// Already gone from the list of attributes of old owner.
|
||||
assert!(old.get_attribute(&ns, &self.identifier.local_name).r() != Some(self))
|
||||
assert!(old.get_attribute(&ns, &self.identifier.local_name).deref() != Some(self))
|
||||
},
|
||||
(Some(old), Some(new)) => assert_eq!(&*old, new),
|
||||
_ => {},
|
||||
|
|
|
@ -7250,8 +7250,10 @@ def camel_to_upper_snake(s):
|
|||
|
||||
def process_arg(expr, arg):
|
||||
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
|
||||
if arg.type.nullable() or arg.type.isSequence() or arg.optional:
|
||||
if arg.variadic or arg.type.isSequence() or arg.type.nullable() and arg.optional:
|
||||
expr += ".r()"
|
||||
elif arg.type.nullable() or arg.optional:
|
||||
expr += ".deref()"
|
||||
else:
|
||||
expr = "&" + expr
|
||||
elif isinstance(arg.type, IDLPromiseType):
|
||||
|
|
|
@ -42,7 +42,6 @@ use std::marker::PhantomData;
|
|||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use style::thread_state;
|
||||
|
||||
/// A rooted value.
|
||||
|
@ -272,13 +271,6 @@ impl<'root, T: DomObject + 'root> RootedReference<'root> for DomRoot<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'root, T: DomObject + 'root> RootedReference<'root> for Dom<T> {
|
||||
type Ref = &'root T;
|
||||
fn r(&'root self) -> &'root T {
|
||||
&self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [Dom<T>] {
|
||||
type Ref = &'root [&'root T];
|
||||
fn r(&'root self) -> &'root [&'root T] {
|
||||
|
@ -286,13 +278,6 @@ impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [Dom<
|
|||
}
|
||||
}
|
||||
|
||||
impl<'root, T: DomObject + 'root> RootedReference<'root> for Rc<T> {
|
||||
type Ref = &'root T;
|
||||
fn r(&'root self) -> &'root T {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'root, T: RootedReference<'root> + 'root> RootedReference<'root> for Option<T> {
|
||||
type Ref = Option<T::Ref>;
|
||||
fn r(&'root self) -> Option<T::Ref> {
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMe
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bluetoothdevice::BluetoothDevice;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
|
@ -80,7 +80,6 @@ impl BluetoothAdvertisingEvent {
|
|||
init: &BluetoothAdvertisingEventInit,
|
||||
) -> Fallible<DomRoot<BluetoothAdvertisingEvent>> {
|
||||
let global = window.upcast::<GlobalScope>();
|
||||
let device = init.device.r();
|
||||
let name = init.name.clone();
|
||||
let appearance = init.appearance.clone();
|
||||
let txPower = init.txPower.clone();
|
||||
|
@ -92,7 +91,7 @@ impl BluetoothAdvertisingEvent {
|
|||
Atom::from(type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
device,
|
||||
&init.device,
|
||||
name,
|
||||
appearance,
|
||||
txPower,
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::CompositionEventBinding::{
|
|||
use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods;
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::uievent::UIEvent;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -53,7 +53,7 @@ impl CompositionEvent {
|
|||
type_,
|
||||
init.parent.parent.bubbles,
|
||||
init.parent.parent.cancelable,
|
||||
init.parent.view.r(),
|
||||
init.parent.view.deref(),
|
||||
init.parent.detail,
|
||||
init.data.clone(),
|
||||
);
|
||||
|
|
|
@ -640,7 +640,7 @@ impl Document {
|
|||
.upcast::<Element>()
|
||||
.has_attribute(&local_name!("href"))
|
||||
});
|
||||
self.base_element.set(base.r());
|
||||
self.base_element.set(base.deref());
|
||||
}
|
||||
|
||||
pub fn dom_count(&self) -> u32 {
|
||||
|
@ -766,7 +766,7 @@ impl Document {
|
|||
{
|
||||
let mut id_map = self.id_map.borrow_mut();
|
||||
let elements = id_map.entry(id.clone()).or_insert(Vec::new());
|
||||
elements.insert_pre_order(element, root.r().upcast::<Node>());
|
||||
elements.insert_pre_order(element, root.upcast::<Node>());
|
||||
}
|
||||
self.reset_form_owner_for_listeners(&id);
|
||||
}
|
||||
|
@ -817,10 +817,10 @@ impl Document {
|
|||
let target = self.find_fragment_node(fragment);
|
||||
|
||||
// Step 1
|
||||
self.set_target_element(target.r());
|
||||
self.set_target_element(target.deref());
|
||||
|
||||
let point = target
|
||||
.r()
|
||||
.as_ref()
|
||||
.map(|element| {
|
||||
// FIXME(#8275, pcwalton): This is pretty bogus when multiple layers are involved.
|
||||
// Really what needs to happen is that this needs to go through layout to ask which
|
||||
|
@ -858,7 +858,7 @@ impl Document {
|
|||
y,
|
||||
global_scope.pipeline_id().root_scroll_id(),
|
||||
ScrollBehavior::Instant,
|
||||
target.r(),
|
||||
target.deref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ impl Document {
|
|||
/// Reassign the focus context to the element that last requested focus during this
|
||||
/// transaction, or none if no elements requested it.
|
||||
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
|
||||
if self.focused == self.possibly_focused.get().r() {
|
||||
if self.focused == self.possibly_focused.get().deref() {
|
||||
return;
|
||||
}
|
||||
if let Some(ref elem) = self.focused.get() {
|
||||
|
@ -937,7 +937,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
self.focused.set(self.possibly_focused.get().r());
|
||||
self.focused.set(self.possibly_focused.get().deref());
|
||||
|
||||
if let Some(ref elem) = self.focused.get() {
|
||||
elem.set_focus_state(true);
|
||||
|
@ -1265,7 +1265,7 @@ impl Document {
|
|||
}
|
||||
|
||||
// Store the current mouse over target for next frame.
|
||||
prev_mouse_over_target.set(maybe_new_target.r());
|
||||
prev_mouse_over_target.set(maybe_new_target.deref());
|
||||
|
||||
self.window
|
||||
.reflow(ReflowGoal::Full, ReflowReason::MouseEvent);
|
||||
|
@ -2859,7 +2859,7 @@ impl Document {
|
|||
|
||||
fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> DomRoot<NodeList> {
|
||||
let doc = self.GetDocumentElement();
|
||||
let maybe_node = doc.r().map(Castable::upcast::<Node>);
|
||||
let maybe_node = doc.deref().map(Castable::upcast::<Node>);
|
||||
let iter = maybe_node
|
||||
.iter()
|
||||
.flat_map(|node| node.traverse_preorder())
|
||||
|
@ -3140,7 +3140,7 @@ impl Document {
|
|||
// https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
|
||||
pub fn enter_fullscreen(&self, pending: &Element) -> Rc<Promise> {
|
||||
// Step 1
|
||||
let promise = Promise::new(self.global().r());
|
||||
let promise = Promise::new(&self.global());
|
||||
let mut error = false;
|
||||
|
||||
// Step 4
|
||||
|
@ -3211,7 +3211,7 @@ impl Document {
|
|||
pub fn exit_fullscreen(&self) -> Rc<Promise> {
|
||||
let global = self.global();
|
||||
// Step 1
|
||||
let promise = Promise::new(global.r());
|
||||
let promise = Promise::new(&global);
|
||||
// Step 2
|
||||
if self.fullscreen_element.get().is_none() {
|
||||
promise.reject_error(Error::Type(String::from("fullscreen is null")));
|
||||
|
@ -3228,7 +3228,7 @@ impl Document {
|
|||
self.send_to_embedder(event);
|
||||
|
||||
// Step 9
|
||||
let trusted_element = Trusted::new(element.r());
|
||||
let trusted_element = Trusted::new(&*element);
|
||||
let trusted_promise = TrustedPromise::new(promise.clone());
|
||||
let handler = ElementPerformFullscreenExit::new(trusted_element, trusted_promise);
|
||||
let pipeline_id = Some(global.pipeline_id());
|
||||
|
@ -3275,7 +3275,6 @@ impl Document {
|
|||
if let Some(listeners) = map.get(id) {
|
||||
for listener in listeners {
|
||||
listener
|
||||
.r()
|
||||
.as_maybe_form_control()
|
||||
.expect("Element must be a form control")
|
||||
.reset_form_owner();
|
||||
|
@ -3841,7 +3840,7 @@ impl DocumentMethods for Document {
|
|||
let parent = root.upcast::<Node>();
|
||||
let child = elem.upcast::<Node>();
|
||||
parent
|
||||
.InsertBefore(child, parent.GetFirstChild().r())
|
||||
.InsertBefore(child, parent.GetFirstChild().deref())
|
||||
.unwrap()
|
||||
},
|
||||
}
|
||||
|
@ -3926,7 +3925,7 @@ impl DocumentMethods for Document {
|
|||
|
||||
// Step 2.
|
||||
let old_body = self.GetBody();
|
||||
if old_body.r() == Some(new_body) {
|
||||
if old_body.deref() == Some(new_body) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::bindings::xmlname::XMLName::InvalidXMLName;
|
||||
use crate::dom::bindings::xmlname::{
|
||||
|
@ -1292,7 +1292,7 @@ impl Element {
|
|||
ScriptThread::enqueue_callback_reaction(self, reaction, None);
|
||||
}
|
||||
|
||||
assert!(attr.GetOwnerElement().r() == Some(self));
|
||||
assert!(attr.GetOwnerElement().deref() == Some(self));
|
||||
self.will_mutate_attr(attr);
|
||||
self.attrs.borrow_mut().push(Dom::from_ref(attr));
|
||||
if attr.namespace() == &ns!() {
|
||||
|
@ -1607,12 +1607,12 @@ impl Element {
|
|||
}
|
||||
},
|
||||
AdjacentPosition::AfterBegin => {
|
||||
Node::pre_insert(node, &self_node, self_node.GetFirstChild().r()).map(Some)
|
||||
Node::pre_insert(node, &self_node, self_node.GetFirstChild().deref()).map(Some)
|
||||
},
|
||||
AdjacentPosition::BeforeEnd => Node::pre_insert(node, &self_node, None).map(Some),
|
||||
AdjacentPosition::AfterEnd => {
|
||||
if let Some(parent) = self_node.GetParentNode() {
|
||||
Node::pre_insert(node, &parent, self_node.GetNextSibling().r()).map(Some)
|
||||
Node::pre_insert(node, &parent, self_node.GetNextSibling().deref()).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -1652,7 +1652,7 @@ impl Element {
|
|||
}
|
||||
|
||||
// Step 9
|
||||
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
|
||||
if doc.GetBody().deref() == self.downcast::<HTMLElement>() &&
|
||||
doc.quirks_mode() == QuirksMode::Quirks &&
|
||||
!self.potentially_scrollable()
|
||||
{
|
||||
|
@ -2121,7 +2121,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// Step 7
|
||||
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
|
||||
if doc.GetBody().deref() == self.downcast::<HTMLElement>() &&
|
||||
doc.quirks_mode() == QuirksMode::Quirks &&
|
||||
!self.potentially_scrollable()
|
||||
{
|
||||
|
@ -2171,7 +2171,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// Step 9
|
||||
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
|
||||
if doc.GetBody().deref() == self.downcast::<HTMLElement>() &&
|
||||
doc.quirks_mode() == QuirksMode::Quirks &&
|
||||
!self.potentially_scrollable()
|
||||
{
|
||||
|
@ -2217,7 +2217,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// Step 7
|
||||
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
|
||||
if doc.GetBody().deref() == self.downcast::<HTMLElement>() &&
|
||||
doc.quirks_mode() == QuirksMode::Quirks &&
|
||||
!self.potentially_scrollable()
|
||||
{
|
||||
|
@ -2268,7 +2268,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// Step 9
|
||||
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
|
||||
if doc.GetBody().deref() == self.downcast::<HTMLElement>() &&
|
||||
doc.quirks_mode() == QuirksMode::Quirks &&
|
||||
!self.potentially_scrollable()
|
||||
{
|
||||
|
@ -2737,7 +2737,7 @@ impl VirtualMethods for Element {
|
|||
|
||||
let doc = document_from_node(self);
|
||||
let fullscreen = doc.GetFullscreenElement();
|
||||
if fullscreen.r() == Some(self) {
|
||||
if fullscreen.deref() == Some(self) {
|
||||
doc.exit_fullscreen();
|
||||
}
|
||||
if let Some(ref value) = *self.id_attribute.borrow() {
|
||||
|
@ -3392,7 +3392,7 @@ impl TaskOnce for ElementPerformFullscreenEnter {
|
|||
fn run_once(self) {
|
||||
let element = self.element.root();
|
||||
let promise = self.promise.root();
|
||||
let document = document_from_node(element.r());
|
||||
let document = document_from_node(&*element);
|
||||
|
||||
// Step 7.1
|
||||
if self.error || !element.fullscreen_element_ready_check() {
|
||||
|
@ -3442,7 +3442,7 @@ impl TaskOnce for ElementPerformFullscreenExit {
|
|||
#[allow(unrooted_must_root)]
|
||||
fn run_once(self) {
|
||||
let element = self.element.root();
|
||||
let document = document_from_node(element.r());
|
||||
let document = document_from_node(&*element);
|
||||
// TODO Step 9.1-5
|
||||
// Step 9.6
|
||||
element.set_fullscreen_state(false);
|
||||
|
|
|
@ -477,7 +477,12 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
|
|||
|
||||
// Step 6.
|
||||
for object in event_path.iter().rev() {
|
||||
invoke(window.r(), object, event, Some(ListenerPhase::Capturing));
|
||||
invoke(
|
||||
window.deref(),
|
||||
object,
|
||||
event,
|
||||
Some(ListenerPhase::Capturing),
|
||||
);
|
||||
if event.stop_propagation.get() {
|
||||
return;
|
||||
}
|
||||
|
@ -489,7 +494,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
|
|||
event.phase.set(EventPhase::AtTarget);
|
||||
|
||||
// Step 8.
|
||||
invoke(window.r(), target, event, None);
|
||||
invoke(window.deref(), target, event, None);
|
||||
if event.stop_propagation.get() {
|
||||
return;
|
||||
}
|
||||
|
@ -505,7 +510,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
|
|||
|
||||
// Step 9.2.
|
||||
for object in event_path {
|
||||
invoke(window.r(), object, event, Some(ListenerPhase::Bubbling));
|
||||
invoke(window.deref(), object, event, Some(ListenerPhase::Bubbling));
|
||||
if event.stop_propagation.get() {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::{EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
|
@ -72,9 +72,9 @@ impl FocusEvent {
|
|||
type_,
|
||||
bubbles,
|
||||
cancelable,
|
||||
init.parent.view.r(),
|
||||
init.parent.view.deref(),
|
||||
init.parent.detail,
|
||||
init.relatedTarget.r(),
|
||||
init.relatedTarget.deref(),
|
||||
);
|
||||
Ok(event)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use crate::dom::bindings::error::{Error, ErrorResult};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
use crate::dom::document::{Document, FocusType};
|
||||
|
@ -694,7 +694,7 @@ impl HTMLElement {
|
|||
.take_while(|elem| !elem.is_labelable_element())
|
||||
.filter_map(DomRoot::downcast::<HTMLLabelElement>)
|
||||
.filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for")))
|
||||
.filter(|elem| elem.first_labelable_descendant().r() == Some(self))
|
||||
.filter(|elem| elem.first_labelable_descendant().deref() == Some(self))
|
||||
.map(DomRoot::upcast::<Node>);
|
||||
|
||||
let id = element.Id();
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTex
|
|||
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::{Dom, DomOnceCell, DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomOnceCell, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::blob::Blob;
|
||||
use crate::dom::document::Document;
|
||||
|
@ -817,7 +817,7 @@ impl HTMLFormElement {
|
|||
|
||||
fn add_control<T: ?Sized + FormControl>(&self, control: &T) {
|
||||
let root = self.upcast::<Element>().root_element();
|
||||
let root = root.r().upcast::<Node>();
|
||||
let root = root.upcast::<Node>();
|
||||
|
||||
let mut controls = self.controls.borrow_mut();
|
||||
controls.insert_pre_order(control.to_element(), root);
|
||||
|
@ -828,7 +828,7 @@ impl HTMLFormElement {
|
|||
let mut controls = self.controls.borrow_mut();
|
||||
controls
|
||||
.iter()
|
||||
.position(|c| c.r() == control)
|
||||
.position(|c| &**c == control)
|
||||
.map(|idx| controls.remove(idx));
|
||||
}
|
||||
}
|
||||
|
@ -1072,11 +1072,10 @@ pub trait FormControl: DomObject {
|
|||
if let Some(o) = old_owner {
|
||||
o.remove_control(self);
|
||||
}
|
||||
let new_owner = new_owner.as_ref().map(|o| {
|
||||
o.add_control(self);
|
||||
o.r()
|
||||
});
|
||||
self.set_form_owner(new_owner);
|
||||
if let Some(ref new_owner) = new_owner {
|
||||
new_owner.add_control(self);
|
||||
}
|
||||
self.set_form_owner(new_owner.deref());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLHeadElementBinding;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::document::{determine_policy_for_token, Document};
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
|
@ -49,7 +49,7 @@ impl HTMLHeadElement {
|
|||
pub fn set_document_referrer(&self) {
|
||||
let doc = document_from_node(self);
|
||||
|
||||
if doc.GetHead().r() != Some(self) {
|
||||
if doc.GetHead().deref() != Some(self) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ impl HTMLHeadElement {
|
|||
});
|
||||
|
||||
for meta in candidates {
|
||||
if let Some(content) = meta.get_attribute(&ns!(), &local_name!("content")).r() {
|
||||
if let Some(ref content) = meta.get_attribute(&ns!(), &local_name!("content")) {
|
||||
let content = content.value();
|
||||
let content_val = content.trim();
|
||||
if !content_val.is_empty() {
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding::KeyboardEvent
|
|||
use crate::dom::bindings::error::{Error, ErrorResult};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::compositionevent::CompositionEvent;
|
||||
use crate::dom::document::Document;
|
||||
|
@ -903,7 +903,7 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>)
|
|||
}
|
||||
}
|
||||
|
||||
do_broadcast(doc.upcast(), broadcaster, owner.r(), group)
|
||||
do_broadcast(doc.upcast(), broadcaster, owner.deref(), group)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#radio-button-group
|
||||
|
@ -914,7 +914,7 @@ fn in_same_group(
|
|||
) -> bool {
|
||||
other.input_type() == InputType::Radio &&
|
||||
// TODO Both a and b are in the same home subtree.
|
||||
other.form_owner().r() == owner &&
|
||||
other.form_owner().deref() == owner &&
|
||||
match (other.radio_group_name(), group) {
|
||||
(Some(ref s1), Some(s2)) => compatibility_caseless_match_str(s1, s2) && s2 != &atom!(""),
|
||||
_ => false
|
||||
|
@ -1629,8 +1629,8 @@ impl Activatable for HTMLInputElement {
|
|||
.query_selector_iter(DOMString::from("input[type=radio]"))
|
||||
.unwrap()
|
||||
.filter_map(DomRoot::downcast::<HTMLInputElement>)
|
||||
.find(|r| in_same_group(&*r, owner.r(), group.as_ref()) && r.Checked());
|
||||
cache.checked_radio = checked_member.r().map(Dom::from_ref);
|
||||
.find(|r| in_same_group(&*r, owner.deref(), group.as_ref()) && r.Checked());
|
||||
cache.checked_radio = checked_member.deref().map(Dom::from_ref);
|
||||
cache.checked_changed = self.checked_changed.get();
|
||||
self.SetChecked(true);
|
||||
},
|
||||
|
@ -1666,22 +1666,21 @@ impl Activatable for HTMLInputElement {
|
|||
InputType::Radio => {
|
||||
// We want to restore state only if the element had been changed in the first place
|
||||
if cache.was_mutable {
|
||||
match cache.checked_radio.r() {
|
||||
Some(o) => {
|
||||
// Avoiding iterating through the whole tree here, instead
|
||||
// we can check if the conditions for radio group siblings apply
|
||||
if in_same_group(
|
||||
&o,
|
||||
self.form_owner().r(),
|
||||
self.radio_group_name().as_ref(),
|
||||
) {
|
||||
o.SetChecked(true);
|
||||
} else {
|
||||
self.SetChecked(false);
|
||||
}
|
||||
},
|
||||
None => self.SetChecked(false),
|
||||
};
|
||||
if let Some(ref o) = cache.checked_radio {
|
||||
// Avoiding iterating through the whole tree here, instead
|
||||
// we can check if the conditions for radio group siblings apply
|
||||
if in_same_group(
|
||||
&o,
|
||||
self.form_owner().deref(),
|
||||
self.radio_group_name().as_ref(),
|
||||
) {
|
||||
o.SetChecked(true);
|
||||
} else {
|
||||
self.SetChecked(false);
|
||||
}
|
||||
} else {
|
||||
self.SetChecked(false);
|
||||
}
|
||||
self.checked_changed.set(cache.checked_changed);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListBi
|
|||
use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||
use crate::dom::document::Document;
|
||||
|
@ -285,7 +285,7 @@ impl HTMLLinkElement {
|
|||
let cors_setting = cors_setting_for_element(element);
|
||||
|
||||
let mq_attribute = element.get_attribute(&ns!(), &local_name!("media"));
|
||||
let value = mq_attribute.r().map(|a| a.value());
|
||||
let value = mq_attribute.as_ref().map(|a| a.value());
|
||||
let mq_str = match value {
|
||||
Some(ref value) => &***value,
|
||||
None => "",
|
||||
|
@ -309,7 +309,7 @@ impl HTMLLinkElement {
|
|||
let media = MediaList::parse(&context, &mut css_parser);
|
||||
|
||||
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
|
||||
let integrity_val = im_attribute.r().map(|a| a.value());
|
||||
let integrity_val = im_attribute.as_ref().map(|a| a.value());
|
||||
let integrity_metadata = match integrity_val {
|
||||
Some(ref value) => &***value,
|
||||
None => "",
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding;
|
|||
use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||
use crate::dom::document::Document;
|
||||
|
@ -83,7 +83,7 @@ impl HTMLMetaElement {
|
|||
|
||||
fn process_attributes(&self) {
|
||||
let element = self.upcast::<Element>();
|
||||
if let Some(name) = element.get_attribute(&ns!(), &local_name!("name")).r() {
|
||||
if let Some(ref name) = element.get_attribute(&ns!(), &local_name!("name")) {
|
||||
let name = name.value().to_ascii_lowercase();
|
||||
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
||||
|
||||
|
@ -106,7 +106,7 @@ impl HTMLMetaElement {
|
|||
return;
|
||||
}
|
||||
let element = self.upcast::<Element>();
|
||||
if let Some(content) = element.get_attribute(&ns!(), &local_name!("content")).r() {
|
||||
if let Some(ref content) = element.get_attribute(&ns!(), &local_name!("content")) {
|
||||
let content = content.value();
|
||||
if !content.is_empty() {
|
||||
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
|
||||
|
@ -136,7 +136,7 @@ impl HTMLMetaElement {
|
|||
|
||||
fn process_referrer_attribute(&self) {
|
||||
let element = self.upcast::<Element>();
|
||||
if let Some(name) = element.get_attribute(&ns!(), &local_name!("name")).r() {
|
||||
if let Some(ref name) = element.get_attribute(&ns!(), &local_name!("name")) {
|
||||
let name = name.value().to_ascii_lowercase();
|
||||
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::codegen::UnionTypes::{
|
|||
use crate::dom::bindings::error::{Error, ErrorResult};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
||||
|
@ -185,14 +185,14 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
|
|||
});
|
||||
|
||||
// Step 5
|
||||
let parent = if let Some(reference_node) = reference_node.r() {
|
||||
let parent = if let Some(ref reference_node) = reference_node {
|
||||
reference_node.GetParentNode().unwrap()
|
||||
} else {
|
||||
root
|
||||
};
|
||||
|
||||
// Step 6
|
||||
Node::pre_insert(node, &parent, reference_node.r()).map(|_| ())
|
||||
Node::pre_insert(node, &parent, reference_node.deref()).map(|_| ())
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-remove
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{
|
||||
|
@ -409,8 +409,8 @@ impl HTMLScriptElement {
|
|||
// Step 13.
|
||||
let for_attribute = element.get_attribute(&ns!(), &local_name!("for"));
|
||||
let event_attribute = element.get_attribute(&ns!(), &local_name!("event"));
|
||||
match (for_attribute.r(), event_attribute.r()) {
|
||||
(Some(for_attribute), Some(event_attribute)) => {
|
||||
match (for_attribute, event_attribute) {
|
||||
(Some(ref for_attribute), Some(ref event_attribute)) => {
|
||||
let for_value = for_attribute.value().to_ascii_lowercase();
|
||||
let for_value = for_value.trim_matches(HTML_SPACE_CHARACTERS);
|
||||
if for_value != "window" {
|
||||
|
@ -441,7 +441,7 @@ impl HTMLScriptElement {
|
|||
|
||||
// Step 18: Integrity metadata.
|
||||
let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
|
||||
let integrity_val = im_attribute.r().map(|a| a.value());
|
||||
let integrity_val = im_attribute.as_ref().map(|a| a.value());
|
||||
let integrity_metadata = match integrity_val {
|
||||
Some(ref value) => &***value,
|
||||
None => "",
|
||||
|
@ -619,7 +619,7 @@ impl HTMLScriptElement {
|
|||
self.run_a_classic_script(&script);
|
||||
|
||||
// Step 6.
|
||||
document.set_current_script(old_script.r());
|
||||
document.set_current_script(old_script.deref());
|
||||
|
||||
// Step 7.
|
||||
if let Some(doc) = neutralized_doc {
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableE
|
|||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
|
@ -119,7 +119,7 @@ impl HTMLTableElement {
|
|||
|
||||
if let Some(section) = section {
|
||||
let reference_element = node.child_elements().find(reference_predicate);
|
||||
let reference_node = reference_element.r().map(|e| e.upcast());
|
||||
let reference_node = reference_element.as_ref().map(|e| e.upcast());
|
||||
|
||||
node.InsertBefore(section.upcast(), reference_node)?;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
|
||||
if let Some(caption) = new_caption {
|
||||
let node = self.upcast::<Node>();
|
||||
node.InsertBefore(caption.upcast(), node.GetFirstChild().r())
|
||||
node.InsertBefore(caption.upcast(), node.GetFirstChild().deref())
|
||||
.expect("Insertion failed");
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
fn filter(&self, elem: &Element, root: &Node) -> bool {
|
||||
elem.is::<HTMLTableSectionElement>() &&
|
||||
elem.local_name() == &local_name!("tbody") &&
|
||||
elem.upcast::<Node>().GetParentNode().r() == Some(root)
|
||||
elem.upcast::<Node>().GetParentNode().deref() == Some(root)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
.find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody"));
|
||||
let reference_element = last_tbody.and_then(|t| t.upcast::<Node>().GetNextSibling());
|
||||
|
||||
node.InsertBefore(tbody.upcast(), reference_element.r())
|
||||
node.InsertBefore(tbody.upcast(), reference_element.deref())
|
||||
.expect("Insertion failed");
|
||||
tbody
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTM
|
|||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use crate::dom::bindings::error::{ErrorResult, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
|
@ -31,7 +31,7 @@ struct CellsFilter;
|
|||
impl CollectionFilter for CellsFilter {
|
||||
fn filter(&self, elem: &Element, root: &Node) -> bool {
|
||||
(elem.is::<HTMLTableCellElement>()) &&
|
||||
elem.upcast::<Node>().GetParentNode().r() == Some(root)
|
||||
elem.upcast::<Node>().GetParentNode().deref() == Some(root)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{
|
|||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use crate::dom::bindings::error::{ErrorResult, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, LayoutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{Element, RawLayoutElementHelpers};
|
||||
|
@ -58,7 +58,8 @@ impl HTMLTableSectionElement {
|
|||
struct RowsFilter;
|
||||
impl CollectionFilter for RowsFilter {
|
||||
fn filter(&self, elem: &Element, root: &Node) -> bool {
|
||||
elem.is::<HTMLTableRowElement>() && elem.upcast::<Node>().GetParentNode().r() == Some(root)
|
||||
elem.is::<HTMLTableRowElement>() &&
|
||||
elem.upcast::<Node>().GetParentNode().deref() == Some(root)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEven
|
|||
use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods;
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::uievent::UIEvent;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -54,7 +54,7 @@ impl InputEvent {
|
|||
type_,
|
||||
init.parent.parent.bubbles,
|
||||
init.parent.parent.cancelable,
|
||||
init.parent.view.r(),
|
||||
init.parent.view.deref(),
|
||||
init.parent.detail,
|
||||
init.data.clone(),
|
||||
init.isComposing,
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::Event;
|
||||
use crate::dom::uievent::UIEvent;
|
||||
|
@ -111,7 +111,7 @@ impl KeyboardEvent {
|
|||
type_,
|
||||
init.parent.parent.parent.bubbles,
|
||||
init.parent.parent.parent.cancelable,
|
||||
init.parent.parent.view.r(),
|
||||
init.parent.parent.view.deref(),
|
||||
init.parent.parent.detail,
|
||||
Key::Unidentified,
|
||||
init.code.clone(),
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
|
@ -115,7 +115,7 @@ impl MouseEvent {
|
|||
type_,
|
||||
bubbles,
|
||||
cancelable,
|
||||
init.parent.parent.view.r(),
|
||||
init.parent.parent.view.deref(),
|
||||
init.parent.parent.detail,
|
||||
init.screenX,
|
||||
init.screenY,
|
||||
|
@ -126,7 +126,7 @@ impl MouseEvent {
|
|||
init.parent.shiftKey,
|
||||
init.parent.metaKey,
|
||||
init.button,
|
||||
init.relatedTarget.r(),
|
||||
init.relatedTarget.deref(),
|
||||
None,
|
||||
);
|
||||
Ok(event)
|
||||
|
|
|
@ -230,11 +230,11 @@ impl Node {
|
|||
assert!(new_child.next_sibling.get().is_none());
|
||||
match before {
|
||||
Some(ref before) => {
|
||||
assert!(before.parent_node.get().r() == Some(self));
|
||||
assert!(before.parent_node.get().deref() == Some(self));
|
||||
let prev_sibling = before.GetPreviousSibling();
|
||||
match prev_sibling {
|
||||
None => {
|
||||
assert!(Some(*before) == self.first_child.get().r());
|
||||
assert!(self.first_child.get().deref() == Some(*before));
|
||||
self.first_child.set(Some(new_child));
|
||||
},
|
||||
Some(ref prev_sibling) => {
|
||||
|
@ -276,27 +276,36 @@ impl Node {
|
|||
///
|
||||
/// Fails unless `child` is a child of this node.
|
||||
fn remove_child(&self, child: &Node, cached_index: Option<u32>) {
|
||||
assert!(child.parent_node.get().r() == Some(self));
|
||||
assert!(child.parent_node.get().deref() == Some(self));
|
||||
let prev_sibling = child.GetPreviousSibling();
|
||||
match prev_sibling {
|
||||
None => {
|
||||
self.first_child.set(child.next_sibling.get().r());
|
||||
self.first_child.set(child.next_sibling.get().deref());
|
||||
},
|
||||
Some(ref prev_sibling) => {
|
||||
prev_sibling.next_sibling.set(child.next_sibling.get().r());
|
||||
prev_sibling
|
||||
.next_sibling
|
||||
.set(child.next_sibling.get().deref());
|
||||
},
|
||||
}
|
||||
let next_sibling = child.GetNextSibling();
|
||||
match next_sibling {
|
||||
None => {
|
||||
self.last_child.set(child.prev_sibling.get().r());
|
||||
self.last_child.set(child.prev_sibling.get().deref());
|
||||
},
|
||||
Some(ref next_sibling) => {
|
||||
next_sibling.prev_sibling.set(child.prev_sibling.get().r());
|
||||
next_sibling
|
||||
.prev_sibling
|
||||
.set(child.prev_sibling.get().deref());
|
||||
},
|
||||
}
|
||||
|
||||
let context = UnbindContext::new(self, prev_sibling.r(), next_sibling.r(), cached_index);
|
||||
let context = UnbindContext::new(
|
||||
self,
|
||||
prev_sibling.deref(),
|
||||
next_sibling.deref(),
|
||||
cached_index,
|
||||
);
|
||||
|
||||
child.prev_sibling.set(None);
|
||||
child.next_sibling.set(None);
|
||||
|
@ -678,7 +687,7 @@ impl Node {
|
|||
document != window.Document(),
|
||||
is_body_element,
|
||||
document.quirks_mode(),
|
||||
html_element.r() == self.downcast::<Element>(),
|
||||
html_element.deref() == self.downcast::<Element>(),
|
||||
) {
|
||||
// Step 2 && Step 5
|
||||
(true, _, _, _) | (_, false, QuirksMode::Quirks, true) => Rect::zero(),
|
||||
|
@ -725,7 +734,7 @@ impl Node {
|
|||
};
|
||||
|
||||
// Step 6.
|
||||
Node::pre_insert(&node, &parent, viable_previous_sibling.r())?;
|
||||
Node::pre_insert(&node, &parent, viable_previous_sibling.deref())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -748,7 +757,7 @@ impl Node {
|
|||
let node = self.owner_doc().node_from_nodes_and_strings(nodes)?;
|
||||
|
||||
// Step 5.
|
||||
Node::pre_insert(&node, &parent, viable_next_sibling.r())?;
|
||||
Node::pre_insert(&node, &parent, viable_next_sibling.deref())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -771,7 +780,7 @@ impl Node {
|
|||
parent.ReplaceChild(&node, self)?;
|
||||
} else {
|
||||
// Step 6.
|
||||
Node::pre_insert(&node, &parent, viable_next_sibling.r())?;
|
||||
Node::pre_insert(&node, &parent, viable_next_sibling.deref())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -783,7 +792,7 @@ impl Node {
|
|||
let node = doc.node_from_nodes_and_strings(nodes)?;
|
||||
// Step 2.
|
||||
let first_child = self.first_child.get();
|
||||
Node::pre_insert(&node, self, first_child.r()).map(|_| ())
|
||||
Node::pre_insert(&node, self, first_child.deref()).map(|_| ())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
||||
|
@ -968,7 +977,7 @@ impl Node {
|
|||
None => return Err(Error::IndexSize),
|
||||
Some(node) => node,
|
||||
};
|
||||
self.InsertBefore(tr_node, node.r())?;
|
||||
self.InsertBefore(tr_node, node.deref())?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1676,7 @@ impl Node {
|
|||
let reference_child = match child {
|
||||
Some(child) if child == node => {
|
||||
reference_child_root = node.GetNextSibling();
|
||||
reference_child_root.r()
|
||||
reference_child_root.deref()
|
||||
},
|
||||
_ => child,
|
||||
};
|
||||
|
@ -1697,7 +1706,7 @@ impl Node {
|
|||
) {
|
||||
node.owner_doc().add_script_and_layout_blocker();
|
||||
debug_assert!(&*node.owner_doc() == &*parent.owner_doc());
|
||||
debug_assert!(child.map_or(true, |child| Some(parent) == child.GetParentNode().r()));
|
||||
debug_assert!(child.map_or(true, |child| Some(parent) == child.GetParentNode().deref()));
|
||||
|
||||
// Step 1.
|
||||
let count = if node.is::<DocumentFragment>() {
|
||||
|
@ -1718,8 +1727,8 @@ impl Node {
|
|||
// Step 3.
|
||||
new_nodes.extend(node.children().map(|kid| Dom::from_ref(&*kid)));
|
||||
// Step 4.
|
||||
for kid in new_nodes.r() {
|
||||
Node::remove(*kid, node, SuppressObserver::Suppressed);
|
||||
for kid in &*new_nodes {
|
||||
Node::remove(kid, node, SuppressObserver::Suppressed);
|
||||
}
|
||||
// Step 5.
|
||||
vtable_for(&node).children_changed(&ChildrenMutation::replace_all(new_nodes.r(), &[]));
|
||||
|
@ -1772,7 +1781,7 @@ impl Node {
|
|||
}
|
||||
if let SuppressObserver::Unsuppressed = suppress_observers {
|
||||
vtable_for(&parent).children_changed(&ChildrenMutation::insert(
|
||||
previous_sibling.r(),
|
||||
previous_sibling.deref(),
|
||||
new_nodes,
|
||||
child,
|
||||
));
|
||||
|
@ -1780,7 +1789,7 @@ impl Node {
|
|||
let mutation = Mutation::ChildList {
|
||||
added: Some(new_nodes),
|
||||
removed: None,
|
||||
prev: previous_sibling.r(),
|
||||
prev: previous_sibling.deref(),
|
||||
next: child,
|
||||
};
|
||||
MutationObserver::queue_a_mutation_record(&parent, mutation);
|
||||
|
@ -1810,8 +1819,8 @@ impl Node {
|
|||
&[] as &[&Node]
|
||||
};
|
||||
// Step 4.
|
||||
for child in removed_nodes.r() {
|
||||
Node::remove(*child, parent, SuppressObserver::Suppressed);
|
||||
for child in &*removed_nodes {
|
||||
Node::remove(child, parent, SuppressObserver::Suppressed);
|
||||
}
|
||||
// Step 5.
|
||||
if let Some(node) = node {
|
||||
|
@ -1883,18 +1892,18 @@ impl Node {
|
|||
// Step 12.
|
||||
if let SuppressObserver::Unsuppressed = suppress_observers {
|
||||
vtable_for(&parent).children_changed(&ChildrenMutation::replace(
|
||||
old_previous_sibling.r(),
|
||||
old_previous_sibling.deref(),
|
||||
&Some(&node),
|
||||
&[],
|
||||
old_next_sibling.r(),
|
||||
old_next_sibling.deref(),
|
||||
));
|
||||
|
||||
let removed = [node];
|
||||
let mutation = Mutation::ChildList {
|
||||
added: None,
|
||||
removed: Some(&removed),
|
||||
prev: old_previous_sibling.r(),
|
||||
next: old_next_sibling.r(),
|
||||
prev: old_previous_sibling.deref(),
|
||||
next: old_next_sibling.deref(),
|
||||
};
|
||||
MutationObserver::queue_a_mutation_record(&parent, mutation);
|
||||
}
|
||||
|
@ -2204,7 +2213,7 @@ impl NodeMethods for Node {
|
|||
};
|
||||
|
||||
// Step 3.
|
||||
Node::replace_all(node.r(), self);
|
||||
Node::replace_all(node.deref(), self);
|
||||
},
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
let characterdata = self.downcast::<CharacterData>().unwrap();
|
||||
|
@ -2308,10 +2317,10 @@ impl NodeMethods for Node {
|
|||
// Step 7-8.
|
||||
let child_next_sibling = child.GetNextSibling();
|
||||
let node_next_sibling = node.GetNextSibling();
|
||||
let reference_child = if child_next_sibling.r() == Some(node) {
|
||||
node_next_sibling.r()
|
||||
let reference_child = if child_next_sibling.deref() == Some(node) {
|
||||
node_next_sibling.deref()
|
||||
} else {
|
||||
child_next_sibling.r()
|
||||
child_next_sibling.deref()
|
||||
};
|
||||
|
||||
// Step 9.
|
||||
|
@ -2343,7 +2352,7 @@ impl NodeMethods for Node {
|
|||
|
||||
// Step 14.
|
||||
vtable_for(&self).children_changed(&ChildrenMutation::replace(
|
||||
previous_sibling.r(),
|
||||
previous_sibling.deref(),
|
||||
&removed_child,
|
||||
nodes,
|
||||
reference_child,
|
||||
|
@ -2352,7 +2361,7 @@ impl NodeMethods for Node {
|
|||
let mutation = Mutation::ChildList {
|
||||
added: Some(nodes),
|
||||
removed: removed.as_ref().map(|r| &r[..]),
|
||||
prev: previous_sibling.r(),
|
||||
prev: previous_sibling.deref(),
|
||||
next: reference_child,
|
||||
};
|
||||
MutationObserver::queue_a_mutation_record(&self, mutation);
|
||||
|
@ -3014,7 +3023,7 @@ where
|
|||
if head_node == node {
|
||||
head += 1;
|
||||
}
|
||||
if elem_node == node.r() || head == self.len() {
|
||||
if elem_node == &*node || head == self.len() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use crate::dom::bindings::codegen::Bindings::NodeListBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::node::{ChildrenMutation, Node};
|
||||
use crate::dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -132,7 +132,7 @@ impl ChildrenList {
|
|||
let last_visited = node.GetFirstChild();
|
||||
ChildrenList {
|
||||
node: Dom::from_ref(node),
|
||||
last_visited: MutNullableDom::new(last_visited.r()),
|
||||
last_visited: MutNullableDom::new(last_visited.deref()),
|
||||
last_index: Cell::new(0u32),
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ impl ChildrenList {
|
|||
}
|
||||
|
||||
fn reset(&self) {
|
||||
self.last_visited.set(self.node.GetFirstChild().r());
|
||||
self.last_visited.set(self.node.GetFirstChild().deref());
|
||||
self.last_index.set(0u32);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding:
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::window::Window;
|
||||
|
@ -59,7 +59,7 @@ impl OfflineAudioCompletionEvent {
|
|||
Atom::from(type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
init.renderedBuffer.r(),
|
||||
&init.renderedBuffer,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::JSTraceable;
|
||||
use crate::dom::bindings::weakref::{WeakRef, WeakRefVec};
|
||||
|
@ -730,7 +730,7 @@ impl RangeMethods for Range {
|
|||
};
|
||||
|
||||
// Step 6.
|
||||
Node::ensure_pre_insertion_validity(node, &parent, reference_node.r())?;
|
||||
Node::ensure_pre_insertion_validity(node, &parent, reference_node.deref())?;
|
||||
|
||||
// Step 7.
|
||||
let split_text;
|
||||
|
@ -738,14 +738,14 @@ impl RangeMethods for Range {
|
|||
Some(text) => {
|
||||
split_text = text.SplitText(start_offset)?;
|
||||
let new_reference = DomRoot::upcast::<Node>(split_text);
|
||||
assert!(new_reference.GetParentNode().r() == Some(&parent));
|
||||
assert!(new_reference.GetParentNode().deref() == Some(&parent));
|
||||
Some(new_reference)
|
||||
},
|
||||
_ => reference_node,
|
||||
};
|
||||
|
||||
// Step 8.
|
||||
let reference_node = if Some(node) == reference_node.r() {
|
||||
let reference_node = if Some(node) == reference_node.deref() {
|
||||
node.GetNextSibling()
|
||||
} else {
|
||||
reference_node
|
||||
|
@ -755,7 +755,9 @@ impl RangeMethods for Range {
|
|||
node.remove_self();
|
||||
|
||||
// Step 10.
|
||||
let new_offset = reference_node.r().map_or(parent.len(), |node| node.index());
|
||||
let new_offset = reference_node
|
||||
.as_ref()
|
||||
.map_or(parent.len(), |node| node.index());
|
||||
|
||||
// Step 11
|
||||
let new_offset = new_offset +
|
||||
|
@ -766,7 +768,7 @@ impl RangeMethods for Range {
|
|||
};
|
||||
|
||||
// Step 12.
|
||||
Node::pre_insert(node, &parent, reference_node.r())?;
|
||||
Node::pre_insert(node, &parent, reference_node.deref())?;
|
||||
|
||||
// Step 13.
|
||||
if self.Collapsed() {
|
||||
|
@ -842,7 +844,7 @@ impl RangeMethods for Range {
|
|||
}
|
||||
|
||||
// Step 8.
|
||||
for child in contained_children.r() {
|
||||
for child in &*contained_children {
|
||||
child.remove_self();
|
||||
}
|
||||
|
||||
|
@ -959,7 +961,7 @@ impl RangeMethods for Range {
|
|||
};
|
||||
|
||||
// Step 2.
|
||||
let element = Element::fragment_parsing_context(&owner_doc, element.r());
|
||||
let element = Element::fragment_parsing_context(&owner_doc, element.deref());
|
||||
|
||||
// Step 3.
|
||||
let fragment_node = element.parse_fragment(fragment)?;
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::dom::bindings::codegen::Bindings::ServoParserBinding;
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::settings_stack::is_execution_stack_empty;
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::characterdata::CharacterData;
|
||||
|
@ -203,7 +203,7 @@ impl ServoParser {
|
|||
|
||||
let fragment_context = FragmentContext {
|
||||
context_elem: context_node,
|
||||
form_elem: form.r(),
|
||||
form_elem: form.deref(),
|
||||
};
|
||||
|
||||
let parser = ServoParser::new(
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMe
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::storage::Storage;
|
||||
|
@ -91,7 +91,7 @@ impl StorageEvent {
|
|||
let oldValue = init.oldValue.clone();
|
||||
let newValue = init.newValue.clone();
|
||||
let url = init.url.clone();
|
||||
let storageArea = init.storageArea.r();
|
||||
let storageArea = init.storageArea.deref();
|
||||
let bubbles = EventBubbles::from(init.parent.bubbles);
|
||||
let cancelable = EventCancelable::from(init.parent.cancelable);
|
||||
let event = StorageEvent::new(
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods};
|
|||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::{DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::characterdata::CharacterData;
|
||||
use crate::dom::document::Document;
|
||||
|
@ -68,7 +68,7 @@ impl TextMethods for Text {
|
|||
if let Some(ref parent) = parent {
|
||||
// Step 7.1.
|
||||
parent
|
||||
.InsertBefore(new_node.upcast(), node.GetNextSibling().r())
|
||||
.InsertBefore(new_node.upcast(), node.GetNextSibling().deref())
|
||||
.unwrap();
|
||||
// Steps 7.2-3.
|
||||
node.ranges()
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
|
|||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::window::Window;
|
||||
|
@ -73,7 +73,7 @@ impl UIEvent {
|
|||
type_,
|
||||
bubbles,
|
||||
cancelable,
|
||||
init.view.r(),
|
||||
init.view.deref(),
|
||||
init.detail,
|
||||
);
|
||||
Ok(event)
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::dom::bindings::error::{throw_dom_exception, Error};
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
|
||||
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::JSTraceable;
|
||||
use crate::dom::bindings::utils::{get_array_index_from_id, AsVoidPtr, WindowProxyHandler};
|
||||
|
@ -488,7 +488,7 @@ impl WindowProxy {
|
|||
}
|
||||
|
||||
pub fn frame_element(&self) -> Option<&Element> {
|
||||
self.frame_element.r()
|
||||
self.frame_element.deref()
|
||||
}
|
||||
|
||||
pub fn document(&self) -> Option<DomRoot<Document>> {
|
||||
|
@ -498,7 +498,7 @@ impl WindowProxy {
|
|||
}
|
||||
|
||||
pub fn parent(&self) -> Option<&WindowProxy> {
|
||||
self.parent.r()
|
||||
self.parent.deref()
|
||||
}
|
||||
|
||||
pub fn top(&self) -> &WindowProxy {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#![cfg_attr(feature = "unstable", feature(on_unimplemented))]
|
||||
#![feature(const_fn)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(inner_deref)]
|
||||
#![feature(plugin)]
|
||||
#![feature(type_alias_enum_variants)]
|
||||
#![deny(unsafe_code)]
|
||||
|
|
|
@ -33,8 +33,8 @@ use crate::dom::bindings::conversions::{
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::ThreadLocalStackRoots;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootCollection};
|
||||
use crate::dom::bindings::root::{RootedReference, ThreadLocalStackRoots};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::structuredclone::StructuredCloneData;
|
||||
use crate::dom::bindings::trace::JSTraceable;
|
||||
|
@ -2196,7 +2196,7 @@ impl ScriptThread {
|
|||
pipeline_id
|
||||
);
|
||||
},
|
||||
Some(window) => window.History().r().activate_state(history_state_id, url),
|
||||
Some(window) => window.History().activate_state(history_state_id, url),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2212,7 +2212,7 @@ impl ScriptThread {
|
|||
pipeline_id
|
||||
);
|
||||
},
|
||||
Some(window) => window.History().r().remove_states(history_states),
|
||||
Some(window) => window.History().remove_states(history_states),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2655,7 +2655,7 @@ impl ScriptThread {
|
|||
global_to_clone,
|
||||
browsing_context_id,
|
||||
top_level_browsing_context_id,
|
||||
parent.r(),
|
||||
parent.deref(),
|
||||
opener,
|
||||
);
|
||||
self.window_proxies
|
||||
|
@ -2701,8 +2701,8 @@ impl ScriptThread {
|
|||
&window,
|
||||
browsing_context_id,
|
||||
top_level_browsing_context_id,
|
||||
iframe.r().map(Castable::upcast),
|
||||
parent.r(),
|
||||
iframe.deref().map(Castable::upcast),
|
||||
parent.deref(),
|
||||
opener,
|
||||
);
|
||||
self.window_proxies
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue