mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
script: Expose node helpers as NodeTraits
and give more descriptive names (#34832)
This puts a few commonly used `Node` helpers into a trait (`NodeTraits`) and gives them more descriptive names and documentation. The renames: - `document_from_node` -> `NodeTraits::owner_document` - `window_from_node` -> `NodeTraits::owner_window` - `stylesheets_owner_from_node<T:` -> `NodeTraits::stylesheet_list_owner` - `containing_shadow_root` -> `NodeTraits::containing_shadow_root` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
621ddd749c
commit
e8f75c9aea
66 changed files with 415 additions and 426 deletions
|
@ -26,7 +26,7 @@ use crate::dom::htmltablecaptionelement::HTMLTableCaptionElement;
|
|||
use crate::dom::htmltablecolelement::HTMLTableColElement;
|
||||
use crate::dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use crate::dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use crate::dom::node::{document_from_node, window_from_node, Node};
|
||||
use crate::dom::node::{Node, NodeTraits};
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
|
@ -149,13 +149,8 @@ impl HTMLTableElement {
|
|||
return section;
|
||||
}
|
||||
|
||||
let section = HTMLTableSectionElement::new(
|
||||
atom.clone(),
|
||||
None,
|
||||
&document_from_node(self),
|
||||
None,
|
||||
can_gc,
|
||||
);
|
||||
let section =
|
||||
HTMLTableSectionElement::new(atom.clone(), None, &self.owner_document(), None, can_gc);
|
||||
match *atom {
|
||||
local_name!("thead") => self.SetTHead(Some(§ion)),
|
||||
local_name!("tfoot") => self.SetTFoot(Some(§ion)),
|
||||
|
@ -192,7 +187,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-table-rows
|
||||
fn Rows(&self) -> DomRoot<HTMLCollection> {
|
||||
let filter = self.get_rows();
|
||||
HTMLCollection::new(&window_from_node(self), self.upcast(), Box::new(filter))
|
||||
HTMLCollection::new(&self.owner_window(), self.upcast(), Box::new(filter))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
||||
|
@ -225,7 +220,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
|
|||
let caption = HTMLTableCaptionElement::new(
|
||||
local_name!("caption"),
|
||||
None,
|
||||
&document_from_node(self),
|
||||
&self.owner_document(),
|
||||
None,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -302,7 +297,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
|
|||
fn TBodies(&self) -> DomRoot<HTMLCollection> {
|
||||
self.tbodies.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&window_from_node(self),
|
||||
&self.owner_window(),
|
||||
self.upcast(),
|
||||
|element, root| {
|
||||
element.is::<HTMLTableSectionElement>() &&
|
||||
|
@ -318,7 +313,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
|
|||
let tbody = HTMLTableSectionElement::new(
|
||||
local_name!("tbody"),
|
||||
None,
|
||||
&document_from_node(self),
|
||||
&self.owner_document(),
|
||||
None,
|
||||
can_gc,
|
||||
);
|
||||
|
@ -346,7 +341,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
|
|||
let new_row = HTMLTableRowElement::new(
|
||||
local_name!("tr"),
|
||||
None,
|
||||
&document_from_node(self),
|
||||
&self.owner_document(),
|
||||
None,
|
||||
can_gc,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue