Ignore:
Timestamp:
Oct 4, 2013, 1:49:21 AM (12 years ago)
Author:
[email protected]
Message:

[CSS Regions] Infinite loop when computing widows
https://bugs.webkit.org/show_bug.cgi?id=122215

Reviewed by David Hyatt.

Source/WebCore:

The patch ensures it's not possible to relayout a block indefinitely because of widows contraints. You can't
break a block more than once to account for widows. This can happen if, for example, some lines are moved
to the next container and there the content breaks in another container again without respecting the widows property.
This is in line with the idea of not leaving empty fragmentation containers during layout.

Test: fast/regions/regions-widows-stack-overflow.html

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
(WebCore::RenderBlockFlow::setBreakAtLineToAvoidWidow):
(WebCore::RenderBlockFlow::setDidBreakAtLineToAvoidWidow):
(WebCore::RenderBlockFlow::clearDidBreakAtLineToAvoidWidow):
(WebCore::RenderBlockFlow::clearShouldBreakAtLineToAvoidWidow):

  • rendering/RenderBlockFlow.h:

(WebCore::RenderBlockFlow::RenderBlockFlowRareData::RenderBlockFlowRareData): Rename the m_shouldBreakAtLineToAvoidWidow
flag to m_didBreakAtLineToAvoidWidow.

(WebCore::RenderBlockFlow::shouldBreakAtLineToAvoidWidow): Use the line index to determine if it should break or not.
(WebCore::RenderBlockFlow::didBreakAtLineToAvoidWidow): Use to determine if a break already happened because of widows.

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::layoutRunsAndFloatsInRange):

LayoutTests:

Test there is no stack overflow when trying to break for widows that are caused by other widows.

  • fast/regions/regions-widows-stack-overflow-expected.html: Added.
  • fast/regions/regions-widows-stack-overflow.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r156876 r156881  
    16751675    }
    16761676
    1677     if (paginated && !style()->hasAutoWidows()) {
     1677    // In case we already adjusted the line positions during this layout to avoid widows
     1678    // then we need to ignore the possibility of having a new widows situation.
     1679    // Otherwise, we risk leaving empty containers which is against the block fragmentation principles.
     1680    // FIXME-BLOCKFLOW: Remove this type conversion once the owning function moves.
     1681    if (paginated && !style()->hasAutoWidows() && !toRenderBlockFlow(this)->didBreakAtLineToAvoidWidow()) {
    16781682        // Check the line boxes to make sure we didn't create unacceptable widows.
    16791683        // However, we'll prioritize orphans - so nothing we do here should create
     
    17321736        }
    17331737    }
     1738
     1739    // FIXME-BLOCKFLOW: Remove this type conversion once the owning function moves.
     1740    toRenderBlockFlow(this)->clearDidBreakAtLineToAvoidWidow();
    17341741}
    17351742
Note: See TracChangeset for help on using the changeset viewer.