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

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

Issue 1870163004: [css-flexbox] slight improvements to mainSizeForPercentageResolution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | 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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1102
1103 LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c hild) 1103 LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c hild)
1104 { 1104 {
1105 // This function implements section 9.8. Definite and Indefinite Sizes, case 1105 // This function implements section 9.8. Definite and Indefinite Sizes, case
1106 // 2) of the flexbox spec. 1106 // 2) of the flexbox spec.
1107 // We need to check for the flexbox to have a definite main size, and for th e 1107 // We need to check for the flexbox to have a definite main size, and for th e
1108 // flex item to have a definite flex basis. 1108 // flex item to have a definite flex basis.
1109 const Length& flexBasis = flexBasisForChild(child); 1109 const Length& flexBasis = flexBasisForChild(child);
1110 if (!mainAxisLengthIsDefinite(child, flexBasis)) 1110 if (!mainAxisLengthIsDefinite(child, flexBasis))
1111 return LayoutUnit(-1); 1111 return LayoutUnit(-1);
1112 LayoutUnit mainSize = isColumnFlow() ? computeDefiniteLogicalHeight() : comp uteDefiniteLogicalWidth(); 1112 if (!flexBasis.hasPercent()) {
1113 if (mainSize == LayoutUnit(-1)) 1113 // If flex basis had a percentage, our size is guaranteed to be definite or the flex item's
1114 return mainSize; 1114 // size could not be definite.
1115 // Otherwise, we make up a percentage to check whether we have a definit e size.
1116 // TODO(cbiesinger): cache this somewhere
1117 if (!mainAxisLengthIsDefinite(child, Length(0, Percent)))
1118 return LayoutUnit(-1);
1119 }
1115 1120
1116 if (hasOrthogonalFlow(child)) 1121 if (hasOrthogonalFlow(child))
1117 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo ntentHeight() : LayoutUnit(-1); 1122 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo ntentHeight() : LayoutUnit(-1);
1118 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent Width() : LayoutUnit(-1); 1123 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent Width() : LayoutUnit(-1);
1119 } 1124 }
1120 1125
1121 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La youtBox& child) 1126 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La youtBox& child)
1122 { 1127 {
1123 if (!hasOrthogonalFlow(child)) 1128 if (!hasOrthogonalFlow(child))
1124 return crossSizeForPercentageResolution(child); 1129 return crossSizeForPercentageResolution(child);
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 ASSERT(child); 1778 ASSERT(child);
1774 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1779 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1775 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1780 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1776 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1781 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1777 adjustAlignmentForChild(*child, newOffset - originalOffset); 1782 adjustAlignmentForChild(*child, newOffset - originalOffset);
1778 } 1783 }
1779 } 1784 }
1780 } 1785 }
1781 1786
1782 } // namespace blink 1787 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698