Chromium Code Reviews| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi s, bool hasInfiniteLineLength) | 601 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi s, bool hasInfiniteLineLength) |
| 602 { | 602 { |
| 603 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); | 603 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); |
| 604 } | 604 } |
| 605 | 605 |
| 606 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const | 606 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const |
| 607 { | 607 { |
| 608 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); | 608 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); |
| 609 } | 609 } |
| 610 | 610 |
| 611 bool RenderFlexibleBox::childHasFiniteCrossSize(RenderBox* child) const | |
| 612 { | |
| 613 if (child->style()->logicalHeight().isFixed()) | |
| 614 return true; | |
| 615 | |
| 616 if (!style()->logicalHeight().isFixed()) | |
| 617 return false; | |
| 618 | |
| 619 if (child->style()->logicalHeight().isPercent()) | |
| 620 return true; | |
| 621 | |
| 622 if (!isMultiline() && needToStretchChildLogicalHeight(child)) | |
| 623 return true; | |
| 624 | |
| 625 return false; | |
| 626 } | |
| 627 | |
| 628 void RenderFlexibleBox::computeAspectRatioOfChild(RenderBox* child, double& aspe ctRatio, bool& hasAspectRatio) | |
|
tony
2014/06/26 16:31:28
The bool seems unnecessary. Set the initial value
harpreet.sk
2014/06/30 09:26:07
Done.
| |
| 629 { | |
| 630 if (child->style()->hasAspectRatio()) { | |
| 631 hasAspectRatio = true; | |
| 632 aspectRatio = child->style()->aspectRatio(); | |
| 633 } else if (child->isRenderImage() && child->intrinsicLogicalHeight()) { | |
|
tony
2014/06/26 16:31:28
Is checking for a RenderImage really the right thi
harpreet.sk
2014/06/30 09:26:07
Sorry only checking for RenderImage is not the rig
| |
| 634 hasAspectRatio = true; | |
| 635 aspectRatio = child->intrinsicLogicalWidth().rawValue() / child->intrins icLogicalHeight().rawValue(); | |
| 636 } | |
| 637 } | |
| 638 | |
| 611 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) | 639 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) |
| 612 { | 640 { |
| 613 child->clearOverrideSize(); | 641 child->clearOverrideSize(); |
| 614 | 642 |
| 615 Length flexBasis = flexBasisForChild(child); | 643 Length flexBasis = flexBasisForChild(child); |
| 644 double aspectRatio = 1.0f; | |
| 645 bool hasAspectRatio = false; | |
| 646 computeAspectRatioOfChild(child, aspectRatio, hasAspectRatio); | |
| 647 | |
| 648 if (hasAspectRatio && flexBasis.isAuto() && childHasFiniteCrossSize(child)) { | |
| 649 if (!isMultiline() && needToStretchChildLogicalHeight(child)) | |
| 650 return aspectRatio * style()->logicalHeight().value(); | |
| 651 return aspectRatio * crossAxisIntrinsicExtentForChild(child); | |
| 652 } | |
| 653 | |
| 616 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { | 654 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { |
| 617 LayoutUnit mainAxisExtent; | 655 LayoutUnit mainAxisExtent; |
| 618 if (hasOrthogonalFlow(child)) { | 656 if (hasOrthogonalFlow(child)) { |
| 619 if (child->needsLayout() || relayoutChildren) { | 657 if (child->needsLayout() || relayoutChildren) { |
| 620 m_intrinsicSizeAlongMainAxis.remove(child); | 658 m_intrinsicSizeAlongMainAxis.remove(child); |
| 621 child->forceChildLayout(); | 659 child->forceChildLayout(); |
| 622 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); | 660 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); |
| 623 } | 661 } |
| 624 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); | 662 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); |
| 625 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); | 663 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1396 ASSERT(child); | 1434 ASSERT(child); |
| 1397 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1435 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
| 1398 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1436 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 1399 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1437 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
| 1400 adjustAlignmentForChild(child, newOffset - originalOffset); | 1438 adjustAlignmentForChild(child, newOffset - originalOffset); |
| 1401 } | 1439 } |
| 1402 } | 1440 } |
| 1403 } | 1441 } |
| 1404 | 1442 |
| 1405 } | 1443 } |
| OLD | NEW |