@@ -900,24 +900,35 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
900
900
901
901
// 3. Return a DOMRectList object containing DOMRect objects in content order, one for each box fragment,
902
902
// describing its border area (including those with a height or width of zero) with the following constraints:
903
- // FIXME: - Apply the transforms that apply to the element and its ancestors.
903
+ // - Apply the transforms that apply to the element and its ancestors.
904
904
// FIXME: - If the element on which the method was invoked has a computed value for the display property of table
905
905
// or inline-table include both the table box and the caption box, if any, but not the anonymous container box.
906
906
// FIXME: - Replace each anonymous block box with its child box(es) and repeat this until no anonymous block boxes
907
907
// are left in the final list.
908
908
const_cast <Document&>(document ()).update_layout ();
909
909
VERIFY (document ().navigable ());
910
910
auto viewport_offset = document ().navigable ()->viewport_scroll_offset ();
911
+
912
+ Gfx::AffineTransform transform;
913
+ for (auto const * containing_block = this ->layout_node (); containing_block; containing_block = containing_block->containing_block ()) {
914
+ Gfx::AffineTransform containing_block_transform;
915
+ if (containing_block->paintable () && containing_block->paintable ()->is_paintable_box ()) {
916
+ auto const & containing_block_paintable_box = static_cast <Painting::PaintableBox const &>(*containing_block->paintable ());
917
+ containing_block_transform = Gfx::extract_2d_affine_transform (containing_block_paintable_box.transform ());
918
+ }
919
+ transform = transform.multiply (containing_block_transform);
920
+ }
921
+
911
922
auto const * paintable = this ->paintable ();
912
923
if (auto const * paintable_box = this ->paintable_box ()) {
913
924
auto absolute_rect = paintable_box->absolute_border_box_rect ();
914
925
absolute_rect.translate_by (-viewport_offset.x (), -viewport_offset.y ());
915
- rects.append (Geometry::DOMRect::create (realm (), absolute_rect.to_type <float >()));
926
+ rects.append (Geometry::DOMRect::create (realm (), transform. map ( absolute_rect.to_type <float >() )));
916
927
} else if (paintable && is<Painting::InlinePaintable>(*paintable)) {
917
928
auto const & inline_paintable = static_cast <Painting::InlinePaintable const &>(*paintable);
918
929
auto absolute_rect = inline_paintable.bounding_rect ();
919
930
absolute_rect.translate_by (-viewport_offset.x (), -viewport_offset.y ());
920
- rects.append (Geometry::DOMRect::create (realm (), absolute_rect.to_type <float >()));
931
+ rects.append (Geometry::DOMRect::create (realm (), transform. map ( absolute_rect.to_type <float >() )));
921
932
} else if (paintable) {
922
933
dbgln (" FIXME: Failed to get client rects for element ({})" , debug_description ());
923
934
}
0 commit comments