Title: [105768] trunk
Revision
105768
Author
[email protected]
Date
2012-01-24 11:52:10 -0800 (Tue, 24 Jan 2012)

Log Message

Incorrect positioning of floating pseudo-elements in table captions
https://bugs.webkit.org/show_bug.cgi?id=76664

Reviewed by Julien Chaffraix.

Source/WebCore:

Tests: fast/table/caption-encloses-overhanging-float-expected.html
       fast/table/caption-encloses-overhanging-float.html

Allow table captions to expand and enclose overhanging floats. When performing
layout on a caption ensure that its logical top is set so that it does not mistakenly
conclude that floats in a previous sibling are intruding into it when they're not.

Mostly diagnosed by Abhishek Arya.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::expandsToEncloseOverhangingFloats): add table captions to the list
 that can enclosed overhanging floats.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::layoutCaption): use the best available approximation of the caption's logical
 top offset before laying it out.
(WebCore::RenderTable::layout):
* rendering/RenderTable.h:

LayoutTests:

* fast/table/caption-encloses-overhanging-float-expected.html: Added.
* fast/table/caption-encloses-overhanging-float.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (105767 => 105768)


--- trunk/LayoutTests/ChangeLog	2012-01-24 19:43:07 UTC (rev 105767)
+++ trunk/LayoutTests/ChangeLog	2012-01-24 19:52:10 UTC (rev 105768)
@@ -1,3 +1,13 @@
+2012-01-22  Robert Hogan  <[email protected]>
+
+        Incorrect positioning of floating pseudo-elements in table captions
+        https://bugs.webkit.org/show_bug.cgi?id=76664
+
+        Reviewed by Julien Chaffraix.
+
+        * fast/table/caption-encloses-overhanging-float-expected.html: Added.
+        * fast/table/caption-encloses-overhanging-float.html: Added.
+
 2012-01-24  Adam Barth  <[email protected]>
 
         Similar to the change below, this patch creates Chromium Mac specific

Added: trunk/LayoutTests/fast/table/caption-encloses-overhanging-float-expected.html (0 => 105768)


--- trunk/LayoutTests/fast/table/caption-encloses-overhanging-float-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/caption-encloses-overhanging-float-expected.html	2012-01-24 19:52:10 UTC (rev 105768)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+  </head>
+  <body>
+    <!--    
+        https://bugs.webkit.org/show_bug.cgi?id=76664
+        The 'a' should be in a red box that sits on the bottom left of an enclosing yellow box.
+    -->
+    <style>
+    .caption1 { background-color:yellow; width: 40px; display: inline-block;}
+    .fl { float: left; background-color:red;}
+    </style>
+    <div class="caption1">caption1<div class="fl">a</div></div>
+  </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/table/caption-encloses-overhanging-float-expected.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/table/caption-encloses-overhanging-float.html (0 => 105768)


--- trunk/LayoutTests/fast/table/caption-encloses-overhanging-float.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/caption-encloses-overhanging-float.html	2012-01-24 19:52:10 UTC (rev 105768)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+  <head>
+  </head>
+  <body>
+    <!--    
+        https://bugs.webkit.org/show_bug.cgi?id=76664
+        The 'a' should be in a red box that sits on the bottom left of an enclosing yellow box.
+    -->
+    <style>
+    .caption1 { background-color:yellow; width: 40px; }
+    .fl { float: left; background-color:red;}
+    </style>
+    <table>
+    <caption class="caption1">caption1<div class="fl">a</div></caption>
+    </table>
+  </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/table/caption-encloses-overhanging-float.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (105767 => 105768)


--- trunk/Source/WebCore/ChangeLog	2012-01-24 19:43:07 UTC (rev 105767)
+++ trunk/Source/WebCore/ChangeLog	2012-01-24 19:52:10 UTC (rev 105768)
@@ -1,3 +1,28 @@
+2012-01-22  Robert Hogan  <[email protected]>
+
+        Incorrect positioning of floating pseudo-elements in table captions
+        https://bugs.webkit.org/show_bug.cgi?id=76664
+
+        Reviewed by Julien Chaffraix.
+
+        Tests: fast/table/caption-encloses-overhanging-float-expected.html
+               fast/table/caption-encloses-overhanging-float.html
+
+        Allow table captions to expand and enclose overhanging floats. When performing
+        layout on a caption ensure that its logical top is set so that it does not mistakenly
+        conclude that floats in a previous sibling are intruding into it when they're not.
+
+        Mostly diagnosed by Abhishek Arya.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::expandsToEncloseOverhangingFloats): add table captions to the list
+         that can enclosed overhanging floats.
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::layoutCaption): use the best available approximation of the caption's logical
+         top offset before laying it out.
+        (WebCore::RenderTable::layout):
+        * rendering/RenderTable.h:
+
 2012-01-24  Kentaro Hara  <[email protected]>
 
         In CodeGeneratorV8.pm, overwrite the output .h/.cpp

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (105767 => 105768)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-01-24 19:43:07 UTC (rev 105767)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-01-24 19:52:10 UTC (rev 105768)
@@ -1515,7 +1515,7 @@
 bool RenderBlock::expandsToEncloseOverhangingFloats() const
 {
     return isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || (parent() && parent()->isDeprecatedFlexibleBox())
-           || hasColumns() || isTableCell() || isFieldset() || isWritingModeRoot() || isRoot();
+           || hasColumns() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() || isRoot();
 }
 
 void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marginInfo)

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (105767 => 105768)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2012-01-24 19:43:07 UTC (rev 105767)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2012-01-24 19:52:10 UTC (rev 105768)
@@ -266,11 +266,20 @@
     }
 }
 
-void RenderTable::adjustLogicalHeightForCaption(RenderBlock* caption)
+void RenderTable::layoutCaption(RenderTableCaption* caption)
 {
     IntRect captionRect(caption->x(), caption->y(), caption->width(), caption->height());
 
+    if (caption->needsLayout()) {
+        // The margins may not be available but ensure the caption is at least located beneath any previous sibling caption
+        // so that it does not mistakenly think any floats in the previous caption intrude into it.
+        caption->setLogicalLocation(IntPoint(caption->marginStart(), caption->marginBefore() + logicalHeight()));
+        // If RenderTableCaption ever gets a layout() function, use it here.
+        caption->layoutIfNeeded();
+    }
+    // Apply the margins to the location now that they are definitely available from layout
     caption->setLogicalLocation(IntPoint(caption->marginStart(), caption->marginBefore() + logicalHeight()));
+
     if (!selfNeedsLayout() && caption->checkForRepaintDuringLayout())
         caption->repaintDuringLayoutIfMoved(captionRect);
 
@@ -331,10 +340,6 @@
         }
     }
 
-    // Only lay out one caption, since it's the only one we're going to end up painting.
-    for (unsigned i = 0; i < m_captions.size(); i++)
-        m_captions[i]->layoutIfNeeded();
-
     // If any table section moved vertically, we will just repaint everything from that
     // section down (it is quite unlikely that any of the following sections
     // did not shift).
@@ -346,7 +351,7 @@
         for (unsigned i = 0; i < m_captions.size(); i++) {
             if (m_captions[i]->style()->captionSide() == CAPBOTTOM)
                 continue;
-            adjustLogicalHeightForCaption(m_captions[i]);
+            layoutCaption(m_captions[i]);
         }
         if (logicalHeight() != oldTableLogicalTop) {
             sectionMoved = true;
@@ -406,7 +411,7 @@
     for (unsigned i = 0; i < m_captions.size(); i++) {
         if (m_captions[i]->style()->captionSide() != CAPBOTTOM)
             continue;
-        adjustLogicalHeightForCaption(m_captions[i]);
+        layoutCaption(m_captions[i]);
     }
 
     if (isPositioned())

Modified: trunk/Source/WebCore/rendering/RenderTable.h (105767 => 105768)


--- trunk/Source/WebCore/rendering/RenderTable.h	2012-01-24 19:43:07 UTC (rev 105767)
+++ trunk/Source/WebCore/rendering/RenderTable.h	2012-01-24 19:52:10 UTC (rev 105768)
@@ -248,7 +248,7 @@
 
     void recalcCollapsedBorders();
     void recalcSections() const;
-    void adjustLogicalHeightForCaption(RenderBlock*);
+    void layoutCaption(RenderTableCaption*);
 
     mutable Vector<LayoutUnit> m_columnPos;
     mutable Vector<ColumnStruct> m_columns;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to