| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const LayoutUnit innerFlexBaseSize; | 83 const LayoutUnit innerFlexBaseSize; |
| 84 const LayoutUnit hypotheticalMainSize; | 84 const LayoutUnit hypotheticalMainSize; |
| 85 LayoutUnit flexedContentSize; | 85 LayoutUnit flexedContentSize; |
| 86 bool frozen; | 86 bool frozen; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 LayoutFlexibleBox::LayoutFlexibleBox(Element* element) | 89 LayoutFlexibleBox::LayoutFlexibleBox(Element* element) |
| 90 : LayoutBlock(element) | 90 : LayoutBlock(element) |
| 91 , m_orderIterator(this) | 91 , m_orderIterator(this) |
| 92 , m_numberOfInFlowChildrenOnFirstLine(-1) | 92 , m_numberOfInFlowChildrenOnFirstLine(-1) |
| 93 , m_hasDefiniteHeight(SizeDefiniteness::Unknown) |
| 93 { | 94 { |
| 94 ASSERT(!childrenInline()); | 95 ASSERT(!childrenInline()); |
| 95 } | 96 } |
| 96 | 97 |
| 97 LayoutFlexibleBox::~LayoutFlexibleBox() | 98 LayoutFlexibleBox::~LayoutFlexibleBox() |
| 98 { | 99 { |
| 99 } | 100 } |
| 100 | 101 |
| 101 LayoutFlexibleBox* LayoutFlexibleBox::createAnonymous(Document* document) | 102 LayoutFlexibleBox* LayoutFlexibleBox::createAnonymous(Document* document) |
| 102 { | 103 { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 computeOverflow(clientLogicalBottomAfterRepositioning()); | 374 computeOverflow(clientLogicalBottomAfterRepositioning()); |
| 374 } | 375 } |
| 375 | 376 |
| 376 updateLayerTransformAfterLayout(); | 377 updateLayerTransformAfterLayout(); |
| 377 | 378 |
| 378 // Update our scroll information if we're overflow:auto/scroll/hidden now th
at we know if | 379 // Update our scroll information if we're overflow:auto/scroll/hidden now th
at we know if |
| 379 // we overflow or not. | 380 // we overflow or not. |
| 380 updateAfterLayout(); | 381 updateAfterLayout(); |
| 381 | 382 |
| 382 clearNeedsLayout(); | 383 clearNeedsLayout(); |
| 384 |
| 385 // We have to reset this, because changes to our ancestors' style |
| 386 // can affect this value. |
| 387 m_hasDefiniteHeight = SizeDefiniteness::Unknown; |
| 383 } | 388 } |
| 384 | 389 |
| 385 void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) const | 390 void LayoutFlexibleBox::paintChildren(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) const |
| 386 { | 391 { |
| 387 BlockPainter::paintChildrenOfFlexibleBox(*this, paintInfo, paintOffset); | 392 BlockPainter::paintChildrenOfFlexibleBox(*this, paintInfo, paintOffset); |
| 388 } | 393 } |
| 389 | 394 |
| 390 void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineCon
text>& lineContexts) | 395 void LayoutFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineCon
text>& lineContexts) |
| 391 { | 396 { |
| 392 LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? LayoutUnit() : line
Contexts[0].crossAxisOffset; | 397 LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? LayoutUnit() : line
Contexts[0].crossAxisOffset; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(const Layou
tBox& child) const | 767 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(const Layou
tBox& child) const |
| 763 { | 768 { |
| 764 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP
addingHeight(); | 769 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP
addingHeight(); |
| 765 } | 770 } |
| 766 | 771 |
| 767 bool LayoutFlexibleBox::mainAxisLengthIsDefinite(const LayoutBox& child, const L
ength& flexBasis) const | 772 bool LayoutFlexibleBox::mainAxisLengthIsDefinite(const LayoutBox& child, const L
ength& flexBasis) const |
| 768 { | 773 { |
| 769 if (flexBasis.isAuto()) | 774 if (flexBasis.isAuto()) |
| 770 return false; | 775 return false; |
| 771 if (flexBasis.hasPercent()) { | 776 if (flexBasis.hasPercent()) { |
| 772 return isColumnFlow() ? | 777 if (!isColumnFlow() || m_hasDefiniteHeight == SizeDefiniteness::Definite
) |
| 773 child.computePercentageLogicalHeight(flexBasis) != -1 : | 778 return true; |
| 774 true; | 779 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) |
| 780 return false; |
| 781 bool definite = child.computePercentageLogicalHeight(flexBasis) != -1; |
| 782 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; |
| 783 return definite; |
| 775 } | 784 } |
| 776 return true; | 785 return true; |
| 777 } | 786 } |
| 778 | 787 |
| 779 bool LayoutFlexibleBox::crossAxisLengthIsDefinite(const LayoutBox& child, const
Length& length) const | 788 bool LayoutFlexibleBox::crossAxisLengthIsDefinite(const LayoutBox& child, const
Length& length) const |
| 780 { | 789 { |
| 781 if (length.isAuto()) | 790 if (length.isAuto()) |
| 782 return false; | 791 return false; |
| 783 if (length.hasPercent()) { | 792 if (length.hasPercent()) { |
| 784 return hasOrthogonalFlow(child) ? | 793 if (hasOrthogonalFlow(child) || m_hasDefiniteHeight == SizeDefiniteness:
:Definite) |
| 785 true : | 794 return true; |
| 786 child.computePercentageLogicalHeight(length) != -1; | 795 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) |
| 796 return false; |
| 797 bool definite = child.computePercentageLogicalHeight(length) != -1; |
| 798 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; |
| 799 return definite; |
| 787 } | 800 } |
| 788 // TODO(cbiesinger): Eventually we should support other types of sizes here.
Requires updating | 801 // TODO(cbiesinger): Eventually we should support other types of sizes here.
Requires updating |
| 789 // computeMainSizeFromAspectRatioUsing. | 802 // computeMainSizeFromAspectRatioUsing. |
| 790 return length.isFixed(); | 803 return length.isFixed(); |
| 791 } | 804 } |
| 792 | 805 |
| 793 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(const LayoutBox& child)
const | 806 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(const LayoutBox& child)
const |
| 794 { | 807 { |
| 795 return (!mainAxisLengthIsDefinite(child, flexBasisForChild(child)) | 808 return (!mainAxisLengthIsDefinite(child, flexBasisForChild(child)) |
| 796 && (hasOrthogonalFlow(child) | 809 && (hasOrthogonalFlow(child) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 // 2) of the flexbox spec. | 1153 // 2) of the flexbox spec. |
| 1141 // We need to check for the flexbox to have a definite main size, and for th
e | 1154 // We need to check for the flexbox to have a definite main size, and for th
e |
| 1142 // flex item to have a definite flex basis. | 1155 // flex item to have a definite flex basis. |
| 1143 const Length& flexBasis = flexBasisForChild(child); | 1156 const Length& flexBasis = flexBasisForChild(child); |
| 1144 if (!mainAxisLengthIsDefinite(child, flexBasis)) | 1157 if (!mainAxisLengthIsDefinite(child, flexBasis)) |
| 1145 return LayoutUnit(-1); | 1158 return LayoutUnit(-1); |
| 1146 if (!flexBasis.hasPercent()) { | 1159 if (!flexBasis.hasPercent()) { |
| 1147 // If flex basis had a percentage, our size is guaranteed to be definite
or the flex item's | 1160 // If flex basis had a percentage, our size is guaranteed to be definite
or the flex item's |
| 1148 // size could not be definite. | 1161 // size could not be definite. |
| 1149 // Otherwise, we make up a percentage to check whether we have a definit
e size. | 1162 // Otherwise, we make up a percentage to check whether we have a definit
e size. |
| 1150 // TODO(cbiesinger): cache this somewhere | |
| 1151 if (!mainAxisLengthIsDefinite(child, Length(0, Percent))) | 1163 if (!mainAxisLengthIsDefinite(child, Length(0, Percent))) |
| 1152 return LayoutUnit(-1); | 1164 return LayoutUnit(-1); |
| 1153 } | 1165 } |
| 1154 | 1166 |
| 1155 if (hasOrthogonalFlow(child)) | 1167 if (hasOrthogonalFlow(child)) |
| 1156 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo
ntentHeight() : LayoutUnit(-1); | 1168 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo
ntentHeight() : LayoutUnit(-1); |
| 1157 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent
Width() : LayoutUnit(-1); | 1169 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent
Width() : LayoutUnit(-1); |
| 1158 } | 1170 } |
| 1159 | 1171 |
| 1160 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La
youtBox& child) | 1172 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La
youtBox& child) |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 ASSERT(child); | 1898 ASSERT(child); |
| 1887 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1899 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1888 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1900 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1889 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1901 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1890 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1902 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1891 } | 1903 } |
| 1892 } | 1904 } |
| 1893 } | 1905 } |
| 1894 | 1906 |
| 1895 } // namespace blink | 1907 } // namespace blink |
| OLD | NEW |