Changeset 152572 in webkit


Ignore:
Timestamp:
Jul 11, 2013 9:17:37 AM (11 years ago)
Author:
abucur@adobe.com
Message:

[CSS Regions] In a region chain with auto-height regions, lines get their length based only on the first region
https://bugs.webkit.org/show_bug.cgi?id=118531

Reviewed by Alexandru Chiculita.

Source/WebCore:

When computing the height a flow thread it's possible to overflow the maximum LayoutUnit and obtain a negative value.
This leads to invalid results during layout when computing the region range and the RenderBoxRegion info for the
descendant boxes of the flow thread.

This issue appears especially during the auto-height algorithm because it initializes the auto-height regions
height with the LayoutUnit::max() / 2 value. Summing two such regions overflows and results in a negative value.

The fix clamps the maximum height of the flow thread to LayoutUnit::max() / 2. This doesn't affect the auto-height
algorithm because regionAtBlockOffset() will still return the correct values as the auto-height regions content
is established and their height updated.

Tests: fast/regions/autoheight-correct-region-for-lines-2.html

fast/regions/autoheight-correct-region-for-lines.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::updateRegionsAndShapesBeforeChildLayout):

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::computeLogicalHeight):
(WebCore::RenderFlowThread::setRegionRangeForBox):
(WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):

  • rendering/RenderFlowThread.h:
  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::maxPageLogicalHeight):

LayoutTests:

Add tests verifying the lines widths are correctly computed in auto-height regions with and without a max-height set.

  • fast/regions/autoheight-correct-region-for-lines-2-expected.html: Added.
  • fast/regions/autoheight-correct-region-for-lines-2.html: Added.
  • fast/regions/autoheight-correct-region-for-lines-expected.html: Added.
  • fast/regions/autoheight-correct-region-for-lines.html: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r152569 r152572  
     12013-07-11  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSS Regions] In a region chain with auto-height regions, lines get their length based only on the first region
     4        https://bugs.webkit.org/show_bug.cgi?id=118531
     5
     6        Reviewed by Alexandru Chiculita.
     7
     8        Add tests verifying the lines widths are correctly computed in auto-height regions with and without a max-height set.
     9
     10        * fast/regions/autoheight-correct-region-for-lines-2-expected.html: Added.
     11        * fast/regions/autoheight-correct-region-for-lines-2.html: Added.
     12        * fast/regions/autoheight-correct-region-for-lines-expected.html: Added.
     13        * fast/regions/autoheight-correct-region-for-lines.html: Added.
     14
    1152013-07-11  Radu Stavila  <stavila@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r152571 r152572  
     12013-07-11  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSS Regions] In a region chain with auto-height regions, lines get their length based only on the first region
     4        https://bugs.webkit.org/show_bug.cgi?id=118531
     5
     6        Reviewed by Alexandru Chiculita.
     7
     8        When computing the height a flow thread it's possible to overflow the maximum LayoutUnit and obtain a negative value.
     9        This leads to invalid results during layout when computing the region range and the RenderBoxRegion info for the
     10        descendant boxes of the flow thread.
     11   
     12        This issue appears especially during the auto-height algorithm because it initializes the auto-height regions
     13        height with the LayoutUnit::max() / 2 value. Summing two such regions overflows and results in a negative value.
     14
     15        The fix clamps the maximum height of the flow thread to LayoutUnit::max() / 2. This doesn't affect the auto-height
     16        algorithm because regionAtBlockOffset() will still return the correct values as the auto-height regions content
     17        is established and their height updated.
     18
     19        Tests: fast/regions/autoheight-correct-region-for-lines-2.html
     20               fast/regions/autoheight-correct-region-for-lines.html
     21
     22        * rendering/RenderBlock.cpp:
     23        (WebCore::RenderBlock::updateRegionsAndShapesBeforeChildLayout):
     24        * rendering/RenderFlowThread.cpp:
     25        (WebCore::RenderFlowThread::computeLogicalHeight):
     26        (WebCore::RenderFlowThread::setRegionRangeForBox):
     27        (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
     28        * rendering/RenderFlowThread.h:
     29        * rendering/RenderRegion.cpp:
     30        (WebCore::RenderRegion::maxPageLogicalHeight):
     31
    1322013-07-11  Timothy Hatcher  <timothy@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r152149 r152572  
    14971497    // Compute the maximum logical height content may cause this block to expand to
    14981498    // FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight
    1499     setLogicalHeight(LayoutUnit::max() / 2);
     1499    setLogicalHeight(RenderFlowThread::maxLogicalHeight());
    15001500    updateLogicalHeight();
    15011501
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r152281 r152572  
    252252    computedValues.m_extent = 0;
    253253
     254    const LayoutUnit maxFlowSize = RenderFlowThread::maxLogicalHeight();
    254255    for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
    255256        RenderRegion* region = *iter;
    256257        ASSERT(!region->needsLayout() || region->isRenderRegionSet());
    257258
    258         computedValues.m_extent += region->logicalHeightOfAllFlowThreadContent();
     259        LayoutUnit distanceToMaxSize = maxFlowSize - computedValues.m_extent;
     260        computedValues.m_extent += std::min(distanceToMaxSize, region->logicalHeightOfAllFlowThreadContent());
     261
     262        // If we reached the maximum size there's no point in going further.
     263        if (computedValues.m_extent == maxFlowSize)
     264            return;
    259265    }
    260266}
     
    686692        return;
    687693
     694    ASSERT(box->logicalHeight() >= 0);
     695
    688696    // FIXME: Not right for differing writing-modes.
    689697    RenderRegion* startRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPage, true);
     
    876884
    877885        LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
    878         LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(LayoutUnit::max() / 2 - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
     886        LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(RenderFlowThread::maxLogicalHeight() - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
    879887
    880888        LayoutRect regionRect(style()->direction() == LTR ? LayoutUnit() : logicalWidth() - regionLogicalWidth, logicalHeight, regionLogicalWidth, regionLogicalHeight);
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r152281 r152572  
    169169    LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const;
    170170
     171    // Used to estimate the maximum height of the flow thread.
     172    static LayoutUnit maxLogicalHeight() { return LayoutUnit::max() / 2; }
     173
    171174protected:
    172175    virtual const char* renderName() const = 0;
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r152281 r152572  
    8282    ASSERT(m_flowThread);
    8383    ASSERT(hasAutoLogicalHeight() && !m_flowThread->inConstrainedLayoutPhase());
    84     return style()->logicalMaxHeight().isUndefined() ? LayoutUnit::max() / 2 : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
     84    return style()->logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
    8585}
    8686
Note: See TracChangeset for help on using the changeset viewer.