Changeset 98594 in webkit


Ignore:
Timestamp:
Oct 27, 2011, 10:04:03 AM (13 years ago)
Author:
tony@chromium.org
Message:

use main/cross instead of logical width/height when talking about flow direction
https://bugs.webkit.org/show_bug.cgi?id=70977

Reviewed by Ojan Vafai.

Flexbox code uses logical in function names to refer to the flow
direction. This is confusing because writing mode also uses logical,
but this is a diffent usage. To avoid confusion, be explicit about
main vs cross axis. Extent is used instead of width/height.

No new tests, just a refactoring.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::mainAxisLengthForChild):
(WebCore::RenderFlexibleBox::crossAxisLength):
(WebCore::RenderFlexibleBox::setCrossExtent):
(WebCore::RenderFlexibleBox::crossExtentForChild):
(WebCore::RenderFlexibleBox::mainExtentForChild):
(WebCore::RenderFlexibleBox::crossAxisExtent):
(WebCore::RenderFlexibleBox::mainAxisExtent):
(WebCore::RenderFlexibleBox::crossAxisContentExtent):
(WebCore::RenderFlexibleBox::mainAxisContentExtent):
(WebCore::RenderFlexibleBox::crossAxisBorderAndPaddingExtent):
(WebCore::RenderFlexibleBox::crossAxisMarginExtentForChild):
(WebCore::RenderFlexibleBox::flowAwareLocationForChild):
(WebCore::RenderFlexibleBox::setFlowAwareLocationForChild):
(WebCore::RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild):
(WebCore::RenderFlexibleBox::mainAxisScrollbarExtentForChild):
(WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem):
(WebCore::RenderFlexibleBox::layoutInlineDirection):
(WebCore::RenderFlexibleBox::positiveFlexForChild): Since flex only

matters in the main axis, there's no reason to deambiguate it here.

(WebCore::RenderFlexibleBox::negativeFlexForChild): Ditto.
(WebCore::RenderFlexibleBox::availableAlignmentSpaceForChild): Alignment is always

in the cross axis direction, so don't include that in the method name.

(WebCore::RenderFlexibleBox::marginBoxAscent):
(WebCore::RenderFlexibleBox::computePreferredMainAxisExtent):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
(WebCore::RenderFlexibleBox::adjustAlignmentForChild): Alignment is always

in the cross axis direction, so don't include that in the method name.

(WebCore::RenderFlexibleBox::alignChildrenBlockDirection):

  • rendering/RenderFlexibleBox.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98593 r98594  
     12011-10-27  Tony Chang  <tony@chromium.org>
     2
     3        use main/cross instead of logical width/height when talking about flow direction
     4        https://bugs.webkit.org/show_bug.cgi?id=70977
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Flexbox code uses logical in function names to refer to the flow
     9        direction. This is confusing because writing mode also uses logical,
     10        but this is a diffent usage. To avoid confusion, be explicit about
     11        main vs cross axis. Extent is used instead of width/height.
     12
     13        No new tests, just a refactoring.
     14
     15        * rendering/RenderFlexibleBox.cpp:
     16        (WebCore::RenderFlexibleBox::mainAxisLengthForChild):
     17        (WebCore::RenderFlexibleBox::crossAxisLength):
     18        (WebCore::RenderFlexibleBox::setCrossExtent):
     19        (WebCore::RenderFlexibleBox::crossExtentForChild):
     20        (WebCore::RenderFlexibleBox::mainExtentForChild):
     21        (WebCore::RenderFlexibleBox::crossAxisExtent):
     22        (WebCore::RenderFlexibleBox::mainAxisExtent):
     23        (WebCore::RenderFlexibleBox::crossAxisContentExtent):
     24        (WebCore::RenderFlexibleBox::mainAxisContentExtent):
     25        (WebCore::RenderFlexibleBox::crossAxisBorderAndPaddingExtent):
     26        (WebCore::RenderFlexibleBox::crossAxisMarginExtentForChild):
     27        (WebCore::RenderFlexibleBox::flowAwareLocationForChild):
     28        (WebCore::RenderFlexibleBox::setFlowAwareLocationForChild):
     29        (WebCore::RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild):
     30        (WebCore::RenderFlexibleBox::mainAxisScrollbarExtentForChild):
     31        (WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem):
     32        (WebCore::RenderFlexibleBox::layoutInlineDirection):
     33        (WebCore::RenderFlexibleBox::positiveFlexForChild): Since flex only
     34            matters in the main axis, there's no reason to deambiguate it here.
     35        (WebCore::RenderFlexibleBox::negativeFlexForChild): Ditto.
     36        (WebCore::RenderFlexibleBox::availableAlignmentSpaceForChild): Alignment is always
     37            in the cross axis direction, so don't include that in the method name.
     38        (WebCore::RenderFlexibleBox::marginBoxAscent):
     39        (WebCore::RenderFlexibleBox::computePreferredMainAxisExtent):
     40        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
     41        (WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
     42        (WebCore::RenderFlexibleBox::adjustAlignmentForChild):  Alignment is always
     43            in the cross axis direction, so don't include that in the method name.
     44        (WebCore::RenderFlexibleBox::alignChildrenBlockDirection):
     45        * rendering/RenderFlexibleBox.h:
     46
    1472011-10-27  Mark Hahnenberg  <mhahnenberg@apple.com>
    248
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r98373 r98594  
    229229}
    230230
    231 Length RenderFlexibleBox::flowAwareLogicalWidthLengthForChild(RenderBox* child) const
     231Length RenderFlexibleBox::mainAxisLengthForChild(RenderBox* child) const
    232232{
    233233    return isHorizontalFlow() ? child->style()->width() : child->style()->height();
    234234}
    235235
    236 bool RenderFlexibleBox::isFlowAwareLogicalHeightAuto() const
    237 {
    238     Length height = isHorizontalFlow() ? style()->height() : style()->width();
    239     return height.isAuto();
    240 }
    241 
    242 void RenderFlexibleBox::setFlowAwareLogicalHeight(LayoutUnit size)
     236Length RenderFlexibleBox::crossAxisLength() const
     237{
     238    return isHorizontalFlow() ? style()->height() : style()->width();
     239}
     240
     241void RenderFlexibleBox::setCrossAxisExtent(LayoutUnit extent)
    243242{
    244243    if (isHorizontalFlow())
    245         setHeight(size);
     244        setHeight(extent);
    246245    else
    247         setWidth(size);
    248 }
    249 
    250 LayoutUnit RenderFlexibleBox::flowAwareLogicalHeightForChild(RenderBox* child)
     246        setWidth(extent);
     247}
     248
     249LayoutUnit RenderFlexibleBox::crossAxisExtentForChild(RenderBox* child)
    251250{
    252251    return isHorizontalFlow() ? child->height() : child->width();
    253252}
    254253
    255 LayoutUnit RenderFlexibleBox::flowAwareLogicalWidthForChild(RenderBox* child)
     254LayoutUnit RenderFlexibleBox::mainAxisExtentForChild(RenderBox* child)
    256255{
    257256    return isHorizontalFlow() ? child->width() : child->height();
    258257}
    259258
    260 LayoutUnit RenderFlexibleBox::flowAwareLogicalHeight() const
     259LayoutUnit RenderFlexibleBox::crossAxisExtent() const
    261260{
    262261    return isHorizontalFlow() ? height() : width();
    263262}
    264263
    265 LayoutUnit RenderFlexibleBox::flowAwareLogicalWidth() const
     264LayoutUnit RenderFlexibleBox::mainAxisExtent() const
    266265{
    267266    return isHorizontalFlow() ? width() : height();
    268267}
    269268
    270 LayoutUnit RenderFlexibleBox::flowAwareContentLogicalHeight() const
     269LayoutUnit RenderFlexibleBox::crossAxisContentExtent() const
    271270{
    272271    return isHorizontalFlow() ? contentHeight() : contentWidth();
    273272}
    274273
    275 LayoutUnit RenderFlexibleBox::flowAwareContentLogicalWidth() const
     274LayoutUnit RenderFlexibleBox::mainAxisContentExtent() const
    276275{
    277276    return isHorizontalFlow() ? contentWidth() : contentHeight();
     
    335334}
    336335
    337 LayoutUnit RenderFlexibleBox::flowAwareBorderAndPaddingLogicalHeight() const
     336LayoutUnit RenderFlexibleBox::crossAxisBorderAndPaddingExtent() const
    338337{
    339338    return isHorizontalFlow() ? borderAndPaddingHeight() : borderAndPaddingWidth();
     
    425424}
    426425
    427 LayoutUnit RenderFlexibleBox::flowAwareMarginLogicalHeightForChild(RenderBox* child) const
     426LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox* child) const
    428427{
    429428    return isHorizontalFlow() ? child->marginTop() + child->marginBottom() : child->marginLeft() + child->marginRight();
    430429}
    431430
    432 LayoutPoint RenderFlexibleBox::flowAwareLogicalLocationForChild(RenderBox* child) const
     431LayoutPoint RenderFlexibleBox::flowAwareLocationForChild(RenderBox* child) const
    433432{
    434433    return isHorizontalFlow() ? child->location() : child->location().transposedPoint();
     
    465464}
    466465
    467 void RenderFlexibleBox::setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint& location)
     466void RenderFlexibleBox::setFlowAwareLocationForChild(RenderBox* child, const LayoutPoint& location)
    468467{
    469468    if (isHorizontalFlow())
     
    473472}
    474473
    475 LayoutUnit RenderFlexibleBox::logicalBorderAndPaddingWidthForChild(RenderBox* child) const
     474LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const
    476475{
    477476    return isHorizontalFlow() ? child->borderAndPaddingWidth() : child->borderAndPaddingHeight();
    478477}
    479478
    480 LayoutUnit RenderFlexibleBox::logicalScrollbarHeightForChild(RenderBox* child) const
     479LayoutUnit RenderFlexibleBox::mainAxisScrollbarExtentForChild(RenderBox* child) const
    481480{
    482481    return isHorizontalFlow() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight();
     
    497496}
    498497
    499 LayoutUnit RenderFlexibleBox::preferredLogicalContentWidthForFlexItem(RenderBox* child) const
    500 {
    501     Length logicalWidthLength = flowAwareLogicalWidthLengthForChild(child);
    502     if (logicalWidthLength.isAuto()) {
    503         LayoutUnit logicalWidth = hasOrthogonalFlow(child) ? child->logicalHeight() : child->maxPreferredLogicalWidth();
    504         return logicalWidth - logicalBorderAndPaddingWidthForChild(child) - logicalScrollbarHeightForChild(child);
    505     }
    506     return logicalWidthLength.calcMinValue(flowAwareContentLogicalWidth());
     498LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem(RenderBox* child) const
     499{
     500    Length mainAxisLength = mainAxisLengthForChild(child);
     501    if (mainAxisLength.isAuto()) {
     502        LayoutUnit mainAxisExtent = hasOrthogonalFlow(child) ? child->logicalHeight() : child->maxPreferredLogicalWidth();
     503        return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) - mainAxisScrollbarExtentForChild(child);
     504    }
     505    return mainAxisLength.calcMinValue(mainAxisContentExtent());
    507506}
    508507
    509508void RenderFlexibleBox::layoutInlineDirection(bool relayoutChildren)
    510509{
    511     LayoutUnit preferredLogicalWidth;
     510    LayoutUnit preferredMainAxisExtent;
    512511    float totalPositiveFlexibility;
    513512    float totalNegativeFlexibility;
    514513    TreeOrderIterator treeIterator(this);
    515514
    516     computePreferredLogicalWidth(relayoutChildren, treeIterator, preferredLogicalWidth, totalPositiveFlexibility, totalNegativeFlexibility);
    517     LayoutUnit availableFreeSpace = flowAwareContentLogicalWidth() - preferredLogicalWidth;
     515    computePreferredMainAxisExtent(relayoutChildren, treeIterator, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility);
     516    LayoutUnit availableFreeSpace = mainAxisContentExtent() - preferredMainAxisExtent;
    518517
    519518    FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues());
     
    528527}
    529528
    530 float RenderFlexibleBox::logicalPositiveFlexForChild(RenderBox* child) const
     529float RenderFlexibleBox::positiveFlexForChild(RenderBox* child) const
    531530{
    532531    return isHorizontalFlow() ? child->style()->flexboxWidthPositiveFlex() : child->style()->flexboxHeightPositiveFlex();
    533532}
    534533
    535 float RenderFlexibleBox::logicalNegativeFlexForChild(RenderBox* child) const
     534float RenderFlexibleBox::negativeFlexForChild(RenderBox* child) const
    536535{
    537536    return isHorizontalFlow() ? child->style()->flexboxWidthNegativeFlex() : child->style()->flexboxHeightNegativeFlex();
    538537}
    539538
    540 LayoutUnit RenderFlexibleBox::availableLogicalHeightForChild(RenderBox* child)
    541 {
    542     LayoutUnit contentLogicalHeight = flowAwareContentLogicalHeight();
    543     LayoutUnit currentChildHeight = flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child);
    544     return contentLogicalHeight - currentChildHeight;
     539LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(RenderBox* child)
     540{
     541    LayoutUnit crossContentExtent = crossAxisContentExtent();
     542    LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child);
     543    return crossContentExtent - childCrossExtent;
    545544}
    546545
     
    549548    LayoutUnit ascent = child->firstLineBoxBaseline();
    550549    if (ascent == -1)
    551         ascent = flowAwareLogicalHeightForChild(child) + flowAwareMarginAfterForChild(child);
     550        ascent = crossAxisExtentForChild(child) + flowAwareMarginAfterForChild(child);
    552551    return ascent + flowAwareMarginBeforeForChild(child);
    553552}
    554553
    555 void RenderFlexibleBox::computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator& iterator, LayoutUnit& preferredLogicalWidth, float& totalPositiveFlexibility, float& totalNegativeFlexibility)
    556 {
    557     preferredLogicalWidth = 0;
     554void RenderFlexibleBox::computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator& iterator, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility)
     555{
     556    preferredMainAxisExtent = 0;
    558557    totalPositiveFlexibility = totalNegativeFlexibility = 0;
    559558
    560     LayoutUnit flexboxAvailableLogicalWidth = flowAwareContentLogicalWidth();
     559    LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
    561560    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
    562         if (flowAwareLogicalWidthLengthForChild(child).isAuto()) {
     561        if (mainAxisLengthForChild(child).isAuto()) {
    563562            child->clearOverrideSize();
    564563            if (!relayoutChildren)
     
    571570        // computes the start/end margins.
    572571        if (isHorizontalFlow()) {
    573             child->setMarginLeft(child->style()->marginLeft().calcMinValue(flexboxAvailableLogicalWidth));
    574             child->setMarginRight(child->style()->marginRight().calcMinValue(flexboxAvailableLogicalWidth));
    575             preferredLogicalWidth += child->marginLeft() + child->marginRight();
     572            child->setMarginLeft(child->style()->marginLeft().calcMinValue(flexboxAvailableContentExtent));
     573            child->setMarginRight(child->style()->marginRight().calcMinValue(flexboxAvailableContentExtent));
     574            preferredMainAxisExtent += child->marginLeft() + child->marginRight();
    576575        } else {
    577             child->setMarginTop(child->style()->marginTop().calcMinValue(flexboxAvailableLogicalWidth));
    578             child->setMarginBottom(child->style()->marginBottom().calcMinValue(flexboxAvailableLogicalWidth));
    579             preferredLogicalWidth += child->marginTop() + child->marginBottom();
     576            child->setMarginTop(child->style()->marginTop().calcMinValue(flexboxAvailableContentExtent));
     577            child->setMarginBottom(child->style()->marginBottom().calcMinValue(flexboxAvailableContentExtent));
     578            preferredMainAxisExtent += child->marginTop() + child->marginBottom();
    580579        }
    581580
    582         preferredLogicalWidth += logicalBorderAndPaddingWidthForChild(child);
    583         preferredLogicalWidth += preferredLogicalContentWidthForFlexItem(child);
    584 
    585         totalPositiveFlexibility += logicalPositiveFlexForChild(child);
    586         totalNegativeFlexibility += logicalNegativeFlexForChild(child);
     581        preferredMainAxisExtent += mainAxisBorderAndPaddingExtentForChild(child);
     582        preferredMainAxisExtent += preferredMainAxisContentExtentForFlexItem(child);
     583
     584        totalPositiveFlexibility += positiveFlexForChild(child);
     585        totalNegativeFlexibility += negativeFlexForChild(child);
    587586    }
    588587}
     
    593592    childSizes.clear();
    594593
    595     LayoutUnit flexboxAvailableLogicalWidth = flowAwareContentLogicalWidth();
     594    LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
    596595    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
    597596        LayoutUnit childPreferredSize;
     
    599598            childPreferredSize = inflexibleItems.get(child);
    600599        else {
    601             childPreferredSize = preferredLogicalContentWidthForFlexItem(child);
     600            childPreferredSize = preferredMainAxisContentExtentForFlexItem(child);
    602601            if (availableFreeSpace > 0 && totalPositiveFlexibility > 0) {
    603                 childPreferredSize += lroundf(availableFreeSpace * logicalPositiveFlexForChild(child) / totalPositiveFlexibility);
     602                childPreferredSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility);
    604603
    605604                Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
    606                 if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth)) {
    607                     childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth);
    608                     availableFreeSpace -= childPreferredSize - preferredLogicalContentWidthForFlexItem(child);
    609                     totalPositiveFlexibility -= logicalPositiveFlexForChild(child);
     605                if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) {
     606                    childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent);
     607                    availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForFlexItem(child);
     608                    totalPositiveFlexibility -= positiveFlexForChild(child);
    610609
    611610                    inflexibleItems.set(child, childPreferredSize);
     
    613612                }
    614613            } else if (availableFreeSpace < 0 && totalNegativeFlexibility > 0) {
    615                 childPreferredSize += lroundf(availableFreeSpace * logicalNegativeFlexForChild(child) / totalNegativeFlexibility);
     614                childPreferredSize += lroundf(availableFreeSpace * negativeFlexForChild(child) / totalNegativeFlexibility);
    616615
    617616                Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
    618                 if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth)) {
    619                     childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth);
    620                     availableFreeSpace += preferredLogicalContentWidthForFlexItem(child) - childPreferredSize;
    621                     totalNegativeFlexibility -= logicalNegativeFlexForChild(child);
     617                if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) {
     618                    childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableContentExtent);
     619                    availableFreeSpace += preferredMainAxisContentExtentForFlexItem(child) - childPreferredSize;
     620                    totalNegativeFlexibility -= negativeFlexForChild(child);
    622621
    623622                    inflexibleItems.set(child, childPreferredSize);
     
    657656
    658657    LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore();
    659     LayoutUnit totalLogicalWidth = flowAwareLogicalWidth();
    660     if (isFlowAwareLogicalHeightAuto())
    661         setFlowAwareLogicalHeight(0);
     658    LayoutUnit totalMainExtent = mainAxisExtent();
     659    if (crossAxisLength().isAuto())
     660        setCrossAxisExtent(0);
    662661    LayoutUnit maxAscent = 0, maxDescent = 0; // Used when flex-align: baseline.
    663662    size_t i = 0;
    664663    for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) {
    665         LayoutUnit childPreferredSize = childSizes[i] + logicalBorderAndPaddingWidthForChild(child);
     664        LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPaddingExtentForChild(child);
    666665        setLogicalOverrideSize(child, childPreferredSize);
    667666        child->setChildNeedsLayout(true);
     
    670669        if (child->style()->flexAlign() == AlignBaseline) {
    671670            LayoutUnit ascent = marginBoxAscent(child);
    672             LayoutUnit descent = (flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child)) - ascent;
     671            LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child)) - ascent;
    673672
    674673            maxAscent = std::max(maxAscent, ascent);
     
    676675
    677676            // FIXME: add flowAwareScrollbarLogicalHeight.
    678             if (isFlowAwareLogicalHeightAuto())
    679                 setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderAndPaddingLogicalHeight() + flowAwareMarginLogicalHeightForChild(child) + maxAscent + maxDescent + scrollbarLogicalHeight()));
    680         } else if (isFlowAwareLogicalHeightAuto())
    681             setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderAndPaddingLogicalHeight() + flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child) + scrollbarLogicalHeight()));
     677            if (crossAxisLength().isAuto())
     678                setCrossAxisExtent(std::max(crossAxisExtent(), crossAxisBorderAndPaddingExtent() + crossAxisMarginExtentForChild(child) + maxAscent + maxDescent + scrollbarLogicalHeight()));
     679        } else if (crossAxisLength().isAuto())
     680            setCrossAxisExtent(std::max(crossAxisExtent(), crossAxisBorderAndPaddingExtent() + crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child) + scrollbarLogicalHeight()));
    682681
    683682        startEdge += flowAwareMarginStartForChild(child);
    684683
    685         LayoutUnit childLogicalWidth = flowAwareLogicalWidthForChild(child);
     684        LayoutUnit childMainExtent = mainAxisExtentForChild(child);
    686685        bool shouldFlipInlineDirection = isColumnFlow() ? true : isLeftToRightFlow();
    687         LayoutUnit logicalLeft = shouldFlipInlineDirection ? startEdge : totalLogicalWidth - startEdge - childLogicalWidth;
     686        LayoutUnit logicalLeft = shouldFlipInlineDirection ? startEdge : totalMainExtent - startEdge - childMainExtent;
    688687
    689688        // FIXME: Supporting layout deltas.
    690         setFlowAwareLogicalLocationForChild(child, IntPoint(logicalLeft, logicalTop + flowAwareMarginBeforeForChild(child)));
    691         startEdge += childLogicalWidth + flowAwareMarginEndForChild(child);
     689        setFlowAwareLocationForChild(child, IntPoint(logicalLeft, logicalTop + flowAwareMarginBeforeForChild(child)));
     690        startEdge += childMainExtent + flowAwareMarginEndForChild(child);
    692691
    693692        if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && style()->flexPack() == PackJustify && childSizes.size() > 1)
     
    698697}
    699698
    700 void RenderFlexibleBox::adjustLocationLogicalTopForChild(RenderBox* child, LayoutUnit delta)
     699void RenderFlexibleBox::adjustAlignmentForChild(RenderBox* child, LayoutUnit delta)
    701700{
    702701    LayoutRect oldRect = child->frameRect();
    703702
    704     setFlowAwareLogicalLocationForChild(child, flowAwareLogicalLocationForChild(child) + LayoutSize(0, delta));
     703    setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + LayoutSize(0, delta));
    705704
    706705    // If the child moved, we have to repaint it as well as any floating/positioned
     
    713712void RenderFlexibleBox::alignChildrenBlockDirection(FlexOrderIterator& iterator, LayoutUnit maxAscent)
    714713{
    715     LayoutUnit logicalHeight = flowAwareLogicalHeight();
     714    LayoutUnit crossExtent = crossAxisExtent();
    716715
    717716    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
    718717        // direction:rtl + flex-flow:column means the cross-axis direction is flipped.
    719718        if (!style()->isLeftToRightDirection() && isColumnFlow()) {
    720             LayoutPoint location = flowAwareLogicalLocationForChild(child);
    721             location.setY(logicalHeight - flowAwareLogicalHeightForChild(child) - location.y());
    722             setFlowAwareLogicalLocationForChild(child, location);
     719            LayoutPoint location = flowAwareLocationForChild(child);
     720            location.setY(crossExtent - crossAxisExtentForChild(child) - location.y());
     721            setFlowAwareLocationForChild(child, location);
    723722        }
    724723
     
    729728            if (height.isAuto()) {
    730729                // FIXME: Clamp to max-height once it's spec'ed (should we align towards the start or center?).
    731                 LayoutUnit stretchedHeight = logicalHeightForChild(child) + RenderFlexibleBox::availableLogicalHeightForChild(child);
     730                LayoutUnit stretchedHeight = logicalHeightForChild(child) + RenderFlexibleBox::availableAlignmentSpaceForChild(child);
    732731                if (isHorizontalFlow())
    733732                    child->setHeight(stretchedHeight);
     
    740739            break;
    741740        case AlignEnd:
    742             adjustLocationLogicalTopForChild(child, RenderFlexibleBox::availableLogicalHeightForChild(child));
     741            adjustAlignmentForChild(child, RenderFlexibleBox::availableAlignmentSpaceForChild(child));
    743742            break;
    744743        case AlignCenter:
    745             adjustLocationLogicalTopForChild(child, RenderFlexibleBox::availableLogicalHeightForChild(child) / 2);
     744            adjustAlignmentForChild(child, RenderFlexibleBox::availableAlignmentSpaceForChild(child) / 2);
    746745            break;
    747746        case AlignBaseline: {
    748747            LayoutUnit ascent = marginBoxAscent(child);
    749             adjustLocationLogicalTopForChild(child, maxAscent - ascent);
     748            adjustAlignmentForChild(child, maxAscent - ascent);
    750749            break;
    751750        }
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r98373 r98594  
    5858    bool isHorizontalFlow() const;
    5959    bool isLeftToRightFlow() const;
    60     bool isFlowAwareLogicalHeightAuto() const;
    61     Length flowAwareLogicalWidthLengthForChild(RenderBox* child) const;
    62     void setFlowAwareLogicalHeight(LayoutUnit);
    63     LayoutUnit flowAwareLogicalHeightForChild(RenderBox* child);
    64     LayoutUnit flowAwareLogicalWidthForChild(RenderBox* child);
    65     LayoutUnit flowAwareLogicalHeight() const;
    66     LayoutUnit flowAwareLogicalWidth() const;
    67     LayoutUnit flowAwareContentLogicalHeight() const;
    68     LayoutUnit flowAwareContentLogicalWidth() const;
     60    Length crossAxisLength() const;
     61    Length mainAxisLengthForChild(RenderBox* child) const;
     62    void setCrossAxisExtent(LayoutUnit);
     63    LayoutUnit crossAxisExtentForChild(RenderBox* child);
     64    LayoutUnit mainAxisExtentForChild(RenderBox* child);
     65    LayoutUnit crossAxisExtent() const;
     66    LayoutUnit mainAxisExtent() const;
     67    LayoutUnit crossAxisContentExtent() const;
     68    LayoutUnit mainAxisContentExtent() const;
    6969    WritingMode transformedWritingMode() const;
    7070    LayoutUnit flowAwareBorderStart() const;
    7171    LayoutUnit flowAwareBorderBefore() const;
    7272    LayoutUnit flowAwareBorderAfter() const;
    73     LayoutUnit flowAwareBorderAndPaddingLogicalHeight() const;
     73    LayoutUnit crossAxisBorderAndPaddingExtent() const;
    7474    LayoutUnit flowAwarePaddingStart() const;
    7575    LayoutUnit flowAwarePaddingBefore() const;
     
    7979    LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
    8080    LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
    81     LayoutUnit flowAwareMarginLogicalHeightForChild(RenderBox* child) const;
    82     LayoutPoint flowAwareLogicalLocationForChild(RenderBox* child) const;
     81    LayoutUnit crossAxisMarginExtentForChild(RenderBox* child) const;
     82    LayoutPoint flowAwareLocationForChild(RenderBox* child) const;
    8383    void setFlowAwareMarginStartForChild(RenderBox* child, LayoutUnit);
    8484    void setFlowAwareMarginEndForChild(RenderBox* child, LayoutUnit);
    8585    // FIXME: Supporting layout deltas.
    86     void setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint&);
    87     void adjustLocationLogicalTopForChild(RenderBox* child, LayoutUnit);
    88     LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child) const;
    89     LayoutUnit logicalScrollbarHeightForChild(RenderBox* child) const;
     86    void setFlowAwareLocationForChild(RenderBox* child, const LayoutPoint&);
     87    void adjustAlignmentForChild(RenderBox* child, LayoutUnit);
     88    LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const;
     89    LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const;
    9090    Length marginStartStyleForChild(RenderBox* child) const;
    9191    Length marginEndStyleForChild(RenderBox* child) const;
    92     LayoutUnit preferredLogicalContentWidthForFlexItem(RenderBox* child) const;
     92    LayoutUnit preferredMainAxisContentExtentForFlexItem(RenderBox* child) const;
    9393
    9494    void layoutInlineDirection(bool relayoutChildren);
    9595
    96     float logicalPositiveFlexForChild(RenderBox* child) const;
    97     float logicalNegativeFlexForChild(RenderBox* child) const;
     96    float positiveFlexForChild(RenderBox* child) const;
     97    float negativeFlexForChild(RenderBox* child) const;
    9898
    99     LayoutUnit availableLogicalHeightForChild(RenderBox*);
     99    LayoutUnit availableAlignmentSpaceForChild(RenderBox*);
    100100    LayoutUnit marginBoxAscent(RenderBox*);
    101101
    102     void computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
     102    void computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
    103103    bool runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
    104104    void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
Note: See TracChangeset for help on using the changeset viewer.