diff options
author | martinfalisse <martinmotteditfalisse@gmail.com> | 2023-01-02 23:01:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-03 20:02:47 +0100 |
commit | 64c353f11cadd9d18e9d89480a4aed1fd644441d (patch) | |
tree | 3d4606c147aa1400915bc7ef53741b841d00913a | |
parent | 25f612f32be3154300c640ecf3e838de748b4cdf (diff) | |
download | serenity-64c353f11cadd9d18e9d89480a4aed1fd644441d.zip |
LibWeb: Parse `border-collapse` property for HTML table
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/ComputedValues.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Enums.json | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Properties.json | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Node.cpp | 3 |
7 files changed, 22 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 404322cd41..39e87261d5 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -72,6 +72,7 @@ public: static CSS::GridTrackPlacement grid_row_start() { return CSS::GridTrackPlacement::make_auto(); } static CSS::Size column_gap() { return CSS::Size::make_auto(); } static CSS::Size row_gap() { return CSS::Size::make_auto(); } + static CSS::BorderCollapse border_collapse() { return CSS::BorderCollapse::Separate; } }; struct BackgroundLayerData { @@ -192,6 +193,7 @@ public: CSS::GridTrackPlacement const& grid_row_start() const { return m_noninherited.grid_row_start; } CSS::Size const& column_gap() const { return m_noninherited.column_gap; } CSS::Size const& row_gap() const { return m_noninherited.row_gap; } + CSS::BorderCollapse border_collapse() const { return m_noninherited.border_collapse; } CSS::LengthBox const& inset() const { return m_noninherited.inset; } const CSS::LengthBox& margin() const { return m_noninherited.margin; } @@ -316,6 +318,7 @@ protected: CSS::GridTrackPlacement grid_row_start { InitialValues::grid_row_start() }; CSS::Size column_gap { InitialValues::column_gap() }; CSS::Size row_gap { InitialValues::row_gap() }; + CSS::BorderCollapse border_collapse { InitialValues::border_collapse() }; } m_noninherited; }; @@ -396,6 +399,7 @@ public: void set_grid_row_start(CSS::GridTrackPlacement value) { m_noninherited.grid_row_start = value; } void set_column_gap(CSS::Size const& column_gap) { m_noninherited.column_gap = column_gap; } void set_row_gap(CSS::Size const& row_gap) { m_noninherited.row_gap = row_gap; } + void set_border_collapse(CSS::BorderCollapse const& border_collapse) { m_noninherited.border_collapse = border_collapse; } void set_fill(Color value) { m_inherited.fill = value; } void set_stroke(Color value) { m_inherited.stroke = value; } diff --git a/Userland/Libraries/LibWeb/CSS/Enums.json b/Userland/Libraries/LibWeb/CSS/Enums.json index 0ddd90f0ce..9c306150b9 100644 --- a/Userland/Libraries/LibWeb/CSS/Enums.json +++ b/Userland/Libraries/LibWeb/CSS/Enums.json @@ -60,6 +60,10 @@ "content-box", "padding-box" ], + "border-collapse": [ + "separate", + "collapse" + ], "box-sizing": [ "border-box", "content-box" diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index 9c6ffde358..8f8fa96fe1 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -266,9 +266,8 @@ "border-collapse": { "inherited": true, "initial": "separate", - "valid-identifiers": [ - "collapse", - "separate" + "valid-types": [ + "border-collapse" ] }, "border-left-color": { diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 8392db5018..bd7ebfafe8 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -202,6 +202,8 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout: return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_bottom().line_style)); case CSS::PropertyID::BorderBottomWidth: return LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_bottom().width)); + case CSS::PropertyID::BorderCollapse: + return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_collapse())); case CSS::PropertyID::BorderLeft: { auto border = layout_node.computed_values().border_left(); auto width = LengthStyleValue::create(Length::make_px(border.width)); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 3b29a61f26..49336f53d7 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -737,4 +737,10 @@ CSS::GridTrackPlacement StyleProperties::grid_row_start() const return value->as_grid_track_placement().grid_track_placement(); } +Optional<CSS::BorderCollapse> StyleProperties::border_collapse() const +{ + auto value = property(CSS::PropertyID::BorderCollapse); + return value_id_to_border_collapse(value->to_identifier()); +} + } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index de2fc3bdad..049977b92f 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -90,6 +90,7 @@ public: CSS::GridTrackPlacement grid_column_start() const; CSS::GridTrackPlacement grid_row_end() const; CSS::GridTrackPlacement grid_row_start() const; + Optional<CSS::BorderCollapse> border_collapse() const; Vector<CSS::Transformation> transformations() const; CSS::TransformOrigin transform_origin() const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index f731ef3ca6..6f40664376 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -605,6 +605,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) computed_values.set_column_gap(computed_style.size_value(CSS::PropertyID::ColumnGap)); computed_values.set_row_gap(computed_style.size_value(CSS::PropertyID::RowGap)); + + if (auto border_collapse = computed_style.border_collapse(); border_collapse.has_value()) + computed_values.set_border_collapse(border_collapse.value()); } bool Node::is_root_element() const |