mirror of
https://github.com/servo/servo
synced 2026-04-30 19:37:43 +02: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:
@@ -942,7 +942,7 @@ pub(crate) enum ModuleOwner {
|
||||
}
|
||||
|
||||
impl ModuleOwner {
|
||||
pub fn global(&self) -> DomRoot<GlobalScope> {
|
||||
pub(crate) fn global(&self) -> DomRoot<GlobalScope> {
|
||||
match &self {
|
||||
ModuleOwner::Worker(worker) => (*worker.root().clone()).global(),
|
||||
ModuleOwner::Window(script) => (*script.root()).global(),
|
||||
|
||||
Reference in New Issue
Block a user