| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  * Copyright (C) 2011 Google Inc. All rights reserved. |     2  * Copyright (C) 2011 Google Inc. All rights reserved. | 
|     3  * |     3  * | 
|     4  * Redistribution and use in source and binary forms, with or without |     4  * Redistribution and use in source and binary forms, with or without | 
|     5  * modification, are permitted provided that the following conditions are |     5  * modification, are permitted provided that the following conditions are | 
|     6  * met: |     6  * met: | 
|     7  * |     7  * | 
|     8  *     * Redistributions of source code must retain the above copyright |     8  *     * Redistributions of source code must retain the above copyright | 
|     9  * notice, this list of conditions and the following disclaimer. |     9  * notice, this list of conditions and the following disclaimer. | 
|    10  *     * Redistributions in binary form must reproduce the above |    10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   120         } |   120         } | 
|   121     } |   121     } | 
|   122  |   122  | 
|   123     maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); |   123     maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); | 
|   124  |   124  | 
|   125     LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth(); |   125     LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth(); | 
|   126     maxLogicalWidth += scrollbarWidth; |   126     maxLogicalWidth += scrollbarWidth; | 
|   127     minLogicalWidth += scrollbarWidth; |   127     minLogicalWidth += scrollbarWidth; | 
|   128 } |   128 } | 
|   129  |   129  | 
|   130 static int synthesizedBaselineFromContentBox(const RenderBox* box, LineDirection
      Mode direction) |   130 static int synthesizedBaselineFromContentBox(const RenderBox& box, LineDirection
      Mode direction) | 
|   131 { |   131 { | 
|   132     return direction == HorizontalLine ? box->borderTop() + box->paddingTop() + 
      box->contentHeight() : box->borderRight() + box->paddingRight() + box->contentWi
      dth(); |   132     return direction == HorizontalLine ? box.borderTop() + box.paddingTop() + bo
      x.contentHeight() : box.borderRight() + box.paddingRight() + box.contentWidth(); | 
|   133 } |   133 } | 
|   134  |   134  | 
|   135 int RenderFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di
      rection, LinePositionMode mode) const |   135 int RenderFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di
      rection, LinePositionMode mode) const | 
|   136 { |   136 { | 
|   137     ASSERT(mode == PositionOnContainingLine); |   137     ASSERT(mode == PositionOnContainingLine); | 
|   138     int baseline = firstLineBoxBaseline(); |   138     int baseline = firstLineBoxBaseline(); | 
|   139     if (baseline == -1) |   139     if (baseline == -1) | 
|   140         baseline = synthesizedBaselineFromContentBox(this, direction); |   140         baseline = synthesizedBaselineFromContentBox(*this, direction); | 
|   141  |   141  | 
|   142     return beforeMarginInLineDirection(direction) + baseline; |   142     return beforeMarginInLineDirection(direction) + baseline; | 
|   143 } |   143 } | 
|   144  |   144  | 
|   145 int RenderFlexibleBox::firstLineBoxBaseline() const |   145 int RenderFlexibleBox::firstLineBoxBaseline() const | 
|   146 { |   146 { | 
|   147     if (isWritingModeRoot() || m_numberOfInFlowChildrenOnFirstLine <= 0) |   147     if (isWritingModeRoot() || m_numberOfInFlowChildrenOnFirstLine <= 0) | 
|   148         return -1; |   148         return -1; | 
|   149     RenderBox* baselineChild = 0; |   149     RenderBox* baselineChild = 0; | 
|   150     int childNumber = 0; |   150     int childNumber = 0; | 
|   151     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
      tor.next()) { |   151     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
      tor.next()) { | 
|   152         if (child->isOutOfFlowPositioned()) |   152         if (child->isOutOfFlowPositioned()) | 
|   153             continue; |   153             continue; | 
|   154         if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
      InCrossAxis(child)) { |   154         if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
      InCrossAxis(*child)) { | 
|   155             baselineChild = child; |   155             baselineChild = child; | 
|   156             break; |   156             break; | 
|   157         } |   157         } | 
|   158         if (!baselineChild) |   158         if (!baselineChild) | 
|   159             baselineChild = child; |   159             baselineChild = child; | 
|   160  |   160  | 
|   161         ++childNumber; |   161         ++childNumber; | 
|   162         if (childNumber == m_numberOfInFlowChildrenOnFirstLine) |   162         if (childNumber == m_numberOfInFlowChildrenOnFirstLine) | 
|   163             break; |   163             break; | 
|   164     } |   164     } | 
|   165  |   165  | 
|   166     if (!baselineChild) |   166     if (!baselineChild) | 
|   167         return -1; |   167         return -1; | 
|   168  |   168  | 
|   169     if (!isColumnFlow() && hasOrthogonalFlow(*baselineChild)) |   169     if (!isColumnFlow() && hasOrthogonalFlow(*baselineChild)) | 
|   170         return crossAxisExtentForChild(*baselineChild) + baselineChild->logicalT
      op(); |   170         return crossAxisExtentForChild(*baselineChild) + baselineChild->logicalT
      op(); | 
|   171     if (isColumnFlow() && !hasOrthogonalFlow(*baselineChild)) |   171     if (isColumnFlow() && !hasOrthogonalFlow(*baselineChild)) | 
|   172         return mainAxisExtentForChild(*baselineChild) + baselineChild->logicalTo
      p(); |   172         return mainAxisExtentForChild(*baselineChild) + baselineChild->logicalTo
      p(); | 
|   173  |   173  | 
|   174     int baseline = baselineChild->firstLineBoxBaseline(); |   174     int baseline = baselineChild->firstLineBoxBaseline(); | 
|   175     if (baseline == -1) { |   175     if (baseline == -1) { | 
|   176         // FIXME: We should pass |direction| into firstLineBoxBaseline and stop 
      bailing out if we're a writing mode root. |   176         // FIXME: We should pass |direction| into firstLineBoxBaseline and stop 
      bailing out if we're a writing mode root. | 
|   177         // This would also fix some cases where the flexbox is orthogonal to its
       container. |   177         // This would also fix some cases where the flexbox is orthogonal to its
       container. | 
|   178         LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine
       : VerticalLine; |   178         LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine
       : VerticalLine; | 
|   179         return synthesizedBaselineFromContentBox(baselineChild, direction) + bas
      elineChild->logicalTop(); |   179         return synthesizedBaselineFromContentBox(*baselineChild, direction) + ba
      selineChild->logicalTop(); | 
|   180     } |   180     } | 
|   181  |   181  | 
|   182     return baseline + baselineChild->logicalTop(); |   182     return baseline + baselineChild->logicalTop(); | 
|   183 } |   183 } | 
|   184  |   184  | 
|   185 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const |   185 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const | 
|   186 { |   186 { | 
|   187     int baseline = firstLineBoxBaseline(); |   187     int baseline = firstLineBoxBaseline(); | 
|   188     if (baseline != -1) |   188     if (baseline != -1) | 
|   189         return baseline; |   189         return baseline; | 
|   190  |   190  | 
|   191     int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
      ; |   191     int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
      ; | 
|   192     return synthesizedBaselineFromContentBox(this, direction) + marginAscent; |   192     return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; | 
|   193 } |   193 } | 
|   194  |   194  | 
|   195 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
      rStyle* childStyle) |   195 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
      rStyle* childStyle) | 
|   196 { |   196 { | 
|   197     ItemPosition align = childStyle->alignSelf(); |   197     ItemPosition align = childStyle->alignSelf(); | 
|   198     if (align == ItemPositionAuto) |   198     if (align == ItemPositionAuto) | 
|   199         align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
      retch : parentStyle->alignItems(); |   199         align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
      retch : parentStyle->alignItems(); | 
|   200     return align; |   200     return align; | 
|   201 } |   201 } | 
|   202  |   202  | 
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   529         return paddingTop(); |   529         return paddingTop(); | 
|   530     case LeftToRightWritingMode: |   530     case LeftToRightWritingMode: | 
|   531         return paddingRight(); |   531         return paddingRight(); | 
|   532     case RightToLeftWritingMode: |   532     case RightToLeftWritingMode: | 
|   533         return paddingLeft(); |   533         return paddingLeft(); | 
|   534     } |   534     } | 
|   535     ASSERT_NOT_REACHED(); |   535     ASSERT_NOT_REACHED(); | 
|   536     return paddingTop(); |   536     return paddingTop(); | 
|   537 } |   537 } | 
|   538  |   538  | 
|   539 LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox* child) con
      st |   539 LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox& child) con
      st | 
|   540 { |   540 { | 
|   541     if (isHorizontalFlow()) |   541     if (isHorizontalFlow()) | 
|   542         return isLeftToRightFlow() ? child->marginLeft() : child->marginRight(); |   542         return isLeftToRightFlow() ? child.marginLeft() : child.marginRight(); | 
|   543     return isLeftToRightFlow() ? child->marginTop() : child->marginBottom(); |   543     return isLeftToRightFlow() ? child.marginTop() : child.marginBottom(); | 
|   544 } |   544 } | 
|   545  |   545  | 
|   546 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox* child) const |   546 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox& child) const | 
|   547 { |   547 { | 
|   548     if (isHorizontalFlow()) |   548     if (isHorizontalFlow()) | 
|   549         return isLeftToRightFlow() ? child->marginRight() : child->marginLeft(); |   549         return isLeftToRightFlow() ? child.marginRight() : child.marginLeft(); | 
|   550     return isLeftToRightFlow() ? child->marginBottom() : child->marginTop(); |   550     return isLeftToRightFlow() ? child.marginBottom() : child.marginTop(); | 
|   551 } |   551 } | 
|   552  |   552  | 
|   553 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox* child) co
      nst |   553 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox& child) co
      nst | 
|   554 { |   554 { | 
|   555     switch (transformedWritingMode()) { |   555     switch (transformedWritingMode()) { | 
|   556     case TopToBottomWritingMode: |   556     case TopToBottomWritingMode: | 
|   557         return child->marginTop(); |   557         return child.marginTop(); | 
|   558     case BottomToTopWritingMode: |   558     case BottomToTopWritingMode: | 
|   559         return child->marginBottom(); |   559         return child.marginBottom(); | 
|   560     case LeftToRightWritingMode: |   560     case LeftToRightWritingMode: | 
|   561         return child->marginLeft(); |   561         return child.marginLeft(); | 
|   562     case RightToLeftWritingMode: |   562     case RightToLeftWritingMode: | 
|   563         return child->marginRight(); |   563         return child.marginRight(); | 
|   564     } |   564     } | 
|   565     ASSERT_NOT_REACHED(); |   565     ASSERT_NOT_REACHED(); | 
|   566     return marginTop(); |   566     return marginTop(); | 
|   567 } |   567 } | 
|   568  |   568  | 
|   569 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox* child) co
      nst |   569 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox& child) co
      nst | 
|   570 { |   570 { | 
|   571     return isHorizontalFlow() ? child->marginHeight() : child->marginWidth(); |   571     return isHorizontalFlow() ? child.marginHeight() : child.marginWidth(); | 
|   572 } |   572 } | 
|   573  |   573  | 
|   574 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtent() const |   574 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtent() const | 
|   575 { |   575 { | 
|   576     return isHorizontalFlow() ? horizontalScrollbarHeight() : verticalScrollbarW
      idth(); |   576     return isHorizontalFlow() ? horizontalScrollbarHeight() : verticalScrollbarW
      idth(); | 
|   577 } |   577 } | 
|   578  |   578  | 
|   579 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtentForChild(RenderBox* child)
       const |   579 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtentForChild(RenderBox& child)
       const | 
|   580 { |   580 { | 
|   581     return isHorizontalFlow() ? child->horizontalScrollbarHeight() : child->vert
      icalScrollbarWidth(); |   581     return isHorizontalFlow() ? child.horizontalScrollbarHeight() : child.vertic
      alScrollbarWidth(); | 
|   582 } |   582 } | 
|   583  |   583  | 
|   584 LayoutPoint RenderFlexibleBox::flowAwareLocationForChild(RenderBox* child) const |   584 LayoutPoint RenderFlexibleBox::flowAwareLocationForChild(RenderBox& child) const | 
|   585 { |   585 { | 
|   586     return isHorizontalFlow() ? child->location() : child->location().transposed
      Point(); |   586     return isHorizontalFlow() ? child.location() : child.location().transposedPo
      int(); | 
|   587 } |   587 } | 
|   588  |   588  | 
|   589 void RenderFlexibleBox::setFlowAwareLocationForChild(RenderBox* child, const Lay
      outPoint& location) |   589 void RenderFlexibleBox::setFlowAwareLocationForChild(RenderBox& child, const Lay
      outPoint& location) | 
|   590 { |   590 { | 
|   591     if (isHorizontalFlow()) |   591     if (isHorizontalFlow()) | 
|   592         child->setLocation(location); |   592         child.setLocation(location); | 
|   593     else |   593     else | 
|   594         child->setLocation(location.transposedPoint()); |   594         child.setLocation(location.transposedPoint()); | 
|   595 } |   595 } | 
|   596  |   596  | 
|   597 LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox* 
      child) const |   597 LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox& 
      child) const | 
|   598 { |   598 { | 
|   599     return isHorizontalFlow() ? child->borderAndPaddingWidth() : child->borderAn
      dPaddingHeight(); |   599     return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP
      addingHeight(); | 
|   600 } |   600 } | 
|   601  |   601  | 
|   602 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi
      s, bool hasInfiniteLineLength) |   602 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi
      s, bool hasInfiniteLineLength) | 
|   603 { |   603 { | 
|   604     return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength
      ); |   604     return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength
      ); | 
|   605 } |   605 } | 
|   606  |   606  | 
|   607 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render
      Box& child, bool hasInfiniteLineLength) const |   607 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render
      Box& child, bool hasInfiniteLineLength) const | 
|   608 { |   608 { | 
|   609     return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI
      nfiniteLineLength) && hasOrthogonalFlow(child); |   609     return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI
      nfiniteLineLength) && hasOrthogonalFlow(child); | 
|   610 } |   610 } | 
|   611  |   611  | 
|   612 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* 
      child, bool hasInfiniteLineLength, bool relayoutChildren) |   612 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& 
      child, bool hasInfiniteLineLength, bool relayoutChildren) | 
|   613 { |   613 { | 
|   614     child->clearOverrideSize(); |   614     child.clearOverrideSize(); | 
|   615  |   615  | 
|   616     if (child->style()->hasAspectRatio() || child->isImage() || child->isVideo()
       || child->isCanvas()) |   616     if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() ||
       child.isCanvas()) | 
|   617         UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |   617         UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 
|   618  |   618  | 
|   619     Length flexBasis = flexBasisForChild(*child); |   619     Length flexBasis = flexBasisForChild(child); | 
|   620     if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength)
      ) { |   620     if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength)
      ) { | 
|   621         LayoutUnit mainAxisExtent; |   621         LayoutUnit mainAxisExtent; | 
|   622         if (hasOrthogonalFlow(*child)) { |   622         if (hasOrthogonalFlow(child)) { | 
|   623             if (child->needsLayout() || relayoutChildren) { |   623             if (child.needsLayout() || relayoutChildren) { | 
|   624                 m_intrinsicSizeAlongMainAxis.remove(child); |   624                 m_intrinsicSizeAlongMainAxis.remove(&child); | 
|   625                 child->forceChildLayout(); |   625                 child.forceChildLayout(); | 
|   626                 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); |   626                 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight()); | 
|   627             } |   627             } | 
|   628             ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); |   628             ASSERT(m_intrinsicSizeAlongMainAxis.contains(&child)); | 
|   629             mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); |   629             mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); | 
|   630         } else { |   630         } else { | 
|   631             mainAxisExtent = child->maxPreferredLogicalWidth(); |   631             mainAxisExtent = child.maxPreferredLogicalWidth(); | 
|   632         } |   632         } | 
|   633         ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >=
       0); |   633         ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >=
       0); | 
|   634         return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); |   634         return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); | 
|   635     } |   635     } | 
|   636     return std::max(LayoutUnit(0), computeMainAxisExtentForChild(*child, MainOrP
      referredSize, flexBasis)); |   636     return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPr
      eferredSize, flexBasis)); | 
|   637 } |   637 } | 
|   638  |   638  | 
|   639 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) |   639 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) | 
|   640 { |   640 { | 
|   641     Vector<LineContext> lineContexts; |   641     Vector<LineContext> lineContexts; | 
|   642     OrderedFlexItemList orderedChildren; |   642     OrderedFlexItemList orderedChildren; | 
|   643     LayoutUnit sumFlexBaseSize; |   643     LayoutUnit sumFlexBaseSize; | 
|   644     double totalFlexGrow; |   644     double totalFlexGrow; | 
|   645     double totalWeightedFlexShrink; |   645     double totalWeightedFlexShrink; | 
|   646     LayoutUnit sumHypotheticalMainSize; |   646     LayoutUnit sumHypotheticalMainSize; | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   703         } |   703         } | 
|   704     } |   704     } | 
|   705     if (!numberOfAutoMargins) |   705     if (!numberOfAutoMargins) | 
|   706         return 0; |   706         return 0; | 
|   707  |   707  | 
|   708     LayoutUnit sizeOfAutoMargin = availableFreeSpace / numberOfAutoMargins; |   708     LayoutUnit sizeOfAutoMargin = availableFreeSpace / numberOfAutoMargins; | 
|   709     availableFreeSpace = 0; |   709     availableFreeSpace = 0; | 
|   710     return sizeOfAutoMargin; |   710     return sizeOfAutoMargin; | 
|   711 } |   711 } | 
|   712  |   712  | 
|   713 void RenderFlexibleBox::updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit
       autoMarginOffset) |   713 void RenderFlexibleBox::updateAutoMarginsInMainAxis(RenderBox& child, LayoutUnit
       autoMarginOffset) | 
|   714 { |   714 { | 
|   715     ASSERT(autoMarginOffset >= 0); |   715     ASSERT(autoMarginOffset >= 0); | 
|   716  |   716  | 
|   717     if (isHorizontalFlow()) { |   717     if (isHorizontalFlow()) { | 
|   718         if (child->style()->marginLeft().isAuto()) |   718         if (child.style()->marginLeft().isAuto()) | 
|   719             child->setMarginLeft(autoMarginOffset); |   719             child.setMarginLeft(autoMarginOffset); | 
|   720         if (child->style()->marginRight().isAuto()) |   720         if (child.style()->marginRight().isAuto()) | 
|   721             child->setMarginRight(autoMarginOffset); |   721             child.setMarginRight(autoMarginOffset); | 
|   722     } else { |   722     } else { | 
|   723         if (child->style()->marginTop().isAuto()) |   723         if (child.style()->marginTop().isAuto()) | 
|   724             child->setMarginTop(autoMarginOffset); |   724             child.setMarginTop(autoMarginOffset); | 
|   725         if (child->style()->marginBottom().isAuto()) |   725         if (child.style()->marginBottom().isAuto()) | 
|   726             child->setMarginBottom(autoMarginOffset); |   726             child.setMarginBottom(autoMarginOffset); | 
|   727     } |   727     } | 
|   728 } |   728 } | 
|   729  |   729  | 
|   730 bool RenderFlexibleBox::hasAutoMarginsInCrossAxis(RenderBox* child) const |   730 bool RenderFlexibleBox::hasAutoMarginsInCrossAxis(RenderBox& child) const | 
|   731 { |   731 { | 
|   732     if (isHorizontalFlow()) |   732     if (isHorizontalFlow()) | 
|   733         return child->style()->marginTop().isAuto() || child->style()->marginBot
      tom().isAuto(); |   733         return child.style()->marginTop().isAuto() || child.style()->marginBotto
      m().isAuto(); | 
|   734     return child->style()->marginLeft().isAuto() || child->style()->marginRight(
      ).isAuto(); |   734     return child.style()->marginLeft().isAuto() || child.style()->marginRight().
      isAuto(); | 
|   735 } |   735 } | 
|   736  |   736  | 
|   737 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCro
      ssAxisExtent, RenderBox* child) |   737 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCro
      ssAxisExtent, RenderBox& child) | 
|   738 { |   738 { | 
|   739     ASSERT(!child->isOutOfFlowPositioned()); |   739     ASSERT(!child.isOutOfFlowPositioned()); | 
|   740     LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
      isExtentForChild(*child); |   740     LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
      isExtentForChild(child); | 
|   741     return lineCrossAxisExtent - childCrossExtent; |   741     return lineCrossAxisExtent - childCrossExtent; | 
|   742 } |   742 } | 
|   743  |   743  | 
|   744 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChildBeforeStretching(La
      youtUnit lineCrossAxisExtent, RenderBox* child) |   744 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChildBeforeStretching(La
      youtUnit lineCrossAxisExtent, RenderBox& child) | 
|   745 { |   745 { | 
|   746     ASSERT(!child->isOutOfFlowPositioned()); |   746     ASSERT(!child.isOutOfFlowPositioned()); | 
|   747     LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
      isIntrinsicExtentForChild(*child); |   747     LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
      isIntrinsicExtentForChild(child); | 
|   748     return lineCrossAxisExtent - childCrossExtent; |   748     return lineCrossAxisExtent - childCrossExtent; | 
|   749 } |   749 } | 
|   750  |   750  | 
|   751 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUni
      t availableAlignmentSpace) |   751 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox& child, LayoutUni
      t availableAlignmentSpace) | 
|   752 { |   752 { | 
|   753     ASSERT(!child->isOutOfFlowPositioned()); |   753     ASSERT(!child.isOutOfFlowPositioned()); | 
|   754     ASSERT(availableAlignmentSpace >= 0); |   754     ASSERT(availableAlignmentSpace >= 0); | 
|   755  |   755  | 
|   756     bool isHorizontal = isHorizontalFlow(); |   756     bool isHorizontal = isHorizontalFlow(); | 
|   757     Length topOrLeft = isHorizontal ? child->style()->marginTop() : child->style
      ()->marginLeft(); |   757     Length topOrLeft = isHorizontal ? child.style()->marginTop() : child.style()
      ->marginLeft(); | 
|   758     Length bottomOrRight = isHorizontal ? child->style()->marginBottom() : child
      ->style()->marginRight(); |   758     Length bottomOrRight = isHorizontal ? child.style()->marginBottom() : child.
      style()->marginRight(); | 
|   759     if (topOrLeft.isAuto() && bottomOrRight.isAuto()) { |   759     if (topOrLeft.isAuto() && bottomOrRight.isAuto()) { | 
|   760         adjustAlignmentForChild(child, availableAlignmentSpace / 2); |   760         adjustAlignmentForChild(child, availableAlignmentSpace / 2); | 
|   761         if (isHorizontal) { |   761         if (isHorizontal) { | 
|   762             child->setMarginTop(availableAlignmentSpace / 2); |   762             child.setMarginTop(availableAlignmentSpace / 2); | 
|   763             child->setMarginBottom(availableAlignmentSpace / 2); |   763             child.setMarginBottom(availableAlignmentSpace / 2); | 
|   764         } else { |   764         } else { | 
|   765             child->setMarginLeft(availableAlignmentSpace / 2); |   765             child.setMarginLeft(availableAlignmentSpace / 2); | 
|   766             child->setMarginRight(availableAlignmentSpace / 2); |   766             child.setMarginRight(availableAlignmentSpace / 2); | 
|   767         } |   767         } | 
|   768         return true; |   768         return true; | 
|   769     } |   769     } | 
|   770     bool shouldAdjustTopOrLeft = true; |   770     bool shouldAdjustTopOrLeft = true; | 
|   771     if (isColumnFlow() && !child->style()->isLeftToRightDirection()) { |   771     if (isColumnFlow() && !child.style()->isLeftToRightDirection()) { | 
|   772         // For column flows, only make this adjustment if topOrLeft corresponds 
      to the "before" margin, |   772         // For column flows, only make this adjustment if topOrLeft corresponds 
      to the "before" margin, | 
|   773         // so that flipForRightToLeftColumn will do the right thing. |   773         // so that flipForRightToLeftColumn will do the right thing. | 
|   774         shouldAdjustTopOrLeft = false; |   774         shouldAdjustTopOrLeft = false; | 
|   775     } |   775     } | 
|   776     if (!isColumnFlow() && child->style()->isFlippedBlocksWritingMode()) { |   776     if (!isColumnFlow() && child.style()->isFlippedBlocksWritingMode()) { | 
|   777         // If we are a flipped writing mode, we need to adjust the opposite side
      . This is only needed |   777         // If we are a flipped writing mode, we need to adjust the opposite side
      . This is only needed | 
|   778         // for row flows because this only affects the block-direction axis. |   778         // for row flows because this only affects the block-direction axis. | 
|   779         shouldAdjustTopOrLeft = false; |   779         shouldAdjustTopOrLeft = false; | 
|   780     } |   780     } | 
|   781  |   781  | 
|   782     if (topOrLeft.isAuto()) { |   782     if (topOrLeft.isAuto()) { | 
|   783         if (shouldAdjustTopOrLeft) |   783         if (shouldAdjustTopOrLeft) | 
|   784             adjustAlignmentForChild(child, availableAlignmentSpace); |   784             adjustAlignmentForChild(child, availableAlignmentSpace); | 
|   785  |   785  | 
|   786         if (isHorizontal) |   786         if (isHorizontal) | 
|   787             child->setMarginTop(availableAlignmentSpace); |   787             child.setMarginTop(availableAlignmentSpace); | 
|   788         else |   788         else | 
|   789             child->setMarginLeft(availableAlignmentSpace); |   789             child.setMarginLeft(availableAlignmentSpace); | 
|   790         return true; |   790         return true; | 
|   791     } |   791     } | 
|   792     if (bottomOrRight.isAuto()) { |   792     if (bottomOrRight.isAuto()) { | 
|   793         if (!shouldAdjustTopOrLeft) |   793         if (!shouldAdjustTopOrLeft) | 
|   794             adjustAlignmentForChild(child, availableAlignmentSpace); |   794             adjustAlignmentForChild(child, availableAlignmentSpace); | 
|   795  |   795  | 
|   796         if (isHorizontal) |   796         if (isHorizontal) | 
|   797             child->setMarginBottom(availableAlignmentSpace); |   797             child.setMarginBottom(availableAlignmentSpace); | 
|   798         else |   798         else | 
|   799             child->setMarginRight(availableAlignmentSpace); |   799             child.setMarginRight(availableAlignmentSpace); | 
|   800         return true; |   800         return true; | 
|   801     } |   801     } | 
|   802     return false; |   802     return false; | 
|   803 } |   803 } | 
|   804  |   804  | 
|   805 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child) |   805 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox& child) | 
|   806 { |   806 { | 
|   807     LayoutUnit ascent = child->firstLineBoxBaseline(); |   807     LayoutUnit ascent = child.firstLineBoxBaseline(); | 
|   808     if (ascent == -1) |   808     if (ascent == -1) | 
|   809         ascent = crossAxisExtentForChild(*child); |   809         ascent = crossAxisExtentForChild(child); | 
|   810     return ascent + flowAwareMarginBeforeForChild(child); |   810     return ascent + flowAwareMarginBeforeForChild(child); | 
|   811 } |   811 } | 
|   812  |   812  | 
|   813 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin) |   813 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin) | 
|   814 { |   814 { | 
|   815     // When resolving the margins, we use the content size for resolving percent
       and calc (for percents in calc expressions) margins. |   815     // When resolving the margins, we use the content size for resolving percent
       and calc (for percents in calc expressions) margins. | 
|   816     // Fortunately, percent margins are always computed with respect to the bloc
      k's width, even for margin-top and margin-bottom. |   816     // Fortunately, percent margins are always computed with respect to the bloc
      k's width, even for margin-top and margin-bottom. | 
|   817     LayoutUnit availableSize = contentLogicalWidth(); |   817     LayoutUnit availableSize = contentLogicalWidth(); | 
|   818     return minimumValueForLength(margin, availableSize); |   818     return minimumValueForLength(margin, availableSize); | 
|   819 } |   819 } | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   833         if (isHorizontalFlow()) { |   833         if (isHorizontalFlow()) { | 
|   834             child->setMarginLeft(computeChildMarginValue(child->style()->marginL
      eft())); |   834             child->setMarginLeft(computeChildMarginValue(child->style()->marginL
      eft())); | 
|   835             child->setMarginRight(computeChildMarginValue(child->style()->margin
      Right())); |   835             child->setMarginRight(computeChildMarginValue(child->style()->margin
      Right())); | 
|   836         } else { |   836         } else { | 
|   837             child->setMarginTop(computeChildMarginValue(child->style()->marginTo
      p())); |   837             child->setMarginTop(computeChildMarginValue(child->style()->marginTo
      p())); | 
|   838             child->setMarginBottom(computeChildMarginValue(child->style()->margi
      nBottom())); |   838             child->setMarginBottom(computeChildMarginValue(child->style()->margi
      nBottom())); | 
|   839         } |   839         } | 
|   840     } |   840     } | 
|   841 } |   841 } | 
|   842  |   842  | 
|   843 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
      utUnit childSize) |   843 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, Layo
      utUnit childSize) | 
|   844 { |   844 { | 
|   845     Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
      )->maxHeight(); |   845     Length max = isHorizontalFlow() ? child.style()->maxWidth() : child.style()-
      >maxHeight(); | 
|   846     if (max.isSpecifiedOrIntrinsic()) { |   846     if (max.isSpecifiedOrIntrinsic()) { | 
|   847         LayoutUnit maxExtent = computeMainAxisExtentForChild(*child, MaxSize, ma
      x); |   847         LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
      ); | 
|   848         if (maxExtent != -1 && childSize > maxExtent) |   848         if (maxExtent != -1 && childSize > maxExtent) | 
|   849             childSize = maxExtent; |   849             childSize = maxExtent; | 
|   850     } |   850     } | 
|   851  |   851  | 
|   852     Length min = isHorizontalFlow() ? child->style()->minWidth() : child->style(
      )->minHeight(); |   852     Length min = isHorizontalFlow() ? child.style()->minWidth() : child.style()-
      >minHeight(); | 
|   853     LayoutUnit minExtent = 0; |   853     LayoutUnit minExtent = 0; | 
|   854     if (min.isSpecifiedOrIntrinsic()) |   854     if (min.isSpecifiedOrIntrinsic()) | 
|   855         minExtent = computeMainAxisExtentForChild(*child, MinSize, min); |   855         minExtent = computeMainAxisExtentForChild(child, MinSize, min); | 
|   856     return std::max(childSize, minExtent); |   856     return std::max(childSize, minExtent); | 
|   857 } |   857 } | 
|   858  |   858  | 
|   859 bool RenderFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
      , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexS
      hrink, LayoutUnit& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool re
      layoutChildren) |   859 bool RenderFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
      , LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexS
      hrink, LayoutUnit& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool re
      layoutChildren) | 
|   860 { |   860 { | 
|   861     orderedChildren.clear(); |   861     orderedChildren.clear(); | 
|   862     sumFlexBaseSize = 0; |   862     sumFlexBaseSize = 0; | 
|   863     totalFlexGrow = totalWeightedFlexShrink = 0; |   863     totalFlexGrow = totalWeightedFlexShrink = 0; | 
|   864     sumHypotheticalMainSize = 0; |   864     sumHypotheticalMainSize = 0; | 
|   865  |   865  | 
|   866     if (!m_orderIterator.currentChild()) |   866     if (!m_orderIterator.currentChild()) | 
|   867         return false; |   867         return false; | 
|   868  |   868  | 
|   869     LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); |   869     LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max()); | 
|   870     hasInfiniteLineLength = lineBreakLength == LayoutUnit::max(); |   870     hasInfiniteLineLength = lineBreakLength == LayoutUnit::max(); | 
|   871  |   871  | 
|   872     bool lineHasInFlowItem = false; |   872     bool lineHasInFlowItem = false; | 
|   873  |   873  | 
|   874     for (RenderBox* child = m_orderIterator.currentChild(); child; child = m_ord
      erIterator.next()) { |   874     for (RenderBox* child = m_orderIterator.currentChild(); child; child = m_ord
      erIterator.next()) { | 
|   875         if (child->isOutOfFlowPositioned()) { |   875         if (child->isOutOfFlowPositioned()) { | 
|   876             orderedChildren.append(child); |   876             orderedChildren.append(child); | 
|   877             continue; |   877             continue; | 
|   878         } |   878         } | 
|   879  |   879  | 
|   880         LayoutUnit childMainAxisExtent = preferredMainAxisContentExtentForChild(
      child, hasInfiniteLineLength, relayoutChildren); |   880         LayoutUnit childMainAxisExtent = preferredMainAxisContentExtentForChild(
      *child, hasInfiniteLineLength, relayoutChildren); | 
|   881         LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx
      tentForChild(child) |   881         LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx
      tentForChild(*child) | 
|   882             + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight()
      ); |   882             + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight()
      ); | 
|   883         LayoutUnit childFlexBaseSize = childMainAxisExtent + childMainAxisMargin
      BorderPadding; |   883         LayoutUnit childFlexBaseSize = childMainAxisExtent + childMainAxisMargin
      BorderPadding; | 
|   884  |   884  | 
|   885         LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa
      x(child, childMainAxisExtent); |   885         LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa
      x(*child, childMainAxisExtent); | 
|   886         LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent 
      + childMainAxisMarginBorderPadding; |   886         LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent 
      + childMainAxisMarginBorderPadding; | 
|   887  |   887  | 
|   888         if (isMultiline() && sumHypotheticalMainSize + childHypotheticalMainSize
       > lineBreakLength && lineHasInFlowItem) |   888         if (isMultiline() && sumHypotheticalMainSize + childHypotheticalMainSize
       > lineBreakLength && lineHasInFlowItem) | 
|   889             break; |   889             break; | 
|   890         orderedChildren.append(child); |   890         orderedChildren.append(child); | 
|   891         lineHasInFlowItem  = true; |   891         lineHasInFlowItem  = true; | 
|   892         sumFlexBaseSize += childFlexBaseSize; |   892         sumFlexBaseSize += childFlexBaseSize; | 
|   893         totalFlexGrow += child->style()->flexGrow(); |   893         totalFlexGrow += child->style()->flexGrow(); | 
|   894         totalWeightedFlexShrink += child->style()->flexShrink() * childMainAxisE
      xtent; |   894         totalWeightedFlexShrink += child->style()->flexShrink() * childMainAxisE
      xtent; | 
|   895         sumHypotheticalMainSize += childHypotheticalMainSize; |   895         sumHypotheticalMainSize += childHypotheticalMainSize; | 
|   896     } |   896     } | 
|   897     return true; |   897     return true; | 
|   898 } |   898 } | 
|   899  |   899  | 
|   900 void RenderFlexibleBox::freezeViolations(const Vector<Violation>& violations, La
      youtUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexSh
      rink, InflexibleFlexItemSize& inflexibleItems, bool hasInfiniteLineLength) |   900 void RenderFlexibleBox::freezeViolations(const Vector<Violation>& violations, La
      youtUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexSh
      rink, InflexibleFlexItemSize& inflexibleItems, bool hasInfiniteLineLength) | 
|   901 { |   901 { | 
|   902     for (size_t i = 0; i < violations.size(); ++i) { |   902     for (size_t i = 0; i < violations.size(); ++i) { | 
|   903         RenderBox* child = violations[i].child; |   903         RenderBox* child = violations[i].child; | 
|   904         LayoutUnit childSize = violations[i].childSize; |   904         LayoutUnit childSize = violations[i].childSize; | 
|   905         LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(c
      hild, hasInfiniteLineLength); |   905         LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(*
      child, hasInfiniteLineLength); | 
|   906         availableFreeSpace -= childSize - preferredChildSize; |   906         availableFreeSpace -= childSize - preferredChildSize; | 
|   907         totalFlexGrow -= child->style()->flexGrow(); |   907         totalFlexGrow -= child->style()->flexGrow(); | 
|   908         totalWeightedFlexShrink -= child->style()->flexShrink() * preferredChild
      Size; |   908         totalWeightedFlexShrink -= child->style()->flexShrink() * preferredChild
      Size; | 
|   909         inflexibleItems.set(child, childSize); |   909         inflexibleItems.set(child, childSize); | 
|   910     } |   910     } | 
|   911 } |   911 } | 
|   912  |   912  | 
|   913 // Returns true if we successfully ran the algorithm and sized the flex items. |   913 // Returns true if we successfully ran the algorithm and sized the flex items. | 
|   914 bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedF
      lexItemList& children, LayoutUnit& availableFreeSpace, double& totalFlexGrow, do
      uble& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems, Vector<L
      ayoutUnit, 16>& childSizes, bool hasInfiniteLineLength) |   914 bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedF
      lexItemList& children, LayoutUnit& availableFreeSpace, double& totalFlexGrow, do
      uble& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems, Vector<L
      ayoutUnit, 16>& childSizes, bool hasInfiniteLineLength) | 
|   915 { |   915 { | 
|   916     childSizes.resize(0); |   916     childSizes.resize(0); | 
|   917     LayoutUnit totalViolation = 0; |   917     LayoutUnit totalViolation = 0; | 
|   918     LayoutUnit usedFreeSpace = 0; |   918     LayoutUnit usedFreeSpace = 0; | 
|   919     Vector<Violation> minViolations; |   919     Vector<Violation> minViolations; | 
|   920     Vector<Violation> maxViolations; |   920     Vector<Violation> maxViolations; | 
|   921     for (size_t i = 0; i < children.size(); ++i) { |   921     for (size_t i = 0; i < children.size(); ++i) { | 
|   922         RenderBox* child = children[i]; |   922         RenderBox* child = children[i]; | 
|   923         if (child->isOutOfFlowPositioned()) { |   923         if (child->isOutOfFlowPositioned()) { | 
|   924             childSizes.append(0); |   924             childSizes.append(0); | 
|   925             continue; |   925             continue; | 
|   926         } |   926         } | 
|   927  |   927  | 
|   928         if (inflexibleItems.contains(child)) |   928         if (inflexibleItems.contains(child)) | 
|   929             childSizes.append(inflexibleItems.get(child)); |   929             childSizes.append(inflexibleItems.get(child)); | 
|   930         else { |   930         else { | 
|   931             LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChi
      ld(child, hasInfiniteLineLength); |   931             LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChi
      ld(*child, hasInfiniteLineLength); | 
|   932             LayoutUnit childSize = preferredChildSize; |   932             LayoutUnit childSize = preferredChildSize; | 
|   933             double extraSpace = 0; |   933             double extraSpace = 0; | 
|   934             if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == Posit
      iveFlexibility && std::isfinite(totalFlexGrow)) |   934             if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == Posit
      iveFlexibility && std::isfinite(totalFlexGrow)) | 
|   935                 extraSpace = availableFreeSpace * child->style()->flexGrow() / t
      otalFlexGrow; |   935                 extraSpace = availableFreeSpace * child->style()->flexGrow() / t
      otalFlexGrow; | 
|   936             else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 && fl
      exSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink)) |   936             else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 && fl
      exSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink)) | 
|   937                 extraSpace = availableFreeSpace * child->style()->flexShrink() *
       preferredChildSize / totalWeightedFlexShrink; |   937                 extraSpace = availableFreeSpace * child->style()->flexShrink() *
       preferredChildSize / totalWeightedFlexShrink; | 
|   938             if (std::isfinite(extraSpace)) |   938             if (std::isfinite(extraSpace)) | 
|   939                 childSize += LayoutUnit::fromFloatRound(extraSpace); |   939                 childSize += LayoutUnit::fromFloatRound(extraSpace); | 
|   940  |   940  | 
|   941             LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(child, ch
      ildSize); |   941             LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, c
      hildSize); | 
|   942             childSizes.append(adjustedChildSize); |   942             childSizes.append(adjustedChildSize); | 
|   943             usedFreeSpace += adjustedChildSize - preferredChildSize; |   943             usedFreeSpace += adjustedChildSize - preferredChildSize; | 
|   944  |   944  | 
|   945             LayoutUnit violation = adjustedChildSize - childSize; |   945             LayoutUnit violation = adjustedChildSize - childSize; | 
|   946             if (violation > 0) |   946             if (violation > 0) | 
|   947                 minViolations.append(Violation(child, adjustedChildSize)); |   947                 minViolations.append(Violation(child, adjustedChildSize)); | 
|   948             else if (violation < 0) |   948             else if (violation < 0) | 
|   949                 maxViolations.append(Violation(child, adjustedChildSize)); |   949                 maxViolations.append(Violation(child, adjustedChildSize)); | 
|   950             totalViolation += violation; |   950             totalViolation += violation; | 
|   951         } |   951         } | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   986 } |   986 } | 
|   987  |   987  | 
|   988 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil
      dPreferredSize) |   988 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil
      dPreferredSize) | 
|   989 { |   989 { | 
|   990     if (hasOrthogonalFlow(child)) |   990     if (hasOrthogonalFlow(child)) | 
|   991         child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA
      ndPaddingLogicalHeight()); |   991         child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA
      ndPaddingLogicalHeight()); | 
|   992     else |   992     else | 
|   993         child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn
      dPaddingLogicalWidth()); |   993         child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn
      dPaddingLogicalWidth()); | 
|   994 } |   994 } | 
|   995  |   995  | 
|   996 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout
      Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode
      ) |   996 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, Layout
      Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode
      ) | 
|   997 { |   997 { | 
|   998     ASSERT(child->isOutOfFlowPositioned()); |   998     ASSERT(child.isOutOfFlowPositioned()); | 
|   999     child->containingBlock()->insertPositionedObject(child); |   999     child.containingBlock()->insertPositionedObject(&child); | 
|  1000     RenderLayer* childLayer = child->layer(); |  1000     RenderLayer* childLayer = child.layer(); | 
|  1001     LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
      t; |  1001     LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
      t; | 
|  1002     if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe
      verse) |  1002     if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe
      verse) | 
|  1003         inlinePosition = mainAxisExtent() - mainAxisOffset; |  1003         inlinePosition = mainAxisExtent() - mainAxisOffset; | 
|  1004     childLayer->setStaticInlinePosition(inlinePosition); |  1004     childLayer->setStaticInlinePosition(inlinePosition); | 
|  1005  |  1005  | 
|  1006     LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
      Offset; |  1006     LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
      Offset; | 
|  1007     if (childLayer->staticBlockPosition() != staticBlockPosition) { |  1007     if (childLayer->staticBlockPosition() != staticBlockPosition) { | 
|  1008         childLayer->setStaticBlockPosition(staticBlockPosition); |  1008         childLayer->setStaticBlockPosition(staticBlockPosition); | 
|  1009         if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
      ode())) |  1009         if (child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMo
      de())) | 
|  1010             child->setChildNeedsLayout(MarkOnlyThis); |  1010             child.setChildNeedsLayout(MarkOnlyThis); | 
|  1011     } |  1011     } | 
|  1012 } |  1012 } | 
|  1013  |  1013  | 
|  1014 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const |  1014 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const | 
|  1015 { |  1015 { | 
|  1016     ItemPosition align = resolveAlignment(style(), child.style()); |  1016     ItemPosition align = resolveAlignment(style(), child.style()); | 
|  1017  |  1017  | 
|  1018     if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) |  1018     if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) | 
|  1019         align = ItemPositionFlexStart; |  1019         align = ItemPositionFlexStart; | 
|  1020  |  1020  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  1032 { |  1032 { | 
|  1033     size_t count = 0; |  1033     size_t count = 0; | 
|  1034     for (size_t i = 0; i < children.size(); ++i) { |  1034     for (size_t i = 0; i < children.size(); ++i) { | 
|  1035         RenderBox* child = children[i]; |  1035         RenderBox* child = children[i]; | 
|  1036         if (!child->isOutOfFlowPositioned()) |  1036         if (!child->isOutOfFlowPositioned()) | 
|  1037             ++count; |  1037             ++count; | 
|  1038     } |  1038     } | 
|  1039     return count; |  1039     return count; | 
|  1040 } |  1040 } | 
|  1041  |  1041  | 
|  1042 void RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox* chil
      d) |  1042 void RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox& chil
      d) | 
|  1043 { |  1043 { | 
|  1044     if (hasAutoMarginsInCrossAxis(child)) { |  1044     if (hasAutoMarginsInCrossAxis(child)) { | 
|  1045         child->updateLogicalHeight(); |  1045         child.updateLogicalHeight(); | 
|  1046         if (isHorizontalFlow()) { |  1046         if (isHorizontalFlow()) { | 
|  1047             if (child->style()->marginTop().isAuto()) |  1047             if (child.style()->marginTop().isAuto()) | 
|  1048                 child->setMarginTop(0); |  1048                 child.setMarginTop(0); | 
|  1049             if (child->style()->marginBottom().isAuto()) |  1049             if (child.style()->marginBottom().isAuto()) | 
|  1050                 child->setMarginBottom(0); |  1050                 child.setMarginBottom(0); | 
|  1051         } else { |  1051         } else { | 
|  1052             if (child->style()->marginLeft().isAuto()) |  1052             if (child.style()->marginLeft().isAuto()) | 
|  1053                 child->setMarginLeft(0); |  1053                 child.setMarginLeft(0); | 
|  1054             if (child->style()->marginRight().isAuto()) |  1054             if (child.style()->marginRight().isAuto()) | 
|  1055                 child->setMarginRight(0); |  1055                 child.setMarginRight(0); | 
|  1056         } |  1056         } | 
|  1057     } |  1057     } | 
|  1058 } |  1058 } | 
|  1059  |  1059  | 
|  1060 bool RenderFlexibleBox::needToStretchChildLogicalHeight(RenderBox& child) const |  1060 bool RenderFlexibleBox::needToStretchChildLogicalHeight(RenderBox& child) const | 
|  1061 { |  1061 { | 
|  1062     if (alignmentForChild(child) != ItemPositionStretch) |  1062     if (alignmentForChild(child) != ItemPositionStretch) | 
|  1063         return false; |  1063         return false; | 
|  1064  |  1064  | 
|  1065     return isHorizontalFlow() && child.style()->height().isAuto(); |  1065     return isHorizontalFlow() && child.style()->height().isAuto(); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  1078  |  1078  | 
|  1079     LayoutUnit totalMainExtent = mainAxisExtent(); |  1079     LayoutUnit totalMainExtent = mainAxisExtent(); | 
|  1080     LayoutUnit maxAscent = 0, maxDescent = 0; // Used when align-items: baseline
      . |  1080     LayoutUnit maxAscent = 0, maxDescent = 0; // Used when align-items: baseline
      . | 
|  1081     LayoutUnit maxChildCrossAxisExtent = 0; |  1081     LayoutUnit maxChildCrossAxisExtent = 0; | 
|  1082     size_t seenInFlowPositionedChildren = 0; |  1082     size_t seenInFlowPositionedChildren = 0; | 
|  1083     bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); |  1083     bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); | 
|  1084     for (size_t i = 0; i < children.size(); ++i) { |  1084     for (size_t i = 0; i < children.size(); ++i) { | 
|  1085         RenderBox* child = children[i]; |  1085         RenderBox* child = children[i]; | 
|  1086  |  1086  | 
|  1087         if (child->isOutOfFlowPositioned()) { |  1087         if (child->isOutOfFlowPositioned()) { | 
|  1088             prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
      et, FlipForRowReverse); |  1088             prepareChildForPositionedLayout(*child, mainAxisOffset, crossAxisOff
      set, FlipForRowReverse); | 
|  1089             continue; |  1089             continue; | 
|  1090         } |  1090         } | 
|  1091  |  1091  | 
|  1092         // FIXME Investigate if this can be removed based on other flags. crbug.
      com/370010 |  1092         // FIXME Investigate if this can be removed based on other flags. crbug.
      com/370010 | 
|  1093         child->setMayNeedPaintInvalidation(true); |  1093         child->setMayNeedPaintInvalidation(true); | 
|  1094  |  1094  | 
|  1095         LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
      ExtentForChild(child); |  1095         LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
      ExtentForChild(*child); | 
|  1096         setLogicalOverrideSize(*child, childPreferredSize); |  1096         setLogicalOverrideSize(*child, childPreferredSize); | 
|  1097         if (childPreferredSize != mainAxisExtentForChild(*child)) { |  1097         if (childPreferredSize != mainAxisExtentForChild(*child)) { | 
|  1098             child->setChildNeedsLayout(MarkOnlyThis); |  1098             child->setChildNeedsLayout(MarkOnlyThis); | 
|  1099         } else { |  1099         } else { | 
|  1100             // To avoid double applying margin changes in updateAutoMarginsInCro
      ssAxis, we reset the margins here. |  1100             // To avoid double applying margin changes in updateAutoMarginsInCro
      ssAxis, we reset the margins here. | 
|  1101             resetAutoMarginsAndLogicalTopInCrossAxis(child); |  1101             resetAutoMarginsAndLogicalTopInCrossAxis(*child); | 
|  1102         } |  1102         } | 
|  1103         // We may have already forced relayout for orthogonal flowing children i
      n preferredMainAxisContentExtentForChild. |  1103         // We may have already forced relayout for orthogonal flowing children i
      n preferredMainAxisContentExtentForChild. | 
|  1104         bool forceChildRelayout = relayoutChildren && !childPreferredMainAxisCon
      tentExtentRequiresLayout(*child, hasInfiniteLineLength); |  1104         bool forceChildRelayout = relayoutChildren && !childPreferredMainAxisCon
      tentExtentRequiresLayout(*child, hasInfiniteLineLength); | 
|  1105         updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, child); |  1105         updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, child); | 
|  1106         child->layoutIfNeeded(); |  1106         child->layoutIfNeeded(); | 
|  1107  |  1107  | 
|  1108         updateAutoMarginsInMainAxis(child, autoMarginOffset); |  1108         updateAutoMarginsInMainAxis(*child, autoMarginOffset); | 
|  1109  |  1109  | 
|  1110         LayoutUnit childCrossAxisMarginBoxExtent; |  1110         LayoutUnit childCrossAxisMarginBoxExtent; | 
|  1111         if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
      InCrossAxis(child)) { |  1111         if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
      InCrossAxis(*child)) { | 
|  1112             LayoutUnit ascent = marginBoxAscentForChild(child); |  1112             LayoutUnit ascent = marginBoxAscentForChild(*child); | 
|  1113             LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAx
      isExtentForChild(*child)) - ascent; |  1113             LayoutUnit descent = (crossAxisMarginExtentForChild(*child) + crossA
      xisExtentForChild(*child)) - ascent; | 
|  1114  |  1114  | 
|  1115             maxAscent = std::max(maxAscent, ascent); |  1115             maxAscent = std::max(maxAscent, ascent); | 
|  1116             maxDescent = std::max(maxDescent, descent); |  1116             maxDescent = std::max(maxDescent, descent); | 
|  1117  |  1117  | 
|  1118             childCrossAxisMarginBoxExtent = maxAscent + maxDescent; |  1118             childCrossAxisMarginBoxExtent = maxAscent + maxDescent; | 
|  1119         } else { |  1119         } else { | 
|  1120             childCrossAxisMarginBoxExtent = crossAxisIntrinsicExtentForChild(*ch
      ild) + crossAxisMarginExtentForChild(child) + crossAxisScrollbarExtentForChild(c
      hild); |  1120             childCrossAxisMarginBoxExtent = crossAxisIntrinsicExtentForChild(*ch
      ild) + crossAxisMarginExtentForChild(*child) + crossAxisScrollbarExtentForChild(
      *child); | 
|  1121         } |  1121         } | 
|  1122         if (!isColumnFlow()) |  1122         if (!isColumnFlow()) | 
|  1123             setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa
      reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros
      sAxisScrollbarExtent())); |  1123             setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa
      reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros
      sAxisScrollbarExtent())); | 
|  1124         maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx
      isMarginBoxExtent); |  1124         maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx
      isMarginBoxExtent); | 
|  1125  |  1125  | 
|  1126         mainAxisOffset += flowAwareMarginStartForChild(child); |  1126         mainAxisOffset += flowAwareMarginStartForChild(*child); | 
|  1127  |  1127  | 
|  1128         LayoutUnit childMainExtent = mainAxisExtentForChild(*child); |  1128         LayoutUnit childMainExtent = mainAxisExtentForChild(*child); | 
|  1129         // In an RTL column situation, this will apply the margin-right/margin-e
      nd on the left. |  1129         // In an RTL column situation, this will apply the margin-right/margin-e
      nd on the left. | 
|  1130         // This will be fixed later in flipForRightToLeftColumn. |  1130         // This will be fixed later in flipForRightToLeftColumn. | 
|  1131         LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi
      sOffset - childMainExtent : mainAxisOffset, |  1131         LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi
      sOffset - childMainExtent : mainAxisOffset, | 
|  1132             crossAxisOffset + flowAwareMarginBeforeForChild(child)); |  1132             crossAxisOffset + flowAwareMarginBeforeForChild(*child)); | 
|  1133  |  1133  | 
|  1134         // FIXME: Supporting layout deltas. |  1134         // FIXME: Supporting layout deltas. | 
|  1135         setFlowAwareLocationForChild(child, childLocation); |  1135         setFlowAwareLocationForChild(*child, childLocation); | 
|  1136         mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(child); |  1136         mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(*child); | 
|  1137  |  1137  | 
|  1138         ++seenInFlowPositionedChildren; |  1138         ++seenInFlowPositionedChildren; | 
|  1139         if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) |  1139         if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) | 
|  1140             mainAxisOffset += justifyContentSpaceBetweenChildren(availableFreeSp
      ace, style()->justifyContent(), numberOfChildrenForJustifyContent); |  1140             mainAxisOffset += justifyContentSpaceBetweenChildren(availableFreeSp
      ace, style()->justifyContent(), numberOfChildrenForJustifyContent); | 
|  1141     } |  1141     } | 
|  1142  |  1142  | 
|  1143     if (isColumnFlow()) |  1143     if (isColumnFlow()) | 
|  1144         setLogicalHeight(mainAxisOffset + flowAwareBorderEnd() + flowAwarePaddin
      gEnd() + scrollbarLogicalHeight()); |  1144         setLogicalHeight(mainAxisOffset + flowAwareBorderEnd() + flowAwarePaddin
      gEnd() + scrollbarLogicalHeight()); | 
|  1145  |  1145  | 
|  1146     if (style()->flexDirection() == FlowColumnReverse) { |  1146     if (style()->flexDirection() == FlowColumnReverse) { | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  1167     mainAxisOffset -= isHorizontalFlow() ? verticalScrollbarWidth() : horizontal
      ScrollbarHeight(); |  1167     mainAxisOffset -= isHorizontalFlow() ? verticalScrollbarWidth() : horizontal
      ScrollbarHeight(); | 
|  1168  |  1168  | 
|  1169     size_t seenInFlowPositionedChildren = 0; |  1169     size_t seenInFlowPositionedChildren = 0; | 
|  1170     for (size_t i = 0; i < children.size(); ++i) { |  1170     for (size_t i = 0; i < children.size(); ++i) { | 
|  1171         RenderBox* child = children[i]; |  1171         RenderBox* child = children[i]; | 
|  1172  |  1172  | 
|  1173         if (child->isOutOfFlowPositioned()) { |  1173         if (child->isOutOfFlowPositioned()) { | 
|  1174             child->layer()->setStaticBlockPosition(mainAxisOffset); |  1174             child->layer()->setStaticBlockPosition(mainAxisOffset); | 
|  1175             continue; |  1175             continue; | 
|  1176         } |  1176         } | 
|  1177         mainAxisOffset -= mainAxisExtentForChild(*child) + flowAwareMarginEndFor
      Child(child); |  1177         mainAxisOffset -= mainAxisExtentForChild(*child) + flowAwareMarginEndFor
      Child(*child); | 
|  1178  |  1178  | 
|  1179         setFlowAwareLocationForChild(child, LayoutPoint(mainAxisOffset, crossAxi
      sOffset + flowAwareMarginBeforeForChild(child))); |  1179         setFlowAwareLocationForChild(*child, LayoutPoint(mainAxisOffset, crossAx
      isOffset + flowAwareMarginBeforeForChild(*child))); | 
|  1180  |  1180  | 
|  1181         mainAxisOffset -= flowAwareMarginStartForChild(child); |  1181         mainAxisOffset -= flowAwareMarginStartForChild(*child); | 
|  1182  |  1182  | 
|  1183         ++seenInFlowPositionedChildren; |  1183         ++seenInFlowPositionedChildren; | 
|  1184         if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) |  1184         if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) | 
|  1185             mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp
      ace, style()->justifyContent(), numberOfChildrenForJustifyContent); |  1185             mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp
      ace, style()->justifyContent(), numberOfChildrenForJustifyContent); | 
|  1186     } |  1186     } | 
|  1187 } |  1187 } | 
|  1188  |  1188  | 
|  1189 static LayoutUnit initialAlignContentOffset(LayoutUnit availableFreeSpace, EAlig
      nContent alignContent, unsigned numberOfLines) |  1189 static LayoutUnit initialAlignContentOffset(LayoutUnit availableFreeSpace, EAlig
      nContent alignContent, unsigned numberOfLines) | 
|  1190 { |  1190 { | 
|  1191     if (numberOfLines <= 1) |  1191     if (numberOfLines <= 1) | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1229  |  1229  | 
|  1230     LayoutUnit availableCrossAxisSpace = crossAxisContentExtent(); |  1230     LayoutUnit availableCrossAxisSpace = crossAxisContentExtent(); | 
|  1231     for (size_t i = 0; i < lineContexts.size(); ++i) |  1231     for (size_t i = 0; i < lineContexts.size(); ++i) | 
|  1232         availableCrossAxisSpace -= lineContexts[i].crossAxisExtent; |  1232         availableCrossAxisSpace -= lineContexts[i].crossAxisExtent; | 
|  1233  |  1233  | 
|  1234     RenderBox* child = m_orderIterator.first(); |  1234     RenderBox* child = m_orderIterator.first(); | 
|  1235     LayoutUnit lineOffset = initialAlignContentOffset(availableCrossAxisSpace, s
      tyle()->alignContent(), lineContexts.size()); |  1235     LayoutUnit lineOffset = initialAlignContentOffset(availableCrossAxisSpace, s
      tyle()->alignContent(), lineContexts.size()); | 
|  1236     for (unsigned lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber
      ) { |  1236     for (unsigned lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber
      ) { | 
|  1237         lineContexts[lineNumber].crossAxisOffset += lineOffset; |  1237         lineContexts[lineNumber].crossAxisOffset += lineOffset; | 
|  1238         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) |  1238         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) | 
|  1239             adjustAlignmentForChild(child, lineOffset); |  1239             adjustAlignmentForChild(*child, lineOffset); | 
|  1240  |  1240  | 
|  1241         if (style()->alignContent() == AlignContentStretch && availableCrossAxis
      Space > 0) |  1241         if (style()->alignContent() == AlignContentStretch && availableCrossAxis
      Space > 0) | 
|  1242             lineContexts[lineNumber].crossAxisExtent += availableCrossAxisSpace 
      / static_cast<unsigned>(lineContexts.size()); |  1242             lineContexts[lineNumber].crossAxisExtent += availableCrossAxisSpace 
      / static_cast<unsigned>(lineContexts.size()); | 
|  1243  |  1243  | 
|  1244         lineOffset += alignContentSpaceBetweenChildren(availableCrossAxisSpace, 
      style()->alignContent(), lineContexts.size()); |  1244         lineOffset += alignContentSpaceBetweenChildren(availableCrossAxisSpace, 
      style()->alignContent(), lineContexts.size()); | 
|  1245     } |  1245     } | 
|  1246 } |  1246 } | 
|  1247  |  1247  | 
|  1248 void RenderFlexibleBox::adjustAlignmentForChild(RenderBox* child, LayoutUnit del
      ta) |  1248 void RenderFlexibleBox::adjustAlignmentForChild(RenderBox& child, LayoutUnit del
      ta) | 
|  1249 { |  1249 { | 
|  1250     if (child->isOutOfFlowPositioned()) { |  1250     if (child.isOutOfFlowPositioned()) { | 
|  1251         LayoutUnit staticInlinePosition = child->layer()->staticInlinePosition()
      ; |  1251         LayoutUnit staticInlinePosition = child.layer()->staticInlinePosition(); | 
|  1252         LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition(); |  1252         LayoutUnit staticBlockPosition = child.layer()->staticBlockPosition(); | 
|  1253         LayoutUnit mainAxis = isColumnFlow() ? staticBlockPosition : staticInlin
      ePosition; |  1253         LayoutUnit mainAxis = isColumnFlow() ? staticBlockPosition : staticInlin
      ePosition; | 
|  1254         LayoutUnit crossAxis = isColumnFlow() ? staticInlinePosition : staticBlo
      ckPosition; |  1254         LayoutUnit crossAxis = isColumnFlow() ? staticInlinePosition : staticBlo
      ckPosition; | 
|  1255         crossAxis += delta; |  1255         crossAxis += delta; | 
|  1256         prepareChildForPositionedLayout(child, mainAxis, crossAxis, NoFlipForRow
      Reverse); |  1256         prepareChildForPositionedLayout(child, mainAxis, crossAxis, NoFlipForRow
      Reverse); | 
|  1257         return; |  1257         return; | 
|  1258     } |  1258     } | 
|  1259  |  1259  | 
|  1260     setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + Layou
      tSize(0, delta)); |  1260     setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + Layou
      tSize(0, delta)); | 
|  1261 } |  1261 } | 
|  1262  |  1262  | 
|  1263 void RenderFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) |  1263 void RenderFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) | 
|  1264 { |  1264 { | 
|  1265     // Keep track of the space between the baseline edge and the after edge of t
      he box for each line. |  1265     // Keep track of the space between the baseline edge and the after edge of t
      he box for each line. | 
|  1266     Vector<LayoutUnit> minMarginAfterBaselines; |  1266     Vector<LayoutUnit> minMarginAfterBaselines; | 
|  1267  |  1267  | 
|  1268     RenderBox* child = m_orderIterator.first(); |  1268     RenderBox* child = m_orderIterator.first(); | 
|  1269     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { |  1269     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { | 
|  1270         LayoutUnit minMarginAfterBaseline = LayoutUnit::max(); |  1270         LayoutUnit minMarginAfterBaseline = LayoutUnit::max(); | 
|  1271         LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisExten
      t; |  1271         LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisExten
      t; | 
|  1272         LayoutUnit maxAscent = lineContexts[lineNumber].maxAscent; |  1272         LayoutUnit maxAscent = lineContexts[lineNumber].maxAscent; | 
|  1273  |  1273  | 
|  1274         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { |  1274         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 
|  1275             ASSERT(child); |  1275             ASSERT(child); | 
|  1276             if (child->isOutOfFlowPositioned()) { |  1276             if (child->isOutOfFlowPositioned()) { | 
|  1277                 if (style()->flexWrap() == FlexWrapReverse) |  1277                 if (style()->flexWrap() == FlexWrapReverse) | 
|  1278                     adjustAlignmentForChild(child, lineCrossAxisExtent); |  1278                     adjustAlignmentForChild(*child, lineCrossAxisExtent); | 
|  1279                 continue; |  1279                 continue; | 
|  1280             } |  1280             } | 
|  1281  |  1281  | 
|  1282             if (updateAutoMarginsInCrossAxis(child, std::max(LayoutUnit(0), avai
      lableAlignmentSpaceForChild(lineCrossAxisExtent, child)))) |  1282             if (updateAutoMarginsInCrossAxis(*child, std::max(LayoutUnit(0), ava
      ilableAlignmentSpaceForChild(lineCrossAxisExtent, *child)))) | 
|  1283                 continue; |  1283                 continue; | 
|  1284  |  1284  | 
|  1285             switch (alignmentForChild(*child)) { |  1285             switch (alignmentForChild(*child)) { | 
|  1286             case ItemPositionAuto: |  1286             case ItemPositionAuto: | 
|  1287                 ASSERT_NOT_REACHED(); |  1287                 ASSERT_NOT_REACHED(); | 
|  1288                 break; |  1288                 break; | 
|  1289             case ItemPositionStretch: { |  1289             case ItemPositionStretch: { | 
|  1290                 applyStretchAlignmentToChild(child, lineCrossAxisExtent); |  1290                 applyStretchAlignmentToChild(*child, lineCrossAxisExtent); | 
|  1291                 // Since wrap-reverse flips cross start and cross end, strech ch
      ildren should be aligned with the cross end. |  1291                 // Since wrap-reverse flips cross start and cross end, strech ch
      ildren should be aligned with the cross end. | 
|  1292                 if (style()->flexWrap() == FlexWrapReverse) |  1292                 if (style()->flexWrap() == FlexWrapReverse) | 
|  1293                     adjustAlignmentForChild(child, availableAlignmentSpaceForChi
      ld(lineCrossAxisExtent, child)); |  1293                     adjustAlignmentForChild(*child, availableAlignmentSpaceForCh
      ild(lineCrossAxisExtent, *child)); | 
|  1294                 break; |  1294                 break; | 
|  1295             } |  1295             } | 
|  1296             case ItemPositionFlexStart: |  1296             case ItemPositionFlexStart: | 
|  1297                 break; |  1297                 break; | 
|  1298             case ItemPositionFlexEnd: |  1298             case ItemPositionFlexEnd: | 
|  1299                 adjustAlignmentForChild(child, availableAlignmentSpaceForChild(l
      ineCrossAxisExtent, child)); |  1299                 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild(
      lineCrossAxisExtent, *child)); | 
|  1300                 break; |  1300                 break; | 
|  1301             case ItemPositionCenter: |  1301             case ItemPositionCenter: | 
|  1302                 adjustAlignmentForChild(child, availableAlignmentSpaceForChild(l
      ineCrossAxisExtent, child) / 2); |  1302                 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild(
      lineCrossAxisExtent, *child) / 2); | 
|  1303                 break; |  1303                 break; | 
|  1304             case ItemPositionBaseline: { |  1304             case ItemPositionBaseline: { | 
|  1305                 // FIXME: If we get here in columns, we want the use the descent
      , except we currently can't get the ascent/descent of orthogonal children. |  1305                 // FIXME: If we get here in columns, we want the use the descent
      , except we currently can't get the ascent/descent of orthogonal children. | 
|  1306                 // https://bugs.webkit.org/show_bug.cgi?id=98076 |  1306                 // https://bugs.webkit.org/show_bug.cgi?id=98076 | 
|  1307                 LayoutUnit ascent = marginBoxAscentForChild(child); |  1307                 LayoutUnit ascent = marginBoxAscentForChild(*child); | 
|  1308                 LayoutUnit startOffset = maxAscent - ascent; |  1308                 LayoutUnit startOffset = maxAscent - ascent; | 
|  1309                 adjustAlignmentForChild(child, startOffset); |  1309                 adjustAlignmentForChild(*child, startOffset); | 
|  1310  |  1310  | 
|  1311                 if (style()->flexWrap() == FlexWrapReverse) |  1311                 if (style()->flexWrap() == FlexWrapReverse) | 
|  1312                     minMarginAfterBaseline = std::min(minMarginAfterBaseline, av
      ailableAlignmentSpaceForChild(lineCrossAxisExtent, child) - startOffset); |  1312                     minMarginAfterBaseline = std::min(minMarginAfterBaseline, av
      ailableAlignmentSpaceForChild(lineCrossAxisExtent, *child) - startOffset); | 
|  1313                 break; |  1313                 break; | 
|  1314             } |  1314             } | 
|  1315             case ItemPositionLastBaseline: |  1315             case ItemPositionLastBaseline: | 
|  1316             case ItemPositionSelfStart: |  1316             case ItemPositionSelfStart: | 
|  1317             case ItemPositionSelfEnd: |  1317             case ItemPositionSelfEnd: | 
|  1318             case ItemPositionStart: |  1318             case ItemPositionStart: | 
|  1319             case ItemPositionEnd: |  1319             case ItemPositionEnd: | 
|  1320             case ItemPositionLeft: |  1320             case ItemPositionLeft: | 
|  1321             case ItemPositionRight: |  1321             case ItemPositionRight: | 
|  1322                 // FIXME: File a bug about implementing that. The extended gramm
      ar |  1322                 // FIXME: File a bug about implementing that. The extended gramm
      ar | 
|  1323                 // is not enabled by default so we shouldn't hit this codepath. |  1323                 // is not enabled by default so we shouldn't hit this codepath. | 
|  1324                 ASSERT_NOT_REACHED(); |  1324                 ASSERT_NOT_REACHED(); | 
|  1325                 break; |  1325                 break; | 
|  1326             } |  1326             } | 
|  1327         } |  1327         } | 
|  1328         minMarginAfterBaselines.append(minMarginAfterBaseline); |  1328         minMarginAfterBaselines.append(minMarginAfterBaseline); | 
|  1329     } |  1329     } | 
|  1330  |  1330  | 
|  1331     if (style()->flexWrap() != FlexWrapReverse) |  1331     if (style()->flexWrap() != FlexWrapReverse) | 
|  1332         return; |  1332         return; | 
|  1333  |  1333  | 
|  1334     // wrap-reverse flips the cross axis start and end. For baseline alignment, 
      this means we |  1334     // wrap-reverse flips the cross axis start and end. For baseline alignment, 
      this means we | 
|  1335     // need to align the after edge of baseline elements with the after edge of 
      the flex line. |  1335     // need to align the after edge of baseline elements with the after edge of 
      the flex line. | 
|  1336     child = m_orderIterator.first(); |  1336     child = m_orderIterator.first(); | 
|  1337     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { |  1337     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { | 
|  1338         LayoutUnit minMarginAfterBaseline = minMarginAfterBaselines[lineNumber]; |  1338         LayoutUnit minMarginAfterBaseline = minMarginAfterBaselines[lineNumber]; | 
|  1339         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { |  1339         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 
|  1340             ASSERT(child); |  1340             ASSERT(child); | 
|  1341             if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMar
      ginsInCrossAxis(child) && minMarginAfterBaseline) |  1341             if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMar
      ginsInCrossAxis(*child) && minMarginAfterBaseline) | 
|  1342                 adjustAlignmentForChild(child, minMarginAfterBaseline); |  1342                 adjustAlignmentForChild(*child, minMarginAfterBaseline); | 
|  1343         } |  1343         } | 
|  1344     } |  1344     } | 
|  1345 } |  1345 } | 
|  1346  |  1346  | 
|  1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni
      t lineCrossAxisExtent) |  1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUni
      t lineCrossAxisExtent) | 
|  1348 { |  1348 { | 
|  1349     if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) { |  1349     if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) { | 
|  1350         // FIXME: If the child has orthogonal flow, then it already has an overr
      ide height set, so use it. |  1350         // FIXME: If the child has orthogonal flow, then it already has an overr
      ide height set, so use it. | 
|  1351         if (!hasOrthogonalFlow(*child)) { |  1351         if (!hasOrthogonalFlow(child)) { | 
|  1352             LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
      *child) ? constrainedChildIntrinsicContentLogicalHeight(*child) : child->logical
      Height(); |  1352             LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
      child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei
      ght(); | 
|  1353             LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
      leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |  1353             LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
      leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); | 
|  1354             ASSERT(!child->needsLayout()); |  1354             ASSERT(!child.needsLayout()); | 
|  1355             LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin
      Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi
      calHeight()); |  1355             LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
      ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica
      lHeight()); | 
|  1356  |  1356  | 
|  1357             // FIXME: Can avoid laying out here in some cases. See https://webki
      t.org/b/87905. |  1357             // FIXME: Can avoid laying out here in some cases. See https://webki
      t.org/b/87905. | 
|  1358             if (desiredLogicalHeight != child->logicalHeight()) { |  1358             if (desiredLogicalHeight != child.logicalHeight()) { | 
|  1359                 child->setOverrideLogicalContentHeight(desiredLogicalHeight - ch
      ild->borderAndPaddingLogicalHeight()); |  1359                 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi
      ld.borderAndPaddingLogicalHeight()); | 
|  1360                 child->setLogicalHeight(0); |  1360                 child.setLogicalHeight(0); | 
|  1361                 child->forceChildLayout(); |  1361                 child.forceChildLayout(); | 
|  1362             } |  1362             } | 
|  1363         } |  1363         } | 
|  1364     } else if (isColumnFlow() && child->style()->logicalWidth().isAuto()) { |  1364     } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) { | 
|  1365         // FIXME: If the child doesn't have orthogonal flow, then it already has
       an override width set, so use it. |  1365         // FIXME: If the child doesn't have orthogonal flow, then it already has
       an override width set, so use it. | 
|  1366         if (hasOrthogonalFlow(*child)) { |  1366         if (hasOrthogonalFlow(child)) { | 
|  1367             LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent 
      - crossAxisMarginExtentForChild(child)); |  1367             LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent 
      - crossAxisMarginExtentForChild(child)); | 
|  1368             childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW
      idth, this); |  1368             childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWi
      dth, this); | 
|  1369  |  1369  | 
|  1370             if (childWidth != child->logicalWidth()) { |  1370             if (childWidth != child.logicalWidth()) { | 
|  1371                 child->setOverrideLogicalContentWidth(childWidth - child->border
      AndPaddingLogicalWidth()); |  1371                 child.setOverrideLogicalContentWidth(childWidth - child.borderAn
      dPaddingLogicalWidth()); | 
|  1372                 child->forceChildLayout(); |  1372                 child.forceChildLayout(); | 
|  1373             } |  1373             } | 
|  1374         } |  1374         } | 
|  1375     } |  1375     } | 
|  1376 } |  1376 } | 
|  1377  |  1377  | 
|  1378 void RenderFlexibleBox::flipForRightToLeftColumn() |  1378 void RenderFlexibleBox::flipForRightToLeftColumn() | 
|  1379 { |  1379 { | 
|  1380     if (style()->isLeftToRightDirection() || !isColumnFlow()) |  1380     if (style()->isLeftToRightDirection() || !isColumnFlow()) | 
|  1381         return; |  1381         return; | 
|  1382  |  1382  | 
|  1383     LayoutUnit crossExtent = crossAxisExtent(); |  1383     LayoutUnit crossExtent = crossAxisExtent(); | 
|  1384     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
      tor.next()) { |  1384     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
      tor.next()) { | 
|  1385         if (child->isOutOfFlowPositioned()) |  1385         if (child->isOutOfFlowPositioned()) | 
|  1386             continue; |  1386             continue; | 
|  1387         LayoutPoint location = flowAwareLocationForChild(child); |  1387         LayoutPoint location = flowAwareLocationForChild(*child); | 
|  1388         // For vertical flows, setFlowAwareLocationForChild will transpose x and
       y, |  1388         // For vertical flows, setFlowAwareLocationForChild will transpose x and
       y, | 
|  1389         // so using the y axis for a column cross axis extent is correct. |  1389         // so using the y axis for a column cross axis extent is correct. | 
|  1390         location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y
      ()); |  1390         location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y
      ()); | 
|  1391         setFlowAwareLocationForChild(child, location); |  1391         setFlowAwareLocationForChild(*child, location); | 
|  1392     } |  1392     } | 
|  1393 } |  1393 } | 
|  1394  |  1394  | 
|  1395 void RenderFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex
      ts, LayoutUnit crossAxisStartEdge) |  1395 void RenderFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex
      ts, LayoutUnit crossAxisStartEdge) | 
|  1396 { |  1396 { | 
|  1397     LayoutUnit contentExtent = crossAxisContentExtent(); |  1397     LayoutUnit contentExtent = crossAxisContentExtent(); | 
|  1398     RenderBox* child = m_orderIterator.first(); |  1398     RenderBox* child = m_orderIterator.first(); | 
|  1399     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { |  1399     for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) 
      { | 
|  1400         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { |  1400         for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
      erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 
|  1401             ASSERT(child); |  1401             ASSERT(child); | 
|  1402             LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
      xtent; |  1402             LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
      xtent; | 
|  1403             LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
       - crossAxisStartEdge; |  1403             LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
       - crossAxisStartEdge; | 
|  1404             LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
      sExtent; |  1404             LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
      sExtent; | 
|  1405             adjustAlignmentForChild(child, newOffset - originalOffset); |  1405             adjustAlignmentForChild(*child, newOffset - originalOffset); | 
|  1406         } |  1406         } | 
|  1407     } |  1407     } | 
|  1408 } |  1408 } | 
|  1409  |  1409  | 
|  1410 } |  1410 } | 
| OLD | NEW |