LibWeb: Parse border-collapse property for HTML table

This commit is contained in:
martinfalisse 2023-01-02 23:01:29 +01:00 committed by Andreas Kling
parent 25f612f32b
commit 64c353f11c
Notes: sideshowbarker 2024-07-17 07:08:37 +09:00
7 changed files with 22 additions and 3 deletions

View file

@ -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; }

View file

@ -60,6 +60,10 @@
"content-box",
"padding-box"
],
"border-collapse": [
"separate",
"collapse"
],
"box-sizing": [
"border-box",
"content-box"

View file

@ -266,9 +266,8 @@
"border-collapse": {
"inherited": true,
"initial": "separate",
"valid-identifiers": [
"collapse",
"separate"
"valid-types": [
"border-collapse"
]
},
"border-left-color": {

View file

@ -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));

View file

@ -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());
}
}

View file

@ -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;

View file

@ -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