LibWeb: Update layout in dump_dom_tree_as_json()

Ensure layout is up to date before serializing the DOM tree as JSON for
the inspector, so that layout information is accurate.
This commit is contained in:
Andreas Kling 2026-02-26 11:55:13 +01:00 committed by Andreas Kling
parent e3b55e2642
commit 4a2d80b493
2 changed files with 3 additions and 0 deletions

View file

@ -3526,6 +3526,8 @@ void Document::set_bg_color(String const& value)
String Document::dump_dom_tree_as_json() const
{
const_cast<Document&>(*this).update_layout(UpdateLayoutReason::InspectDOMTree);
StringBuilder builder;
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
serialize_tree_as_json(json);

View file

@ -107,6 +107,7 @@ enum class InvalidateLayoutTreeReason {
X(HTMLImageElementY) \
X(HTMLInputElementHeight) \
X(HTMLInputElementWidth) \
X(InspectDOMTree) \
X(InternalsHitTest) \
X(MediaQueryListMatches) \
X(NavigableSelectedText) \