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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 } | 807 } |
808 | 808 |
809 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child) | 809 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child) |
810 { | 810 { |
811 LayoutUnit ascent = child->firstLineBoxBaseline(); | 811 LayoutUnit ascent = child->firstLineBoxBaseline(); |
812 if (ascent == -1) | 812 if (ascent == -1) |
813 ascent = crossAxisExtentForChild(child); | 813 ascent = crossAxisExtentForChild(child); |
814 return ascent + flowAwareMarginBeforeForChild(child); | 814 return ascent + flowAwareMarginBeforeForChild(child); |
815 } | 815 } |
816 | 816 |
817 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin, RenderView*
view) | 817 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin) |
818 { | 818 { |
819 // When resolving the margins, we use the content size for resolving percent
and calc (for percents in calc expressions) margins. | 819 // When resolving the margins, we use the content size for resolving percent
and calc (for percents in calc expressions) margins. |
820 // Fortunately, percent margins are always computed with respect to the bloc
k's width, even for margin-top and margin-bottom. | 820 // Fortunately, percent margins are always computed with respect to the bloc
k's width, even for margin-top and margin-bottom. |
821 LayoutUnit availableSize = contentLogicalWidth(); | 821 LayoutUnit availableSize = contentLogicalWidth(); |
822 return minimumValueForLength(margin, availableSize, view); | 822 return minimumValueForLength(margin, availableSize); |
823 } | 823 } |
824 | 824 |
825 void RenderFlexibleBox::prepareOrderIteratorAndMargins() | 825 void RenderFlexibleBox::prepareOrderIteratorAndMargins() |
826 { | 826 { |
827 RenderView* renderView = view(); | |
828 OrderIteratorPopulator populator(m_orderIterator); | 827 OrderIteratorPopulator populator(m_orderIterator); |
829 | 828 |
830 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 829 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
831 populator.collectChild(child); | 830 populator.collectChild(child); |
832 | 831 |
833 if (child->isOutOfFlowPositioned()) | 832 if (child->isOutOfFlowPositioned()) |
834 continue; | 833 continue; |
835 | 834 |
836 // Before running the flex algorithm, 'auto' has a margin of 0. | 835 // Before running the flex algorithm, 'auto' has a margin of 0. |
837 // Also, if we're not auto sizing, we don't do a layout that computes th
e start/end margins. | 836 // Also, if we're not auto sizing, we don't do a layout that computes th
e start/end margins. |
838 if (isHorizontalFlow()) { | 837 if (isHorizontalFlow()) { |
839 child->setMarginLeft(computeChildMarginValue(child->style()->marginL
eft(), renderView)); | 838 child->setMarginLeft(computeChildMarginValue(child->style()->marginL
eft())); |
840 child->setMarginRight(computeChildMarginValue(child->style()->margin
Right(), renderView)); | 839 child->setMarginRight(computeChildMarginValue(child->style()->margin
Right())); |
841 } else { | 840 } else { |
842 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p(), renderView)); | 841 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p())); |
843 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom(), renderView)); | 842 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom())); |
844 } | 843 } |
845 } | 844 } |
846 } | 845 } |
847 | 846 |
848 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) | 847 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) |
849 { | 848 { |
850 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); | 849 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); |
851 if (max.isSpecifiedOrIntrinsic()) { | 850 if (max.isSpecifiedOrIntrinsic()) { |
852 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
); | 851 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
); |
853 if (maxExtent != -1 && childSize > maxExtent) | 852 if (maxExtent != -1 && childSize > maxExtent) |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 ASSERT(child); | 1365 ASSERT(child); |
1367 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1366 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
1368 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1367 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
1369 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1368 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
1370 adjustAlignmentForChild(child, newOffset - originalOffset); | 1369 adjustAlignmentForChild(child, newOffset - originalOffset); |
1371 } | 1370 } |
1372 } | 1371 } |
1373 } | 1372 } |
1374 | 1373 |
1375 } | 1374 } |
OLD | NEW |