diff options
author | tanishka <109246904+taniishkaaa@users.noreply.github.com> | 2024-10-08 18:28:09 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 12:58:09 +0000 |
commit | 39133a547846ead67be0d8ad7dac026cb318dd2d (patch) | |
tree | 492a179407739778fa73f2d0791d6217568f4556 /components/script/webdriver_handlers.rs | |
parent | 38c5ebbf8e52aebe5155c80fa1ea4da81838d7de (diff) | |
download | servo-39133a547846ead67be0d8ad7dac026cb318dd2d.tar.gz servo-39133a547846ead67be0d8ad7dac026cb318dd2d.zip |
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>
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r-- | components/script/webdriver_handlers.rs | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index a5d957d9f44..e43c2047490 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -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; - - 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 6 - 7 - let x = (left + right) / 2; - let y = (top + bottom) / 2; - - // Step 8 - Point2D::new(x, y) - }) + 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; + + // 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; + + // 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), |