mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibWeb: Improve table colspan and rowspan spec alignment
This patch improves the spec alignment [1] for the table `colspan` and `rowspan` attributes by: - Handling min and max for `colspan`. - Handling max for `rowspan`. [1] https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
This commit is contained in:
parent
04bc9b14d0
commit
f0a772edef
Notes:
sideshowbarker
2024-07-16 23:52:10 +09:00
Author: https://github.com/Jon4t4n Commit: https://github.com/SerenityOS/serenity/commit/f0a772edef Pull-request: https://github.com/SerenityOS/serenity/pull/20140 Issue: https://github.com/SerenityOS/serenity/issues/19937 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/nico
@ -95,9 +95,25 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
||||
apply_border_style(CSS::PropertyID::BorderBottomStyle, CSS::PropertyID::BorderBottomWidth, CSS::PropertyID::BorderBottomColor);
|
||||
}
|
||||
|
||||
// This implements step 8 in the spec here:
|
||||
// https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
|
||||
unsigned int HTMLTableCellElement::col_span() const
|
||||
{
|
||||
return Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::colspan)).value_or(1);
|
||||
auto optional_value = Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::colspan));
|
||||
|
||||
// If parsing that value failed, or returned zero, or if the attribute is absent, then let colspan be 1, instead.
|
||||
if (!optional_value.has_value() || optional_value.value() == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto value = optional_value.value();
|
||||
|
||||
// If colspan is greater than 1000, let it be 1000 instead.
|
||||
if (value > 1000) {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTableCellElement::set_col_span(unsigned int value)
|
||||
@ -105,9 +121,19 @@ WebIDL::ExceptionOr<void> HTMLTableCellElement::set_col_span(unsigned int value)
|
||||
return set_attribute(HTML::AttributeNames::colspan, DeprecatedString::number(value));
|
||||
}
|
||||
|
||||
// This implements step 9 in the spec here:
|
||||
// https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
|
||||
unsigned int HTMLTableCellElement::row_span() const
|
||||
{
|
||||
return Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::rowspan)).value_or(1);
|
||||
// If parsing that value failed or if the attribute is absent, then let rowspan be 1, instead.
|
||||
auto value = Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::rowspan)).value_or(1);
|
||||
|
||||
// If rowspan is greater than 65534, let it be 65534 instead.
|
||||
if (value > 65534) {
|
||||
return 65534;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTableCellElement::set_row_span(unsigned int value)
|
||||
|
Loading…
Reference in New Issue
Block a user