https://bugs.webkit.org/show_bug.cgi?id=68638
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 18:12:20 +0000 (18:12 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2011 18:12:20 +0000 (18:12 +0000)
Make RenderFlowThread cache whether or not it has regions of varying widths. This will
be relevant for performance as we begin adding code to do custom block painting and
layout based off regions not having the same width.

Reviewed by Dan Bernstein and Adam Roben.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::RenderFlowThread):
(WebCore::RenderFlowThread::layout):
* rendering/RenderFlowThread.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h

index ccca441..4168d27 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-22  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=68638
+        
+        Make RenderFlowThread cache whether or not it has regions of varying widths. This will
+        be relevant for performance as we begin adding code to do custom block painting and
+        layout based off regions not having the same width.
+
+        Reviewed by Dan Bernstein and Adam Roben.
+
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::RenderFlowThread):
+        (WebCore::RenderFlowThread::layout):
+        * rendering/RenderFlowThread.h:
+
 2011-09-22  Anders Carlsson  <andersca@apple.com>
 
         FrameView::invalidateRect and FrameView::setFrameRect shouldn't take LayoutRects
index 47fbd90..c33bba3 100644 (file)
@@ -47,6 +47,7 @@ RenderFlowThread::RenderFlowThread(Node* node, const AtomicString& flowThread)
     , m_flowThread(flowThread)
     , m_hasValidRegions(false)
     , m_regionsInvalidated(false)
+    , m_regionsHaveUniformLogicalWidth(true)
     , m_regionFittingDisableCount(0)
 {
     setIsAnonymous(false);
@@ -303,6 +304,9 @@ void RenderFlowThread::layout()
     bool regionsChanged = m_regionsInvalidated && m_everHadLayout;
     if (m_regionsInvalidated) {
         m_regionsInvalidated = false;
+        m_hasValidRegions = false;
+        m_regionsHaveUniformLogicalWidth = true;
+        LayoutUnit previousRegionLogicalWidth = 0;
         if (hasRegions()) {
             int logicalHeight = 0;
             for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
@@ -313,17 +317,26 @@ void RenderFlowThread::layout()
 
                 ASSERT(!region->needsLayout());
                 
-                m_hasValidRegions = true;
+                LayoutUnit regionLogicalWidth;
 
                 IntRect regionRect;
                 if (isHorizontalWritingMode()) {
                     regionRect = IntRect(0, logicalHeight, region->contentWidth(), region->contentHeight());
                     logicalHeight += regionRect.height();
+                    regionLogicalWidth = region->contentWidth();
                 } else {
                     regionRect = IntRect(logicalHeight, 0, region->contentWidth(), region->contentHeight());
                     logicalHeight += regionRect.width();
+                    regionLogicalWidth = region->contentHeight();
                 }
 
+                if (!m_hasValidRegions)
+                    m_hasValidRegions = true;
+                else if (m_regionsHaveUniformLogicalWidth && previousRegionLogicalWidth != regionLogicalWidth)
+                    m_regionsHaveUniformLogicalWidth = false;
+
+                previousRegionLogicalWidth = regionLogicalWidth;
+
                 region->setRegionRect(regionRect);
             }
         }
index f116fca..c1230da 100644 (file)
@@ -105,6 +105,8 @@ public:
     void disableRegionFitting() { m_regionFittingDisableCount++; }
     void enableRegionFitting() { ASSERT(m_regionFittingDisableCount > 0); m_regionFittingDisableCount--; }
 
+    bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
+    
     RenderRegion* mapFromFlowToRegion(TransformState&) const;
 
 private:
@@ -137,6 +139,7 @@ private:
 
     bool m_hasValidRegions;
     bool m_regionsInvalidated;
+    bool m_regionsHaveUniformLogicalWidth;
     unsigned m_regionFittingDisableCount;
 };