1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

LibWeb: Start work towards modern CSS "display" values

Until now, we've internally thought of the CSS "display" property as a
single-value property. In practice, "display" is a much more complex
property that comes in a number of configurations.

The most interesting one is the two-part format that describes the
outside and inside behavior of a box. Switching our own internal
representation towards this model will allow for much cleaner
abstractions around layout and the various formatting contexts.

Note that we don't *parse* two-part "display" yet, this is only about
changing the internal representation of the property.

Spec: https://drafts.csswg.org/css-display
This commit is contained in:
Andreas Kling 2021-10-06 17:57:44 +02:00
parent 1552873275
commit 85a0772147
22 changed files with 214 additions and 161 deletions

View file

@ -22,7 +22,7 @@ HTMLBRElement::~HTMLBRElement()
RefPtr<Layout::Node> HTMLBRElement::create_layout_node()
{
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
return adopt_ref(*new Layout::BreakNode(document(), *this, move(style)));
}

View file

@ -40,7 +40,7 @@ unsigned HTMLCanvasElement::height() const
RefPtr<Layout::Node> HTMLCanvasElement::create_layout_node()
{
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
return adopt_ref(*new Layout::CanvasBox(document(), *this, move(style)));
}

View file

@ -71,7 +71,7 @@ void HTMLImageElement::parse_attribute(const FlyString& name, const String& valu
RefPtr<Layout::Node> HTMLImageElement::create_layout_node()
{
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));
}

View file

@ -47,7 +47,7 @@ RefPtr<Layout::Node> HTMLInputElement::create_layout_node()
return nullptr;
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
if (type().equals_ignoring_case("submit") || type().equals_ignoring_case("button"))

View file

@ -22,7 +22,7 @@ HTMLLabelElement::~HTMLLabelElement()
RefPtr<Layout::Node> HTMLLabelElement::create_layout_node()
{
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
auto layout_node = adopt_ref(*new Layout::Label(document(), this, move(style)));

View file

@ -47,7 +47,7 @@ RefPtr<Layout::Node> HTMLObjectElement::create_layout_node()
return HTMLElement::create_layout_node();
auto style = document().style_computer().compute_style(*this);
if (style->display() == CSS::Display::None)
if (style->display().is_none())
return nullptr;
if (m_image_loader.has_image())
return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));