From 7d3feb3952c47d793c6da7c5393c918c2a5df7d8 Mon Sep 17 00:00:00 2001 From: Ojan Vafai Date: Fri, 31 Oct 2014 12:41:40 -0700 Subject: [PATCH] Remove line breaking to avoid window. Now that we don't have multi-column or pagination, this is dead code. This also means we don't need to call layoutBlockFlow in a loop. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/697713002 --- engine/core/rendering/RenderBlockFlow.cpp | 52 +------------------ engine/core/rendering/RenderBlockFlow.h | 15 +----- .../core/rendering/RenderBlockLineLayout.cpp | 2 - 3 files changed, 3 insertions(+), 66 deletions(-) diff --git a/engine/core/rendering/RenderBlockFlow.cpp b/engine/core/rendering/RenderBlockFlow.cpp index f1c8dedc9..56e61eac9 100644 --- a/engine/core/rendering/RenderBlockFlow.cpp +++ b/engine/core/rendering/RenderBlockFlow.cpp @@ -161,42 +161,6 @@ bool RenderBlockFlow::updateLogicalWidthAndColumnWidth() return RenderBlock::updateLogicalWidthAndColumnWidth(); } -void RenderBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak) -{ - ASSERT(lineToBreak >= 0); - ensureRareData(); - ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow); - m_rareData->m_lineBreakToAvoidWidow = lineToBreak; -} - -void RenderBlockFlow::setDidBreakAtLineToAvoidWidow() -{ - ASSERT(!shouldBreakAtLineToAvoidWidow()); - - // This function should be called only after a break was applied to avoid widows - // so assert |m_rareData| exists. - ASSERT(m_rareData); - - m_rareData->m_didBreakAtLineToAvoidWidow = true; -} - -void RenderBlockFlow::clearDidBreakAtLineToAvoidWidow() -{ - if (!m_rareData) - return; - - m_rareData->m_didBreakAtLineToAvoidWidow = false; -} - -void RenderBlockFlow::clearShouldBreakAtLineToAvoidWidow() const -{ - ASSERT(shouldBreakAtLineToAvoidWidow()); - if (!m_rareData) - return; - - m_rareData->m_lineBreakToAvoidWidow = -1; -} - bool RenderBlockFlow::isSelfCollapsingBlock() const { m_hasOnlySelfCollapsingChildren = RenderBlock::isSelfCollapsingBlock(); @@ -218,13 +182,7 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren) SubtreeLayoutScope layoutScope(*this); - // Multiple passes might be required for column and pagination based layout - // In the case of the old column code the number of passes will only be two - // however, in the newer column code the number of passes could equal the - // number of columns. - bool done = false; - while (!done) - done = layoutBlockFlow(relayoutChildren, layoutScope); + layoutBlockFlow(relayoutChildren, layoutScope); updateLayerTransformAfterLayout(); @@ -238,7 +196,7 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren) clearNeedsLayout(); } -inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayoutScope& layoutScope) +inline void RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayoutScope& layoutScope) { LayoutUnit oldLeft = logicalLeft(); bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); @@ -278,11 +236,6 @@ inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayou if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlockFormattingContext()) setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); - if (shouldBreakAtLineToAvoidWidow()) { - setEverHadLayout(true); - return false; - } - // Calculate our new height. LayoutUnit oldHeight = logicalHeight(); LayoutUnit oldClientAfterEdge = clientLogicalBottom(); @@ -311,7 +264,6 @@ inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayou computeOverflow(oldClientAfterEdge); m_descendantsWithFloatsMarkedForLayout = false; - return true; } void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child) diff --git a/engine/core/rendering/RenderBlockFlow.h b/engine/core/rendering/RenderBlockFlow.h index 8a4f58d87..6a4265839 100644 --- a/engine/core/rendering/RenderBlockFlow.h +++ b/engine/core/rendering/RenderBlockFlow.h @@ -156,7 +156,7 @@ protected: void determineLogicalLeftPositionForChild(RenderBox* child); private: - bool layoutBlockFlow(bool relayoutChildren, SubtreeLayoutScope&); + void layoutBlockFlow(bool relayoutChildren, SubtreeLayoutScope&); void layoutBlockChildren(bool relayoutChildren, SubtreeLayoutScope&, LayoutUnit beforeEdge, LayoutUnit afterEdge); void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFloatLogicalBottom); @@ -199,14 +199,6 @@ private: void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionOpportunityCount); - bool shouldBreakAtLineToAvoidWidow() const { return m_rareData && m_rareData->m_lineBreakToAvoidWidow >= 0; } - void clearShouldBreakAtLineToAvoidWidow() const; - int lineBreakToAvoidWidow() const { return m_rareData ? m_rareData->m_lineBreakToAvoidWidow : -1; } - void setBreakAtLineToAvoidWidow(int); - void clearDidBreakAtLineToAvoidWidow(); - void setDidBreakAtLineToAvoidWidow(); - bool didBreakAtLineToAvoidWidow() const { return m_rareData && m_rareData->m_didBreakAtLineToAvoidWidow; } - public: struct FloatWithRect { FloatWithRect(RenderBox* f) @@ -254,8 +246,6 @@ public: public: RenderBlockFlowRareData(const RenderBlockFlow* block) : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block)) - , m_lineBreakToAvoidWidow(-1) - , m_didBreakAtLineToAvoidWidow(false) , m_discardMarginBefore(false) , m_discardMarginAfter(false) { @@ -280,9 +270,6 @@ public: } MarginValues m_margins; - - int m_lineBreakToAvoidWidow; - bool m_didBreakAtLineToAvoidWidow : 1; bool m_discardMarginBefore : 1; bool m_discardMarginAfter : 1; }; diff --git a/engine/core/rendering/RenderBlockLineLayout.cpp b/engine/core/rendering/RenderBlockLineLayout.cpp index 60191f547..bc51a62e9 100644 --- a/engine/core/rendering/RenderBlockLineLayout.cpp +++ b/engine/core/rendering/RenderBlockLineLayout.cpp @@ -800,8 +800,6 @@ void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, lineMidpointState.reset(); resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); } - - clearDidBreakAtLineToAvoidWidow(); } void RenderBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) -- GitLab