Browse Source

LibWeb: Update layout in Element.getBoundingClientRect()

Andreas Kling 3 năm trước cách đây
mục cha
commit
25f6d2e2ab

+ 3 - 0
Userland/Libraries/LibWeb/DOM/Element.cpp

@@ -539,6 +539,9 @@ bool Element::serializes_as_void() const
 // https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
 // https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
 NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
 NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
 {
 {
+    // // NOTE: Ensure that layout is up-to-date before looking at metrics.
+    const_cast<Document&>(document()).update_layout();
+
     // FIXME: Support inline layout nodes as well.
     // FIXME: Support inline layout nodes as well.
     auto* paint_box = this->paint_box();
     auto* paint_box = this->paint_box();
     if (!paint_box)
     if (!paint_box)