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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108098
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-17 Julien Chaffraix <jchaffraix@webkit.org>
+
+ 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 <rbuis@rim.com>
ASSERT (and crash) with dynamically moved <font-face>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<p>Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=7180">7180</a>: 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>
--- /dev/null
+<!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="https://bugs.webkit.org/show_bug.cgi?id=7180">7180</a>: 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>
+2012-02-17 Julien Chaffraix <jchaffraix@webkit.org>
+
+ 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 <rbuis@rim.com>
ASSERT (and crash) with dynamically moved <font-face>
setFlag(InDetachFlag);
if (renderer())
- renderer()->destroy();
+ renderer()->destroyAndCleanupAnonymousWrappers();
setRenderer(0);
Document* doc = document();
}
}
+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();
// 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).