Changeset 96423 in webkit


Ignore:
Timestamp:
Sep 30, 2011 2:04:45 PM (13 years ago)
Author:
hyatt@apple.com
Message:

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

[CSS3 Regions] Fix some bugs in the computation of the logical left and width offsets
for blocks in variable width regions. Specifically, this patch addresses a minor bug
with overflow:hidden/scroll/auto block placement and with RTL directionality.

Reviewed by Sam Weinig.

Source/WebCore:

Added five new tests in fast/regions.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::logicalRightOffsetForContent):
Avoid a double fetch of the border box in a given region by not calling
logicalLeftOffsetForContent. No correctness change here. It's just cleaner.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::borderBoxRectInRegion):
Change the shifted optimization to be cached for "self" rather than for "containing block".
Rework the adjustment loop to handle changes in directionality and to fix correctness
issues with RTL.

(WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
Don't double adjust if an object uses line width as the containing block width. In that
case we already computed the line width in the region, so we don't need to apply any
additional fixup.

(WebCore::RenderBox::renderBoxRegionInfo):

  • rendering/RenderBoxRegionInfo.h:

(WebCore::RenderBoxRegionInfo::RenderBoxRegionInfo):
(WebCore::RenderBoxRegionInfo::isShifted):
Changed the shifted code to be on self rather than on containing block.

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::layout):
Refactor the layout code for RenderFlowThread to properly set up region rects assuming
right alignment in RTL code. This change forces us to compute our maximum logical width
first before looping through the regions again to set their content rects.

LayoutTests:

  • fast/regions/overflow-in-variable-width-regions.html: Added.
  • fast/regions/overflow-rtl-in-variable-width-regions.html: Added.
  • fast/regions/percentage-margins-mixed-ltr-dominant-regions.html: Added.
  • fast/regions/percentage-margins-mixed-rtl-dominant-regions.html: Added.
  • fast/regions/percentage-margins-rtl-variable-width-regions.html: Added.
  • platform/mac/fast/regions/overflow-in-variable-width-regions-expected.png: Added.
  • platform/mac/fast/regions/overflow-in-variable-width-regions-expected.txt: Added.
  • platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.png: Added.
  • platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.txt: Added.
  • platform/mac/fast/regions/percentage-margins-mixed-ltr-dominant-regions-expected.png: Added.
  • platform/mac/fast/regions/percentage-margins-mixed-ltr-dominant-regions-expected.txt: Added.
  • platform/mac/fast/regions/percentage-margins-mixed-rtl-dominant-regions-expected.png: Added.
  • platform/mac/fast/regions/percentage-margins-mixed-rtl-dominant-regions-expected.txt: Added.
  • platform/mac/fast/regions/percentage-margins-rtl-variable-width-regions-expected.png: Added.
  • platform/mac/fast/regions/percentage-margins-rtl-variable-width-regions-expected.txt: Added.
Location:
trunk
Files:
15 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96420 r96423  
     12011-09-30  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=69167
     4       
     5        [CSS3 Regions] Fix some bugs in the computation of the logical left and width offsets
     6        for blocks in variable width regions. Specifically, this patch addresses a minor bug
     7        with overflow:hidden/scroll/auto block placement and with RTL directionality.
     8
     9        Reviewed by Sam Weinig.
     10
     11        * fast/regions/overflow-in-variable-width-regions.html: Added.
     12        * fast/regions/overflow-rtl-in-variable-width-regions.html: Added.
     13        * fast/regions/percentage-margins-mixed-ltr-dominant-regions.html: Added.
     14        * fast/regions/percentage-margins-mixed-rtl-dominant-regions.html: Added.
     15        * fast/regions/percentage-margins-rtl-variable-width-regions.html: Added.
     16        * platform/mac/fast/regions/overflow-in-variable-width-regions-expected.png: Added.
     17        * platform/mac/fast/regions/overflow-in-variable-width-regions-expected.txt: Added.
     18        * platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.png: Added.
     19        * platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.txt: Added.
     20        * platform/mac/fast/regions/percentage-margins-mixed-ltr-dominant-regions-expected.png: Added.
     21        * platform/mac/fast/regions/percentage-margins-mixed-ltr-dominant-regions-expected.txt: Added.
     22        * platform/mac/fast/regions/percentage-margins-mixed-rtl-dominant-regions-expected.png: Added.
     23        * platform/mac/fast/regions/percentage-margins-mixed-rtl-dominant-regions-expected.txt: Added.
     24        * platform/mac/fast/regions/percentage-margins-rtl-variable-width-regions-expected.png: Added.
     25        * platform/mac/fast/regions/percentage-margins-rtl-variable-width-regions-expected.txt: Added.
     26
    1272011-09-30  Adam Barth  <abarth@webkit.org>
    228
  • trunk/Source/WebCore/ChangeLog

    r96422 r96423  
     12011-09-30  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=69167
     4       
     5        [CSS3 Regions] Fix some bugs in the computation of the logical left and width offsets
     6        for blocks in variable width regions. Specifically, this patch addresses a minor bug
     7        with overflow:hidden/scroll/auto block placement and with RTL directionality.
     8
     9        Reviewed by Sam Weinig.
     10
     11        Added five new tests in fast/regions.
     12
     13        * rendering/RenderBlock.cpp:
     14        (WebCore::RenderBlock::logicalRightOffsetForContent):
     15        Avoid a double fetch of the border box in a given region by not calling
     16        logicalLeftOffsetForContent. No correctness change here. It's just cleaner.
     17
     18        * rendering/RenderBox.cpp:
     19        (WebCore::RenderBox::borderBoxRectInRegion):
     20        Change the shifted optimization to be cached for "self" rather than for "containing block".
     21        Rework the adjustment loop to handle changes in directionality and to fix correctness
     22        issues with RTL.
     23
     24        (WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
     25        Don't double adjust if an object uses line width as the containing block width. In that
     26        case we already computed the line width in the region, so we don't need to apply any
     27        additional fixup.
     28
     29        (WebCore::RenderBox::renderBoxRegionInfo):
     30        * rendering/RenderBoxRegionInfo.h:
     31        (WebCore::RenderBoxRegionInfo::RenderBoxRegionInfo):
     32        (WebCore::RenderBoxRegionInfo::isShifted):
     33        Changed the shifted code to be on self rather than on containing block.
     34
     35        * rendering/RenderFlowThread.cpp:
     36        (WebCore::RenderFlowThread::layout):
     37        Refactor the layout code for RenderFlowThread to properly set up region rects assuming
     38        right alignment in RTL code. This change forces us to compute our maximum logical width
     39        first before looping through the regions again to set their content rects.
     40
    1412011-09-30  Andreas Kling  <kling@webkit.org>
    242
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r96408 r96423  
    35753575        return logicalRightOffset;
    35763576    LayoutRect boxRect = borderBoxRectInRegionAtPosition(position);
    3577     return logicalLeftOffsetForContent(position) + availableLogicalWidth() - (logicalWidth() - (isHorizontalWritingMode() ? boxRect.width() : boxRect.height()));
     3577    return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? boxRect.maxX() : boxRect.maxY()));
    35783578}
    35793579
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r96408 r96423  
    212212    LayoutUnit logicalLeft = boxInfo->logicalLeft();
    213213       
    214     // Now apply the parent left inset since it is cumulative whenever anything in the containing block chain shifts.
    215     const RenderBox* currentBox = this;
    216     while (boxInfo->containingBlockChainIsShifted()) {
    217         currentBox = currentBox->containingBlock();
     214    // Now apply the parent inset since it is cumulative whenever anything in the containing block chain shifts.
     215    const RenderBox* currentBox = containingBlock();
     216    boxInfo = currentBox->renderBoxRegionInfo(region);
     217    while (boxInfo && boxInfo->isShifted()) {
     218        RenderBox* containerBox = currentBox->containingBlock();
     219        LayoutUnit widthDelta = currentBox->logicalWidth() - boxInfo->logicalWidth();
     220        if (containerBox->style()->direction() == LTR) {
     221            if (currentBox->style()->direction() == RTL)
     222                logicalLeft -= widthDelta;
     223            else
     224                logicalLeft += boxInfo->logicalLeft();
     225           
     226        } else {
     227            if (currentBox->style()->direction() == LTR)
     228                logicalLeft += widthDelta;
     229            else
     230                logicalLeft -= widthDelta - boxInfo->logicalLeft();
     231        }
     232        currentBox = containerBox;
    218233        boxInfo = currentBox->renderBoxRegionInfo(region);
    219         if (!boxInfo)
    220             break;
    221         logicalLeft += boxInfo->logicalLeft();
    222234    }
    223235   
     
    12611273{
    12621274    LayoutUnit result = containingBlockLogicalWidthForContent();
     1275    if (shrinkToAvoidFloats()) // We already sized to the available line width, so no need to adjust.
     1276        return result;
    12631277    RenderBlock* cb = containingBlock();
    12641278    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region);
     
    18721886        logicalLeftOffset += startMarginDelta;
    18731887    else
    1874         logicalLeftOffset += widthDelta - startMarginDelta;
     1888        logicalLeftOffset -= (widthDelta + startMarginDelta);
    18751889   
    18761890    // Set our values back.
     
    18801894
    18811895    RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(region);
    1882     bool containingBlockChainIsShifted = containingBlockInfo && (containingBlockInfo->containingBlockChainIsShifted()
    1883         || containingBlockInfo->logicalLeft());
    1884        
     1896    bool isShifted = containingBlockInfo && (containingBlockInfo->isShifted()
     1897        || (style()->direction() == LTR && logicalLeftOffset)
     1898        || (style()->direction() == RTL && (logicalWidth() - (logicalLeftOffset + logicalWidthInRegion))));
     1899
    18851900    // FIXME: Although it's unlikely, these boxes can go outside our bounds, and so we will need to incorporate them into overflow.
    1886     return region->setRenderBoxRegionInfo(this, logicalLeftOffset, logicalWidthInRegion, containingBlockChainIsShifted);
     1901    return region->setRenderBoxRegionInfo(this, logicalLeftOffset, logicalWidthInRegion, isShifted);
    18871902}
    18881903
  • trunk/Source/WebCore/rendering/RenderBoxRegionInfo.h

    r96408 r96423  
    3232class RenderBoxRegionInfo {
    3333public:
    34     RenderBoxRegionInfo(LayoutUnit logicalLeft, LayoutUnit logicalWidth, bool containingBlockChainIsShifted)
     34    RenderBoxRegionInfo(LayoutUnit logicalLeft, LayoutUnit logicalWidth, bool isShifted)
    3535        : m_logicalLeft(logicalLeft)
    3636        , m_logicalWidth(logicalWidth)
    37         , m_containingBlockChainIsShifted(containingBlockChainIsShifted)
     37        , m_isShifted(isShifted)
    3838    { }
    3939
     
    4141    LayoutUnit logicalWidth() const { return m_logicalWidth; }
    4242   
    43     bool containingBlockChainIsShifted() const { return m_containingBlockChainIsShifted; }
     43    bool isShifted() const { return m_isShifted; }
    4444
    4545private:
    4646    LayoutUnit m_logicalLeft;
    4747    LayoutUnit m_logicalWidth;
    48     bool m_containingBlockChainIsShifted;
     48    bool m_isShifted;
    4949};
    5050
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r96408 r96423  
    312312        LayoutUnit previousRegionLogicalHeight = 0;
    313313        if (hasRegions()) {
    314             int logicalHeight = 0;
    315314            for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
    316315                RenderRegion* region = *iter;
    317 
    318316                if (!region->isValid())
    319317                    continue;
    320 
    321318                ASSERT(!region->needsLayout());
    322319               
     
    326323                LayoutUnit regionLogicalHeight;
    327324
    328                 IntRect regionRect;
    329325                if (isHorizontalWritingMode()) {
    330                     regionRect = IntRect(0, logicalHeight, region->contentWidth(), region->contentHeight());
    331                     logicalHeight += regionRect.height();
    332326                    regionLogicalWidth = region->contentWidth();
    333327                    regionLogicalHeight = region->contentHeight();
    334328                } else {
    335                     regionRect = IntRect(logicalHeight, 0, region->contentWidth(), region->contentHeight());
    336                     logicalHeight += regionRect.width();
    337329                    regionLogicalWidth = region->contentHeight();
    338330                    regionLogicalHeight = region->contentWidth();
     
    349341
    350342                previousRegionLogicalWidth = regionLogicalWidth;
    351 
     343            }
     344           
     345            computeLogicalWidth(); // Called to get the maximum logical width for the region.
     346           
     347            LayoutUnit logicalHeight = 0;
     348            for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
     349                RenderRegion* region = *iter;
     350                if (!region->isValid())
     351                    continue;
     352                LayoutRect regionRect;
     353                if (isHorizontalWritingMode()) {
     354                    regionRect = IntRect(style()->direction() == LTR ? 0 : logicalWidth() - region->contentWidth(), logicalHeight, region->contentWidth(), region->contentHeight());
     355                    logicalHeight += regionRect.height();
     356                } else {
     357                    regionRect = IntRect(logicalHeight, style()->direction() == LTR ? 0 : logicalWidth() - region->contentHeight(), region->contentWidth(), region->contentHeight());
     358                    logicalHeight += regionRect.width();
     359                }
    352360                region->setRegionRect(regionRect);
    353361            }
Note: See TracChangeset for help on using the changeset viewer.