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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 LayoutBox* child; | 68 LayoutBox* child; |
69 LayoutUnit childSize; | 69 LayoutUnit childSize; |
70 }; | 70 }; |
71 | 71 |
72 | 72 |
73 LayoutFlexibleBox::LayoutFlexibleBox(Element* element) | 73 LayoutFlexibleBox::LayoutFlexibleBox(Element* element) |
74 : LayoutBlock(element) | 74 : LayoutBlock(element) |
75 , m_orderIterator(this) | 75 , m_orderIterator(this) |
76 , m_numberOfInFlowChildrenOnFirstLine(-1) | 76 , m_numberOfInFlowChildrenOnFirstLine(-1) |
| 77 , m_originalAvailableFreeSpaceInitialized(false) |
| 78 , m_originalAvailableFreeSpace(0) |
77 { | 79 { |
78 ASSERT(!childrenInline()); | 80 ASSERT(!childrenInline()); |
79 } | 81 } |
80 | 82 |
81 LayoutFlexibleBox::~LayoutFlexibleBox() | 83 LayoutFlexibleBox::~LayoutFlexibleBox() |
82 { | 84 { |
83 } | 85 } |
84 | 86 |
85 LayoutFlexibleBox* LayoutFlexibleBox::createAnonymous(Document* document) | 87 LayoutFlexibleBox* LayoutFlexibleBox::createAnonymous(Document* document) |
86 { | 88 { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 for (size_t i = 0; i < children.size(); ++i) { | 956 for (size_t i = 0; i < children.size(); ++i) { |
955 LayoutBox* child = children[i]; | 957 LayoutBox* child = children[i]; |
956 if (child->isOutOfFlowPositioned()) { | 958 if (child->isOutOfFlowPositioned()) { |
957 childSizes.append(0); | 959 childSizes.append(0); |
958 continue; | 960 continue; |
959 } | 961 } |
960 | 962 |
961 if (inflexibleItems.contains(child)) { | 963 if (inflexibleItems.contains(child)) { |
962 childSizes.append(inflexibleItems.get(child)); | 964 childSizes.append(inflexibleItems.get(child)); |
963 } else { | 965 } else { |
| 966 if (!m_originalAvailableFreeSpaceInitialized) { |
| 967 m_originalAvailableFreeSpace = availableFreeSpace; |
| 968 m_originalAvailableFreeSpaceInitialized = true; |
| 969 } |
| 970 if (totalFlexGrow < 1.0f) { |
| 971 LayoutUnit desiredPortionOfOriginalFreeSpace = LayoutUnit(m_orig
inalAvailableFreeSpace * totalFlexGrow); |
| 972 if (availableFreeSpace > 0) |
| 973 availableFreeSpace = std::min(availableFreeSpace, desiredPor
tionOfOriginalFreeSpace); |
| 974 else |
| 975 availableFreeSpace = std::max(availableFreeSpace, desiredPor
tionOfOriginalFreeSpace); |
| 976 } |
| 977 |
964 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild
(*child); | 978 LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild
(*child); |
965 LayoutUnit childSize = childInnerFlexBaseSize; | 979 LayoutUnit childSize = childInnerFlexBaseSize; |
966 double extraSpace = 0; | 980 double extraSpace = 0; |
967 bool childShrunk = false; | 981 bool childShrunk = false; |
968 if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == Posit
iveFlexibility && std::isfinite(totalFlexGrow)) { | 982 if (availableFreeSpace > 0 && totalFlexGrow > 0 && flexSign == Posit
iveFlexibility && std::isfinite(totalFlexGrow)) { |
969 extraSpace = availableFreeSpace * child->style()->flexGrow() / t
otalFlexGrow; | 983 extraSpace = availableFreeSpace * child->style()->flexGrow() / t
otalFlexGrow; |
970 } else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 &&
flexSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink) && chi
ld->style()->flexShrink()) { | 984 } else if (availableFreeSpace < 0 && totalWeightedFlexShrink > 0 &&
flexSign == NegativeFlexibility && std::isfinite(totalWeightedFlexShrink) && chi
ld->style()->flexShrink()) { |
971 extraSpace = availableFreeSpace * child->style()->flexShrink() *
childInnerFlexBaseSize / totalWeightedFlexShrink; | 985 extraSpace = availableFreeSpace * child->style()->flexShrink() *
childInnerFlexBaseSize / totalWeightedFlexShrink; |
972 childShrunk = true; | 986 childShrunk = true; |
973 } | 987 } |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 ASSERT(child); | 1471 ASSERT(child); |
1458 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1472 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
1459 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1473 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
1460 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1474 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
1461 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1475 adjustAlignmentForChild(*child, newOffset - originalOffset); |
1462 } | 1476 } |
1463 } | 1477 } |
1464 } | 1478 } |
1465 | 1479 |
1466 } | 1480 } |
OLD | NEW |