Explorar o código

LibWeb: Make border-collapse actually inherited

Move it to the inherited section of ComputedValues.
Andi Gallo %!s(int64=2) %!d(string=hai) anos
pai
achega
52956d355c

+ 154 - 0
Tests/LibWeb/Layout/expected/table/border-collapse-is-inherited.txt

@@ -0,0 +1,154 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (0,0) content-size 800x228.34375 [BFC] children: not-inline
+    BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
+      TextNode <#text>
+    BlockContainer <body> at (8,8) content-size 784x212.34375 children: not-inline
+      BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
+        TextNode <#text>
+      BlockContainer <div.horizontal> at (8,8) content-size 784x212.34375 children: inline
+        line 0 width: 163.90625, height: 212.34375, bottom: 212.34375, baseline: 13.53125
+          frag 0 from BlockContainer start: 0, length: 0, rect: [9,22 161.90625x197.34375]
+        TextNode <#text>
+        BlockContainer <table> at (9,22) content-size 161.90625x197.34375 inline-block [BFC] children: not-inline
+          BlockContainer <(anonymous)> at (9,22) content-size 161.90625x0 children: inline
+            TextNode <#text>
+          TableWrapper <(anonymous)> at (9,22) content-size 161.90625x197.34375 inline-block [BFC] children: not-inline
+            Box <(anonymous)> at (9,22) content-size 161.90625x197.34375 inline-table table-box [TFC] children: not-inline
+              Box <tbody> at (9,22) content-size 161.90625x197.34375 table-row-group children: not-inline
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+                Box <tr> at (9,22) content-size 161.90625x39.46875 table-row children: not-inline
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (30,33) content-size 14.265625x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 14.265625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [30,33 14.265625x17.46875]
+                        "A"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (86.265625,33) content-size 12.546875x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [88.265625,33 9.34375x17.46875]
+                        "B"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (140.8125,33) content-size 9.09375x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 6.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [141.8125,33 6.34375x17.46875]
+                        "1"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+                Box <tr> at (9,61.46875) content-size 161.90625x39.46875 table-row children: not-inline
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (30,72.46875) content-size 14.265625x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 10.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [32,72.46875 10.3125x17.46875]
+                        "C"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (86.265625,72.46875) content-size 12.546875x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 11.140625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [87.265625,72.46875 11.140625x17.46875]
+                        "D"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (140.8125,72.46875) content-size 9.09375x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 8.8125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [140.8125,72.46875 8.8125x17.46875]
+                        "2"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+                Box <tr> at (9,100.9375) content-size 161.90625x39.46875 table-row children: not-inline
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (30,111.9375) content-size 14.265625x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 11.859375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [31,111.9375 11.859375x17.46875]
+                        "E"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (86.265625,111.9375) content-size 12.546875x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 12.546875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [86.265625,111.9375 12.546875x17.46875]
+                        "F"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (140.8125,111.9375) content-size 9.09375x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 9.09375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [140.8125,111.9375 9.09375x17.46875]
+                        "3"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+                Box <tr> at (9,140.40625) content-size 161.90625x39.46875 table-row children: not-inline
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (30,151.40625) content-size 14.265625x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 13.234375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [31,151.40625 13.234375x17.46875]
+                        "G"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (86.265625,151.40625) content-size 12.546875x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 12.234375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [86.265625,151.40625 12.234375x17.46875]
+                        "H"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (140.8125,151.40625) content-size 9.09375x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 7.75, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [141.8125,151.40625 7.75x17.46875]
+                        "4"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+                Box <tr> at (9,179.875) content-size 161.90625x39.46875 table-row children: not-inline
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (30,190.875) content-size 14.265625x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 4.59375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [35,190.875 4.59375x17.46875]
+                        "I"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (86.265625,190.875) content-size 12.546875x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 8.90625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [88.265625,190.875 8.90625x17.46875]
+                        "J"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                  BlockContainer <td> at (140.8125,190.875) content-size 9.09375x17.46875 table-cell [BFC] children: inline
+                    line 0 width: 8.453125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                      frag 0 from TextNode start: 0, length: 1, rect: [140.8125,190.875 8.453125x17.46875]
+                        "5"
+                    TextNode <#text>
+                  BlockContainer <(anonymous)> (not painted) children: inline
+                    TextNode <#text>
+                BlockContainer <(anonymous)> (not painted) children: inline
+                  TextNode <#text>
+              BlockContainer <(anonymous)> at (9,22) content-size 0x0 children: inline
+                TextNode <#text>
+        TextNode <#text>
+      BlockContainer <(anonymous)> at (8,220.34375) content-size 784x0 children: inline
+        TextNode <#text>

+ 71 - 0
Tests/LibWeb/Layout/input/table/border-collapse-is-inherited.html

@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width">
+    <title>Collapsed table</title>
+    <style>
+        html {
+            font-family: sans-serif;
+        }
+
+        table {
+            border-collapse: collapse;
+            border-spacing: 20px 10px;
+            border: 1px solid blue;
+        }
+
+        td,
+        th {
+            border: 1px solid black;
+            padding: 10px 20px;
+        }
+
+        td {
+            text-align: center;
+        }
+
+        .horizontal>* {
+            display: inline-block;
+        }
+    </style>
+</head>
+
+<body>
+    <div class=horizontal>
+        <table>
+            <tbody>
+                <tr>
+                    <td>A</td>
+                    <td>B</td>
+                    <td>1</td>
+                </tr>
+                <tr>
+                    <td>C</td>
+                    <td>D</td>
+                    <td>2</td>
+                </tr>
+                <tr>
+                    <td>E</td>
+                    <td>F</td>
+                    <td>3</td>
+                </tr>
+                <tr>
+                    <td>G</td>
+                    <td>H</td>
+                    <td>4</td>
+                </tr>
+                <tr>
+                    <td>I</td>
+                    <td>J</td>
+                    <td>5</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+
+
+</body>
+
+</html>

+ 3 - 3
Userland/Libraries/LibWeb/CSS/ComputedValues.h

@@ -279,7 +279,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::BorderCollapse border_collapse() const { return m_inherited.border_collapse; }
     Vector<Vector<String>> const& grid_template_areas() const { return m_noninherited.grid_template_areas; }
 
     CSS::LengthBox const& inset() const { return m_noninherited.inset; }
@@ -335,6 +335,7 @@ protected:
         float font_size { InitialValues::font_size() };
         int font_weight { InitialValues::font_weight() };
         CSS::FontVariant font_variant { InitialValues::font_variant() };
+        CSS::BorderCollapse border_collapse { InitialValues::border_collapse() };
         CSS::Length border_spacing_horizontal { InitialValues::border_spacing() };
         CSS::Length border_spacing_vertical { InitialValues::border_spacing() };
         CSS::CaptionSide caption_side { InitialValues::caption_side() };
@@ -425,7 +426,6 @@ 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() };
         Vector<Vector<String>> grid_template_areas { InitialValues::grid_template_areas() };
         Gfx::Color stop_color { InitialValues::stop_color() };
         float stop_opacity { InitialValues::stop_opacity() };
@@ -519,7 +519,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_border_collapse(CSS::BorderCollapse const& border_collapse) { m_inherited.border_collapse = border_collapse; }
     void set_grid_template_areas(Vector<Vector<String>> const& grid_template_areas) { m_noninherited.grid_template_areas = grid_template_areas; }
     void set_transition_delay(CSS::Time const& transition_delay) { m_noninherited.transition_delay = transition_delay; }