mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
script: Expose NodeTraits::owner_global
/ Window::as_global_scope
(#34843)
Expose two new helpers and start using them as much as possible. - `NodeTraits::owner_global`: which gets the `GlobalScope` that currenty owns a `Node`. This may be different than `.global()` in the case that the `Node` was adopted by a different `Document`. - `Window::as_global_scope`: A helper to avoid having to cast so much when treating a `Window` like a `GlobalScope`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
17e2ca3f01
commit
e42b4b793d
33 changed files with 262 additions and 258 deletions
|
@ -20,7 +20,7 @@ use crate::dom::htmlareaelement::HTMLAreaElement;
|
|||
use crate::dom::htmlformelement::HTMLFormElement;
|
||||
use crate::dom::htmllinkelement::HTMLLinkElement;
|
||||
use crate::dom::node::NodeTraits;
|
||||
use crate::dom::types::{Element, GlobalScope};
|
||||
use crate::dom::types::Element;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
@ -412,12 +412,12 @@ pub fn follow_hyperlink(
|
|||
let referrer = if relations.contains(LinkRelations::NO_REFERRER) {
|
||||
Referrer::NoReferrer
|
||||
} else {
|
||||
target_window.upcast::<GlobalScope>().get_referrer()
|
||||
target_window.as_global_scope().get_referrer()
|
||||
};
|
||||
|
||||
// Step 14
|
||||
let pipeline_id = target_window.upcast::<GlobalScope>().pipeline_id();
|
||||
let secure = target_window.upcast::<GlobalScope>().is_secure_context();
|
||||
let pipeline_id = target_window.as_global_scope().pipeline_id();
|
||||
let secure = target_window.as_global_scope().is_secure_context();
|
||||
let load_data = LoadData::new(
|
||||
LoadOrigin::Script(document.origin().immutable().clone()),
|
||||
url,
|
||||
|
@ -431,7 +431,8 @@ pub fn follow_hyperlink(
|
|||
debug!("following hyperlink to {}", load_data.url);
|
||||
target.root().load_url(history_handling, false, load_data, CanGc::note());
|
||||
});
|
||||
target_window
|
||||
target_document
|
||||
.owner_global()
|
||||
.task_manager()
|
||||
.dom_manipulation_task_source()
|
||||
.queue(task);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue