LibWeb: Add element adjust_computed_style and move set_property() to it

This commit is contained in:
Bastiaan van der Plaat 2024-03-07 21:27:37 +01:00 committed by Andreas Kling
parent 928287b782
commit 69e4f924b7
Notes: sideshowbarker 2024-07-17 08:34:29 +09:00
9 changed files with 30 additions and 23 deletions

View file

@ -31,19 +31,17 @@ HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::Qualified
HTMLTextAreaElement::~HTMLTextAreaElement() = default;
JS::GCPtr<Layout::Node> HTMLTextAreaElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
void HTMLTextAreaElement::adjust_computed_style(CSS::StyleProperties& 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::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
if (style.display().is_inline_outside() && style.display().is_flow_inside())
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
if (style->property(CSS::PropertyID::Width)->has_auto())
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(cols(), CSS::Length::Type::Ch)));
if (style->property(CSS::PropertyID::Height)->has_auto())
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length(rows(), CSS::Length::Type::Lh)));
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
if (style.property(CSS::PropertyID::Width)->has_auto())
style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(cols(), CSS::Length::Type::Ch)));
if (style.property(CSS::PropertyID::Height)->has_auto())
style.set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length(rows(), CSS::Length::Type::Lh)));
}
void HTMLTextAreaElement::initialize(JS::Realm& realm)