- Revision
- 275059
- Author
- [email protected]
- Date
- 2021-03-25 14:45:05 -0700 (Thu, 25 Mar 2021)
Log Message
Collapse newly adjacent anonymous table cells when a table cell is detached from between them.
https://bugs.webkit.org/show_bug.cgi?id=220934
Reviewed by Zalan Bujtas.
Source/WebCore:
We already had support for collapsing newly adjacent table row cells when a
table row cell is detached from between them. We need to do this for anonymous
table cells too.
Test: fast/table/table-anonymous-cell-collapse.html
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::destroyAndCleanUpAnonymousWrappers): Call
into the RenderTreeBuilder::Table to collapse anonymous table cells when
needed.
* rendering/updating/RenderTreeBuilderTable.cpp:
(WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblings):
Factor out the existing collapseAndDestroyAnonymousSiblingRows into
something re-usable.
(WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingCells):
Added.
(WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows):
Factored out to collapseAndDestroyAnonymousSiblings.
* rendering/updating/RenderTreeBuilderTable.h:
LayoutTests:
* fast/table/table-anonymous-cell-collapse-expected.html: Added.
* fast/table/table-anonymous-cell-collapse.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (275058 => 275059)
--- trunk/LayoutTests/ChangeLog 2021-03-25 21:34:57 UTC (rev 275058)
+++ trunk/LayoutTests/ChangeLog 2021-03-25 21:45:05 UTC (rev 275059)
@@ -1,3 +1,13 @@
+2021-03-25 Cameron McCormack <[email protected]>
+
+ Collapse newly adjacent anonymous table cells when a table cell is detached from between them.
+ https://bugs.webkit.org/show_bug.cgi?id=220934
+
+ Reviewed by Zalan Bujtas.
+
+ * fast/table/table-anonymous-cell-collapse-expected.html: Added.
+ * fast/table/table-anonymous-cell-collapse.html: Added.
+
2021-03-25 Tim Nguyen <[email protected]>
Enable normalization-conic-2.html WPT now that underlying bug is fixed.
Added: trunk/LayoutTests/fast/table/table-anonymous-cell-collapse-expected.html (0 => 275059)
--- trunk/LayoutTests/fast/table/table-anonymous-cell-collapse-expected.html (rev 0)
+++ trunk/LayoutTests/fast/table/table-anonymous-cell-collapse-expected.html 2021-03-25 21:45:05 UTC (rev 275059)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+td { display: block; }
+</style>
+Test passes if
+<table border="3" cellpadding="10">
+ <td>each cell</td>
+ <td>is in its</td>
+ <td>own row.</td>
+</table>
Added: trunk/LayoutTests/fast/table/table-anonymous-cell-collapse.html (0 => 275059)
--- trunk/LayoutTests/fast/table/table-anonymous-cell-collapse.html (rev 0)
+++ trunk/LayoutTests/fast/table/table-anonymous-cell-collapse.html 2021-03-25 21:45:05 UTC (rev 275059)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+Test passes if
+<table border="3" cellpadding="10">
+ <td id=first>each cell</td>
+ <td id=second>is in its</td>
+ <td style="display: block;">own row.</td>
+</table>
+<script>
+document.body.offsetHeight;
+first.style.display = "block";
+second.style.display = "block";
+</script>
Modified: trunk/Source/WebCore/ChangeLog (275058 => 275059)
--- trunk/Source/WebCore/ChangeLog 2021-03-25 21:34:57 UTC (rev 275058)
+++ trunk/Source/WebCore/ChangeLog 2021-03-25 21:45:05 UTC (rev 275059)
@@ -1,3 +1,30 @@
+2021-03-25 Cameron McCormack <[email protected]>
+
+ Collapse newly adjacent anonymous table cells when a table cell is detached from between them.
+ https://bugs.webkit.org/show_bug.cgi?id=220934
+
+ Reviewed by Zalan Bujtas.
+
+ We already had support for collapsing newly adjacent table row cells when a
+ table row cell is detached from between them. We need to do this for anonymous
+ table cells too.
+
+ Test: fast/table/table-anonymous-cell-collapse.html
+
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::destroyAndCleanUpAnonymousWrappers): Call
+ into the RenderTreeBuilder::Table to collapse anonymous table cells when
+ needed.
+ * rendering/updating/RenderTreeBuilderTable.cpp:
+ (WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblings):
+ Factor out the existing collapseAndDestroyAnonymousSiblingRows into
+ something re-usable.
+ (WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingCells):
+ Added.
+ (WebCore::RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows):
+ Factored out to collapseAndDestroyAnonymousSiblings.
+ * rendering/updating/RenderTreeBuilderTable.h:
+
2021-03-25 Tim Nguyen <[email protected]>
Fix edge cases in normalization of conic-gradient color stops
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (275058 => 275059)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2021-03-25 21:34:57 UTC (rev 275058)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2021-03-25 21:45:05 UTC (rev 275059)
@@ -51,6 +51,7 @@
#include "RenderSVGRoot.h"
#include "RenderSVGText.h"
#include "RenderTable.h"
+#include "RenderTableCell.h"
#include "RenderTableRow.h"
#include "RenderTableSection.h"
#include "RenderText.h"
@@ -826,9 +827,20 @@
};
clearFloatsAndOutOfFlowPositionedObjects();
- if (is<RenderTableRow>(destroyRoot))
- tableBuilder().collapseAndDestroyAnonymousSiblingRows(downcast<RenderTableRow>(destroyRoot));
+ auto collapseAndDestroyAnonymousSiblings = [&] {
+ // FIXME: Probably need to handle other table parts here as well.
+ if (is<RenderTableCell>(destroyRoot)) {
+ tableBuilder().collapseAndDestroyAnonymousSiblingCells(downcast<RenderTableCell>(destroyRoot));
+ return;
+ }
+ if (is<RenderTableRow>(destroyRoot)) {
+ tableBuilder().collapseAndDestroyAnonymousSiblingRows(downcast<RenderTableRow>(destroyRoot));
+ return;
+ }
+ };
+ collapseAndDestroyAnonymousSiblings();
+
// FIXME: Do not try to collapse/cleanup the anonymous wrappers inside destroy (see webkit.org/b/186746).
auto destroyRootParent = makeWeakPtr(*destroyRoot.parent());
if (&rendererToDestroy != &destroyRoot) {
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp (275058 => 275059)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp 2021-03-25 21:34:57 UTC (rev 275058)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp 2021-03-25 21:45:05 UTC (rev 275059)
@@ -247,26 +247,28 @@
return false;
}
-void RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows(RenderTableRow& row)
+template <typename Parent, typename Child>
+void RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblings(Parent* parent, Child* previousSibling, Child* nextSibling)
{
- auto* section = row.section();
- if (!section)
+ if (!parent || !previousSibling || !nextSibling)
return;
- auto* before = row.previousRow();
- if (!before)
- return;
+ if (previousSibling->isAnonymous() && nextSibling->isAnonymous()) {
+ m_builder.moveAllChildren(*nextSibling, *previousSibling, RenderTreeBuilder::NormalizeAfterInsertion::No);
+ auto toDestroy = m_builder.detach(*parent, *nextSibling);
+ }
- auto* after = row.nextRow();
- if (!after)
- return;
+ previousSibling->setNeedsLayout();
+}
- if (before->isAnonymous() && after->isAnonymous()) {
- m_builder.moveAllChildren(*after, *before, RenderTreeBuilder::NormalizeAfterInsertion::No);
- auto toDestroy = m_builder.detach(*section, *after);
- }
+void RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingCells(RenderTableCell& cell)
+{
+ collapseAndDestroyAnonymousSiblings(cell.row(), cell.previousCell(), cell.nextCell());
+}
- before->setNeedsLayout();
+void RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows(RenderTableRow& row)
+{
+ collapseAndDestroyAnonymousSiblings(row.section(), row.previousRow(), row.nextRow());
}
}
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.h (275058 => 275059)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.h 2021-03-25 21:34:57 UTC (rev 275058)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderTable.h 2021-03-25 21:45:05 UTC (rev 275059)
@@ -32,6 +32,7 @@
class RenderElement;
class RenderObject;
class RenderTable;
+class RenderTableCell;
class RenderTableSection;
class RenderTableRow;
class RenderTreeBuilder;
@@ -51,9 +52,13 @@
bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
+ void collapseAndDestroyAnonymousSiblingCells(RenderTableCell&);
void collapseAndDestroyAnonymousSiblingRows(RenderTableRow&);
private:
+ template <typename Parent, typename Child>
+ void collapseAndDestroyAnonymousSiblings(Parent*, Child* previousChild, Child* nextChild);
+
RenderTreeBuilder& m_builder;
};