Title: [208281] trunk/Source/WebCore
Revision
208281
Author
za...@apple.com
Date
2016-11-02 07:17:21 -0700 (Wed, 02 Nov 2016)

Log Message

[Tables] Simplified layout skips captions.
https://bugs.webkit.org/show_bug.cgi?id=164284

Reviewed by David Hyatt.

This patch ensures that we take care of simplified normalflow captions during layout.

Covered by fast/regions/table-caption-as-region.html

* rendering/RenderTable.cpp:
(WebCore::RenderTable::layoutCaption):
(WebCore::RenderTable::layoutCaptions): _caption_side is 2bits, can't use bitmask.
(WebCore::RenderTable::simplifiedNormalFlowLayout):
(WebCore::RenderTable::layout):
* rendering/RenderTable.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208280 => 208281)


--- trunk/Source/WebCore/ChangeLog	2016-11-02 13:38:54 UTC (rev 208280)
+++ trunk/Source/WebCore/ChangeLog	2016-11-02 14:17:21 UTC (rev 208281)
@@ -1,3 +1,21 @@
+2016-11-02  Zalan Bujtas  <za...@apple.com>
+
+        [Tables] Simplified layout skips captions.
+        https://bugs.webkit.org/show_bug.cgi?id=164284
+
+        Reviewed by David Hyatt.
+
+        This patch ensures that we take care of simplified normalflow captions during layout.    
+
+        Covered by fast/regions/table-caption-as-region.html
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::layoutCaption):
+        (WebCore::RenderTable::layoutCaptions): _caption_side is 2bits, can't use bitmask. 
+        (WebCore::RenderTable::simplifiedNormalFlowLayout):
+        (WebCore::RenderTable::layout):
+        * rendering/RenderTable.h:
+
 2016-11-02  Youenn Fablet  <you...@apple.com>
 
         REGRESSION(r207753-207755): ASSERTION FAILED: m_parsedStyleSheetCache->isInMemoryCache()

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (208280 => 208281)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2016-11-02 13:38:54 UTC (rev 208280)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2016-11-02 14:17:21 UTC (rev 208281)
@@ -381,26 +381,39 @@
     return LayoutUnit();
 }
 
-void RenderTable::layoutCaption(RenderTableCaption* caption)
+void RenderTable::layoutCaption(RenderTableCaption& caption)
 {
-    LayoutRect captionRect(caption->frameRect());
+    LayoutRect captionRect(caption.frameRect());
 
-    if (caption->needsLayout()) {
+    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(LayoutPoint(caption->marginStart(), caption->marginBefore() + logicalHeight()));
+        caption.setLogicalLocation(LayoutPoint(caption.marginStart(), caption.marginBefore() + logicalHeight()));
         // If RenderTableCaption ever gets a layout() function, use it here.
-        caption->layoutIfNeeded();
+        caption.layoutIfNeeded();
     }
     // Apply the margins to the location now that they are definitely available from layout
-    caption->setLogicalLocation(LayoutPoint(caption->marginStart(), caption->marginBefore() + logicalHeight()));
+    caption.setLogicalLocation(LayoutPoint(caption.marginStart(), caption.marginBefore() + logicalHeight()));
 
-    if (!selfNeedsLayout() && caption->checkForRepaintDuringLayout())
-        caption->repaintDuringLayoutIfMoved(captionRect);
+    if (!selfNeedsLayout() && caption.checkForRepaintDuringLayout())
+        caption.repaintDuringLayoutIfMoved(captionRect);
 
-    setLogicalHeight(logicalHeight() + caption->logicalHeight() + caption->marginBefore() + caption->marginAfter());
+    setLogicalHeight(logicalHeight() + caption.logicalHeight() + caption.marginBefore() + caption.marginAfter());
 }
 
+void RenderTable::layoutCaptions(BottomCaptionLayoutPhase bottomCaptionLayoutPhase)
+{
+    if (m_captions.isEmpty())
+        return;
+    // FIXME: Collapse caption margin.
+    for (unsigned i = 0; i < m_captions.size(); ++i) {
+        if ((bottomCaptionLayoutPhase == BottomCaptionLayoutPhase::Yes && m_captions[i]->style().captionSide() != CAPBOTTOM)
+            || (bottomCaptionLayoutPhase == BottomCaptionLayoutPhase::No && m_captions[i]->style().captionSide() == CAPBOTTOM))
+            continue;
+        layoutCaption(*m_captions[i]);
+    }
+}
+
 void RenderTable::distributeExtraLogicalHeight(LayoutUnit extraLogicalHeight)
 {
     if (extraLogicalHeight <= 0)
@@ -417,10 +430,12 @@
 
 void RenderTable::simplifiedNormalFlowLayout()
 {
+    layoutCaptions();
     for (RenderTableSection* section = topSection(); section; section = sectionBelow(section)) {
         section->layoutIfNeeded();
         section->computeOverflowFromCells();
     }
+    layoutCaptions(BottomCaptionLayoutPhase::Yes);
 }
 
 void RenderTable::layout()
@@ -484,17 +499,10 @@
     bool sectionMoved = false;
     LayoutUnit movedSectionLogicalTop = 0;
 
-    // FIXME: Collapse caption margin.
-    if (!m_captions.isEmpty()) {
-        for (unsigned i = 0; i < m_captions.size(); i++) {
-            if (m_captions[i]->style().captionSide() == CAPBOTTOM)
-                continue;
-            layoutCaption(m_captions[i]);
-        }
-        if (logicalHeight() != oldTableLogicalTop) {
-            sectionMoved = true;
-            movedSectionLogicalTop = std::min(logicalHeight(), oldTableLogicalTop);
-        }
+    layoutCaptions();
+    if (!m_captions.isEmpty() && logicalHeight() != oldTableLogicalTop) {
+        sectionMoved = true;
+        movedSectionLogicalTop = std::min(logicalHeight(), oldTableLogicalTop);
     }
 
     LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? LayoutUnit() : paddingBefore());
@@ -553,11 +561,7 @@
 
     setLogicalHeight(logicalHeight() + borderAndPaddingAfter);
 
-    for (unsigned i = 0; i < m_captions.size(); i++) {
-        if (m_captions[i]->style().captionSide() != CAPBOTTOM)
-            continue;
-        layoutCaption(m_captions[i]);
-    }
+    layoutCaptions(BottomCaptionLayoutPhase::Yes);
 
     if (isOutOfFlowPositioned())
         updateLogicalHeight();

Modified: trunk/Source/WebCore/rendering/RenderTable.h (208280 => 208281)


--- trunk/Source/WebCore/rendering/RenderTable.h	2016-11-02 13:38:54 UTC (rev 208280)
+++ trunk/Source/WebCore/rendering/RenderTable.h	2016-11-02 14:17:21 UTC (rev 208281)
@@ -319,7 +319,9 @@
 
     void recalcCollapsedBorders();
     void recalcSections() const;
-    void layoutCaption(RenderTableCaption*);
+    enum class BottomCaptionLayoutPhase { Yes, No };
+    void layoutCaptions(BottomCaptionLayoutPhase = BottomCaptionLayoutPhase::No);
+    void layoutCaption(RenderTableCaption&);
 
     void distributeExtraLogicalHeight(LayoutUnit extraLogicalHeight);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to