diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-03 19:55:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-03 18:55:01 +0000 |
commit | e8f75c9aea37d49d988f209281169af1fed05d8e (patch) | |
tree | feb84b30238157c296b83c8a04394c853d5052f6 /components/script/dom/htmliframeelement.rs | |
parent | 621ddd749c7655a93547f52a438f2e2941d7df15 (diff) | |
download | servo-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/htmliframeelement.rs')
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index c0b43296f22..5de8470b568 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -37,7 +37,7 @@ use crate::dom::element::{ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::htmlelement::HTMLElement; -use crate::dom::node::{document_from_node, window_from_node, Node, NodeDamage, UnbindContext}; +use crate::dom::node::{Node, NodeDamage, NodeTraits, UnbindContext}; use crate::dom::virtualmethods::VirtualMethods; use crate::dom::windowproxy::WindowProxy; use crate::script_runtime::CanGc; @@ -105,7 +105,7 @@ impl HTMLIFrameElement { if url.is_empty() { None } else { - document_from_node(self).base_url().join(&url).ok() + self.owner_document().base_url().join(&url).ok() } }) .unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap()) @@ -148,7 +148,7 @@ impl HTMLIFrameElement { Some(id) => id, }; - let document = document_from_node(self); + let document = self.owner_document(); { let load_blocker = &self.load_blocker; @@ -180,7 +180,7 @@ impl HTMLIFrameElement { }, }; - let window = window_from_node(self); + let window = self.owner_window(); let old_pipeline_id = self.pipeline_id(); let new_pipeline_id = PipelineId::new(); self.pending_pipeline_id.set(Some(new_pipeline_id)); @@ -256,8 +256,8 @@ impl HTMLIFrameElement { .has_attribute(&local_name!("srcdoc")) { let url = ServoUrl::parse("about:srcdoc").unwrap(); - let document = document_from_node(self); - let window = window_from_node(self); + let document = self.owner_document(); + let window = self.owner_window(); let pipeline_id = Some(window.upcast::<GlobalScope>().pipeline_id()); let mut load_data = LoadData::new( LoadOrigin::Script(document.origin().immutable().clone()), @@ -277,7 +277,7 @@ impl HTMLIFrameElement { return; } - let window = window_from_node(self); + let window = self.owner_window(); // https://html.spec.whatwg.org/multipage/#attr-iframe-name // Note: the spec says to set the name 'when the nested browsing context is created'. @@ -307,7 +307,7 @@ impl HTMLIFrameElement { // Step 2.4: Let referrerPolicy be the current state of element's referrerpolicy content // attribute. - let document = document_from_node(self); + let document = self.owner_document(); let referrer_policy_token = self.ReferrerPolicy(); // Note: despite not being explicitly stated in the spec steps, this falls back to @@ -390,8 +390,8 @@ impl HTMLIFrameElement { // compatible #4965](https://github.com/whatwg/html/issues/4965) // let url = ServoUrl::parse("about:blank").unwrap(); - let document = document_from_node(self); - let window = window_from_node(self); + let document = self.owner_document(); + let window = self.owner_window(); let pipeline_id = Some(window.upcast::<GlobalScope>().pipeline_id()); let load_data = LoadData::new( LoadOrigin::Script(document.origin().immutable().clone()), @@ -763,7 +763,7 @@ impl VirtualMethods for HTMLIFrameElement { LoadBlocker::terminate(blocker, CanGc::note()); // https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded - let window = window_from_node(self); + let window = self.owner_window(); let (sender, receiver) = ProfiledIpc::channel(self.global().time_profiler_chan().clone()).unwrap(); |