Move line grid functionality from RenderBlock into RenderBlockFlow.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 18:22:50 +0000 (18:22 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 18:22:50 +0000 (18:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121502

Reviewed by Dean Jackson.

* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
(WebCore::LayoutState::establishLineGrid):
* rendering/LayoutState.h:
(WebCore::LayoutState::lineGrid):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::willBeDestroyed):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::RenderBlockRareData::RenderBlockRareData):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::willBeDestroyed):
(WebCore::RenderBlockFlow::layoutLineGridBox):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::RenderBlockFlowRareData::RenderBlockFlowRareData):
(WebCore::RenderBlockFlow::lineGridBox):
(WebCore::RenderBlockFlow::setLineGridBox):
* rendering/RenderBlockLineLayout.cpp:
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::lineSnapAdjustment):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/LayoutState.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RootInlineBox.cpp

index 45f4cd0..23a6ad3 100644 (file)
@@ -1,3 +1,30 @@
+2013-09-27  David Hyatt  <hyatt@apple.com>
+
+        Move line grid functionality from RenderBlock into RenderBlockFlow.
+        https://bugs.webkit.org/show_bug.cgi?id=121502
+
+        Reviewed by Dean Jackson.
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        (WebCore::LayoutState::establishLineGrid):
+        * rendering/LayoutState.h:
+        (WebCore::LayoutState::lineGrid):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::willBeDestroyed):
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::RenderBlockRareData::RenderBlockRareData):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::willBeDestroyed):
+        (WebCore::RenderBlockFlow::layoutLineGridBox):
+        * rendering/RenderBlockFlow.h:
+        (WebCore::RenderBlockFlow::RenderBlockFlowRareData::RenderBlockFlowRareData):
+        (WebCore::RenderBlockFlow::lineGridBox):
+        (WebCore::RenderBlockFlow::setLineGridBox):
+        * rendering/RenderBlockLineLayout.cpp:
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::lineSnapAdjustment):
+
 2013-09-27  Andreas Kling  <akling@apple.com>
 
         Re-indent Settings.h
index c57870a..c13b932 100644 (file)
@@ -132,7 +132,7 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz
 
     // If we have a new grid to track, then add it to our set.
     if (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isRenderBlockFlow())
-        establishLineGrid(toRenderBlock(renderer));
+        establishLineGrid(toRenderBlockFlow(renderer));
 
     // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
 }
@@ -228,13 +228,13 @@ void LayoutState::propagateLineGridInfo(RenderBox* renderer)
     m_lineGridPaginationOrigin = m_next->m_lineGridPaginationOrigin;
 }
 
-void LayoutState::establishLineGrid(RenderBlock* block)
+void LayoutState::establishLineGrid(RenderBlockFlow* block)
 {
     // First check to see if this grid has been established already.
     if (m_lineGrid) {
         if (m_lineGrid->style()->lineGrid() == block->style()->lineGrid())
             return;
-        RenderBlock* currentGrid = m_lineGrid;
+        RenderBlockFlow* currentGrid = m_lineGrid;
         for (LayoutState* currentState = m_next; currentState; currentState = currentState->m_next) {
             if (currentState->m_lineGrid == currentGrid)
                 continue;
index e47230b..492a753 100644 (file)
@@ -35,6 +35,7 @@ namespace WebCore {
 
 class RenderArena;
 class RenderBlock;
+class RenderBlockFlow;
 class RenderBox;
 class RenderObject;
 class RenderFlowThread;
@@ -90,7 +91,7 @@ public:
     LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
     bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
 
-    RenderBlock* lineGrid() const { return m_lineGrid; }
+    RenderBlockFlow* lineGrid() const { return m_lineGrid; }
     LayoutSize lineGridOffset() const { return m_lineGridOffset; }
     LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; }
 
@@ -106,7 +107,7 @@ private:
     void* operator new(size_t) throw();
 
     void propagateLineGridInfo(RenderBox*);
-    void establishLineGrid(RenderBlock*);
+    void establishLineGrid(RenderBlockFlow*);
 
     void computeLineGridPaginationOrigin(RenderBox*);
 
@@ -123,7 +124,7 @@ public:
     // If the enclosing pagination model is a column model, then this will store column information for easy retrieval/manipulation.
     ColumnInfo* m_columnInfo;
     // The current line grid that we're snapping to and the offset of the start of the grid.
-    RenderBlock* m_lineGrid;
+    RenderBlockFlow* m_lineGrid;
     LayoutState* m_next;
 #if ENABLE(CSS_SHAPES)
     ShapeInsideInfo* m_shapeInsideInfo;
index 497a1e0..2c09e52 100644 (file)
@@ -247,9 +247,6 @@ void RenderBlock::willBeDestroyed()
 
     m_lineBoxes.deleteLineBoxes(renderArena());
 
-    if (lineGridBox())
-        lineGridBox()->destroy(renderArena());
-
     if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0))
         gDelayedUpdateScrollInfoSet->remove(this);
 
index 617d30d..e5a18a9 100644 (file)
@@ -337,17 +337,6 @@ public:
     LayoutUnit pageLogicalOffset() const { return m_rareData ? m_rareData->m_pageLogicalOffset : LayoutUnit(); }
     void setPageLogicalOffset(LayoutUnit);
 
-    RootInlineBox* lineGridBox() const { return m_rareData ? m_rareData->m_lineGridBox : 0; }
-    void setLineGridBox(RootInlineBox* box)
-    {
-        if (!m_rareData)
-            m_rareData = adoptPtr(new RenderBlockRareData());
-        if (m_rareData->m_lineGridBox)
-            m_rareData->m_lineGridBox->destroy(renderArena());
-        m_rareData->m_lineGridBox = box;
-    }
-    void layoutLineGridBox();
-
     // Accessors for logical width/height and margins in the containing block's block-flow direction.
     enum ApplyLayoutDeltaMode { ApplyLayoutDelta, DoNotApplyLayoutDelta };
     LayoutUnit logicalWidthForChild(const RenderBox* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
@@ -854,14 +843,11 @@ public:
         RenderBlockRareData() 
             : m_paginationStrut(0)
             , m_pageLogicalOffset(0)
-            , m_lineGridBox(0)
         { 
         }
 
         LayoutUnit m_paginationStrut;
         LayoutUnit m_pageLogicalOffset;
-        
-        RootInlineBox* m_lineGridBox;
 
 #if ENABLE(CSS_SHAPES)
         OwnPtr<ShapeInsideInfo> m_shapeInsideInfo;
index 18b9fca..a803d55 100644 (file)
@@ -29,6 +29,7 @@
 #include "RenderFlowThread.h"
 #include "RenderLayer.h"
 #include "RenderView.h"
+#include "VerticalPositionCache.h"
 
 using namespace std;
 
@@ -84,6 +85,14 @@ RenderBlockFlow::~RenderBlockFlow()
 {
 }
 
+void RenderBlockFlow::willBeDestroyed()
+{
+    if (lineGridBox())
+        lineGridBox()->destroy(renderArena());
+
+    RenderBlock::willBeDestroyed();
+}
+
 void RenderBlockFlow::clearFloats()
 {
     if (m_floatingObjects)
@@ -1432,4 +1441,27 @@ bool RenderBlockFlow::relayoutToAvoidWidows(LayoutStateMaintainer& statePusher)
     return true;
 }
 
+void RenderBlockFlow::layoutLineGridBox()
+{
+    if (style()->lineGrid() == RenderStyle::initialLineGrid()) {
+        setLineGridBox(0);
+        return;
+    }
+    
+    setLineGridBox(0);
+
+    RootInlineBox* lineGridBox = new (renderArena()) RootInlineBox(*this);
+    lineGridBox->setHasTextChildren(); // Needed to make the line ascent/descent actually be honored in quirks mode.
+    lineGridBox->setConstructed();
+    GlyphOverflowAndFallbackFontsMap textBoxDataMap;
+    VerticalPositionCache verticalPositionCache;
+    lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, verticalPositionCache);
+    
+    setLineGridBox(lineGridBox);
+    
+    // FIXME: If any of the characteristics of the box change compared to the old one, then we need to do a deep dirtying
+    // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
+    // to this grid.
+}
+
 } // namespace WebCore
index 0e16d79..3824029 100644 (file)
@@ -35,8 +35,10 @@ public:
     virtual bool isRenderBlockFlow() const OVERRIDE FINAL { return true; }
     
     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
-    
+
 protected:
+    virtual void willBeDestroyed() OVERRIDE;
+    
     // This method is called at the start of layout to wipe away all of the floats in our floating objects list. It also
     // repopulates the list with any floats that intrude from previous siblings or parents. Floats that were added by
     // descendants are gone when this call completes and will get added back later on after the children have gotten
@@ -87,6 +89,7 @@ public:
         RenderBlockFlowRareData(const RenderBlockFlow* block)
             : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block))
             , m_lineBreakToAvoidWidow(-1)
+            , m_lineGridBox(0)
             , m_discardMarginBefore(false)
             , m_discardMarginAfter(false)
             , m_shouldBreakAtLineToAvoidWidow(false)
@@ -112,6 +115,8 @@ public:
         
         MarginValues m_margins;
         int m_lineBreakToAvoidWidow;
+        RootInlineBox* m_lineGridBox;
+
         bool m_discardMarginBefore : 1;
         bool m_discardMarginAfter : 1;
         bool m_shouldBreakAtLineToAvoidWidow : 1;
@@ -213,6 +218,17 @@ public:
     void setBreakAtLineToAvoidWidow(int);
     bool relayoutToAvoidWidows(LayoutStateMaintainer&);
 
+    RootInlineBox* lineGridBox() const { return m_rareData ? m_rareData->m_lineGridBox : 0; }
+    void setLineGridBox(RootInlineBox* box)
+    {
+        if (!m_rareData)
+            m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
+        if (m_rareData->m_lineGridBox)
+            m_rareData->m_lineGridBox->destroy(renderArena());
+        m_rareData->m_lineGridBox = box;
+    }
+    void layoutLineGridBox();
+
 protected:
     LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData->m_margins.positiveMarginBefore() : RenderBlockFlowRareData::positiveMarginBeforeDefault(this); }
     LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData->m_margins.negativeMarginBefore() : RenderBlockFlowRareData::negativeMarginBeforeDefault(this); }
index 46266c9..374a69a 100644 (file)
@@ -3469,28 +3469,4 @@ LayoutUnit RenderBlock::startAlignedOffsetForLine(LayoutUnit position, bool firs
     return logicalLeft;
 }
 
-
-void RenderBlock::layoutLineGridBox()
-{
-    if (style()->lineGrid() == RenderStyle::initialLineGrid()) {
-        setLineGridBox(0);
-        return;
-    }
-    
-    setLineGridBox(0);
-
-    RootInlineBox* lineGridBox = new (renderArena()) RootInlineBox(*this);
-    lineGridBox->setHasTextChildren(); // Needed to make the line ascent/descent actually be honored in quirks mode.
-    lineGridBox->setConstructed();
-    GlyphOverflowAndFallbackFontsMap textBoxDataMap;
-    VerticalPositionCache verticalPositionCache;
-    lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, verticalPositionCache);
-    
-    setLineGridBox(lineGridBox);
-    
-    // FIXME: If any of the characteristics of the box change compared to the old one, then we need to do a deep dirtying
-    // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
-    // to this grid.
-}
-
 }
index 0e95f04..10cb47f 100644 (file)
@@ -33,7 +33,6 @@
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderArena.h"
-#include "RenderBlock.h"
 #include "RenderFlowThread.h"
 #include "RenderView.h"
 #include "VerticalPositionCache.h"
@@ -385,7 +384,7 @@ LayoutUnit RootInlineBox::lineSnapAdjustment(LayoutUnit delta) const
 
     // Get the current line grid and offset.
     LayoutState* layoutState = block().view().layoutState();
-    RenderBlock* lineGrid = layoutState->lineGrid();
+    RenderBlockFlow* lineGrid = layoutState->lineGrid();
     LayoutSize lineGridOffset = layoutState->lineGridOffset();
     if (!lineGrid || lineGrid->style()->writingMode() != block().style()->writingMode())
         return 0;