mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rename Root<T> to DomRoot<T>
In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>, where Root<T> will be able to handle all the things that need to be rooted that have a stable traceable address that doesn't move for the whole lifetime of the root. Stay tuned.
This commit is contained in:
parent
577370746e
commit
f87c2a8d76
291 changed files with 1774 additions and 1770 deletions
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::error::{Error, ErrorResult};
|
||||
use dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::root::{Dom, MutNullableDom, Root, RootedReference};
|
||||
use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
use dom::document::{Document, FocusType};
|
||||
|
@ -61,7 +61,7 @@ impl HTMLElement {
|
|||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Root<HTMLElement> {
|
||||
pub fn new(local_name: LocalName, prefix: Option<Prefix>, document: &Document) -> DomRoot<HTMLElement> {
|
||||
Node::reflect_node(box HTMLElement::new_inherited(local_name, prefix, document),
|
||||
document,
|
||||
HTMLElementBinding::Wrap)
|
||||
|
@ -111,7 +111,7 @@ impl HTMLElement {
|
|||
|
||||
impl HTMLElementMethods for HTMLElement {
|
||||
// https://html.spec.whatwg.org/multipage/#the-style-attribute
|
||||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||
fn Style(&self) -> DomRoot<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
let global = window_from_node(self);
|
||||
CSSStyleDeclaration::new(&global,
|
||||
|
@ -143,7 +143,7 @@ impl HTMLElementMethods for HTMLElement {
|
|||
document_and_element_event_handlers!();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-dataset
|
||||
fn Dataset(&self) -> Root<DOMStringMap> {
|
||||
fn Dataset(&self) -> DomRoot<DOMStringMap> {
|
||||
self.dataset.or_init(|| DOMStringMap::new(self))
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ impl HTMLElementMethods for HTMLElement {
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
|
||||
fn GetOffsetParent(&self) -> Option<Root<Element>> {
|
||||
fn GetOffsetParent(&self) -> Option<DomRoot<Element>> {
|
||||
if self.is::<HTMLBodyElement>() || self.is::<HTMLHtmlElement>() {
|
||||
return None;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ impl HTMLElement {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-lfe-labels
|
||||
pub fn labels(&self) -> Root<NodeList> {
|
||||
pub fn labels(&self) -> DomRoot<NodeList> {
|
||||
debug_assert!(self.is_labelable_element());
|
||||
|
||||
let element = self.upcast::<Element>();
|
||||
|
@ -514,14 +514,14 @@ impl HTMLElement {
|
|||
let ancestors =
|
||||
self.upcast::<Node>()
|
||||
.ancestors()
|
||||
.filter_map(Root::downcast::<HTMLElement>)
|
||||
.filter_map(DomRoot::downcast::<HTMLElement>)
|
||||
// If we reach a labelable element, we have a guarantee no ancestors above it
|
||||
// will be a label for this HTMLElement
|
||||
.take_while(|elem| !elem.is_labelable_element())
|
||||
.filter_map(Root::downcast::<HTMLLabelElement>)
|
||||
.filter_map(DomRoot::downcast::<HTMLLabelElement>)
|
||||
.filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for")))
|
||||
.filter(|elem| elem.first_labelable_descendant().r() == Some(self))
|
||||
.map(Root::upcast::<Node>);
|
||||
.map(DomRoot::upcast::<Node>);
|
||||
|
||||
let id = element.Id();
|
||||
let id = match &id as &str {
|
||||
|
@ -533,10 +533,10 @@ impl HTMLElement {
|
|||
let root_element = element.root_element();
|
||||
let root_node = root_element.upcast::<Node>();
|
||||
let children = root_node.traverse_preorder()
|
||||
.filter_map(Root::downcast::<Element>)
|
||||
.filter_map(DomRoot::downcast::<Element>)
|
||||
.filter(|elem| elem.is::<HTMLLabelElement>())
|
||||
.filter(|elem| elem.get_string_attribute(&local_name!("for")) == id)
|
||||
.map(Root::upcast::<Node>);
|
||||
.map(DomRoot::upcast::<Node>);
|
||||
|
||||
NodeList::new_simple_list(&window, children.chain(ancestors))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue