Changeset 79930 in webkit


Ignore:
Timestamp:
Feb 28, 2011, 3:21:36 PM (14 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=46500, make positioned elements work with vertical text. Change staticX and staticY
to be staticInlinePosition and staticBlockPosition. Patch all of the computations involving these variables to be writing
mode aware. Mixed writing modes are not yet supported.

Reviewed by Dan Bernstein.

Added new tests in fast/block/positioning/auto.

Source/WebCore:

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::adjustPositionedBlock):
(WebCore::RenderBlock::layoutPositionedObjects):

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::startOffsetForLine):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::appendRunsForObject):
(WebCore::setStaticPositions):
(WebCore::RenderBlock::skipTrailingWhitespace):
(WebCore::RenderBlock::skipLeadingWhitespace):
(WebCore::RenderBlock::findNextLineBreak):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::positionLineBox):
(WebCore::computeInlineStaticDistance):
(WebCore::RenderBox::computePositionedLogicalWidth):
(WebCore::computeBlockStaticDistance):
(WebCore::RenderBox::computePositionedLogicalHeight):
(WebCore::RenderBox::computePositionedLogicalWidthReplaced):
(WebCore::RenderBox::computePositionedLogicalHeightReplaced):

  • rendering/RenderBoxModelObject.h:

(WebCore::RenderBoxModelObject::borderAndPaddingLogicalLeft):
(WebCore::RenderBoxModelObject::borderAndPaddingStart):
(WebCore::RenderBoxModelObject::borderLogicalLeft):
(WebCore::RenderBoxModelObject::borderLogicalRight):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutHorizontalBox):
(WebCore::RenderFlexibleBox::layoutVerticalBox):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::relativePositionedInlineOffset):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::RenderLayer):

  • rendering/RenderLayer.h:

(WebCore::RenderLayer::staticInlinePosition):
(WebCore::RenderLayer::staticBlockPosition):
(WebCore::RenderLayer::setStaticInlinePosition):
(WebCore::RenderLayer::setStaticBlockPosition):

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::hasAutoLeftAndRight):
(WebCore::InheritedFlags::hasAutoTopAndBottom):
(WebCore::InheritedFlags::hasStaticInlinePosition):
(WebCore::InheritedFlags::hasStaticBlockPosition):

LayoutTests:

  • fast/block/positioning/auto/vertical-lr: Added.
  • fast/block/positioning/auto/vertical-lr/001.html: Added.
  • fast/block/positioning/auto/vertical-lr/002.html: Added.
  • fast/block/positioning/auto/vertical-lr/003.html: Added.
  • fast/block/positioning/auto/vertical-lr/004.html: Added.
  • fast/block/positioning/auto/vertical-lr/005.html: Added.
  • fast/block/positioning/auto/vertical-lr/006.html: Added.
  • fast/block/positioning/auto/vertical-lr/007.html: Added.
  • fast/block/positioning/auto/vertical-rl: Added.
  • fast/block/positioning/auto/vertical-rl/001.html: Added.
  • fast/block/positioning/auto/vertical-rl/002.html: Added.
  • fast/block/positioning/auto/vertical-rl/003.html: Added.
  • fast/block/positioning/auto/vertical-rl/004.html: Added.
  • fast/block/positioning/auto/vertical-rl/005.html: Added.
  • fast/block/positioning/auto/vertical-rl/006.html: Added.
  • fast/block/positioning/auto/vertical-rl/007.html: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.txt: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.checksum: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.png: Added.
  • platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.txt: Added.
Location:
trunk
Files:
60 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r79921 r79930  
     12011-02-28  David Hyatt  <[email protected]>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=46500, make positioned elements work with vertical text.  Change staticX and staticY
     6        to be staticInlinePosition and staticBlockPosition.  Patch all of the computations involving these variables to be writing
     7        mode aware.  Mixed writing modes are not yet supported.
     8
     9        Added new tests in fast/block/positioning/auto.
     10
     11        * fast/block/positioning/auto/vertical-lr: Added.
     12        * fast/block/positioning/auto/vertical-lr/001.html: Added.
     13        * fast/block/positioning/auto/vertical-lr/002.html: Added.
     14        * fast/block/positioning/auto/vertical-lr/003.html: Added.
     15        * fast/block/positioning/auto/vertical-lr/004.html: Added.
     16        * fast/block/positioning/auto/vertical-lr/005.html: Added.
     17        * fast/block/positioning/auto/vertical-lr/006.html: Added.
     18        * fast/block/positioning/auto/vertical-lr/007.html: Added.
     19        * fast/block/positioning/auto/vertical-rl: Added.
     20        * fast/block/positioning/auto/vertical-rl/001.html: Added.
     21        * fast/block/positioning/auto/vertical-rl/002.html: Added.
     22        * fast/block/positioning/auto/vertical-rl/003.html: Added.
     23        * fast/block/positioning/auto/vertical-rl/004.html: Added.
     24        * fast/block/positioning/auto/vertical-rl/005.html: Added.
     25        * fast/block/positioning/auto/vertical-rl/006.html: Added.
     26        * fast/block/positioning/auto/vertical-rl/007.html: Added.
     27        * platform/mac/fast/block/positioning/auto/vertical-lr: Added.
     28        * platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.checksum: Added.
     29        * platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.png: Added.
     30        * platform/mac/fast/block/positioning/auto/vertical-lr/001-expected.txt: Added.
     31        * platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.checksum: Added.
     32        * platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.png: Added.
     33        * platform/mac/fast/block/positioning/auto/vertical-lr/002-expected.txt: Added.
     34        * platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.checksum: Added.
     35        * platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.png: Added.
     36        * platform/mac/fast/block/positioning/auto/vertical-lr/003-expected.txt: Added.
     37        * platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.checksum: Added.
     38        * platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.png: Added.
     39        * platform/mac/fast/block/positioning/auto/vertical-lr/004-expected.txt: Added.
     40        * platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.checksum: Added.
     41        * platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.png: Added.
     42        * platform/mac/fast/block/positioning/auto/vertical-lr/005-expected.txt: Added.
     43        * platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.checksum: Added.
     44        * platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.png: Added.
     45        * platform/mac/fast/block/positioning/auto/vertical-lr/006-expected.txt: Added.
     46        * platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.checksum: Added.
     47        * platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.png: Added.
     48        * platform/mac/fast/block/positioning/auto/vertical-lr/007-expected.txt: Added.
     49        * platform/mac/fast/block/positioning/auto/vertical-rl: Added.
     50        * platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.checksum: Added.
     51        * platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.png: Added.
     52        * platform/mac/fast/block/positioning/auto/vertical-rl/001-expected.txt: Added.
     53        * platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.checksum: Added.
     54        * platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.png: Added.
     55        * platform/mac/fast/block/positioning/auto/vertical-rl/002-expected.txt: Added.
     56        * platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.checksum: Added.
     57        * platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.png: Added.
     58        * platform/mac/fast/block/positioning/auto/vertical-rl/003-expected.txt: Added.
     59        * platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.checksum: Added.
     60        * platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.png: Added.
     61        * platform/mac/fast/block/positioning/auto/vertical-rl/004-expected.txt: Added.
     62        * platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.checksum: Added.
     63        * platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.png: Added.
     64        * platform/mac/fast/block/positioning/auto/vertical-rl/005-expected.txt: Added.
     65        * platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.checksum: Added.
     66        * platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.png: Added.
     67        * platform/mac/fast/block/positioning/auto/vertical-rl/006-expected.txt: Added.
     68        * platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.checksum: Added.
     69        * platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.png: Added.
     70        * platform/mac/fast/block/positioning/auto/vertical-rl/007-expected.txt: Added.
     71
    1722011-02-28  Jungshik Shin  <[email protected]>
    273
  • trunk/Source/WebCore/ChangeLog

    r79925 r79930  
     12011-02-28  David Hyatt  <[email protected]>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=46500, make positioned elements work with vertical text.  Change staticX and staticY
     6        to be staticInlinePosition and staticBlockPosition.  Patch all of the computations involving these variables to be writing
     7        mode aware.  Mixed writing modes are not yet supported.
     8
     9        Added new tests in fast/block/positioning/auto.
     10
     11        * rendering/RenderBlock.cpp:
     12        (WebCore::RenderBlock::adjustPositionedBlock):
     13        (WebCore::RenderBlock::layoutPositionedObjects):
     14        * rendering/RenderBlock.h:
     15        (WebCore::RenderBlock::startOffsetForLine):
     16        * rendering/RenderBlockLineLayout.cpp:
     17        (WebCore::RenderBlock::appendRunsForObject):
     18        (WebCore::setStaticPositions):
     19        (WebCore::RenderBlock::skipTrailingWhitespace):
     20        (WebCore::RenderBlock::skipLeadingWhitespace):
     21        (WebCore::RenderBlock::findNextLineBreak):
     22        * rendering/RenderBox.cpp:
     23        (WebCore::RenderBox::positionLineBox):
     24        (WebCore::computeInlineStaticDistance):
     25        (WebCore::RenderBox::computePositionedLogicalWidth):
     26        (WebCore::computeBlockStaticDistance):
     27        (WebCore::RenderBox::computePositionedLogicalHeight):
     28        (WebCore::RenderBox::computePositionedLogicalWidthReplaced):
     29        (WebCore::RenderBox::computePositionedLogicalHeightReplaced):
     30        * rendering/RenderBoxModelObject.h:
     31        (WebCore::RenderBoxModelObject::borderAndPaddingLogicalLeft):
     32        (WebCore::RenderBoxModelObject::borderAndPaddingStart):
     33        (WebCore::RenderBoxModelObject::borderLogicalLeft):
     34        (WebCore::RenderBoxModelObject::borderLogicalRight):
     35        * rendering/RenderFlexibleBox.cpp:
     36        (WebCore::RenderFlexibleBox::layoutHorizontalBox):
     37        (WebCore::RenderFlexibleBox::layoutVerticalBox):
     38        * rendering/RenderInline.cpp:
     39        (WebCore::RenderInline::relativePositionedInlineOffset):
     40        * rendering/RenderLayer.cpp:
     41        (WebCore::RenderLayer::RenderLayer):
     42        * rendering/RenderLayer.h:
     43        (WebCore::RenderLayer::staticInlinePosition):
     44        (WebCore::RenderLayer::staticBlockPosition):
     45        (WebCore::RenderLayer::setStaticInlinePosition):
     46        (WebCore::RenderLayer::setStaticBlockPosition):
     47        * rendering/style/RenderStyle.h:
     48        (WebCore::InheritedFlags::hasAutoLeftAndRight):
     49        (WebCore::InheritedFlags::hasAutoTopAndBottom):
     50        (WebCore::InheritedFlags::hasStaticInlinePosition):
     51        (WebCore::InheritedFlags::hasStaticBlockPosition):
     52
    1532011-02-28  Balazs Kelemen  <[email protected]>
    254
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r79834 r79930  
    14141414void RenderBlock::adjustPositionedBlock(RenderBox* child, const MarginInfo& marginInfo)
    14151415{
    1416     if (child->style()->hasStaticX()) {
    1417         if (style()->isLeftToRightDirection())
    1418             child->layer()->setStaticX(borderLeft() + paddingLeft());
    1419         else
    1420             child->layer()->setStaticX(borderRight() + paddingRight());
    1421     }
    1422 
    1423     if (child->style()->hasStaticY()) {
    1424         int y = height();
     1416    bool isHorizontal = style()->isHorizontalWritingMode();
     1417    bool hasStaticInlinePosition = child->style()->hasStaticInlinePosition(isHorizontal);
     1418    bool hasStaticBlockPosition = child->style()->hasStaticBlockPosition(isHorizontal);
     1419    RenderLayer* childLayer = child->layer();
     1420       
     1421    if (hasStaticInlinePosition)
     1422        childLayer->setStaticInlinePosition(borderAndPaddingStart());
     1423
     1424    if (hasStaticBlockPosition) {
     1425        int logicalTop = logicalHeight();
    14251426        if (!marginInfo.canCollapseWithMarginBefore()) {
    14261427            child->computeBlockDirectionMargins(this);
    1427             int marginTop = child->marginTop();
    1428             int collapsedTopPos = marginInfo.positiveMargin();
    1429             int collapsedTopNeg = marginInfo.negativeMargin();
    1430             if (marginTop > 0) {
    1431                 if (marginTop > collapsedTopPos)
    1432                     collapsedTopPos = marginTop;
     1428            int marginBefore = marginBeforeForChild(child);
     1429            int collapsedBeforePos = marginInfo.positiveMargin();
     1430            int collapsedBeforeNeg = marginInfo.negativeMargin();
     1431            if (marginBefore > 0) {
     1432                if (marginBefore > collapsedBeforePos)
     1433                    collapsedBeforePos = marginBefore;
    14331434            } else {
    1434                 if (-marginTop > collapsedTopNeg)
    1435                     collapsedTopNeg = -marginTop;
     1435                if (-marginBefore > collapsedBeforeNeg)
     1436                    collapsedBeforeNeg = -marginBefore;
    14361437            }
    1437             y += (collapsedTopPos - collapsedTopNeg) - marginTop;
    1438         }
    1439         RenderLayer* childLayer = child->layer();
    1440         if (childLayer->staticY() != y) {
    1441             child->layer()->setStaticY(y);
     1438            logicalTop += (collapsedBeforePos - collapsedBeforeNeg) - marginBefore;
     1439        }
     1440        if (childLayer->staticBlockPosition() != logicalTop) {
     1441            childLayer->setStaticBlockPosition(logicalTop);
    14421442            child->setChildNeedsLayout(true, false);
    14431443        }
     
    21222122        // objects that are positioned implicitly like this.  Such objects are rare, and so in typical DHTML menu usage (where everything is
    21232123        // positioned explicitly) this should not incur a performance penalty.
    2124         if (relayoutChildren || (r->style()->hasStaticY() && r->parent() != this && r->parent()->isBlockFlow()))
     2124        if (relayoutChildren || (r->style()->hasStaticBlockPosition(style()->isHorizontalWritingMode()) && r->parent() != this && r->parent()->isBlockFlow()))
    21252125            r->setChildNeedsLayout(true, false);
    21262126           
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r79900 r79930  
    102102    int logicalRightOffsetForLine(int position, bool firstLine) const { return logicalRightOffsetForLine(position, logicalRightOffsetForContent(), firstLine); }
    103103    int logicalLeftOffsetForLine(int position, bool firstLine) const { return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(), firstLine); }
    104    
     104    int startOffsetForLine(int position, bool firstLine) const { return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine) : logicalRightOffsetForLine(position, firstLine); }
     105
    105106    virtual VisiblePosition positionForPoint(const IntPoint&);
    106107   
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r79817 r79930  
    116116{
    117117    if (start > end || obj->isFloating() ||
    118         (obj->isPositioned() && !obj->style()->hasStaticX() && !obj->style()->hasStaticY() && !obj->container()->isRenderInline()))
     118        (obj->isPositioned() && !obj->style()->hasAutoLeftAndRight() && !obj->style()->hasAutoTopAndBottom() && !obj->container()->isRenderInline()))
    119119        return;
    120120
     
    12971297}
    12981298
     1299static void setStaticPositions(RenderBlock* block, RenderBox* child)
     1300{
     1301    // FIXME: The math here is actually not really right. It's a best-guess approximation that
     1302    // will work for the common cases
     1303    RenderObject* containerBlock = child->container();
     1304    if (containerBlock->isRenderInline()) {
     1305        // A relative positioned inline encloses us. In this case, we also have to determine our
     1306        // position as though we were an inline. Set |staticInlinePosition| and |staticBlockPosition| on the relative positioned
     1307        // inline so that we can obtain the value later.
     1308        toRenderInline(containerBlock)->layer()->setStaticInlinePosition(block->startOffsetForLine(block->logicalHeight(), false));
     1309        toRenderInline(containerBlock)->layer()->setStaticBlockPosition(block->logicalHeight());
     1310    }
     1311
     1312    bool isHorizontal = block->style()->isHorizontalWritingMode();
     1313    bool hasStaticInlinePosition = child->style()->hasStaticInlinePosition(isHorizontal);
     1314    bool hasStaticBlockPosition = child->style()->hasStaticBlockPosition(isHorizontal);
     1315
     1316    if (hasStaticInlinePosition) {
     1317        if (child->style()->isOriginalDisplayInlineType())
     1318            child->layer()->setStaticInlinePosition(block->startOffsetForLine(block->logicalHeight(), false));
     1319        else
     1320            child->layer()->setStaticInlinePosition(block->borderAndPaddingStart());
     1321    }
     1322
     1323    if (hasStaticBlockPosition)
     1324        child->layer()->setStaticBlockPosition(block->logicalHeight());
     1325}
     1326
    12991327// FIXME: The entire concept of the skipTrailingWhitespace function is flawed, since we really need to be building
    13001328// line boxes even for containers that may ultimately collapse away.  Otherwise we'll never get positioned
     
    13091337        if (object->isFloating()) {
    13101338            insertFloatingObject(toRenderBox(object));
    1311         } else if (object->isPositioned()) {
    1312             // FIXME: The math here is actually not really right.  It's a best-guess approximation that
    1313             // will work for the common cases
    1314             RenderObject* c = object->container();
    1315             if (c->isRenderInline()) {
    1316                 // A relative positioned inline encloses us.  In this case, we also have to determine our
    1317                 // position as though we were an inline.  Set |staticX| and |staticY| on the relative positioned
    1318                 // inline so that we can obtain the value later.
    1319                 toRenderInline(c)->layer()->setStaticX(style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(height(), false) : logicalRightOffsetForLine(height(), false));
    1320                 toRenderInline(c)->layer()->setStaticY(height());
    1321             }
    1322    
    1323             RenderBox* box = toRenderBox(object);
    1324             if (box->style()->hasStaticX()) {
    1325                 if (box->style()->isOriginalDisplayInlineType())
    1326                     box->layer()->setStaticX(style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(height(), false) : width() - logicalRightOffsetForLine(height(), false));
    1327                 else
    1328                     box->layer()->setStaticX(style()->isLeftToRightDirection() ? borderLeft() + paddingLeft() : borderRight() + paddingRight());
    1329             }
    1330    
    1331             if (box->style()->hasStaticY())
    1332                 box->layer()->setStaticY(height());
    1333         }
     1339        } else if (object->isPositioned())
     1340            setStaticPositions(this, toRenderBox(object));
    13341341        iterator.increment();
    13351342    }
     
    13451352            positionNewFloatOnLine(insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine);
    13461353            availableWidth = availableLogicalWidthForLine(logicalHeight(), firstLine);
    1347         } else if (object->isPositioned()) {
    1348             // FIXME: The math here is actually not really right.  It's a best-guess approximation that
    1349             // will work for the common cases
    1350             RenderObject* c = object->container();
    1351             if (c->isRenderInline()) {
    1352                 // A relative positioned inline encloses us.  In this case, we also have to determine our
    1353                 // position as though we were an inline.  Set |staticX| and |staticY| on the relative positioned
    1354                 // inline so that we can obtain the value later.
    1355                 toRenderInline(c)->layer()->setStaticX(style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(height(), firstLine) : logicalRightOffsetForLine(height(), firstLine));
    1356                 toRenderInline(c)->layer()->setStaticY(height());
    1357             }
    1358    
    1359             RenderBox* box = toRenderBox(object);
    1360             if (box->style()->hasStaticX()) {
    1361                 if (box->style()->isOriginalDisplayInlineType())
    1362                     box->layer()->setStaticX(style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(height(), firstLine) : width() - logicalRightOffsetForLine(height(), firstLine));
    1363                 else
    1364                     box->layer()->setStaticX(style()->isLeftToRightDirection() ? borderLeft() + paddingLeft() : borderRight() + paddingRight());
    1365             }
    1366    
    1367             if (box->style()->hasStaticY())
    1368                 box->layer()->setStaticY(height());
    1369         }
     1354        } else if (object->isPositioned())
     1355            setStaticPositions(this, toRenderBox(object));
    13701356        resolver.increment();
    13711357    }
     
    15581544            } else if (o->isPositioned()) {
    15591545                // If our original display wasn't an inline type, then we can
    1560                 // go ahead and determine our static x position now.
     1546                // go ahead and determine our static inline position now.
    15611547                RenderBox* box = toRenderBox(o);
    15621548                bool isInlineType = box->style()->isOriginalDisplayInlineType();
    1563                 bool needToSetStaticX = box->style()->hasStaticX();
    1564                 if (box->style()->hasStaticX() && !isInlineType) {
    1565                     box->layer()->setStaticX(o->parent()->style()->isLeftToRightDirection() ?
    1566                                   borderLeft() + paddingLeft() :
    1567                                   borderRight() + paddingRight());
    1568                     needToSetStaticX = false;
     1549                bool needToSetStaticInlinePosition = box->style()->hasStaticInlinePosition(style()->isHorizontalWritingMode());
     1550                if (needToSetStaticInlinePosition && !isInlineType) {
     1551                    box->layer()->setStaticInlinePosition(borderAndPaddingStart());
     1552                    needToSetStaticInlinePosition = false;
    15691553                }
    15701554
    15711555                // If our original display was an INLINE type, then we can go ahead
    15721556                // and determine our static y position now.
    1573                 bool needToSetStaticY = box->style()->hasStaticY();
    1574                 if (box->style()->hasStaticY() && isInlineType) {
    1575                     box->layer()->setStaticY(height());
    1576                     needToSetStaticY = false;
     1557                bool needToSetStaticBlockPosition = box->style()->hasStaticBlockPosition(style()->isHorizontalWritingMode());
     1558                if (needToSetStaticBlockPosition && isInlineType) {
     1559                    box->layer()->setStaticBlockPosition(logicalHeight());
     1560                    needToSetStaticBlockPosition = false;
    15771561                }
    15781562               
    1579                 bool needToCreateLineBox = needToSetStaticX || needToSetStaticY;
     1563                bool needToCreateLineBox = needToSetStaticInlinePosition || needToSetStaticBlockPosition;
    15801564                RenderObject* c = o->container();
    1581                 if (c->isRenderInline() && (!needToSetStaticX || !needToSetStaticY))
     1565                if (c->isRenderInline() && (!needToSetStaticInlinePosition || !needToSetStaticBlockPosition))
    15821566                    needToCreateLineBox = true;
    15831567
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r79725 r79930  
    13091309        // Cache the x position only if we were an INLINE type originally.
    13101310        bool wasInline = style()->isOriginalDisplayInlineType();
    1311         if (wasInline && style()->hasStaticX()) {
     1311        if (wasInline && style()->hasStaticInlinePosition(box->isHorizontal())) {
    13121312            // The value is cached in the xPos of the box.  We only need this value if
    13131313            // our object was inline originally, since otherwise it would have ended up underneath
    13141314            // the inlines.
    1315             layer()->setStaticX(box->x());
     1315            layer()->setStaticInlinePosition(lroundf(box->logicalLeft()));
    13161316            setChildNeedsLayout(true, false); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
    1317         } else if (!wasInline && style()->hasStaticY()) {
     1317        } else if (!wasInline && style()->hasStaticBlockPosition(box->isHorizontal())) {
    13181318            // Our object was a block originally, so we make our normal flow position be
    13191319            // just below the line box (as though all the inlines that came before us got
    13201320            // wrapped in an anonymous block, which is what would have happened had we been
    13211321            // in flow).  This value was cached in the y() of the box.
    1322             layer()->setStaticY(box->y());
     1322            layer()->setStaticBlockPosition(box->logicalTop());
    13231323            setChildNeedsLayout(true, false); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
    13241324        }
     
    20982098    heightResult -= (containingBlock->borderBefore() + containingBlock->borderAfter());
    20992099    return heightResult;
     2100}
     2101
     2102static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const RenderBox* child, const RenderBoxModelObject* containerBlock, int containerLogicalWidth,
     2103                                        TextDirection containerDirection)
     2104{
     2105    if (!logicalLeft.isAuto() || !logicalRight.isAuto())
     2106        return;
     2107
     2108    // FIXME: The static distance computation has not been patched for mixed writing modes yet.
     2109    if (containerDirection == LTR) {
     2110        int staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
     2111        for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->parent()) {
     2112            if (curr->isBox())
     2113                staticPosition += toRenderBox(curr)->logicalLeft();
     2114        }
     2115        logicalLeft.setValue(Fixed, staticPosition);
     2116    } else {
     2117        RenderBox* enclosingBox = child->parent()->enclosingBox();
     2118        int staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalRight();
     2119        staticPosition -= enclosingBox->logicalWidth();
     2120        for (RenderObject* curr = enclosingBox; curr && curr != containerBlock; curr = curr->parent()) {
     2121            if (curr->isBox())
     2122                staticPosition -= toRenderBox(curr)->logicalLeft();
     2123        }
     2124        logicalRight.setValue(Fixed, staticPosition);
     2125    }
    21002126}
    21012127
     
    21782204    // see FIXME 2
    21792205    // Calculate the static distance if needed.
    2180     // FIXME: The static distance computation has not been patched for writing modes yet.
    2181     if (logicalLeft.isAuto() && logicalRight.isAuto()) {
    2182         if (containerDirection == LTR) {
    2183             // 'staticX' should already have been set through layout of the parent.
    2184             int staticPosition = layer()->staticX() - containerBlock->borderLeft();
    2185             for (RenderObject* curr = parent(); curr && curr != containerBlock; curr = curr->parent()) {
    2186                 if (curr->isBox())
    2187                     staticPosition += toRenderBox(curr)->x();
    2188             }
    2189             logicalLeft.setValue(Fixed, staticPosition);
    2190         } else {
    2191             RenderBox* enclosingBox = parent()->enclosingBox();
    2192             // 'staticX' should already have been set through layout of the parent.
    2193             int staticPosition = layer()->staticX() + containerLogicalWidth + containerBlock->borderRight();
    2194             staticPosition -= enclosingBox->width();
    2195             for (RenderObject* curr = enclosingBox; curr && curr != containerBlock; curr = curr->parent()) {
    2196                 if (curr->isBox())
    2197                     staticPosition -= toRenderBox(curr)->x();
    2198             }
    2199             logicalRight.setValue(Fixed, staticPosition);
    2200         }
    2201     }
    2202 
     2206    computeInlineStaticDistance(logicalLeft, logicalRight, this, containerBlock, containerLogicalWidth, containerDirection);
     2207   
    22032208    // Calculate constraint equation values for 'width' case.
    22042209    int logicalWidthResult;
     
    24482453}
    24492454
     2455static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom, const RenderBox* child, const RenderBoxModelObject* containerBlock)
     2456{
     2457    if (!logicalTop.isAuto() || !logicalBottom.isAuto())
     2458        return;
     2459   
     2460    // FIXME: The static distance computation has not been patched for mixed writing modes.
     2461    int staticLogicalTop = child->layer()->staticBlockPosition() - containerBlock->borderBefore();
     2462    for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->parent()) {
     2463        if (curr->isBox() && !curr->isTableRow())
     2464            staticLogicalTop += toRenderBox(curr)->logicalTop();
     2465    }
     2466    logicalTop.setValue(Fixed, staticLogicalTop);
     2467}
     2468
    24502469void RenderBox::computePositionedLogicalHeight()
    24512470{
     
    24972516    // see FIXME 2
    24982517    // Calculate the static distance if needed.
    2499     // FIXME: The static distance computation has not been patched for writing modes.
    2500     if (logicalTop.isAuto() && logicalBottom.isAuto()) {
    2501         // staticY should already have been set through layout of the parent()
    2502         int staticTop = layer()->staticY() - containerBlock->borderTop();
    2503         for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
    2504             if (po->isBox() && !po->isTableRow())
    2505                 staticTop += toRenderBox(po)->y();
    2506         }
    2507         logicalTop.setValue(Fixed, staticTop);
    2508     }
    2509 
     2518    computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock);
    25102519
    25112520    int logicalHeightResult; // Needed to compute overflow.
     
    27482757    \*-----------------------------------------------------------------------*/
    27492758    // see FIXME 2
    2750     // FIXME: Static position computation has not been patched for writing modes yet.
    2751     if (logicalLeft.isAuto() && logicalRight.isAuto()) {
    2752         // see FIXME 1
    2753         if (containerDirection == LTR) {
    2754             // 'staticX' should already have been set through layout of the parent.
    2755             int staticPosition = layer()->staticX() - containerBlock->borderLeft();
    2756             for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
    2757                 if (po->isBox())
    2758                     staticPosition += toRenderBox(po)->x();
    2759             }
    2760             logicalLeft.setValue(Fixed, staticPosition);
    2761         } else {
    2762             RenderObject* po = parent();
    2763             // 'staticX' should already have been set through layout of the parent.
    2764             int staticPosition = layer()->staticX() + containerLogicalWidth + containerBlock->borderRight();
    2765             for ( ; po && po != containerBlock; po = po->parent()) {
    2766                 if (po->isBox())
    2767                     staticPosition += toRenderBox(po)->x();
    2768             }
    2769             logicalRight.setValue(Fixed, staticPosition);
    2770         }
    2771     }
     2759    computeInlineStaticDistance(logicalLeft, logicalRight, this, containerBlock, containerLogicalWidth, containerDirection);
    27722760
    27732761    /*-----------------------------------------------------------------------*\
     
    29302918    \*-----------------------------------------------------------------------*/
    29312919    // see FIXME 2
    2932     // FIXME: The static distance computation has not been patched for writing modes yet.
    2933     if (logicalTop.isAuto() && logicalBottom.isAuto()) {
    2934         // staticY should already have been set through layout of the parent().
    2935         int staticTop = layer()->staticY() - containerBlock->borderTop();
    2936         for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) {
    2937             if (po->isBox() && !po->isTableRow())
    2938                 staticTop += toRenderBox(po)->y();
    2939         }
    2940         logicalTop.setValue(Fixed, staticTop);
    2941     }
     2920    computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock);
    29422921
    29432922    /*-----------------------------------------------------------------------*\
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r76083 r79930  
    9090    int borderAndPaddingLogicalHeight() const { return borderBefore() + borderAfter() + paddingBefore() + paddingAfter(); }
    9191    int borderAndPaddingLogicalWidth() const { return borderStart() + borderEnd() + paddingStart() + paddingEnd(); }
     92    int borderAndPaddingLogicalLeft() const { return style()->isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
     93
     94    int borderAndPaddingStart() const { return borderStart() + paddingStart(); }
     95    int borderLogicalLeft() const { return style()->isHorizontalWritingMode() ? borderLeft() : borderTop(); }
     96    int borderLogicalRight() const { return style()->isHorizontalWritingMode() ? borderRight() : borderBottom(); }
    9297
    9398    virtual int marginTop() const = 0;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r79286 r79930  
    413413            if (child->isPositioned()) {
    414414                child->containingBlock()->insertPositionedObject(child);
    415                 if (child->style()->hasStaticX()) {
    416                     if (style()->isLeftToRightDirection())
    417                         child->layer()->setStaticX(xPos);
    418                     else child->layer()->setStaticX(width() - xPos);
    419                 }
    420                 if (child->style()->hasStaticY()) {
    421                     RenderLayer* childLayer = child->layer();
    422                     if (childLayer->staticY() != yPos) {
    423                         child->layer()->setStaticY(yPos);
     415                RenderLayer* childLayer = child->layer();
     416                if (child->style()->hasStaticInlinePosition(style()->isHorizontalWritingMode()))
     417                    childLayer->setStaticInlinePosition(xPos);
     418                if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingMode())) {
     419                    if (childLayer->staticBlockPosition() != yPos) {
     420                        childLayer->setStaticBlockPosition(yPos);
    424421                        child->setChildNeedsLayout(true, false);
    425422                    }
     
    679676            if (child->isPositioned()) {
    680677                child->containingBlock()->insertPositionedObject(child);
    681                 if (child->style()->hasStaticX()) {
     678                RenderLayer* childLayer = child->layer();
     679                if (child->style()->hasStaticInlinePosition(style()->isHorizontalWritingMode())) {
    682680                    if (style()->isLeftToRightDirection())
    683                         child->layer()->setStaticX(borderLeft()+paddingLeft());
     681                        childLayer->setStaticInlinePosition(borderLeft() + paddingLeft());
    684682                    else
    685                         child->layer()->setStaticX(borderRight()+paddingRight());
     683                        childLayer->setStaticInlinePosition(borderRight() + paddingRight());
    686684                }
    687                 if (child->style()->hasStaticY()) {
    688                     RenderLayer* childLayer = child->layer();
    689                     if (childLayer->staticY() != height()) {
    690                         child->layer()->setStaticY(height());
     685                if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingMode())) {
     686                    if (childLayer->staticBlockPosition() != height()) {
     687                        childLayer->setStaticBlockPosition(height());
    691688                        child->setChildNeedsLayout(true, false);
    692689                    }
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r79734 r79930  
    929929IntSize RenderInline::relativePositionedInlineOffset(const RenderBox* child) const
    930930{
     931    // FIXME: This function isn't right with mixed writing modes.
     932
    931933    ASSERT(isRelPositioned());
    932934    if (!isRelPositioned())
     
    937939    // relative to the inline itself.
    938940
    939     IntSize offset;
    940     int sx;
    941     int sy;
     941    IntSize logicalOffset;
     942    int inlinePosition;
     943    int blockPosition;
    942944    if (firstLineBox()) {
    943         sx = firstLineBox()->x();
    944         sy = firstLineBox()->y();
     945        inlinePosition = lroundf(firstLineBox()->logicalLeft());
     946        blockPosition = firstLineBox()->logicalTop();
    945947    } else {
    946         sx = layer()->staticX();
    947         sy = layer()->staticY();
    948     }
    949 
    950     if (!child->style()->hasStaticX())
    951         offset.setWidth(sx);
     948        inlinePosition = layer()->staticInlinePosition();
     949        blockPosition = layer()->staticBlockPosition();
     950    }
     951
     952    if (!child->style()->hasStaticInlinePosition(style()->isHorizontalWritingMode()))
     953        logicalOffset.setWidth(inlinePosition);
     954
    952955    // This is not terribly intuitive, but we have to match other browsers.  Despite being a block display type inside
    953956    // an inline, we still keep our x locked to the left of the relative positioned inline.  Arguably the correct
     
    956959    else if (!child->style()->isOriginalDisplayInlineType())
    957960        // Avoid adding in the left border/padding of the containing block twice.  Subtract it out.
    958         offset.setWidth(sx - (child->containingBlock()->borderLeft() + child->containingBlock()->paddingLeft()));
    959 
    960     if (!child->style()->hasStaticY())
    961         offset.setHeight(sy);
    962 
    963     return offset;
     961        logicalOffset.setWidth(inlinePosition - child->containingBlock()->borderAndPaddingLogicalLeft());
     962
     963    if (!child->style()->hasStaticBlockPosition(style()->isHorizontalWritingMode()))
     964        logicalOffset.setHeight(blockPosition);
     965
     966    return style()->isHorizontalWritingMode() ? logicalOffset : logicalOffset.transposedSize();
    964967}
    965968
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r79360 r79930  
    177177#endif
    178178    , m_marquee(0)
    179     , m_staticX(0)
    180     , m_staticY(0)
     179    , m_staticInlinePosition(0)
     180    , m_staticBlockPosition(0)
    181181    , m_reflection(0)
    182182    , m_scrollCorner(0)
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r78618 r79930  
    398398    void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; }
    399399   
    400     int staticX() const { return m_staticX; }
    401     int staticY() const { return m_staticY; }
    402     void setStaticX(int staticX) { m_staticX = staticX; }
    403     void setStaticY(int staticY) { m_staticY = staticY; }
     400    int staticInlinePosition() const { return m_staticInlinePosition; }
     401    int staticBlockPosition() const { return m_staticBlockPosition; }
     402    void setStaticInlinePosition(int position) { m_staticInlinePosition = position; }
     403    void setStaticBlockPosition(int position) { m_staticBlockPosition = position; }
    404404
    405405    bool hasTransform() const { return renderer()->hasTransform(); }
     
    695695   
    696696    // Cached normal flow values for absolute positioned elements with static left/top values.
    697     int m_staticX;
    698     int m_staticY;
     697    int m_staticInlinePosition;
     698    int m_staticBlockPosition;
    699699   
    700700    OwnPtr<TransformationMatrix> m_transform;
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r79733 r79930  
    381381    // Whether or not a positioned element requires normal flow x/y to be computed
    382382    // to determine its position.
    383     bool hasStaticX() const { return left().isAuto() && right().isAuto(); }
    384     bool hasStaticY() const { return top().isAuto() && bottom().isAuto(); }
     383    bool hasAutoLeftAndRight() const { return left().isAuto() && right().isAuto(); }
     384    bool hasAutoTopAndBottom() const { return top().isAuto() && bottom().isAuto(); }
     385    bool hasStaticInlinePosition(bool horizontal) const { return horizontal ? hasAutoLeftAndRight() : hasAutoTopAndBottom(); }
     386    bool hasStaticBlockPosition(bool horizontal) const { return horizontal ? hasAutoTopAndBottom() : hasAutoLeftAndRight(); }
    385387
    386388    EPosition position() const { return static_cast<EPosition>(noninherited_flags._position); }
Note: See TracChangeset for help on using the changeset viewer.