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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 previousMaxContentFlexFraction = countIntrinsicSizeForAlgorithmChange(ma
xPreferredLogicalWidth, child, previousMaxContentFlexFraction); | 130 previousMaxContentFlexFraction = countIntrinsicSizeForAlgorithmChange(ma
xPreferredLogicalWidth, child, previousMaxContentFlexFraction); |
131 } | 131 } |
132 | 132 |
133 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); | 133 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); |
134 | 134 |
135 // Due to negative margins, it is possible that we calculated a negative int
rinsic width. Make sure that we | 135 // Due to negative margins, it is possible that we calculated a negative int
rinsic width. Make sure that we |
136 // never return a negative width. | 136 // never return a negative width. |
137 minLogicalWidth = std::max(LayoutUnit(), minLogicalWidth); | 137 minLogicalWidth = std::max(LayoutUnit(), minLogicalWidth); |
138 maxLogicalWidth = std::max(LayoutUnit(), maxLogicalWidth); | 138 maxLogicalWidth = std::max(LayoutUnit(), maxLogicalWidth); |
139 | 139 |
140 LayoutUnit scrollbarWidth(intrinsicScrollbarLogicalWidth()); | 140 LayoutUnit scrollbarWidth(scrollbarLogicalWidth()); |
141 maxLogicalWidth += scrollbarWidth; | 141 maxLogicalWidth += scrollbarWidth; |
142 minLogicalWidth += scrollbarWidth; | 142 minLogicalWidth += scrollbarWidth; |
143 } | 143 } |
144 | 144 |
145 float LayoutFlexibleBox::countIntrinsicSizeForAlgorithmChange(LayoutUnit maxPref
erredLogicalWidth, LayoutBox* child, float previousMaxContentFlexFraction) const | 145 float LayoutFlexibleBox::countIntrinsicSizeForAlgorithmChange(LayoutUnit maxPref
erredLogicalWidth, LayoutBox* child, float previousMaxContentFlexFraction) const |
146 { | 146 { |
147 // Determine whether the new version of the intrinsic size algorithm of the
flexbox | 147 // Determine whether the new version of the intrinsic size algorithm of the
flexbox |
148 // spec would produce a different result than our above algorithm. | 148 // spec would produce a different result than our above algorithm. |
149 // The algorithm produces a different result iff the max-content flex fracti
on | 149 // The algorithm produces a different result iff the max-content flex fracti
on |
150 // (as defined in the new algorithm) is not identical for each flex item. | 150 // (as defined in the new algorithm) is not identical for each flex item. |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child) | 789 void LayoutFlexibleBox::cacheChildMainSize(const LayoutBox& child) |
790 { | 790 { |
791 ASSERT(!child.needsLayout()); | 791 ASSERT(!child.needsLayout()); |
792 LayoutUnit mainSize; | 792 LayoutUnit mainSize; |
793 if (hasOrthogonalFlow(child)) { | 793 if (hasOrthogonalFlow(child)) { |
794 mainSize = child.logicalHeight(); | 794 mainSize = child.logicalHeight(); |
795 } else { | 795 } else { |
796 // The max preferred logical width includes the intrinsic scrollbar logi
cal width, which is only set for | 796 // The max preferred logical width includes the intrinsic scrollbar logi
cal width, which is only set for |
797 // overflow: scroll. To handle overflow: auto, we have to take scrollbar
LogicalWidth() into account, and then | 797 // overflow: scroll. To handle overflow: auto, we have to take scrollbar
LogicalWidth() into account, and then |
798 // subtract the intrinsic width again so as to not double-count overflow
: scroll scrollbars. | 798 // subtract the intrinsic width again so as to not double-count overflow
: scroll scrollbars. |
799 mainSize = child.maxPreferredLogicalWidth() + child.scrollbarLogicalWidt
h() - child.intrinsicScrollbarLogicalWidth(); | 799 mainSize = child.maxPreferredLogicalWidth() + child.scrollbarLogicalWidt
h() - child.scrollbarLogicalWidth(); |
800 } | 800 } |
801 m_intrinsicSizeAlongMainAxis.set(&child, mainSize); | 801 m_intrinsicSizeAlongMainAxis.set(&child, mainSize); |
802 m_relaidOutChildren.add(&child); | 802 m_relaidOutChildren.add(&child); |
803 } | 803 } |
804 | 804 |
805 void LayoutFlexibleBox::clearCachedMainSizeForChild(const LayoutBox& child) | 805 void LayoutFlexibleBox::clearCachedMainSizeForChild(const LayoutBox& child) |
806 { | 806 { |
807 m_intrinsicSizeAlongMainAxis.remove(&child); | 807 m_intrinsicSizeAlongMainAxis.remove(&child); |
808 } | 808 } |
809 | 809 |
(...skipping 13 matching lines...) Expand all Loading... |
823 if (childLayoutType == NeverLayout) | 823 if (childLayoutType == NeverLayout) |
824 return LayoutUnit(); | 824 return LayoutUnit(); |
825 | 825 |
826 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intrinsi
cSizeAlongMainAxis.contains(&child)) { | 826 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intrinsi
cSizeAlongMainAxis.contains(&child)) { |
827 child.forceChildLayout(); | 827 child.forceChildLayout(); |
828 cacheChildMainSize(child); | 828 cacheChildMainSize(child); |
829 } | 829 } |
830 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); | 830 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); |
831 } else { | 831 } else { |
832 // We don't need to add scrollbarLogicalWidth here. For overflow: scroll
, the preferred width | 832 // We don't need to add scrollbarLogicalWidth here. For overflow: scroll
, the preferred width |
833 // already includes the scrollbar size (via intrinsicScrollbarLogicalWid
th()). For overflow: auto, | 833 // already includes the scrollbar size (via scrollbarLogicalWidth()). Fo
r overflow: auto, |
834 // childFlexBaseSizeRequiresLayout returns true and we handle that via t
he other branch | 834 // childFlexBaseSizeRequiresLayout returns true and we handle that via t
he other branch |
835 // of this if. | 835 // of this if. |
836 mainAxisExtent = child.maxPreferredLogicalWidth(); | 836 mainAxisExtent = child.maxPreferredLogicalWidth(); |
837 } | 837 } |
838 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); | 838 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); |
839 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); | 839 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); |
840 } | 840 } |
841 | 841 |
842 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, SubtreeLayoutScop
e& layoutScope) | 842 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, SubtreeLayoutScop
e& layoutScope) |
843 { | 843 { |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 ASSERT(child); | 1862 ASSERT(child); |
1863 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1863 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
1864 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1864 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
1865 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1865 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
1866 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1866 adjustAlignmentForChild(*child, newOffset - originalOffset); |
1867 } | 1867 } |
1868 } | 1868 } |
1869 } | 1869 } |
1870 | 1870 |
1871 } // namespace blink | 1871 } // namespace blink |
OLD | NEW |