Replace CanGc::note() calls with arguments in components/script/dom (#33692)

* Replace CanGc::note() calls with arguments in components/script/dom

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Add methods to Bindings.conf

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Modify existing interface sections

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Resolve conflicts

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-08 18:28:09 +05:30 committed by GitHub
parent 38c5ebbf8e
commit 39133a5478
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 53 additions and 31 deletions

View file

@ -382,28 +382,31 @@ fn get_element_in_view_center_point(element: &Element) -> Option<Point2D<i64>> {
.and_then(|body| {
// Step 1: Let rectangle be the first element of the DOMRect sequence
// returned by calling getClientRects() on element.
element.GetClientRects().first().map(|rectangle| {
let x = rectangle.X().round() as i64;
let y = rectangle.Y().round() as i64;
let width = rectangle.Width().round() as i64;
let height = rectangle.Height().round() as i64;
element
.GetClientRects(CanGc::note())
.first()
.map(|rectangle| {
let x = rectangle.X().round() as i64;
let y = rectangle.Y().round() as i64;
let width = rectangle.Width().round() as i64;
let height = rectangle.Height().round() as i64;
let client_width = body.ClientWidth() as i64;
let client_height = body.ClientHeight() as i64;
let client_width = body.ClientWidth() as i64;
let client_height = body.ClientHeight() as i64;
// Steps 2 - 5
let left = cmp::max(0, cmp::min(x, x + width));
let right = cmp::min(client_width, cmp::max(x, x + width));
let top = cmp::max(0, cmp::min(y, y + height));
let bottom = cmp::min(client_height, cmp::max(y, y + height));
// Steps 2 - 5
let left = cmp::max(0, cmp::min(x, x + width));
let right = cmp::min(client_width, cmp::max(x, x + width));
let top = cmp::max(0, cmp::min(y, y + height));
let bottom = cmp::min(client_height, cmp::max(y, y + height));
// Steps 6 - 7
let x = (left + right) / 2;
let y = (top + bottom) / 2;
// Steps 6 - 7
let x = (left + right) / 2;
let y = (top + bottom) / 2;
// Step 8
Point2D::new(x, y)
})
// Step 8
Point2D::new(x, y)
})
})
}
@ -930,7 +933,7 @@ pub fn handle_get_bounding_client_rect(
.downcast::<Element>(
) {
Some(element) => {
let rect = element.GetBoundingClientRect();
let rect = element.GetBoundingClientRect(CanGc::note());
Ok(Rect::new(
Point2D::new(rect.X() as f32, rect.Y() as f32),
Size2D::new(rect.Width() as f32, rect.Height() as f32),