Title: [274739] trunk
Revision
274739
Author
[email protected]
Date
2021-03-19 14:45:20 -0700 (Fri, 19 Mar 2021)

Log Message

Source/WebCore:
Anonymous table rows do not collapse if there are any other non-anonymous table row siblings.
https://bugs.webkit.org/show_bug.cgi?id=223490

Patch by Cameron McCormack <[email protected]> on 2021-03-19
Reviewed by Zalan Bujtas.

Currently, when a RenderTableRow is detached from its parent, we will
check whether all of the remaining RenderTableRow siblings are anonymous
before deciding to merge them.  This means that if removing the
RenderTableRow would produce a sequence of anonymous RenderTableRows
that could be collapsed, but we have some other non-anonymous
RenderTableRow as a sibling, then we'll incorrectly skip the collapsing.

Instead we should look only to the previous and next sibling, and
collapse them together if they're both anonymous.

Test: fast/table/table-anonymous-row-collapse.html

* rendering/updating/RenderTreeBuilderTable.cpp:
(WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows):
Change from requiring all siblings after the detachment to be anonymous, to
looking only at the previous and following siblings.

LayoutTests:
Anonymous table rows do not collapse if there are any other non-anonymous table row siblings
https://bugs.webkit.org/show_bug.cgi?id=223490

Patch by Cameron McCormack <[email protected]> on 2021-03-19
Reviewed by Zalan Bujtas.

* fast/table/table-anonymous-row-collapse-expected.html: Added.
* fast/table/table-anonymous-row-collapse.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274738 => 274739)


--- trunk/LayoutTests/ChangeLog	2021-03-19 21:25:13 UTC (rev 274738)
+++ trunk/LayoutTests/ChangeLog	2021-03-19 21:45:20 UTC (rev 274739)
@@ -1,3 +1,13 @@
+2021-03-19  Cameron McCormack  <[email protected]>
+
+        Anonymous table rows do not collapse if there are any other non-anonymous table row siblings
+        https://bugs.webkit.org/show_bug.cgi?id=223490
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/table/table-anonymous-row-collapse-expected.html: Added.
+        * fast/table/table-anonymous-row-collapse.html: Added.
+
 2021-03-19  Jer Noble  <[email protected]>
 
         Many media/media-fragments/ tests are crashing due to other tests that run before them.

Added: trunk/LayoutTests/fast/table/table-anonymous-row-collapse-expected.html (0 => 274739)


--- trunk/LayoutTests/fast/table/table-anonymous-row-collapse-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-anonymous-row-collapse-expected.html	2021-03-19 21:45:20 UTC (rev 274739)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<div style="display: table;">
+  <div style="display: table-row-group;">
+    <span style="display: table-cell;">Test passes if this text is&#xa0;</span>
+    <span style="display: table-cell;">all on one line.</span>
+    <div style="display: table-row;"></div>
+  </div>
+</div>
+

Added: trunk/LayoutTests/fast/table/table-anonymous-row-collapse.html (0 => 274739)


--- trunk/LayoutTests/fast/table/table-anonymous-row-collapse.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/table-anonymous-row-collapse.html	2021-03-19 21:45:20 UTC (rev 274739)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<div style="display: table;">
+  <div style="display: table-row-group;">
+    <span style="display: table-cell;">Test passes if this text is&#xa0;</span>
+    <div id=second style="display: table-row;"></div>
+    <span style="display: table-cell;">all on one line.</span>
+    <div style="display: table-row;"></div>
+  </div>
+</div>
+<script>
+document.body.offsetHeight;
+second.remove();
+</script>

Modified: trunk/Source/WebCore/ChangeLog (274738 => 274739)


--- trunk/Source/WebCore/ChangeLog	2021-03-19 21:25:13 UTC (rev 274738)
+++ trunk/Source/WebCore/ChangeLog	2021-03-19 21:45:20 UTC (rev 274739)
@@ -1,3 +1,27 @@
+2021-03-19  Cameron McCormack  <[email protected]>
+
+        Anonymous table rows do not collapse if there are any other non-anonymous table row siblings.
+        https://bugs.webkit.org/show_bug.cgi?id=223490
+
+        Reviewed by Zalan Bujtas.
+
+        Currently, when a RenderTableRow is detached from its parent, we will
+        check whether all of the remaining RenderTableRow siblings are anonymous
+        before deciding to merge them.  This means that if removing the
+        RenderTableRow would produce a sequence of anonymous RenderTableRows
+        that could be collapsed, but we have some other non-anonymous
+        RenderTableRow as a sibling, then we'll incorrectly skip the collapsing.
+
+        Instead we should look only to the previous and next sibling, and
+        collapse them together if they're both anonymous.
+
+        Test: fast/table/table-anonymous-row-collapse.html
+
+        * rendering/updating/RenderTreeBuilderTable.cpp:
+        (WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows):
+        Change from requiring all siblings after the detachment to be anonymous, to
+        looking only at the previous and following siblings.
+
 2021-03-19  Jer Noble  <[email protected]>
 
         Many media/media-fragments/ tests are crashing due to other tests that run before them.

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp (274738 => 274739)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp	2021-03-19 21:25:13 UTC (rev 274738)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp	2021-03-19 21:45:20 UTC (rev 274739)
@@ -253,32 +253,20 @@
     if (!section)
         return;
 
-    // All siblings generated?
-    for (auto* current = section->firstRow(); current; current = current->nextRow()) {
-        if (current == &row)
-            continue;
-        if (!current->isAnonymous())
-            return;
+    auto* before = row.previousRow();
+    if (!before)
+        return;
+
+    auto* after = row.nextRow();
+    if (!after)
+        return;
+
+    if (before->isAnonymous() && after->isAnonymous()) {
+        m_builder.moveAllChildren(*after, *before, RenderTreeBuilder::NormalizeAfterInsertion::No);
+        auto toDestroy = m_builder.detach(*section, *after);
     }
 
-    RenderTableRow* rowToInsertInto = nullptr;
-    auto* currentRow = section->firstRow();
-    while (currentRow) {
-        if (currentRow == &row) {
-            currentRow = currentRow->nextRow();
-            continue;
-        }
-        if (!rowToInsertInto) {
-            rowToInsertInto = currentRow;
-            currentRow = currentRow->nextRow();
-            continue;
-        }
-        m_builder.moveAllChildren(*currentRow, *rowToInsertInto, RenderTreeBuilder::NormalizeAfterInsertion::No);
-        auto toDestroy = m_builder.detach(*section, *currentRow);
-        currentRow = currentRow->nextRow();
-    }
-    if (rowToInsertInto)
-        rowToInsertInto->setNeedsLayout();
+    before->setNeedsLayout();
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to