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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 else | 572 else |
573 child->setOverrideWidth(childPreferredSize); | 573 child->setOverrideWidth(childPreferredSize); |
574 } | 574 } |
575 | 575 |
576 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout
Unit mainAxisOffset, LayoutUnit crossAxisOffset) | 576 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout
Unit mainAxisOffset, LayoutUnit crossAxisOffset) |
577 { | 577 { |
578 ASSERT(child->isPositioned()); | 578 ASSERT(child->isPositioned()); |
579 child->containingBlock()->insertPositionedObject(child); | 579 child->containingBlock()->insertPositionedObject(child); |
580 RenderLayer* childLayer = child->layer(); | 580 RenderLayer* childLayer = child->layer(); |
581 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
t; | 581 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
t; |
582 if (style()->flexDirection() == FlowRowReverse) | 582 if (style()->flexFlow() == FlowRowReverse) |
583 inlinePosition = mainAxisExtent() - mainAxisOffset; | 583 inlinePosition = mainAxisExtent() - mainAxisOffset; |
584 childLayer->setStaticInlinePosition(inlinePosition); // FIXME: Not right for
regions. | 584 childLayer->setStaticInlinePosition(inlinePosition); // FIXME: Not right for
regions. |
585 | 585 |
586 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; | 586 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; |
587 if (childLayer->staticBlockPosition() != staticBlockPosition) { | 587 if (childLayer->staticBlockPosition() != staticBlockPosition) { |
588 childLayer->setStaticBlockPosition(staticBlockPosition); | 588 childLayer->setStaticBlockPosition(staticBlockPosition); |
589 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) | 589 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) |
590 child->setChildNeedsLayout(true, false); | 590 child->setChildNeedsLayout(true, false); |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 void RenderFlexibleBox::layoutAndPlaceChildren(FlexOrderIterator& iterator, cons
t WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float tota
lPositiveFlexibility) | 594 void RenderFlexibleBox::layoutAndPlaceChildren(FlexOrderIterator& iterator, cons
t WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float tota
lPositiveFlexibility) |
595 { | 595 { |
596 LayoutUnit startEdge = flowAwareBorderStart() + flowAwarePaddingStart(); | 596 LayoutUnit startEdge = flowAwareBorderStart() + flowAwarePaddingStart(); |
597 | 597 |
598 if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) { | 598 if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) { |
599 if (style()->flexPack() == PackEnd) | 599 if (style()->flexPack() == PackEnd) |
600 startEdge += availableFreeSpace; | 600 startEdge += availableFreeSpace; |
601 else if (style()->flexPack() == PackCenter) | 601 else if (style()->flexPack() == PackCenter) |
602 startEdge += availableFreeSpace / 2; | 602 startEdge += availableFreeSpace / 2; |
603 } | 603 } |
604 | 604 |
605 LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore(); | 605 LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore(); |
606 LayoutUnit totalMainExtent = mainAxisExtent(); | 606 LayoutUnit totalMainExtent = mainAxisExtent(); |
607 LayoutUnit maxAscent = 0, maxDescent = 0; // Used when flex-align: baseline. | 607 LayoutUnit maxAscent = 0, maxDescent = 0; // Used when flex-align: baseline. |
608 size_t i = 0; | 608 size_t i = 0; |
609 for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++
i) { | 609 for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++
i) { |
610 if (child->isPositioned()) { | 610 if (child->isPositioned()) { |
611 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
et); | 611 prepareChildForPositionedLayout(child, startEdge, logicalTop); |
612 mainAxisOffset += packingSpaceBetweenChildren(availableFreeSpace, to
talPositiveFlexibility, style()->flexPack(), childSizes.size()); | 612 if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) &&
style()->flexPack() == PackJustify && childSizes.size() > 1) |
| 613 startEdge += availableFreeSpace / (childSizes.size() - 1); |
613 continue; | 614 continue; |
614 } | 615 } |
615 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); | 616 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); |
616 setLogicalOverrideSize(child, childPreferredSize); | 617 setLogicalOverrideSize(child, childPreferredSize); |
617 child->setChildNeedsLayout(true); | 618 child->setChildNeedsLayout(true); |
618 child->layoutIfNeeded(); | 619 child->layoutIfNeeded(); |
619 | 620 |
620 if (child->style()->flexAlign() == AlignBaseline) { | 621 if (child->style()->flexAlign() == AlignBaseline) { |
621 LayoutUnit ascent = marginBoxAscent(child); | 622 LayoutUnit ascent = marginBoxAscent(child); |
622 LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(child)) - ascent; | 623 LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(child)) - ascent; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 case AlignBaseline: { | 697 case AlignBaseline: { |
697 LayoutUnit ascent = marginBoxAscent(child); | 698 LayoutUnit ascent = marginBoxAscent(child); |
698 adjustAlignmentForChild(child, maxAscent - ascent); | 699 adjustAlignmentForChild(child, maxAscent - ascent); |
699 break; | 700 break; |
700 } | 701 } |
701 } | 702 } |
702 } | 703 } |
703 } | 704 } |
704 | 705 |
705 } | 706 } |
OLD | NEW |