LibWeb: Separate comparator for cell border specificity
Add a cell border specificity comparator which preserves the winning border logic according to specification and makes it possible to sort borders by specificity. This will be important for handling the style of table cell corners in a way consistent with other browsers.
This commit is contained in:
parent
85c1b93eb7
commit
f489d85edd
Notes:
sideshowbarker
2024-07-17 17:06:59 +09:00
Author: https://github.com/axgallo Commit: https://github.com/SerenityOS/serenity/commit/f489d85edd Pull-request: https://github.com/SerenityOS/serenity/pull/19751
1 changed files with 19 additions and 11 deletions
|
@ -857,9 +857,9 @@ void TableFormattingContext::position_cell_boxes()
|
|||
}
|
||||
}
|
||||
|
||||
static const CSS::BorderData& winning_border_style(const CSS::BorderData& a, const CSS::BorderData& b)
|
||||
static bool border_is_less_specific(const CSS::BorderData& a, const CSS::BorderData& b)
|
||||
{
|
||||
// Implements steps 1, 2 and 3 of border conflict resolution algorithm.
|
||||
// Implements criteria for steps 1, 2 and 3 of border conflict resolution algorithm.
|
||||
static HashMap<CSS::LineStyle, unsigned> const line_style_score = {
|
||||
{ CSS::LineStyle::Inset, 0 },
|
||||
{ CSS::LineStyle::Groove, 1 },
|
||||
|
@ -870,29 +870,37 @@ static const CSS::BorderData& winning_border_style(const CSS::BorderData& a, con
|
|||
{ CSS::LineStyle::Solid, 6 },
|
||||
{ CSS::LineStyle::Double, 7 },
|
||||
};
|
||||
|
||||
if (a.line_style == CSS::LineStyle::Hidden) {
|
||||
return a;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (b.line_style == CSS::LineStyle::Hidden) {
|
||||
return b;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a.line_style == CSS::LineStyle::None) {
|
||||
return b;
|
||||
return true;
|
||||
}
|
||||
if (b.line_style == CSS::LineStyle::None) {
|
||||
return a;
|
||||
return false;
|
||||
}
|
||||
if (a.width > b.width) {
|
||||
return a;
|
||||
return false;
|
||||
} else if (a.width < b.width) {
|
||||
return b;
|
||||
return true;
|
||||
}
|
||||
if (*line_style_score.get(a.line_style) > *line_style_score.get(b.line_style)) {
|
||||
return a;
|
||||
return false;
|
||||
} else if (*line_style_score.get(a.line_style) < *line_style_score.get(b.line_style)) {
|
||||
return b;
|
||||
return true;
|
||||
}
|
||||
return a;
|
||||
return false;
|
||||
}
|
||||
|
||||
static const CSS::BorderData& winning_border_style(const CSS::BorderData& a, const CSS::BorderData& b)
|
||||
{
|
||||
return border_is_less_specific(a, b) ? b : a;
|
||||
}
|
||||
|
||||
const CSS::BorderData& TableFormattingContext::border_data_conflicting_edge(TableFormattingContext::ConflictingEdge const& conflicting_edge)
|
||||
|
|
Loading…
Add table
Reference in a new issue