Title: [111217] trunk/Source/WebCore
Revision
111217
Author
[email protected]
Date
2012-03-19 12:28:39 -0700 (Mon, 19 Mar 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=81534

[New Multicolumn] Make the multi-column block re-layout its children when the column width/count change.
Cache the count/width on the multi-column block for easy access.

Reviewed by Antti Koivisto.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::recomputeLogicalWidth):
(WebCore::RenderBlock::layoutBlock):
* rendering/RenderBlock.h:
Virtualize the code that recomputes the logical width for a block and sets relayoutChildren to true,
so that column code can subclass the method to also check for changes in the column width/count.

* rendering/RenderMultiColumnBlock.cpp:
(WebCore::RenderMultiColumnBlock::computeColumnCountAndWidth):
The column count/width determination algorithm in one method on the RenderMultiColumnBlock. It's a copy
of the code from RenderBlock (which will be going away eventually).

(WebCore::RenderMultiColumnBlock::recomputeLogicalWidth):
* rendering/RenderMultiColumnBlock.h:
(RenderMultiColumnBlock):
Subclassed method to also check for changes in the column width to set relayoutChildren to true.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111216 => 111217)


--- trunk/Source/WebCore/ChangeLog	2012-03-19 19:19:12 UTC (rev 111216)
+++ trunk/Source/WebCore/ChangeLog	2012-03-19 19:28:39 UTC (rev 111217)
@@ -1,3 +1,29 @@
+2012-03-19  David Hyatt  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=81534
+
+        [New Multicolumn] Make the multi-column block re-layout its children when the column width/count change.
+        Cache the count/width on the multi-column block for easy access.
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::recomputeLogicalWidth):
+        (WebCore::RenderBlock::layoutBlock):
+        * rendering/RenderBlock.h:
+        Virtualize the code that recomputes the logical width for a block and sets relayoutChildren to true,
+        so that column code can subclass the method to also check for changes in the column width/count.
+
+        * rendering/RenderMultiColumnBlock.cpp:
+        (WebCore::RenderMultiColumnBlock::computeColumnCountAndWidth):
+        The column count/width determination algorithm in one method on the RenderMultiColumnBlock. It's a copy
+        of the code from RenderBlock (which will be going away eventually).
+
+        (WebCore::RenderMultiColumnBlock::recomputeLogicalWidth):
+        * rendering/RenderMultiColumnBlock.h:
+        (RenderMultiColumnBlock):
+        Subclassed method to also check for changes in the column width to set relayoutChildren to true.
+
 2012-03-19  Michal Mocny  <[email protected]>
 
         [chromium] Updating WebGraphicsContext3D MemoryAllocation callback to accept a struct with have backbuffer suggestion.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (111216 => 111217)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-19 19:19:12 UTC (rev 111216)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-19 19:28:39 UTC (rev 111217)
@@ -1423,6 +1423,17 @@
         enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage());
 }
 
+bool RenderBlock::recomputeLogicalWidth()
+{
+    LayoutUnit oldWidth = logicalWidth();
+    LayoutUnit oldColumnWidth = desiredColumnWidth();
+
+    computeLogicalWidth();
+    calcColumnWidth();
+
+    return oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth();
+}
+
 void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight, BlockLayoutPass layoutPass)
 {
     ASSERT(needsLayout());
@@ -1435,17 +1446,11 @@
 
     LayoutRepainter repainter(*this, everHadLayout() && checkForRepaintDuringLayout());
 
-    LayoutUnit oldWidth = logicalWidth();
-    LayoutUnit oldColumnWidth = desiredColumnWidth();
+    if (recomputeLogicalWidth())
+        relayoutChildren = true;
 
-    computeLogicalWidth();
-    calcColumnWidth();
-
     m_overflow.clear();
 
-    if (oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth())
-        relayoutChildren = true;
-
     // If nothing changed about our floating positioned objects, let's go ahead and try to place them as
     // floats to avoid doing two passes.
     BlockLayoutPass floatsLayoutPass = layoutPass;

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (111216 => 111217)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2012-03-19 19:19:12 UTC (rev 111216)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2012-03-19 19:28:39 UTC (rev 111217)
@@ -985,6 +985,8 @@
 
     virtual bool requiresColumns(int desiredColumnCount) const;
 
+    virtual bool recomputeLogicalWidth();
+
 public:
     LayoutUnit offsetFromLogicalTopOfFirstPage() const;
     RenderRegion* regionAtBlockOffset(LayoutUnit) const;

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp (111216 => 111217)


--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp	2012-03-19 19:19:12 UTC (rev 111216)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp	2012-03-19 19:28:39 UTC (rev 111217)
@@ -26,13 +26,53 @@
 #include "config.h"
 #include "RenderMultiColumnBlock.h"
 
+using namespace std;
+
 namespace WebCore {
 
 RenderMultiColumnBlock::RenderMultiColumnBlock(Node* node)
     : RenderBlock(node)
+    , m_columnCount(1)
+    , m_columnWidth(0)
 {
 }
 
+void RenderMultiColumnBlock::computeColumnCountAndWidth()
+{
+    // Calculate our column width and column count.
+    // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744
+    m_columnCount = 1;
+    m_columnWidth = contentLogicalWidth();
+    
+    ASSERT(!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth());
+
+    LayoutUnit availWidth = m_columnWidth;
+    LayoutUnit colGap = columnGap();
+    LayoutUnit colWidth = max<LayoutUnit>(1, LayoutUnit(style()->columnWidth()));
+    int colCount = max<int>(1, style()->columnCount());
+
+    if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) {
+        m_columnCount = colCount;
+        m_columnWidth = max<LayoutUnit>(0, (availWidth - ((m_columnCount - 1) * colGap)) / m_columnCount);
+    } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount()) {
+        m_columnCount = max<LayoutUnit>(1, (availWidth + colGap) / (colWidth + colGap));
+        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
+    } else {
+        m_columnCount = max<LayoutUnit>(min<LayoutUnit>(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
+        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
+    }
+}
+
+bool RenderMultiColumnBlock::recomputeLogicalWidth()
+{
+    bool relayoutChildren = RenderBlock::recomputeLogicalWidth();
+    LayoutUnit oldColumnWidth = m_columnWidth;
+    computeColumnCountAndWidth();
+    if (m_columnWidth != oldColumnWidth)
+        relayoutChildren = true;
+    return relayoutChildren;
+}
+
 const char* RenderMultiColumnBlock::renderName() const
 {    
     if (isFloating())

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h (111216 => 111217)


--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h	2012-03-19 19:19:12 UTC (rev 111216)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h	2012-03-19 19:28:39 UTC (rev 111217)
@@ -37,6 +37,14 @@
     
 private:
     virtual const char* renderName() const;
+
+    virtual bool recomputeLogicalWidth();
+    void computeColumnCountAndWidth();
+
+private:
+    unsigned m_columnCount;   // The default column count/width that are based off our containing block width. These values represent only the default,
+    LayoutUnit m_columnWidth; // since a multi-column block that is split across variable width pages or regions will have different column counts and widths in each.
+                              // These values will be cached (eventually) for multi-column blocks.
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to