mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 08:48:49 +00:00
LibWeb: Use parse_non_negative_integer for colspan and rowspan parsing
`DeprecatedString::to_int` calls `StringUtils::convert_to_int` internally. However, the integer parsing is not done in an HTML spec-compliant way. For example, `colspan="2;"` is valid according to the spec. But, with the current implementation, we will fail to parse "2;", and instead fall back to using 1 as the colspan value. This patch changes the `HTMLTableCellElement::col_span` and `HTMLTableCellElement::row_span` methods to use the `Web::HTML::parse_non_negative_integer` function that will parse the attribute value in an HTML spec-compliant way.
This commit is contained in:
parent
9812031a02
commit
04bc9b14d0
Notes:
sideshowbarker
2024-07-17 04:34:25 +09:00
Author: https://github.com/Jon4t4n
Commit: 04bc9b14d0
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
5 changed files with 405 additions and 2 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLTableCellElement.h>
|
||||
#include <LibWeb/HTML/HTMLTableElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -96,7 +97,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
|||
|
||||
unsigned int HTMLTableCellElement::col_span() const
|
||||
{
|
||||
return attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
|
||||
return Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::colspan)).value_or(1);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTableCellElement::set_col_span(unsigned int value)
|
||||
|
@ -106,7 +107,7 @@ WebIDL::ExceptionOr<void> HTMLTableCellElement::set_col_span(unsigned int value)
|
|||
|
||||
unsigned int HTMLTableCellElement::row_span() const
|
||||
{
|
||||
return attribute(HTML::AttributeNames::rowspan).to_uint().value_or(1);
|
||||
return Web::HTML::parse_non_negative_integer(attribute(HTML::AttributeNames::rowspan)).value_or(1);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTableCellElement::set_row_span(unsigned int value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue