LibWeb: Don't crash on HTML input element with display: inline

This would previously assert in InlineFormattingContext because we had
an outwardly inline box that wasn't inwardly flow.

Fix this by converting text-based input boxes to inline-blocks. This is
an ad-hoc solution, and there might be a much better way to solve it.
This commit is contained in:
Andreas Kling 2023-03-19 20:35:42 +01:00
parent 00999a245c
commit a6d1307aa4
Notes: sideshowbarker 2024-07-17 18:49:10 +09:00
3 changed files with 25 additions and 1 deletions

View file

@ -71,7 +71,12 @@ JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::
if (type_state() == TypeAttributeState::RadioButton)
return heap().allocate_without_realm<Layout::RadioButton>(document(), *this, move(style));
return heap().allocate_without_realm<Layout::BlockContainer>(document(), this, move(style));
// AD-HOC: We rewrite `display: inline` to `display: inline-block`.
// This is required for the internal shadow tree to work correctly in layout.
if (style->display().is_inline_outside() && style->display().is_flow_inside())
style->set_property(CSS::PropertyID::Display, CSS::IdentifierStyleValue::create(CSS::ValueID::InlineBlock));
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
}
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)