Title: [127297] trunk/Source/WebCore
Revision
127297
Author
[email protected]
Date
2012-08-31 11:51:39 -0700 (Fri, 31 Aug 2012)

Log Message

[New Multicolumn] Implement column repainting.
https://bugs.webkit.org/show_bug.cgi?id=95593

Reviewed by Dan Bernstein.
        
Make the new columns repaint properly. Note this code is a significant improvement over the
old multicolumn code in that repaints are properly issued per-column, i.e., no more fuzzy
uniting of rects.

* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::columnIndexAtOffset):
(WebCore):
(WebCore::RenderMultiColumnSet::repaintFlowThreadContent):
* rendering/RenderMultiColumnSet.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127296 => 127297)


--- trunk/Source/WebCore/ChangeLog	2012-08-31 18:45:30 UTC (rev 127296)
+++ trunk/Source/WebCore/ChangeLog	2012-08-31 18:51:39 UTC (rev 127297)
@@ -1,3 +1,20 @@
+2012-08-31  David Hyatt  <[email protected]>
+
+        [New Multicolumn] Implement column repainting.
+        https://bugs.webkit.org/show_bug.cgi?id=95593
+
+        Reviewed by Dan Bernstein.
+        
+        Make the new columns repaint properly. Note this code is a significant improvement over the
+        old multicolumn code in that repaints are properly issued per-column, i.e., no more fuzzy
+        uniting of rects.
+
+        * rendering/RenderMultiColumnSet.cpp:
+        (WebCore::RenderMultiColumnSet::columnIndexAtOffset):
+        (WebCore):
+        (WebCore::RenderMultiColumnSet::repaintFlowThreadContent):
+        * rendering/RenderMultiColumnSet.h:
+
 2012-08-31  Alok Priyadarshi  <[email protected]>
 
         [chromium] Layout tests svg-filters.html and alpha.html are crashing intermittently

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (127296 => 127297)


--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp	2012-08-31 18:45:30 UTC (rev 127296)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp	2012-08-31 18:51:39 UTC (rev 127297)
@@ -108,6 +108,22 @@
     return LayoutRect(colLogicalTop, colLogicalLeft, colLogicalHeight, colLogicalWidth);
 }
 
+unsigned RenderMultiColumnSet::columnIndexAtOffset(LayoutUnit offset) const
+{
+    LayoutRect portionRect(flowThreadPortionRect());
+    LayoutUnit flowThreadLogicalTop = isHorizontalWritingMode() ? portionRect.y() : portionRect.x();
+    LayoutUnit flowThreadLogicalBottom = isHorizontalWritingMode() ? portionRect.maxY() : portionRect.maxX();
+    
+    // Handle the offset being out of range.
+    if (offset < flowThreadLogicalTop)
+        return 0;
+    if (offset >= flowThreadLogicalBottom)
+        return columnCount() - 1;
+    
+    // Just divide by the column height to determine the correct column.
+    return static_cast<float>(offset - flowThreadLogicalTop) / computedColumnHeight();
+}
+
 LayoutRect RenderMultiColumnSet::flowThreadPortionRectAt(unsigned index) const
 {
     LayoutRect portionRect = flowThreadPortionRect();
@@ -305,6 +321,44 @@
     return !result.addNodeToRectBasedTestResult(node(), locationInContainer, boundsRect);
 }
 
+void RenderMultiColumnSet::repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const
+{
+    // Figure out the start and end columns and only check within that range so that we don't walk the
+    // entire column set. Put the repaint rect into flow thread coordinates by flipping it first.
+    LayoutRect flowThreadRepaintRect(repaintRect);
+    flowThread()->flipForWritingMode(flowThreadRepaintRect);
+    
+    // Now we can compare this rect with the flow thread portions owned by each column. First let's
+    // just see if the repaint rect intersects our flow thread portion at all.
+    LayoutRect clippedRect(flowThreadRepaintRect);
+    clippedRect.intersect(RenderRegion::flowThreadPortionOverflowRect());
+    if (clippedRect.isEmpty())
+        return;
+    
+    // Now we know we intersect at least one column. Let's figure out the logical top and logical
+    // bottom of the area we're repainting.
+    LayoutUnit repaintLogicalTop = isHorizontalWritingMode() ? flowThreadRepaintRect.y() : flowThreadRepaintRect.x();
+    LayoutUnit repaintLogicalBottom = (isHorizontalWritingMode() ? flowThreadRepaintRect.maxY() : flowThreadRepaintRect.maxX()) - 1;
+    
+    unsigned startColumn = columnIndexAtOffset(repaintLogicalTop);
+    unsigned endColumn = columnIndexAtOffset(repaintLogicalBottom);
+    
+    LayoutUnit colGap = columnGap();
+    unsigned colCount = columnCount();
+    for (unsigned i = startColumn; i <= endColumn; i++) {
+        LayoutRect colRect = columnRectAt(i);
+        
+        // Get the portion of the flow thread that corresponds to this column.
+        LayoutRect flowThreadPortion = flowThreadPortionRectAt(i);
+        
+        // Now get the overflow rect that corresponds to the column.
+        LayoutRect flowThreadOverflowPortion = flowThreadPortionOverflowRect(flowThreadPortion, i, colCount, colGap);
+
+        // Do a repaint for this specific column.
+        repaintFlowThreadContentRectangle(repaintRect, immediate, flowThreadPortion, flowThreadOverflowPortion, colRect.location());
+    }
+}
+
 const char* RenderMultiColumnSet::renderName() const
 {    
     return "RenderMultiColumnSet";

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.h (127296 => 127297)


--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.h	2012-08-31 18:45:30 UTC (rev 127296)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.h	2012-08-31 18:51:39 UTC (rev 127297)
@@ -76,6 +76,8 @@
     // FIXME: This will change once we have column sets constrained by enclosing pages, etc.
     virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; }
     
+    virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const OVERRIDE;
+
     virtual const char* renderName() const;
     
     void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset);
@@ -87,7 +89,9 @@
 
     LayoutRect flowThreadPortionRectAt(unsigned index) const;
     LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, int colGap) const;
-
+    
+    unsigned columnIndexAtOffset(LayoutUnit) const;
+    
     unsigned m_computedColumnCount;
     LayoutUnit m_computedColumnWidth;
     LayoutUnit m_computedColumnHeight;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to