Changeset 96975 in webkit


Ignore:
Timestamp:
Oct 7, 2011 1:15:11 PM (12 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=69658

[CSS3 Regions] Box painting of overflow into regions is incorrect because children were being
incorrectly clamped to their containing block region ranges. Change the clamping model so that
renderRegionForLine no longer does it. A block will now truly have an accurate range across
all the regions that paint it. Instead, do the clamping at the time a child box asks the containing
block for its information. At that time clamp to the start and end regions, so that we never ask
a containing block for info about a region that it doesn't exist in.

Reviewed by Anders Carlsson.

Source/WebCore:

Added new test in fast/regions and updated an old result to be correct.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::pageLogicalHeightForOffset):
(WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
(WebCore::RenderBlock::regionAtBlockOffset):
(WebCore::RenderBlock::clampToStartAndEndRegions):

  • rendering/RenderBlock.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::borderBoxRectInRegion):
(WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
(WebCore::RenderBox::renderBoxRegionInfo):

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::renderRegionForLine):
(WebCore::RenderFlowThread::regionLogicalWidthForLine):
(WebCore::RenderFlowThread::regionLogicalHeightForLine):
(WebCore::RenderFlowThread::regionRemainingLogicalHeightForLine):
(WebCore::RenderFlowThread::mapFromFlowToRegion):
(WebCore::RenderFlowThread::setRegionRangeForBox):

  • rendering/RenderFlowThread.h:

LayoutTests:

  • fast/regions/bottom-overflow-out-of-first-region.html: Added.
  • fast/regions/top-overflow-out-of-second-region.html:
  • platform/mac/fast/regions/bottom-overflow-out-of-first-region-expected.png: Added.
  • platform/mac/fast/regions/bottom-overflow-out-of-first-region-expected.txt: Added.
  • platform/mac/fast/regions/top-overflow-out-of-second-region-expected.png:
  • platform/mac/fast/regions/top-overflow-out-of-second-region-expected.txt:
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96974 r96975  
     12011-10-07  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=69658
     4       
     5        [CSS3 Regions] Box painting of overflow into regions is incorrect because children were being
     6        incorrectly clamped to their containing block region ranges. Change the clamping model so that
     7        renderRegionForLine no longer does it. A block will now truly have an accurate range across
     8        all the regions that paint it. Instead, do the clamping at the time a child box asks the containing
     9        block for its information. At that time clamp to the start and end regions, so that we never ask
     10        a containing block for info about a region that it doesn't exist in.
     11
     12        Reviewed by Anders Carlsson.
     13
     14        * fast/regions/bottom-overflow-out-of-first-region.html: Added.
     15        * fast/regions/top-overflow-out-of-second-region.html:
     16        * platform/mac/fast/regions/bottom-overflow-out-of-first-region-expected.png: Added.
     17        * platform/mac/fast/regions/bottom-overflow-out-of-first-region-expected.txt: Added.
     18        * platform/mac/fast/regions/top-overflow-out-of-second-region-expected.png:
     19        * platform/mac/fast/regions/top-overflow-out-of-second-region-expected.txt:
     20
    1212011-10-07  Chang Shu  <cshu@webkit.org>
    222
  • trunk/LayoutTests/fast/regions/top-overflow-out-of-second-region.html

    r96842 r96975  
    2222        border: 1px solid black;
    2323        content: -webkit-from-flow("flow1");
    24         display:inline-block
    2524    }
    2625
     
    3534    }
    3635
    37     #container { margin-top:150px }
    38 
    3936</style>
    4037
     
    4441It is overflowing upwards out of the blue block, and so the portion that overflows should continue to use the blue block's
    4542containing block width. The blue block does not exist in region one, so using some hypothetical made-up width is incorrect.
    46 The overflow should be spilling out of the top of region two. <font color=red>RIGHT NOW THIS TEST HAS INCORRECT RESULTS.</font></p>
     43The overflow should be spilling out of the top of region two and be painted in region one.
    4744
    4845<div id="content">
  • trunk/LayoutTests/platform/mac/fast/regions/top-overflow-out-of-second-region-expected.txt

    r96842 r96975  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x452
    4   RenderBlock {HTML} at (0,0) size 800x452
    5     RenderBody {BODY} at (8,16) size 784x428
     3layer at (0,0) size 800x418
     4  RenderBlock {HTML} at (0,0) size 800x418
     5    RenderBody {BODY} at (8,16) size 784x394
    66      RenderBlock {P} at (0,0) size 784x72
    77        RenderText {#text} at (0,0) size 779x72
     
    99          text run at (0,18) width 731: "overflowing upwards out of the blue block, and so the portion that overflows should continue to use the blue block's"
    1010          text run at (0,36) width 779: "containing block width. The blue block does not exist in region one, so using some hypothetical made-up width is incorrect."
    11           text run at (0,54) width 386: "The overflow should be spilling out of the top of region two. "
    12         RenderInline {FONT} at (0,0) size 389x18 [color=#FF0000]
    13           RenderText {#text} at (386,54) size 389x18
    14             text run at (386,54) width 389: "RIGHT NOW THIS TEST HAS INCORRECT RESULTS."
    15       RenderBlock {DIV} at (0,222) size 784x206
    16         RenderRegion {DIV} at (0,100) size 302x102 [border: (1px solid #000000)]
    17         RenderText {#text} at (302,188) size 4x18
    18           text run at (302,188) width 4: " "
    19         RenderRegion {DIV} at (306,0) size 402x202 [border: (1px solid #000000)]
    20         RenderText {#text} at (708,188) size 4x18
    21           text run at (708,188) width 4: " "
    22         RenderRegion {DIV} at (712,200) size 2x2 [border: (1px solid #000000)]
    23         RenderText {#text} at (0,0) size 0x0
     11          text run at (0,54) width 565: "The overflow should be spilling out of the top of region two and be painted in region one."
     12      RenderBlock {DIV} at (0,88) size 784x306
     13        RenderRegion {DIV} at (0,0) size 302x102 [border: (1px solid #000000)]
     14        RenderRegion {DIV} at (0,102) size 402x202 [border: (1px solid #000000)]
     15        RenderRegion {DIV} at (0,304) size 2x2 [border: (1px solid #000000)]
    2416Flow Threads
    2517  Thread with flow-name 'flow1'
    2618    layer at (0,0) size 400x300
    2719      RenderFlowThread at (0,0) size 400x300
    28         RenderBlock {DIV} at (0,0) size 400x165
    29           RenderBlock {DIV} at (5,100) size 390x60 [border: (1px solid #0000FF)]
    30             RenderBlock {DIV} at (48,-99) size 293x158 [border: (1px solid #008000)]
     20        RenderBlock {DIV} at (0,0) size 400x177
     21          RenderBlock {DIV} at (5,100) size 390x72 [border: (1px solid #0000FF)]
     22            RenderBlock {DIV} at (48,-99) size 293x170 [border: (1px solid #008000)]
    3123              RenderBlock {P} at (1,17) size 291x54
    3224                RenderText {#text} at (0,0) size 291x54
     
    3527                  text run at (0,36) width 112: "top of the second "
    3628                  text run at (112,36) width 44: "region."
    37               RenderBlock {P} at (1,87) size 291x54
     29              RenderBlock {P} at (1,99) size 291x54
    3830                RenderText {#text} at (0,0) size 291x54
    3931                  text run at (0,0) width 291: "These lines should all fit to the width of the"
  • trunk/Source/WebCore/ChangeLog

    r96974 r96975  
     12011-10-07  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=69658
     4       
     5        [CSS3 Regions] Box painting of overflow into regions is incorrect because children were being
     6        incorrectly clamped to their containing block region ranges. Change the clamping model so that
     7        renderRegionForLine no longer does it. A block will now truly have an accurate range across
     8        all the regions that paint it. Instead, do the clamping at the time a child box asks the containing
     9        block for its information. At that time clamp to the start and end regions, so that we never ask
     10        a containing block for info about a region that it doesn't exist in.
     11
     12        Reviewed by Anders Carlsson.
     13
     14        Added new test in fast/regions and updated an old result to be correct.
     15
     16        * rendering/RenderBlock.cpp:
     17        (WebCore::RenderBlock::pageLogicalHeightForOffset):
     18        (WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
     19        (WebCore::RenderBlock::regionAtBlockOffset):
     20        (WebCore::RenderBlock::clampToStartAndEndRegions):
     21        * rendering/RenderBlock.h:
     22        * rendering/RenderBox.cpp:
     23        (WebCore::RenderBox::borderBoxRectInRegion):
     24        (WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
     25        (WebCore::RenderBox::renderBoxRegionInfo):
     26        * rendering/RenderFlowThread.cpp:
     27        (WebCore::RenderFlowThread::renderRegionForLine):
     28        (WebCore::RenderFlowThread::regionLogicalWidthForLine):
     29        (WebCore::RenderFlowThread::regionLogicalHeightForLine):
     30        (WebCore::RenderFlowThread::regionRemainingLogicalHeightForLine):
     31        (WebCore::RenderFlowThread::mapFromFlowToRegion):
     32        (WebCore::RenderFlowThread::setRegionRangeForBox):
     33        * rendering/RenderFlowThread.h:
     34
    1352011-10-07  Chang Shu  <cshu@webkit.org>
    236
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r96859 r96975  
    62296229    if (!inRenderFlowThread())
    62306230        return renderView->layoutState()->m_pageLogicalHeight;
    6231     return enclosingRenderFlowThread()->regionLogicalHeightForLine(offset + offsetFromLogicalTopOfFirstPage(), this);
     6231    return enclosingRenderFlowThread()->regionLogicalHeightForLine(offset + offsetFromLogicalTopOfFirstPage());
    62326232}
    62336233
     
    62486248    }
    62496249   
    6250     return enclosingRenderFlowThread()->regionRemainingLogicalHeightForLine(offset, this, pageBoundaryRule);
     6250    return enclosingRenderFlowThread()->regionRemainingLogicalHeightForLine(offset, pageBoundaryRule);
    62516251}
    62526252
     
    64426442        return 0;
    64436443
    6444     return flowThread->renderRegionForLine(offsetFromLogicalTopOfFirstPage() + blockOffset, this, true);
     6444    return flowThread->renderRegionForLine(offsetFromLogicalTopOfFirstPage() + blockOffset, true);
    64456445}
    64466446
     
    64556455   
    64566456    return flowThread->logicalWidthChangedInRegions(this, offsetFromLogicalTopOfFirstPage());
     6457}
     6458
     6459RenderRegion* RenderBlock::clampToStartAndEndRegions(RenderRegion* region) const
     6460{
     6461    ASSERT(region && inRenderFlowThread());
     6462   
     6463    // We need to clamp to the block, since we want any lines or blocks that overflow out of the
     6464    // logical top or logical bottom of the block to size as though the border box in the first and
     6465    // last regions extended infinitely. Otherwise the lines are going to size according to the regions
     6466    // they overflow into, which makes no sense when this block doesn't exist in |region| at all.
     6467    RenderRegion* startRegion;
     6468    RenderRegion* endRegion;
     6469    enclosingRenderFlowThread()->getRegionRangeForBox(this, startRegion, endRegion);
     6470   
     6471    if (startRegion && region->offsetFromLogicalTopOfFirstPage() < startRegion->offsetFromLogicalTopOfFirstPage())
     6472        return startRegion;
     6473    if (endRegion && region->offsetFromLogicalTopOfFirstPage() > endRegion->offsetFromLogicalTopOfFirstPage())
     6474        return endRegion;
     6475   
     6476    return region;
    64576477}
    64586478
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r96859 r96975  
    897897    RenderRegion* regionAtBlockOffset(LayoutUnit) const;
    898898    bool logicalWidthChangedInRegions() const;
     899   
     900public:
     901    RenderRegion* clampToStartAndEndRegions(RenderRegion*) const;
    899902
    900903private:
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r96859 r96975  
    214214    // Now apply the parent inset since it is cumulative whenever anything in the containing block chain shifts.
    215215    // FIXME: Doesn't work right with perpendicular writing modes.
    216     const RenderBox* currentBox = containingBlock();
     216    const RenderBlock* currentBox = containingBlock();
    217217    offsetFromTopOfFirstPage -= logicalTop();
    218218    RenderBoxRegionInfo* currentBoxInfo = currentBox->renderBoxRegionInfo(region, offsetFromTopOfFirstPage);
     
    224224        offsetFromTopOfFirstPage -= logicalTop();
    225225        currentBox = currentBox->containingBlock();
     226        region = currentBox->clampToStartAndEndRegions(region);
    226227        currentBoxInfo = currentBox->renderBoxRegionInfo(region, offsetFromTopOfFirstPage);
    227228    }
     
    12851286
    12861287    RenderBlock* cb = containingBlock();
     1288    RenderRegion* containingBlockRegion = cb->clampToStartAndEndRegions(region);
    12871289    if (shrinkToAvoidFloats()) {
    12881290        LayoutUnit offsetFromLogicalTopOfRegion = region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage;
    1289         return cb->availableLogicalWidthForLine(max(logicalTop(), logicalTop() + offsetFromLogicalTopOfRegion), false, region, offsetFromLogicalTopOfFirstPage - logicalTop());
     1291        return cb->availableLogicalWidthForLine(max(logicalTop(), logicalTop() + offsetFromLogicalTopOfRegion), false, containingBlockRegion, offsetFromLogicalTopOfFirstPage - logicalTop());
    12901292    }
    12911293    LayoutUnit result = cb->availableLogicalWidth();
    1292     RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region, offsetFromLogicalTopOfFirstPage - logicalTop());
     1294    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(containingBlockRegion, offsetFromLogicalTopOfFirstPage - logicalTop());
    12931295    if (!boxInfo)
    12941296        return result;
     
    19131915        logicalLeftOffset += cb->style()->isLeftToRightDirection() ? startPositionDelta : -startPositionDelta;
    19141916    }
    1915     RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(region, offsetFromLogicalTopOfFirstPage - logicalTop());
     1917   
     1918    RenderRegion* clampedContainingBlockRegion = cb->clampToStartAndEndRegions(region);
     1919    RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(clampedContainingBlockRegion, offsetFromLogicalTopOfFirstPage - logicalTop());
    19161920    bool isShifted = containingBlockInfo && (containingBlockInfo->isShifted()
    19171921        || (style()->direction() == LTR && logicalLeftOffset)
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r96842 r96975  
    533533}
    534534
    535 RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, const RenderBox* box, bool extendLastRegion) const
     535RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, bool extendLastRegion) const
    536536{
    537537    ASSERT(!m_regionsInvalidated);
    538    
    539     // We need to clamp blockOffset to our border box, since we want any lines or blocks that overflow out of the
    540     // logical top or logical bottom to size as though the border box in the first and last regions extended infinitely.
    541     // Otherwise the lines are going to size according to the regions they overflow into, which makes no sense when, for example,
    542     // the ancestor blocks may not exist in the region either.
    543     RenderRegion* startRegion;
    544     RenderRegion* endRegion;
    545     if (box == this) {
    546         startRegion = firstRegion();
    547         endRegion = lastRegion();
    548     } else // Clamp to our containing block's set of regions.
    549         getRegionRangeForBox(box->containingBlock(), startRegion, endRegion);
    550538
    551539    // If no region matches the position and extendLastRegion is true, it will return
     
    555543    // FIXME: The regions are always in order, optimize this search.
    556544    bool useHorizontalWritingMode = isHorizontalWritingMode();
    557     for (RenderRegionList::const_iterator iter = m_regionList.find(startRegion); iter != m_regionList.end(); ++iter) {
     545    for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
    558546        RenderRegion* region = *iter;
    559547        if (!region->isValid())
     
    570558        if (extendLastRegion)
    571559            lastValidRegion = region;
    572            
    573         if (region == endRegion)
    574             break;
    575560    }
    576561
     
    578563}
    579564
    580 LayoutUnit RenderFlowThread::regionLogicalWidthForLine(LayoutUnit position, const RenderBox* box) const
    581 {
    582     RenderRegion* region = renderRegionForLine(position, box, true);
     565LayoutUnit RenderFlowThread::regionLogicalWidthForLine(LayoutUnit position) const
     566{
     567    RenderRegion* region = renderRegionForLine(position, true);
    583568    if (!region)
    584569        return contentLogicalWidth();
     
    586571}
    587572
    588 LayoutUnit RenderFlowThread::regionLogicalHeightForLine(LayoutUnit position, const RenderBox* box) const
    589 {
    590     RenderRegion* region = renderRegionForLine(position, box);
     573LayoutUnit RenderFlowThread::regionLogicalHeightForLine(LayoutUnit position) const
     574{
     575    RenderRegion* region = renderRegionForLine(position);
    591576    if (!region)
    592577        return 0;
     
    594579}
    595580
    596 LayoutUnit RenderFlowThread::regionRemainingLogicalHeightForLine(LayoutUnit position, const RenderBox* box, PageBoundaryRule pageBoundaryRule) const
    597 {
    598     RenderRegion* region = renderRegionForLine(position, box);
     581LayoutUnit RenderFlowThread::regionRemainingLogicalHeightForLine(LayoutUnit position, PageBoundaryRule pageBoundaryRule) const
     582{
     583    RenderRegion* region = renderRegionForLine(position);
    599584    if (!region)
    600585        return 0;
     
    624609
    625610    LayoutPoint center = boxRect.center();
    626     RenderRegion* renderRegion = renderRegionForLine(isHorizontalWritingMode() ? center.y() : center.x(), this, true);
     611    RenderRegion* renderRegion = renderRegionForLine(isHorizontalWritingMode() ? center.y() : center.x(), true);
    627612    if (!renderRegion)
    628613        return 0;
     
    762747{
    763748    // FIXME: Not right for differing writing-modes.
    764     RenderRegion* startRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage, box, true);
    765     RenderRegion* endRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage + box->logicalHeight(), box, true);
     749    RenderRegion* startRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage, true);
     750    RenderRegion* endRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage + box->logicalHeight(), true);
    766751    RenderRegionRange* range = m_regionRangeMap.get(box);
    767752    if (range) {
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r96842 r96975  
    9999    void repaintRectangleInRegions(const LayoutRect&, bool immediate);
    100100
    101     LayoutUnit regionLogicalWidthForLine(LayoutUnit position, const RenderBox*) const;
    102     LayoutUnit regionLogicalHeightForLine(LayoutUnit position, const RenderBox*) const;
    103     LayoutUnit regionRemainingLogicalHeightForLine(LayoutUnit position, const RenderBox*, PageBoundaryRule = IncludePageBoundary) const;
    104     RenderRegion* renderRegionForLine(LayoutUnit position, const RenderBox*, bool extendLastRegion = false) const;
     101    LayoutUnit regionLogicalWidthForLine(LayoutUnit position) const;
     102    LayoutUnit regionLogicalHeightForLine(LayoutUnit position) const;
     103    LayoutUnit regionRemainingLogicalHeightForLine(LayoutUnit position, PageBoundaryRule = IncludePageBoundary) const;
     104    RenderRegion* renderRegionForLine(LayoutUnit position, bool extendLastRegion = false) const;
    105105
    106106    bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
Note: See TracChangeset for help on using the changeset viewer.