refact: move create_image_bitmap to ImageBitmap Impl (#37348) (#37602)

This PR moves the `create_image_bitmap` method from `GlobalScope` to a
helper function within the `ImageBitmap` implementation in
`imagebitmap.rs`.

Moving this method improves code organization and maintainability. Given
that `globalscope.rs` is already quite large, relocating
`create_image_bitmap` to `imagebitmap.rs` places it closer to the
`ImageBitmap` struct it primarily operates on.

As mentioned in the issue description (No dedicated tests are required
for this change, as long as the project builds), which it does using
`./mach build`. Also ran `./mach fmt` and `./mach test-tidy` which both
didn't report any issue.

Closes #37348

Signed-off-by: Bhuwan Pandit <bhuwanpandit109@gmail.com>
This commit is contained in:
Bhuwan Pandit 2025-06-21 05:12:11 +01:00 committed by GitHub
parent 0832ec5d96
commit d7269c0f3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 409 additions and 390 deletions

View file

@ -152,7 +152,7 @@ use crate::dom::storage::Storage;
#[cfg(feature = "bluetooth")]
use crate::dom::testrunner::TestRunner;
use crate::dom::trustedtypepolicyfactory::TrustedTypePolicyFactory;
use crate::dom::types::UIEvent;
use crate::dom::types::{ImageBitmap, UIEvent};
use crate::dom::webglrenderingcontext::WebGLCommandSender;
#[cfg(feature = "webgpu")]
use crate::dom::webgpu::identityhub::IdentityHub;
@ -1209,9 +1209,16 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
options: &ImageBitmapOptions,
can_gc: CanGc,
) -> Rc<Promise> {
let p = self
.as_global_scope()
.create_image_bitmap(image, 0, 0, None, None, options, can_gc);
let p = ImageBitmap::create_image_bitmap(
self.as_global_scope(),
image,
0,
0,
None,
None,
options,
can_gc,
);
p
}
@ -1226,7 +1233,8 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
options: &ImageBitmapOptions,
can_gc: CanGc,
) -> Rc<Promise> {
let p = self.as_global_scope().create_image_bitmap(
let p = ImageBitmap::create_image_bitmap(
self.as_global_scope(),
image,
sx,
sy,