diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-07 10:56:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-07 09:56:02 +0000 |
commit | e42b4b793d52e756e79c8a408b3f7e99219493f5 (patch) | |
tree | 1346ec6841f8e37b00018c836a29fb227f026d41 /components/script/dom/htmlimageelement.rs | |
parent | 17e2ca3f013e2ff8e7d7bca08d93c6c723a2b71d (diff) | |
download | servo-e42b4b793d52e756e79c8a408b3f7e99219493f5.tar.gz servo-e42b4b793d52e756e79c8a408b3f7e99219493f5.zip |
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>
Diffstat (limited to 'components/script/dom/htmlimageelement.rs')
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 274faf873f0..ac6a7ae5a7d 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -881,8 +881,9 @@ impl HTMLImageElement { /// Step 8-12 of html.spec.whatwg.org/multipage/#update-the-image-data fn update_the_image_data_sync_steps(&self, can_gc: CanGc) { let document = self.owner_document(); - let window = document.window(); - let task_source = window.task_manager().dom_manipulation_task_source(); + let global = self.owner_global(); + let task_manager = global.task_manager(); + let task_source = task_manager.dom_manipulation_task_source(); let this = Trusted::new(self); let (src, pixel_density) = match self.select_image_source() { // Step 8 @@ -1014,8 +1015,10 @@ impl HTMLImageElement { let this = Trusted::new(self); let src = src.0; - window.task_manager().dom_manipulation_task_source().queue( - task!(image_load_event: move || { + self.owner_global() + .task_manager() + .dom_manipulation_task_source() + .queue(task!(image_load_event: move || { let this = this.root(); { let mut current_request = @@ -1025,8 +1028,7 @@ impl HTMLImageElement { } // TODO: restart animation, if set. this.upcast::<EventTarget>().fire_event(atom!("load"), CanGc::note()); - }), - ); + })); return; } } @@ -1062,7 +1064,7 @@ impl HTMLImageElement { let trusted_node = Trusted::new(elem); let (responder_sender, responder_receiver) = ipc::channel().unwrap(); let task_source = elem - .owner_window() + .owner_global() .task_manager() .networking_task_source() .to_sendable(); @@ -1240,9 +1242,8 @@ impl HTMLImageElement { selected_pixel_density: f64, ) { let this = Trusted::new(self); - let window = self.owner_window(); let src = src.0; - window.task_manager().dom_manipulation_task_source().queue( + self.owner_global().task_manager().dom_manipulation_task_source().queue( task!(image_load_event: move || { let this = this.root(); let relevant_mutation = this.generation.get() != generation; |