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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 child.setLocationAndUpdateOverflowControlsIfNeeded(location); | 584 child.setLocationAndUpdateOverflowControlsIfNeeded(location); |
585 else | 585 else |
586 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo
int()); | 586 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo
int()); |
587 } | 587 } |
588 | 588 |
589 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(LayoutBox&
child) const | 589 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(LayoutBox&
child) const |
590 { | 590 { |
591 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP
addingHeight(); | 591 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP
addingHeight(); |
592 } | 592 } |
593 | 593 |
594 bool LayoutFlexibleBox::mainAxisLengthIsIndefinite(LayoutBox& child, const Lengt
h& flexBasis) const | 594 bool LayoutFlexibleBox::mainAxisLengthIsDefinite(LayoutBox& child, const Length&
flexBasis) const |
595 { | 595 { |
596 if (flexBasis.isAuto()) | 596 if (flexBasis.isAuto()) |
597 return true; | 597 return false; |
598 if (flexBasis.hasPercent()) { | 598 if (flexBasis.hasPercent()) { |
599 return isColumnFlow() ? | 599 return isColumnFlow() ? |
600 child.computePercentageLogicalHeight(flexBasis) == -1 : | 600 child.computePercentageLogicalHeight(flexBasis) != -1 : |
601 !hasDefiniteLogicalWidth(); | 601 hasDefiniteLogicalWidth(); |
602 } | 602 } |
603 // FIXME(cbiesinger): Is this correct? | 603 // FIXME(cbiesinger): Is this correct? |
604 return false; | 604 return true; |
605 } | 605 } |
606 | 606 |
607 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(LayoutBox& child) const | 607 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(LayoutBox& child) const |
608 { | 608 { |
609 return mainAxisLengthIsIndefinite(child, flexBasisForChild(child)) && hasOrt
hogonalFlow(child); | 609 return !mainAxisLengthIsDefinite(child, flexBasisForChild(child)) && hasOrth
ogonalFlow(child); |
610 } | 610 } |
611 | 611 |
612 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child,
ChildLayoutType childLayoutType) | 612 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child,
ChildLayoutType childLayoutType) |
613 { | 613 { |
614 child.clearOverrideSize(); | 614 child.clearOverrideSize(); |
615 | 615 |
616 if (child.isImage() || child.isVideo() || child.isCanvas()) | 616 if (child.isImage() || child.isVideo() || child.isCanvas()) |
617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
618 | 618 |
619 Length flexBasis = flexBasisForChild(child); | 619 Length flexBasis = flexBasisForChild(child); |
620 if (mainAxisLengthIsIndefinite(child, flexBasis)) { | 620 if (!mainAxisLengthIsDefinite(child, flexBasis)) { |
621 LayoutUnit mainAxisExtent; | 621 LayoutUnit mainAxisExtent; |
622 if (hasOrthogonalFlow(child)) { | 622 if (hasOrthogonalFlow(child)) { |
623 if (childLayoutType == NeverLayout) | 623 if (childLayoutType == NeverLayout) |
624 return LayoutUnit(); | 624 return LayoutUnit(); |
625 | 625 |
626 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intr
insicSizeAlongMainAxis.contains(&child)) { | 626 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intr
insicSizeAlongMainAxis.contains(&child)) { |
627 m_intrinsicSizeAlongMainAxis.remove(&child); | 627 m_intrinsicSizeAlongMainAxis.remove(&child); |
628 child.forceChildLayout(); | 628 child.forceChildLayout(); |
629 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight()); | 629 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight()); |
630 } | 630 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 // min size, but we have an indefinite size in that axis. | 857 // min size, but we have an indefinite size in that axis. |
858 minExtent = std::max(LayoutUnit(), minExtent); | 858 minExtent = std::max(LayoutUnit(), minExtent); |
859 } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) ==
OVISIBLE) { | 859 } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) ==
OVISIBLE) { |
860 // css-flexbox section 4.5 | 860 // css-flexbox section 4.5 |
861 LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, L
ength(MinContent)); | 861 LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, L
ength(MinContent)); |
862 ASSERT(contentSize >= 0); | 862 ASSERT(contentSize >= 0); |
863 if (maxExtent != -1 && contentSize > maxExtent) | 863 if (maxExtent != -1 && contentSize > maxExtent) |
864 contentSize = maxExtent; | 864 contentSize = maxExtent; |
865 | 865 |
866 Length mainSize = isHorizontalFlow() ? child.styleRef().width() : child.
styleRef().height(); | 866 Length mainSize = isHorizontalFlow() ? child.styleRef().width() : child.
styleRef().height(); |
867 if (!mainAxisLengthIsIndefinite(child, mainSize)) { | 867 if (mainAxisLengthIsDefinite(child, mainSize)) { |
868 LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, M
ainOrPreferredSize, mainSize); | 868 LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, M
ainOrPreferredSize, mainSize); |
869 ASSERT(resolvedMainSize >= 0); | 869 ASSERT(resolvedMainSize >= 0); |
870 LayoutUnit specifiedSize = maxExtent != -1 ? std::min(resolvedMainSi
ze, maxExtent) : resolvedMainSize; | 870 LayoutUnit specifiedSize = maxExtent != -1 ? std::min(resolvedMainSi
ze, maxExtent) : resolvedMainSize; |
871 | 871 |
872 minExtent = std::min(specifiedSize, contentSize); | 872 minExtent = std::min(specifiedSize, contentSize); |
873 } else { | 873 } else { |
874 minExtent = contentSize; | 874 minExtent = contentSize; |
875 } | 875 } |
876 // TODO(cbiesinger): Implement aspect ratio handling (here, transferred
size) - crbug.com/249112 | 876 // TODO(cbiesinger): Implement aspect ratio handling (here, transferred
size) - crbug.com/249112 |
877 } | 877 } |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 ASSERT(child); | 1447 ASSERT(child); |
1448 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1448 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
1449 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1449 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
1450 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1450 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
1451 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1451 adjustAlignmentForChild(*child, newOffset - originalOffset); |
1452 } | 1452 } |
1453 } | 1453 } |
1454 } | 1454 } |
1455 | 1455 |
1456 } | 1456 } |
OLD | NEW |