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

Side by Side Diff: Source/core/layout/LayoutFlexibleBox.cpp

Issue 1258693005: [css-flexbox] Correctly determine whether a percentage height is definite (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix tests Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return child.size().height(); 356 return child.size().height();
357 } 357 }
358 358
359 LayoutUnit LayoutFlexibleBox::childIntrinsicWidth(LayoutBox& child) const 359 LayoutUnit LayoutFlexibleBox::childIntrinsicWidth(LayoutBox& child) const
360 { 360 {
361 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil d)) 361 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil d))
362 return constrainedChildIntrinsicContentLogicalHeight(child); 362 return constrainedChildIntrinsicContentLogicalHeight(child);
363 return child.size().width(); 363 return child.size().width();
364 } 364 }
365 365
366 bool LayoutFlexibleBox::mainAxisExtentIsDefinite() const
367 {
368 return isColumnFlow() ? hasDefiniteLogicalHeight() : hasDefiniteLogicalWidth ();
369 }
370
371 LayoutUnit LayoutFlexibleBox::crossAxisIntrinsicExtentForChild(LayoutBox& child) const 366 LayoutUnit LayoutFlexibleBox::crossAxisIntrinsicExtentForChild(LayoutBox& child) const
372 { 367 {
373 return isHorizontalFlow() ? childIntrinsicHeight(child) : childIntrinsicWidt h(child); 368 return isHorizontalFlow() ? childIntrinsicHeight(child) : childIntrinsicWidt h(child);
374 } 369 }
375 370
376 LayoutUnit LayoutFlexibleBox::mainAxisExtentForChild(LayoutBox& child) const 371 LayoutUnit LayoutFlexibleBox::mainAxisExtentForChild(LayoutBox& child) const
377 { 372 {
378 return isHorizontalFlow() ? child.size().width() : child.size().height(); 373 return isHorizontalFlow() ? child.size().width() : child.size().height();
379 } 374 }
380 375
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 child.setLocationAndUpdateOverflowControlsIfNeeded(location); 584 child.setLocationAndUpdateOverflowControlsIfNeeded(location);
590 else 585 else
591 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo int()); 586 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo int());
592 } 587 }
593 588
594 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(LayoutBox& child) const 589 LayoutUnit LayoutFlexibleBox::mainAxisBorderAndPaddingExtentForChild(LayoutBox& child) const
595 { 590 {
596 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP addingHeight(); 591 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndP addingHeight();
597 } 592 }
598 593
599 bool LayoutFlexibleBox::mainAxisLengthIsIndefinite(const Length& flexBasis) cons t 594 bool LayoutFlexibleBox::mainAxisLengthIsIndefinite(LayoutBox& child, const Lengt h& flexBasis) const
leviw_travelin_and_unemployed 2015/08/05 00:06:25 Maybe a TODO change this to definite :p
cbiesinger 2015/08/05 04:46:38 https://codereview.chromium.org/1268253002/
600 { 595 {
601 return flexBasis.isAuto() || (flexBasis.hasPercent() && !mainAxisExtentIsDef inite()); 596 if (flexBasis.isAuto())
597 return true;
598 if (flexBasis.hasPercent()) {
599 return isColumnFlow() ?
600 child.computePercentageLogicalHeight(flexBasis) == -1 :
601 !hasDefiniteLogicalWidth();
602 }
603 // FIXME(cbiesinger): Is this correct?
604 return false;
602 } 605 }
603 606
604 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(LayoutBox& child) const 607 bool LayoutFlexibleBox::childFlexBaseSizeRequiresLayout(LayoutBox& child) const
605 { 608 {
606 return mainAxisLengthIsIndefinite(flexBasisForChild(child)) && hasOrthogonal Flow(child); 609 return mainAxisLengthIsIndefinite(child, flexBasisForChild(child)) && hasOrt hogonalFlow(child);
607 } 610 }
608 611
609 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child, ChildLayoutType childLayoutType) 612 LayoutUnit LayoutFlexibleBox::computeInnerFlexBaseSizeForChild(LayoutBox& child, ChildLayoutType childLayoutType)
610 { 613 {
611 child.clearOverrideSize(); 614 child.clearOverrideSize();
612 615
613 if (child.isImage() || child.isVideo() || child.isCanvas()) 616 if (child.isImage() || child.isVideo() || child.isCanvas())
614 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); 617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem);
615 618
616 Length flexBasis = flexBasisForChild(child); 619 Length flexBasis = flexBasisForChild(child);
617 if (mainAxisLengthIsIndefinite(flexBasis)) { 620 if (mainAxisLengthIsIndefinite(child, flexBasis)) {
618 LayoutUnit mainAxisExtent; 621 LayoutUnit mainAxisExtent;
619 if (hasOrthogonalFlow(child)) { 622 if (hasOrthogonalFlow(child)) {
620 if (childLayoutType == NeverLayout) 623 if (childLayoutType == NeverLayout)
621 return LayoutUnit(); 624 return LayoutUnit();
622 625
623 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intr insicSizeAlongMainAxis.contains(&child)) { 626 if (child.needsLayout() || childLayoutType == ForceLayout || !m_intr insicSizeAlongMainAxis.contains(&child)) {
624 m_intrinsicSizeAlongMainAxis.remove(&child); 627 m_intrinsicSizeAlongMainAxis.remove(&child);
625 child.forceChildLayout(); 628 child.forceChildLayout();
626 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight()); 629 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight());
627 } 630 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // min size, but we have an indefinite size in that axis. 857 // min size, but we have an indefinite size in that axis.
855 minExtent = std::max(LayoutUnit(), minExtent); 858 minExtent = std::max(LayoutUnit(), minExtent);
856 } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) { 859 } else if (childShrunk && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE) {
857 // css-flexbox section 4.5 860 // css-flexbox section 4.5
858 LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, L ength(MinContent)); 861 LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, L ength(MinContent));
859 ASSERT(contentSize >= 0); 862 ASSERT(contentSize >= 0);
860 if (maxExtent != -1 && contentSize > maxExtent) 863 if (maxExtent != -1 && contentSize > maxExtent)
861 contentSize = maxExtent; 864 contentSize = maxExtent;
862 865
863 Length mainSize = isHorizontalFlow() ? child.styleRef().width() : child. styleRef().height(); 866 Length mainSize = isHorizontalFlow() ? child.styleRef().width() : child. styleRef().height();
864 if (!mainAxisLengthIsIndefinite(mainSize)) { 867 if (!mainAxisLengthIsIndefinite(child, mainSize)) {
865 LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, M ainOrPreferredSize, mainSize); 868 LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, M ainOrPreferredSize, mainSize);
866 ASSERT(resolvedMainSize >= 0); 869 ASSERT(resolvedMainSize >= 0);
867 LayoutUnit specifiedSize = maxExtent != -1 ? std::min(resolvedMainSi ze, maxExtent) : resolvedMainSize; 870 LayoutUnit specifiedSize = maxExtent != -1 ? std::min(resolvedMainSi ze, maxExtent) : resolvedMainSize;
868 871
869 minExtent = std::min(specifiedSize, contentSize); 872 minExtent = std::min(specifiedSize, contentSize);
870 } else { 873 } else {
871 minExtent = contentSize; 874 minExtent = contentSize;
872 } 875 }
873 // 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
874 } 877 }
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 ASSERT(child); 1447 ASSERT(child);
1445 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1448 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1446 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1449 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1447 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1450 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1448 adjustAlignmentForChild(*child, newOffset - originalOffset); 1451 adjustAlignmentForChild(*child, newOffset - originalOffset);
1449 } 1452 }
1450 } 1453 }
1451 } 1454 }
1452 1455
1453 } 1456 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698