| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // computeMainSizeFromAspectRatioUsing. | 700 // computeMainSizeFromAspectRatioUsing. |
| 701 return length.isFixed(); | 701 return length.isFixed(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(const LayoutBox& child)
const | 704 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(const LayoutBox& child)
const |
| 705 { | 705 { |
| 706 return !mainAxisLengthIsDefinite(child, flexBasisForChild(child)) && ( | 706 return !mainAxisLengthIsDefinite(child, flexBasisForChild(child)) && ( |
| 707 hasOrthogonalFlow(child) || crossAxisOverflowForChild(child) == OAUTO); | 707 hasOrthogonalFlow(child) || crossAxisOverflowForChild(child) == OAUTO); |
| 708 } | 708 } |
| 709 | 709 |
| 710 void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child) |
| 711 { |
| 712 ASSERT(!child.needsLayout()); |
| 713 LayoutUnit mainSize; |
| 714 if (hasOrthogonalFlow(child)) { |
| 715 mainSize = child.logicalHeight(); |
| 716 } else { |
| 717 // The max preferred logical width includes the intrinsic scrollbar logi
cal width, which is only set for |
| 718 // overflow: scroll. To handle overflow: auto, we have to take scrollbar
LogicalWidth() into account, and then |
| 719 // subtract the intrinsic width again so as to not double-count overflow
: scroll scrollbars. |
| 720 mainSize = child.maxPreferredLogicalWidth() + child.scrollbarLogicalWidt
h() - child.intrinsicScrollbarLogicalWidth(); |
| 721 } |
| 722 m_intrinsicSizeAlongMainAxis.set(&child, mainSize); |
| 723 } |
| 724 |
| 710 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child,
ChildLayoutType childLayoutType) | 725 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child,
ChildLayoutType childLayoutType) |
| 711 { | 726 { |
| 712 child.clearOverrideSize(); | 727 child.clearOverrideSize(); |
| 713 | 728 |
| 714 if (child.isImage() || child.isVideo() || child.isCanvas()) | 729 if (child.isImage() || child.isVideo() || child.isCanvas()) |
| 715 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 730 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
| 716 | 731 |
| 717 Length flexBasis = flexBasisForChild(child); | 732 Length flexBasis = flexBasisForChild(child); |
| 718 if (mainAxisLengthIsDefinite(child, flexBasis)) | 733 if (mainAxisLengthIsDefinite(child, flexBasis)) |
| 719 return std::max(LayoutUnit(), computeMainAxisExtentForChild(child, MainO
rPreferredSize, flexBasis)); | 734 return std::max(LayoutUnit(), computeMainAxisExtentForChild(child, MainO
rPreferredSize, flexBasis)); |
| 720 | 735 |
| 721 LayoutUnit mainAxisExtent; | 736 LayoutUnit mainAxisExtent; |
| 722 if (childFlexBaseSizeRequiresLayout(child)) { | 737 if (childFlexBaseSizeRequiresLayout(child)) { |
| 723 if (childLayoutType == NeverLayout) | 738 if (childLayoutType == NeverLayout) |
| 724 return LayoutUnit(); | 739 return LayoutUnit(); |
| 725 | 740 |
| 726 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intrinsi
cSizeAlongMainAxis.contains(&child)) { | 741 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intrinsi
cSizeAlongMainAxis.contains(&child)) { |
| 727 child.forceChildLayout(); | 742 child.forceChildLayout(); |
| 728 m_intrinsicSizeAlongMainAxis.set(&child, hasOrthogonalFlow(child) ?
child.logicalHeight() : child.logicalWidth()); | 743 cacheChildMainSize(child); |
| 729 } | 744 } |
| 730 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); | 745 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); |
| 731 } else { | 746 } else { |
| 732 // We don't need to add scrollbarLogicalWidth here. For overflow: scroll
, the preferred width | 747 // We don't need to add scrollbarLogicalWidth here. For overflow: scroll
, the preferred width |
| 733 // already includes the scrollbar size (via intrinsicScrollbarLogicalWid
th()). For overflow: auto, | 748 // already includes the scrollbar size (via intrinsicScrollbarLogicalWid
th()). For overflow: auto, |
| 734 // childFlexBaseSizeRequiresLayout returns true and we handle that via t
he other branch | 749 // childFlexBaseSizeRequiresLayout returns true and we handle that via t
he other branch |
| 735 // of this if. | 750 // of this if. |
| 736 mainAxisExtent = child.maxPreferredLogicalWidth(); | 751 mainAxisExtent = child.maxPreferredLogicalWidth(); |
| 737 } | 752 } |
| 738 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); | 753 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 orderedChildren.append(child); | 1048 orderedChildren.append(child); |
| 1034 continue; | 1049 continue; |
| 1035 } | 1050 } |
| 1036 | 1051 |
| 1037 // If this condition is true, then computeMainAxisExtentForChild will ca
ll child.contentLogicalHeight() | 1052 // If this condition is true, then computeMainAxisExtentForChild will ca
ll child.contentLogicalHeight() |
| 1038 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min
/max/preferred size, | 1053 // and child.scrollbarLogicalHeight(), so if the child has intrinsic min
/max/preferred size, |
| 1039 // run layout on it now to make sure its logical height and scroll bars
are up-to-date. | 1054 // run layout on it now to make sure its logical height and scroll bars
are up-to-date. |
| 1040 if (childHasIntrinsicMainAxisSize(*child) && child->needsLayout()) { | 1055 if (childHasIntrinsicMainAxisSize(*child) && child->needsLayout()) { |
| 1041 child->clearOverrideSize(); | 1056 child->clearOverrideSize(); |
| 1042 child->layoutIfNeeded(); | 1057 child->layoutIfNeeded(); |
| 1043 // Keep our cache up-to-date | 1058 cacheChildMainSize(*child); |
| 1044 m_intrinsicSizeAlongMainAxis.set(child, hasOrthogonalFlow(*child) ?
child->logicalHeight() : child->logicalWidth()); | |
| 1045 } | 1059 } |
| 1046 | 1060 |
| 1047 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*ch
ild, relayoutChildren ? ForceLayout : LayoutIfNeeded); | 1061 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(*ch
ild, relayoutChildren ? ForceLayout : LayoutIfNeeded); |
| 1048 LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx
tentForChild(*child) | 1062 LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingEx
tentForChild(*child) |
| 1049 + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight()
); | 1063 + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight()
); |
| 1050 LayoutUnit childOuterFlexBaseSize = childInnerFlexBaseSize + childMainAx
isMarginBorderPadding; | 1064 LayoutUnit childOuterFlexBaseSize = childInnerFlexBaseSize + childMainAx
isMarginBorderPadding; |
| 1051 | 1065 |
| 1052 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa
x(*child, childInnerFlexBaseSize); | 1066 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMa
x(*child, childInnerFlexBaseSize); |
| 1053 LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent
+ childMainAxisMarginBorderPadding; | 1067 LayoutUnit childHypotheticalMainSize = childMinMaxAppliedMainAxisExtent
+ childMainAxisMarginBorderPadding; |
| 1054 | 1068 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 ASSERT(child); | 1637 ASSERT(child); |
| 1624 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1638 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1625 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1639 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1626 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1640 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1627 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1641 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1628 } | 1642 } |
| 1629 } | 1643 } |
| 1630 } | 1644 } |
| 1631 | 1645 |
| 1632 } // namespace blink | 1646 } // namespace blink |
| OLD | NEW |