[New Multicolumn] Refactor flow thread repainting.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2012 17:37:47 +0000 (17:37 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2012 17:37:47 +0000 (17:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95586

Reviewed by Simon Fraser.

Refactor flow thread repainting in regions to delegate the work to the region. This allows subclasses
to customize how the repainting happens so that individual repaints can be issued for columns and pages
inside sets.

repaintFlowThreadContent is the new virtual function that can be subclassed by sets to customize
the repaint process.

repaintFlowThreadContentRectangle is a parameterized helper that will be called for each individual
column and page in a set.

* WebCore.exp.in:
Change repaintRectangle's signature to be const.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::repaintRectangleInRegions):
Now delegates the work for each region to RenderRegion::repaintFlowThreadContent.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::repaintUsingContainer):
(WebCore::RenderObject::repaint):
(WebCore::RenderObject::repaintRectangle):
(WebCore::RenderObject::isRooted):
* rendering/RenderObject.h:
Change a bunch of functions to be const.

* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::repaintFlowThreadContent):
(WebCore):
(WebCore::RenderRegion::repaintFlowThreadContentRectangle):
* rendering/RenderRegion.h:
(RenderRegion):
Add the two new functions (the virtual repaintFlowThreadContent and the helper it
uses, repaintFlowThreadContentRectangle).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@127280 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderRegion.h

index 769ae1b..0753a1a 100644 (file)
@@ -1,3 +1,44 @@
+2012-08-31  David Hyatt  <hyatt@apple.com>
+
+        [New Multicolumn] Refactor flow thread repainting.
+        https://bugs.webkit.org/show_bug.cgi?id=95586
+
+        Reviewed by Simon Fraser.
+
+        Refactor flow thread repainting in regions to delegate the work to the region. This allows subclasses
+        to customize how the repainting happens so that individual repaints can be issued for columns and pages
+        inside sets.
+        
+        repaintFlowThreadContent is the new virtual function that can be subclassed by sets to customize
+        the repaint process.
+        
+        repaintFlowThreadContentRectangle is a parameterized helper that will be called for each individual
+        column and page in a set.
+
+        * WebCore.exp.in:
+        Change repaintRectangle's signature to be const.
+
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::repaintRectangleInRegions):
+        Now delegates the work for each region to RenderRegion::repaintFlowThreadContent.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::repaintUsingContainer):
+        (WebCore::RenderObject::repaint):
+        (WebCore::RenderObject::repaintRectangle):
+        (WebCore::RenderObject::isRooted):
+        * rendering/RenderObject.h:
+        Change a bunch of functions to be const.
+
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::repaintFlowThreadContent):
+        (WebCore):
+        (WebCore::RenderRegion::repaintFlowThreadContentRectangle):
+        * rendering/RenderRegion.h:
+        (RenderRegion):
+        Add the two new functions (the virtual repaintFlowThreadContent and the helper it
+        uses, repaintFlowThreadContentRectangle).
+
 2012-08-31  Yong Li  <yoli@rim.com>
 
         [BlackBerry] Disable GCController timer for PLATFORM(BLACKBERRY)
index c2cbaca..b577e6f 100644 (file)
@@ -184,7 +184,7 @@ __ZN7WebCore12PrintContext9spoolPageERNS_15GraphicsContextEif
 __ZN7WebCore12PrintContext9spoolRectERNS_15GraphicsContextERKNS_7IntRectE
 __ZN7WebCore12PrintContextC1EPNS_5FrameE
 __ZN7WebCore12PrintContextD1Ev
-__ZN7WebCore12RenderObject16repaintRectangleERKNS_20FractionalLayoutRectEb
+__ZNK7WebCore12RenderObject16repaintRectangleERKNS_20FractionalLayoutRectEb
 __ZN7WebCore12RenderObject19scrollRectToVisibleERKNS_20FractionalLayoutRectERKNS_15ScrollAlignmentES6_
 __ZN7WebCore12RenderWidget28resumeWidgetHierarchyUpdatesEv
 __ZN7WebCore12RenderWidget29suspendWidgetHierarchyUpdatesEv
index 09c43d2..059ff48 100644 (file)
@@ -317,33 +317,18 @@ void RenderFlowThread::repaintRectangleInRegions(const LayoutRect& repaintRect,
     if (!shouldRepaint(repaintRect) || !hasValidRegionInfo())
         return;
 
+    LayoutStateDisabler layoutStateDisabler(view()); // We can't use layout state to repaint, since the regions are somewhere else.
+
+    // We can't use currentFlowThread as it is possible to have interleaved flow threads and the wrong one could be used.
+    // Let each region figure out the proper enclosing flow thread.
+    CurrentRenderFlowThreadDisabler disabler(view());
+    
     for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
         RenderRegion* region = *iter;
         if (!region->isValid())
             continue;
 
-        // We only have to issue a repaint in this region if the region rect intersects the repaint rect.
-        LayoutRect flippedFlowThreadPortionRect(region->flowThreadPortionRect());
-        LayoutRect flippedFlowThreadPortionOverflowRect(region->flowThreadPortionOverflowRect());
-        flipForWritingMode(flippedFlowThreadPortionRect); // Put the region rects into physical coordinates.
-        flipForWritingMode(flippedFlowThreadPortionOverflowRect);
-
-        LayoutRect clippedRect(repaintRect);
-        clippedRect.intersect(flippedFlowThreadPortionOverflowRect);
-        if (clippedRect.isEmpty())
-            continue;
-
-        // Put the region rect into the region's physical coordinate space.
-        clippedRect.setLocation(region->contentBoxRect().location() + (clippedRect.location() - flippedFlowThreadPortionRect.location()));
-
-        // Now switch to the region's writing mode coordinate space and let it repaint itself.
-        region->flipForWritingMode(clippedRect);
-        LayoutStateDisabler layoutStateDisabler(view()); // We can't use layout state to repaint, since the region is somewhere else.
-
-        // Can't use currentFlowThread as it possible to have imbricated flow threads and the wrong one could be used,
-        // so, we let each region figure out the proper enclosing flow thread
-        CurrentRenderFlowThreadDisabler disabler(view());
-        region->repaintRectangle(clippedRect, immediate);
+        region->repaintFlowThreadContent(repaintRect, immediate);
     }
 }
 
index c60d760..e88482d 100755 (executable)
@@ -1279,7 +1279,7 @@ RenderBoxModelObject* RenderObject::containerForRepaint() const
     return repaintContainer;
 }
 
-void RenderObject::repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect& r, bool immediate)
+void RenderObject::repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect& r, bool immediate) const
 {
     if (!repaintContainer) {
         view()->repaintViewRectangle(r, immediate);
@@ -1322,7 +1322,7 @@ void RenderObject::repaintUsingContainer(RenderBoxModelObject* repaintContainer,
 #endif
 }
 
-void RenderObject::repaint(bool immediate)
+void RenderObject::repaint(bool immediate) const
 {
     // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
     RenderView* view;
@@ -1336,7 +1336,7 @@ void RenderObject::repaint(bool immediate)
     repaintUsingContainer(repaintContainer ? repaintContainer : view, clippedOverflowRectForRepaint(repaintContainer), immediate);
 }
 
-void RenderObject::repaintRectangle(const LayoutRect& r, bool immediate)
+void RenderObject::repaintRectangle(const LayoutRect& r, bool immediate) const
 {
     // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
     RenderView* view;
@@ -2201,9 +2201,9 @@ LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
     return LayoutRect();
 }
 
-bool RenderObject::isRooted(RenderView** view)
+bool RenderObject::isRooted(RenderView** view) const
 {
-    RenderObject* o = this;
+    const RenderObject* o = this;
     while (o->parent())
         o = o->parent();
 
@@ -2211,7 +2211,7 @@ bool RenderObject::isRooted(RenderView** view)
         return false;
 
     if (view)
-        *view = toRenderView(o);
+        *view = const_cast<RenderView*>(toRenderView(o));
 
     return true;
 }
index 086a4bc..22b8300 100644 (file)
@@ -586,7 +586,7 @@ public:
     RenderView* view() const;
 
     // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
-    bool isRooted(RenderView** = 0);
+    bool isRooted(RenderView** = 0) const;
 
     Node* node() const { return isAnonymous() ? 0 : m_node; }
 
@@ -752,14 +752,14 @@ public:
     RenderBoxModelObject* containerForRepaint() const;
     // Actually do the repaint of rect r for this object which has been computed in the coordinate space
     // of repaintContainer. If repaintContainer is 0, repaint via the view.
-    void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect&, bool immediate = false);
+    void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect&, bool immediate = false) const;
     
     // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
     // style changes.
-    void repaint(bool immediate = false);
+    void repaint(bool immediate = false) const;
 
     // Repaint a specific subrectangle within a given object.  The rect |r| is in the object's coordinate space.
-    void repaintRectangle(const LayoutRect&, bool immediate = false);
+    void repaintRectangle(const LayoutRect&, bool immediate = false) const;
 
     // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
     bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, const LayoutRect* newBoundsPtr = 0, const LayoutRect* newOutlineBoxPtr = 0);
index 80f4306..934e0f9 100644 (file)
@@ -209,6 +209,34 @@ void RenderRegion::layout()
     // We'll need to expand RenderBoxRegionInfo to also hold left and right overflow values.
 }
 
+void RenderRegion::repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const
+{
+    repaintFlowThreadContentRectangle(repaintRect, immediate, flowThreadPortionRect(), flowThreadPortionOverflowRect(), contentBoxRect().location());
+}
+
+void RenderRegion::repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, bool immediate, const LayoutRect& flowThreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regionLocation) const
+{
+    // We only have to issue a repaint in this region if the region rect intersects the repaint rect.
+    LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect);
+    LayoutRect flippedFlowThreadPortionOverflowRect(flowThreadPortionOverflowRect);
+    flowThread()->flipForWritingMode(flippedFlowThreadPortionRect); // Put the region rects into physical coordinates.
+    flowThread()->flipForWritingMode(flippedFlowThreadPortionOverflowRect);
+
+    LayoutRect clippedRect(repaintRect);
+    clippedRect.intersect(flippedFlowThreadPortionOverflowRect);
+    if (clippedRect.isEmpty())
+        return;
+
+    // Put the region rect into the region's physical coordinate space.
+    clippedRect.setLocation(regionLocation + (clippedRect.location() - flippedFlowThreadPortionRect.location()));
+
+    // Now switch to the region's writing mode coordinate space and let it repaint itself.
+    flipForWritingMode(clippedRect);
+    
+    // Issue the repaint.
+    repaintRectangle(clippedRect, immediate);
+}
+
 void RenderRegion::installFlowThread()
 {
     ASSERT(view());
index 79fb759..7c9b87f 100644 (file)
@@ -116,11 +116,15 @@ public:
     // Whether or not this region is a set.
     virtual bool isRenderRegionSet() const { return false; }
     
+    virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const;
+
 protected:
     void setRegionObjectsRegionStyle();
     void restoreRegionObjectsOriginalStyle();
 
     LayoutRect overflowRectForFlowThreadPortion(LayoutRect flowThreadPortionRect, bool isFirstPortion, bool isLastPortion) const;
+    void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, bool immediate, const LayoutRect& flowThreadPortionRect,
+                                           const LayoutRect& flowThreadPortionOverflowRect, const LayoutPoint& regionLocation) const;
 
 private:
     virtual const char* renderName() const { return "RenderRegion"; }