mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Update layout in HTMLElement.offset{Top,Left}
We can't report layout-dependent metrics without first ensuring that layout is up-to-date.
This commit is contained in:
parent
9e274d9501
commit
2371446952
Notes:
sideshowbarker
2024-07-17 17:49:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2371446952
@ -141,6 +141,9 @@ String HTMLElement::inner_text()
|
||||
// // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop
|
||||
int HTMLElement::offset_top() const
|
||||
{
|
||||
// NOTE: Ensure that layout is up-to-date before looking at metrics.
|
||||
const_cast<DOM::Document&>(document()).update_layout();
|
||||
|
||||
if (is<HTML::HTMLBodyElement>(this) || !layout_node() || !parent_element() || !parent_element()->layout_node())
|
||||
return 0;
|
||||
auto position = layout_node()->box_type_agnostic_position();
|
||||
@ -151,6 +154,9 @@ int HTMLElement::offset_top() const
|
||||
// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetleft
|
||||
int HTMLElement::offset_left() const
|
||||
{
|
||||
// NOTE: Ensure that layout is up-to-date before looking at metrics.
|
||||
const_cast<DOM::Document&>(document()).update_layout();
|
||||
|
||||
if (is<HTML::HTMLBodyElement>(this) || !layout_node() || !parent_element() || !parent_element()->layout_node())
|
||||
return 0;
|
||||
auto position = layout_node()->box_type_agnostic_position();
|
||||
|
Loading…
Reference in New Issue
Block a user