Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: Source/core/rendering/RenderFlexibleBox.cpp

Issue 343103003: Flexbox: Allow intrinsic aspect ratios to inform main-size calculation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP Patch Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi s, bool hasInfiniteLineLength) 624 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi s, bool hasInfiniteLineLength)
625 { 625 {
626 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); 626 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength);
627 } 627 }
628 628
629 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const 629 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const
630 { 630 {
631 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); 631 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child);
632 } 632 }
633 633
634 bool RenderFlexibleBox::childHasFiniteCrossSize(RenderBox* child) const
635 {
636 if (child->style()->logicalHeight().isAuto())
637 return false;
638 if (child->style()->logicalHeight().isPercent() && !style()->logicalHeight() .isFixed())
639 return false;
640 return true;
641 }
642
634 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) 643 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren)
635 { 644 {
636 child->clearOverrideSize(); 645 child->clearOverrideSize();
637 646
638 Length flexBasis = flexBasisForChild(child); 647 Length flexBasis = flexBasisForChild(child);
648 if (child->style()->hasAspectRatio() && flexBasis.isAuto() && childHasFinite CrossSize(child))
649 return child->style()->aspectRatio() * crossAxisIntrinsicExtentForChild( child);
639 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { 650 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) {
640 LayoutUnit mainAxisExtent; 651 LayoutUnit mainAxisExtent;
641 if (hasOrthogonalFlow(child)) { 652 if (hasOrthogonalFlow(child)) {
642 if (child->needsLayout() || relayoutChildren) { 653 if (child->needsLayout() || relayoutChildren) {
643 m_intrinsicSizeAlongMainAxis.remove(child); 654 m_intrinsicSizeAlongMainAxis.remove(child);
644 child->forceChildLayout(); 655 child->forceChildLayout();
645 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); 656 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight());
646 } 657 }
647 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); 658 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child));
648 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); 659 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 ASSERT(child); 1430 ASSERT(child);
1420 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1431 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1421 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1432 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1422 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1433 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1423 adjustAlignmentForChild(child, newOffset - originalOffset); 1434 adjustAlignmentForChild(child, newOffset - originalOffset);
1424 } 1435 }
1425 } 1436 }
1426 } 1437 }
1427 1438
1428 } 1439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698