[CSSRegions] Incorrect computed height for content with region-break-before
[WebKit-https.git] / Source / WebCore / rendering / RenderFlowThread.cpp
index ce182cd..13809b0 100644 (file)
@@ -856,7 +856,7 @@ bool RenderFlowThread::addForcedRegionBreak(LayoutUnit offsetBreakInFlowThread,
 
     RenderRegionList::iterator regionIter = m_regionList.find(region);
     ASSERT(regionIter != m_regionList.end());
-    for (; (regionIter != m_regionList.end()) && (currentRegionOffsetInFlowThread < offsetBreakInFlowThread); ++regionIter) {
+    for (; regionIter != m_regionList.end(); ++regionIter) {
         RenderRegion* region = *regionIter;
         if (region->needsOverrideLogicalContentHeightComputation()) {
             mapToUse.set(breakChild, region);
@@ -871,6 +871,12 @@ bool RenderFlowThread::addForcedRegionBreak(LayoutUnit offsetBreakInFlowThread,
             currentRegionOffsetInFlowThread += regionOverrideLogicalContentHeight;
         } else
             currentRegionOffsetInFlowThread += isHorizontalWritingMode() ? region->flowThreadPortionRect().height() : region->flowThreadPortionRect().width();
+
+        // If the current offset if greater than the break offset, bail out and skip the current region.
+        if (currentRegionOffsetInFlowThread >= offsetBreakInFlowThread) {
+            ++regionIter;
+            break;
+        }
     }
 
     // The remaining auto logical height regions in the chain that were unable to receive content