aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmllinkelement.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2025-01-03 19:55:01 +0100
committerGitHub <noreply@github.com>2025-01-03 18:55:01 +0000
commite8f75c9aea37d49d988f209281169af1fed05d8e (patch)
treefeb84b30238157c296b83c8a04394c853d5052f6 /components/script/dom/htmllinkelement.rs
parent621ddd749c7655a93547f52a438f2e2941d7df15 (diff)
downloadservo-e8f75c9aea37d49d988f209281169af1fed05d8e.tar.gz
servo-e8f75c9aea37d49d988f209281169af1fed05d8e.zip
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>
Diffstat (limited to 'components/script/dom/htmllinkelement.rs')
-rw-r--r--components/script/dom/htmllinkelement.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index f34f508c71c..9f6e34dccfc 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -47,10 +47,7 @@ use crate::dom::element::{
ElementCreator,
};
use crate::dom::htmlelement::HTMLElement;
-use crate::dom::node::{
- document_from_node, stylesheets_owner_from_node, window_from_node, BindContext, Node,
- UnbindContext,
-};
+use crate::dom::node::{BindContext, Node, NodeTraits, UnbindContext};
use crate::dom::performanceresourcetiming::InitiatorType;
use crate::dom::stylesheet::StyleSheet as DOMStyleSheet;
use crate::dom::virtualmethods::VirtualMethods;
@@ -160,7 +157,7 @@ impl HTMLLinkElement {
// HTMLStyleElement::set_stylesheet.
#[allow(crown::unrooted_must_root)]
pub fn set_stylesheet(&self, s: Arc<Stylesheet>) {
- let stylesheets_owner = stylesheets_owner_from_node(self);
+ let stylesheets_owner = self.stylesheet_list_owner();
if let Some(ref s) = *self.stylesheet.borrow() {
stylesheets_owner.remove_stylesheet(self.upcast(), s)
}
@@ -177,7 +174,7 @@ impl HTMLLinkElement {
self.get_stylesheet().map(|sheet| {
self.cssom_stylesheet.or_init(|| {
CSSStyleSheet::new(
- &window_from_node(self),
+ &self.owner_window(),
self.upcast::<Element>(),
"text/css".into(),
None, // todo handle location
@@ -298,7 +295,8 @@ impl VirtualMethods for HTMLLinkElement {
if let Some(s) = self.stylesheet.borrow_mut().take() {
self.clean_stylesheet_ownership();
- stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s);
+ self.stylesheet_list_owner()
+ .remove_stylesheet(self.upcast(), &s);
}
}
}
@@ -391,7 +389,7 @@ impl HTMLLinkElement {
/// <https://html.spec.whatwg.org/multipage/#concept-link-obtain>
fn handle_stylesheet_url(&self, href: &str) {
- let document = document_from_node(self);
+ let document = self.owner_document();
if document.browsing_context().is_none() {
return;
}
@@ -463,7 +461,7 @@ impl HTMLLinkElement {
}
fn handle_favicon_url(&self, href: &str, _sizes: &Option<String>) {
- let document = document_from_node(self);
+ let document = self.owner_document();
match document.base_url().join(href) {
Ok(url) => {
let window = document.window();