Title: [108098] trunk
- Revision
- 108098
- Author
- [email protected]
- Date
- 2012-02-17 11:02:36 -0800 (Fri, 17 Feb 2012)
Log Message
Table cell's anonymous wrappers are left in the tree, impacting our layout
https://bugs.webkit.org/show_bug.cgi?id=7180
Reviewed by David Hyatt.
Source/WebCore:
Tests: fast/table/table-switch-cell-position-bad-layout-expected.html
fast/table/table-switch-cell-position-bad-layout.html
This patch implements cell's anonymous wrapper removal at detach time.
Trimming the render tree when we remove objects from it would be more complex
to generalize as several objects override the behavior to do their own clean-ups.
This would also open more potential for programming errors.
This change is limited to table cells' as a simple step towards fixing bug 52123
and more generally eliminate some anonymous wrappers from the tree at detach time.
* dom/Node.cpp:
(WebCore::Node::detach):
Patched detach to call destroyAndCleanupAnonymousWrappers. The Document does not need
to clean up any anonymous wrappers on detach.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::destroyAndCleanupAnonymousWrappers):
Added this method to wrap destroy() call and trim the render tree. To avoid slowing down
detach in some cases, added a fast path.
* rendering/RenderObject.h: Added destroyAndCleanupAnonymousWrappers.
LayoutTests:
* fast/table/table-switch-cell-position-bad-layout-expected.html: Added.
* fast/table/table-switch-cell-position-bad-layout.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (108097 => 108098)
--- trunk/LayoutTests/ChangeLog 2012-02-17 19:00:54 UTC (rev 108097)
+++ trunk/LayoutTests/ChangeLog 2012-02-17 19:02:36 UTC (rev 108098)
@@ -1,3 +1,13 @@
+2012-02-17 Julien Chaffraix <[email protected]>
+
+ Table cell's anonymous wrappers are left in the tree, impacting our layout
+ https://bugs.webkit.org/show_bug.cgi?id=7180
+
+ Reviewed by David Hyatt.
+
+ * fast/table/table-switch-cell-position-bad-layout-expected.html: Added.
+ * fast/table/table-switch-cell-position-bad-layout.html: Added.
+
2012-02-17 Rob Buis <[email protected]>
ASSERT (and crash) with dynamically moved <font-face>
Added: trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout-expected.html (0 => 108098)
--- trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout-expected.html (rev 0)
+++ trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout-expected.html 2012-02-17 19:02:36 UTC (rev 108098)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Bug <a href="" Table cell's anonymous wrappers are left in the tree, impacting our layout.</p>
+<p>There should be no red in the output.</p>
+<div style="width: 200px; height: 200px; background-color: green"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout.html (0 => 108098)
--- trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout.html (rev 0)
+++ trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout.html 2012-02-17 19:02:36 UTC (rev 108098)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ table {
+ background-color: red;
+ border-spacing: 0px;
+ }
+ td {
+ background-color: green;
+ height: 100px;
+ padding: 0px;
+ width: 200px;
+ }
+ </style>
+</head>
+<body>
+<p>Bug <a href="" Table cell's anonymous wrappers are left in the tree, impacting our layout.</p>
+<p>There should be no red in the output.</p>
+<table>
+ <tr>
+ <td id="togglePosition"></td>
+ </tr>
+ <tr>
+ <td></td>
+ </tr>
+</table>
+<script>
+ var element = document.getElementById("togglePosition");
+ element.style.position = "absolute";
+
+ element.offsetWidth;
+
+ element.style.position = "static";
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/table/table-switch-cell-position-bad-layout.html
___________________________________________________________________
Added: svn:executable
Modified: trunk/Source/WebCore/ChangeLog (108097 => 108098)
--- trunk/Source/WebCore/ChangeLog 2012-02-17 19:00:54 UTC (rev 108097)
+++ trunk/Source/WebCore/ChangeLog 2012-02-17 19:02:36 UTC (rev 108098)
@@ -1,3 +1,34 @@
+2012-02-17 Julien Chaffraix <[email protected]>
+
+ Table cell's anonymous wrappers are left in the tree, impacting our layout
+ https://bugs.webkit.org/show_bug.cgi?id=7180
+
+ Reviewed by David Hyatt.
+
+ Tests: fast/table/table-switch-cell-position-bad-layout-expected.html
+ fast/table/table-switch-cell-position-bad-layout.html
+
+ This patch implements cell's anonymous wrapper removal at detach time.
+
+ Trimming the render tree when we remove objects from it would be more complex
+ to generalize as several objects override the behavior to do their own clean-ups.
+ This would also open more potential for programming errors.
+
+ This change is limited to table cells' as a simple step towards fixing bug 52123
+ and more generally eliminate some anonymous wrappers from the tree at detach time.
+
+ * dom/Node.cpp:
+ (WebCore::Node::detach):
+ Patched detach to call destroyAndCleanupAnonymousWrappers. The Document does not need
+ to clean up any anonymous wrappers on detach.
+
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::destroyAndCleanupAnonymousWrappers):
+ Added this method to wrap destroy() call and trim the render tree. To avoid slowing down
+ detach in some cases, added a fast path.
+
+ * rendering/RenderObject.h: Added destroyAndCleanupAnonymousWrappers.
+
2012-02-17 Rob Buis <[email protected]>
ASSERT (and crash) with dynamically moved <font-face>
Modified: trunk/Source/WebCore/dom/Node.cpp (108097 => 108098)
--- trunk/Source/WebCore/dom/Node.cpp 2012-02-17 19:00:54 UTC (rev 108097)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-02-17 19:02:36 UTC (rev 108098)
@@ -1340,7 +1340,7 @@
setFlag(InDetachFlag);
if (renderer())
- renderer()->destroy();
+ renderer()->destroyAndCleanupAnonymousWrappers();
setRenderer(0);
Document* doc = document();
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (108097 => 108098)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2012-02-17 19:00:54 UTC (rev 108097)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2012-02-17 19:02:36 UTC (rev 108098)
@@ -2259,6 +2259,33 @@
}
}
+void RenderObject::destroyAndCleanupAnonymousWrappers()
+{
+ RenderObject* parent = this->parent();
+
+ // If the tree is destroyed or our parent is not anonymous, there is no need for a clean-up phase.
+ if (documentBeingDestroyed() || !parent || !parent->isAnonymous()) {
+ destroy();
+ return;
+ }
+
+ bool parentIsLeftOverAnonymousWrapper = false;
+
+ // Currently we only remove anonymous cells' wrapper but we should remove all unneeded
+ // wrappers. See http://webkit.org/b/52123 as an example where this is needed.
+ if (parent->isTableCell())
+ parentIsLeftOverAnonymousWrapper = parent->firstChild() == this && parent->lastChild() == this;
+
+ destroy();
+
+ // WARNING: |this| is deleted here.
+
+ if (parentIsLeftOverAnonymousWrapper) {
+ ASSERT(!parent->firstChild());
+ parent->destroyAndCleanupAnonymousWrappers();
+ }
+}
+
void RenderObject::destroy()
{
willBeDestroyed();
Modified: trunk/Source/WebCore/rendering/RenderObject.h (108097 => 108098)
--- trunk/Source/WebCore/rendering/RenderObject.h 2012-02-17 19:00:54 UTC (rev 108097)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2012-02-17 19:02:36 UTC (rev 108098)
@@ -801,6 +801,7 @@
// as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
bool documentBeingDestroyed() const;
+ void destroyAndCleanupAnonymousWrappers();
virtual void destroy();
// Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes