Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 399423006: Move widow-avoiding code from RenderBlock down to RenderBlockFlow. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlockFlow.cpp
diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp
index 3e4de0392b0c57801f779774aebed52103668b70..7809a387bae96c456d236998a23a889674d9814b 100644
--- a/Source/core/rendering/RenderBlockFlow.cpp
+++ b/Source/core/rendering/RenderBlockFlow.cpp
@@ -280,6 +280,42 @@ void RenderBlockFlow::setColumnCountAndHeight(unsigned count, LayoutUnit pageLog
}
}
+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();
@@ -557,7 +593,7 @@ void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
// Now we have a final top position. See if it really does end up being different from our estimate.
// clearFloatsIfNeeded can also mark the child as needing a layout even though we didn't move. This happens
// when collapseMargins dynamically adds overhanging floats because of a child with negative margins.
- if (logicalTopAfterClear != logicalTopEstimate || child->needsLayout() || (paginated && childRenderBlock && childRenderBlock->shouldBreakAtLineToAvoidWidow())) {
+ if (logicalTopAfterClear != logicalTopEstimate || child->needsLayout() || (paginated && childRenderBlockFlow && childRenderBlockFlow->shouldBreakAtLineToAvoidWidow())) {
SubtreeLayoutScope layoutScope(*child);
if (child->shrinkToAvoidFloats()) {
// The child's width depends on the line width.
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698