Prechádzať zdrojové kódy

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.
Jonatan Klemets 2 rokov pred
rodič
commit
04bc9b14d0

+ 120 - 0
Tests/LibWeb/Layout/expected/table/colspan-with-trailing-characters.txt

@@ -0,0 +1,120 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (0,0) content-size 800x103.875 [BFC] children: not-inline
+    BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
+      TextNode <#text>
+    BlockContainer <body> at (8,8) content-size 784x87.875 children: not-inline
+      BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
+        TextNode <#text>
+      TableWrapper <(anonymous)> at (8,8) content-size 229.359375x87.875 [BFC] children: not-inline
+        Box <table> at (9,9) content-size 227.359375x85.875 table-box [TFC] children: not-inline
+          BlockContainer <(anonymous)> (not painted) children: inline
+            TextNode <#text>
+          Box <tbody> at (9,9) content-size 227.359375x85.875 table-row-group children: not-inline
+            Box <tr> at (9,9) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (11,11) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 70.046875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [11,11 70.046875x17.46875]
+                    "Header 1"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (85.046875,11) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 72.515625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [85.046875,11 72.515625x17.46875]
+                    "Header 2"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (161.5625,11) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 72.796875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [161.5625,11 72.796875x17.46875]
+                    "Header 3"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,30.46875) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,32.46875) content-size 223.359375x17.46875 table-cell [BFC] children: inline
+                line 0 width: 41.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [102,32.46875 41.84375x17.46875]
+                    "Cell 1"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,51.9375) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,53.9375) content-size 223.359375x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [101,53.9375 44.3125x17.46875]
+                    "Cell 2"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,73.40625) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,75.40625) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.59375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [24,75.40625 44.59375x17.46875]
+                    "Cell 3"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,75.40625) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 43.25, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [100.046875,75.40625 43.25x17.46875]
+                    "Cell 4"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (161.5625,75.40625) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 43.953125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [175.5625,75.40625 43.953125x17.46875]
+                    "Cell 5"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+      BlockContainer <(anonymous)> at (8,95.875) content-size 784x0 children: inline
+        TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+  PaintableWithLines (BlockContainer<HTML>) [0,0 800x103.875]
+    PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
+    PaintableWithLines (BlockContainer<BODY>) [8,8 784x87.875]
+      PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
+      PaintableWithLines (TableWrapper(anonymous)) [8,8 229.359375x87.875]
+        PaintableBox (Box<TABLE>) [8,8 229.359375x87.875]
+          PaintableBox (Box<TBODY>) [9,9 227.359375x85.875]
+            PaintableBox (Box<TR>) [9,9 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TH>) [9,9 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TH>) [83.046875,9 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TH>) [159.5625,9 76.796875x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,30.46875 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,30.46875 227.359375x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,51.9375 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,51.9375 227.359375x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,73.40625 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,73.40625 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,73.40625 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [159.5625,73.40625 76.796875x21.46875]
+                TextPaintable (TextNode<#text>)
+      PaintableWithLines (BlockContainer(anonymous)) [8,95.875 784x0]

+ 204 - 0
Tests/LibWeb/Layout/expected/table/rowspan-with-trailing-characters.txt

@@ -0,0 +1,204 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (0,0) content-size 800x146.8125 [BFC] children: not-inline
+    BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
+      TextNode <#text>
+    BlockContainer <body> at (8,8) content-size 784x130.8125 children: not-inline
+      BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
+        TextNode <#text>
+      TableWrapper <(anonymous)> at (8,8) content-size 229.359375x130.8125 [BFC] children: not-inline
+        Box <table> at (9,9) content-size 227.359375x128.8125 table-box [TFC] children: not-inline
+          BlockContainer <(anonymous)> (not painted) children: inline
+            TextNode <#text>
+          Box <tbody> at (9,9) content-size 227.359375x128.8125 table-row-group children: not-inline
+            Box <tr> at (9,9) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (11,11) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 70.046875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [11,11 70.046875x17.46875]
+                    "Header 1"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (85.046875,11) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 72.515625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [85.046875,11 72.515625x17.46875]
+                    "Header 2"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <th> at (161.5625,11) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 72.796875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 8, rect: [161.5625,11 72.796875x17.46875]
+                    "Header 3"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,30.46875) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,32.46875) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 41.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [25,32.46875 41.84375x17.46875]
+                    "Cell 1"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,32.46875) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [99.046875,32.46875 44.3125x17.46875]
+                    "Cell 2"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (161.5625,43.203125) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.59375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [175.5625,43.203125 44.59375x17.46875]
+                    "Cell 3"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,51.9375) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,53.9375) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 43.25, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [24,53.9375 43.25x17.46875]
+                    "Cell 4"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,53.9375) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 43.953125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [99.046875,53.9375 43.953125x17.46875]
+                    "Cell 5"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,73.40625) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,75.40625) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.234375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [24,75.40625 44.234375x17.46875]
+                    "Cell 6"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,75.40625) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.21875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [99.046875,75.40625 44.21875x17.46875]
+                    "Cell 7"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (161.5625,75.40625) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.984375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [175.5625,75.40625 44.984375x17.46875]
+                    "Cell 8"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,94.875) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,96.875) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 44.328125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 6, rect: [24,96.875 44.328125x17.46875]
+                    "Cell 9"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,96.875) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 51.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 7, rect: [96.046875,96.875 51.4375x17.46875]
+                    "Cell 10"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (161.5625,107.609375) content-size 72.796875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 48.1875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 7, rect: [173.5625,107.609375 48.1875x17.46875]
+                    "Cell 11"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,116.34375) content-size 227.359375x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,118.34375) content-size 70.046875x17.46875 table-cell [BFC] children: inline
+                line 0 width: 50.65625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 7, rect: [21,118.34375 50.65625x17.46875]
+                    "Cell 12"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (85.046875,118.34375) content-size 72.515625x17.46875 table-cell [BFC] children: inline
+                line 0 width: 50.9375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 7, rect: [96.046875,118.34375 50.9375x17.46875]
+                    "Cell 13"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+      BlockContainer <(anonymous)> at (8,138.8125) content-size 784x0 children: inline
+        TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+  PaintableWithLines (BlockContainer<HTML>) [0,0 800x146.8125]
+    PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
+    PaintableWithLines (BlockContainer<BODY>) [8,8 784x130.8125]
+      PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
+      PaintableWithLines (TableWrapper(anonymous)) [8,8 229.359375x130.8125]
+        PaintableBox (Box<TABLE>) [8,8 229.359375x130.8125]
+          PaintableBox (Box<TBODY>) [9,9 227.359375x128.8125]
+            PaintableBox (Box<TR>) [9,9 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TH>) [9,9 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TH>) [83.046875,9 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TH>) [159.5625,9 76.796875x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,30.46875 227.359375x21.46875] overflow: [9,30.46875 227.359375x42.9375]
+              PaintableWithLines (BlockContainer<TD>) [9,30.46875 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,30.46875 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [159.5625,30.46875 76.796875x42.9375]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,51.9375 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,51.9375 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,51.9375 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,73.40625 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,73.40625 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,73.40625 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [159.5625,73.40625 76.796875x21.46875]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,94.875 227.359375x21.46875] overflow: [9,94.875 227.359375x42.9375]
+              PaintableWithLines (BlockContainer<TD>) [9,94.875 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,94.875 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [159.5625,94.875 76.796875x42.9375]
+                TextPaintable (TextNode<#text>)
+            PaintableBox (Box<TR>) [9,116.34375 227.359375x21.46875]
+              PaintableWithLines (BlockContainer<TD>) [9,116.34375 74.046875x21.46875]
+                TextPaintable (TextNode<#text>)
+              PaintableWithLines (BlockContainer<TD>) [83.046875,116.34375 76.515625x21.46875]
+                TextPaintable (TextNode<#text>)
+      PaintableWithLines (BlockContainer(anonymous)) [8,138.8125 784x0]

+ 33 - 0
Tests/LibWeb/Layout/input/table/colspan-with-trailing-characters.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <title>Colspan relaxed parsing</title>
+    <style>
+        table, td {
+            border: 1px solid black;
+            border-spacing: 0;
+            text-align: center;
+        }
+    </style>
+</head>
+<body>
+    <table border="1">
+        <tr>
+            <th>Header 1</th>
+            <th>Header 2</th>
+            <th>Header 3</th>
+        </tr>
+        <tr>
+            <td colspan="3">Cell 1</td>
+        </tr>
+        <tr>
+            <td colspan="3foo">Cell 2</td>
+        </tr>
+        <tr>
+            <td>Cell 3</td>
+            <td>Cell 4</td>
+            <td>Cell 5</td>
+        </tr>
+    </table>
+</body>
+</html>

+ 45 - 0
Tests/LibWeb/Layout/input/table/rowspan-with-trailing-characters.html

@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <title>Rowspan relaxed parsing</title>
+    <style>
+        table, td {
+            border: 1px solid black;
+            border-spacing: 0;
+            text-align: center;
+        }
+    </style>
+</head>
+<body>
+<table border="1">
+    <tr>
+        <th>Header 1</th>
+        <th>Header 2</th>
+        <th>Header 3</th>
+    </tr>
+    <tr>
+        <td>Cell 1</td>
+        <td>Cell 2</td>
+        <td rowspan="2">Cell 3</td>
+    </tr>
+    <tr>
+        <td>Cell 4</td>
+        <td>Cell 5</td>
+    </tr>
+    <tr>
+        <td>Cell 6</td>
+        <td>Cell 7</td>
+        <td>Cell 8</td>
+    </tr>
+    <tr>
+        <td>Cell 9</td>
+        <td>Cell 10</td>
+        <td rowspan="2foo">Cell 11</td>
+    </tr>
+    <tr>
+        <td>Cell 12</td>
+        <td>Cell 13</td>
+    </tr>
+</table>
+</body>
+</html>

+ 3 - 2
Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp

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