mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Don't crash when encountering border-spacing: calc(...)
This allows us to progress further on this WPT test: https://wpt.live/quirks/unitless-length/quirks.html ...although it still crashes before finishing.
This commit is contained in:
parent
10853898fc
commit
5e240f997c
Notes:
github-actions[bot]
2024-10-09 13:15:20 +00:00
Author: https://github.com/awesomekling
Commit: 5e240f997c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1698
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 26 additions and 6 deletions
|
@ -0,0 +1,10 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
|
||||||
|
BlockContainer <div> at (8,8) content-size 784x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0]
|
||||||
|
PaintableWithLines (BlockContainer<DIV>) [8,8 784x0]
|
|
@ -0,0 +1,6 @@
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
border-spacing: calc(2px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
|
@ -402,20 +402,24 @@ Optional<CSS::ImageRendering> StyleProperties::image_rendering() const
|
||||||
return keyword_to_image_rendering(value->to_keyword());
|
return keyword_to_image_rendering(value->to_keyword());
|
||||||
}
|
}
|
||||||
|
|
||||||
CSS::Length StyleProperties::border_spacing_horizontal() const
|
CSS::Length StyleProperties::border_spacing_horizontal(Layout::Node const& layout_node) const
|
||||||
{
|
{
|
||||||
auto value = property(CSS::PropertyID::BorderSpacing);
|
auto value = property(CSS::PropertyID::BorderSpacing);
|
||||||
if (value->is_length())
|
if (value->is_length())
|
||||||
return value->as_length().length();
|
return value->as_length().length();
|
||||||
|
if (value->is_math())
|
||||||
|
return value->as_math().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||||
auto const& list = value->as_value_list();
|
auto const& list = value->as_value_list();
|
||||||
return list.value_at(0, false)->as_length().length();
|
return list.value_at(0, false)->as_length().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSS::Length StyleProperties::border_spacing_vertical() const
|
CSS::Length StyleProperties::border_spacing_vertical(Layout::Node const& layout_node) const
|
||||||
{
|
{
|
||||||
auto value = property(CSS::PropertyID::BorderSpacing);
|
auto value = property(CSS::PropertyID::BorderSpacing);
|
||||||
if (value->is_length())
|
if (value->is_length())
|
||||||
return value->as_length().length();
|
return value->as_length().length();
|
||||||
|
if (value->is_math())
|
||||||
|
return value->as_math().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||||
auto const& list = value->as_value_list();
|
auto const& list = value->as_value_list();
|
||||||
return list.value_at(1, false)->as_length().length();
|
return list.value_at(1, false)->as_length().length();
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ public:
|
||||||
Optional<CSS::TextAlign> text_align() const;
|
Optional<CSS::TextAlign> text_align() const;
|
||||||
Optional<CSS::TextJustify> text_justify() const;
|
Optional<CSS::TextJustify> text_justify() const;
|
||||||
Optional<CSS::TextOverflow> text_overflow() const;
|
Optional<CSS::TextOverflow> text_overflow() const;
|
||||||
CSS::Length border_spacing_horizontal() const;
|
CSS::Length border_spacing_horizontal(Layout::Node const&) const;
|
||||||
CSS::Length border_spacing_vertical() const;
|
CSS::Length border_spacing_vertical(Layout::Node const&) const;
|
||||||
Optional<CSS::CaptionSide> caption_side() const;
|
Optional<CSS::CaptionSide> caption_side() const;
|
||||||
CSS::Clip clip() const;
|
CSS::Clip clip() const;
|
||||||
CSS::Display display() const;
|
CSS::Display display() const;
|
||||||
|
|
|
@ -613,8 +613,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
||||||
if (float_.has_value())
|
if (float_.has_value())
|
||||||
computed_values.set_float(float_.value());
|
computed_values.set_float(float_.value());
|
||||||
|
|
||||||
computed_values.set_border_spacing_horizontal(computed_style.border_spacing_horizontal());
|
computed_values.set_border_spacing_horizontal(computed_style.border_spacing_horizontal(*this));
|
||||||
computed_values.set_border_spacing_vertical(computed_style.border_spacing_vertical());
|
computed_values.set_border_spacing_vertical(computed_style.border_spacing_vertical(*this));
|
||||||
|
|
||||||
auto caption_side = computed_style.caption_side();
|
auto caption_side = computed_style.caption_side();
|
||||||
if (caption_side.has_value())
|
if (caption_side.has_value())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue