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

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

Issue 1304853002: Add a use counter to determine compat impact of changing flexbox's intrinsic size calculation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: new function 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 LayoutFlexibleBox* layoutObject = new LayoutFlexibleBox(nullptr); 87 LayoutFlexibleBox* layoutObject = new LayoutFlexibleBox(nullptr);
88 layoutObject->setDocumentForAnonymous(document); 88 layoutObject->setDocumentForAnonymous(document);
89 return layoutObject; 89 return layoutObject;
90 } 90 }
91 91
92 void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt h, LayoutUnit& maxLogicalWidth) const 92 void LayoutFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt h, LayoutUnit& maxLogicalWidth) const
93 { 93 {
94 // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start ho noring it though until 94 // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start ho noring it though until
95 // the flex shorthand stops setting it to 0. 95 // the flex shorthand stops setting it to 0.
96 // See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/2 40765. 96 // See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/2 40765.
97 float previousMaxContentFlexFraction = -1;
97 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 98 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
98 if (child->isOutOfFlowPositioned()) 99 if (child->isOutOfFlowPositioned())
99 continue; 100 continue;
100 101
101 LayoutUnit margin = marginIntrinsicLogicalWidthForChild(*child); 102 LayoutUnit margin = marginIntrinsicLogicalWidthForChild(*child);
102 103
103 LayoutUnit minPreferredLogicalWidth; 104 LayoutUnit minPreferredLogicalWidth;
104 LayoutUnit maxPreferredLogicalWidth; 105 LayoutUnit maxPreferredLogicalWidth;
105 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode(); 106 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode();
106 if (hasOrthogonalWritingMode) { 107 if (hasOrthogonalWritingMode) {
(...skipping 11 matching lines...) Expand all
118 if (isMultiline()) { 119 if (isMultiline()) {
119 // For multiline, the min preferred width is if you put a break between each item. 120 // For multiline, the min preferred width is if you put a break between each item.
120 minLogicalWidth = std::max(minLogicalWidth, minPreferredLogicalW idth); 121 minLogicalWidth = std::max(minLogicalWidth, minPreferredLogicalW idth);
121 } else { 122 } else {
122 minLogicalWidth += minPreferredLogicalWidth; 123 minLogicalWidth += minPreferredLogicalWidth;
123 } 124 }
124 } else { 125 } else {
125 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth ); 126 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth );
126 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth ); 127 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth );
127 } 128 }
129
130 previousMaxContentFlexFraction = countIntrinsicSizeForAlgorithmChange(ma xPreferredLogicalWidth, child, previousMaxContentFlexFraction);
128 } 131 }
129 132
130 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 133 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
131 134
132 LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth(); 135 LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
133 maxLogicalWidth += scrollbarWidth; 136 maxLogicalWidth += scrollbarWidth;
134 minLogicalWidth += scrollbarWidth; 137 minLogicalWidth += scrollbarWidth;
135 } 138 }
136 139
140 float LayoutFlexibleBox::countIntrinsicSizeForAlgorithmChange(LayoutUnit maxPref erredLogicalWidth, LayoutBox* child, float previousMaxContentFlexFraction) const
141 {
142 // Determine whether the new version of the intrinsic size algorithm of the flexbox
143 // spec would produce a different result than our above algorithm.
144 // The algorithm produces a different result iff the max-content flex fracti on
145 // (as defined in the new algorithm) is not identical for each flex item.
146 if (isColumnFlow())
147 return previousMaxContentFlexFraction;
148 Length flexBasis = child->styleRef().flexBasis();
149 float flexGrow = child->styleRef().flexGrow();
150 // A flex-basis of auto will lead to a max-content flex fraction of zero, so just like
151 // an inflexible item it would compute to a size of max-content, so we ignor e it here.
152 if (flexBasis.isAuto() || flexGrow == 0)
153 return previousMaxContentFlexFraction;
154 flexGrow = std::max(1.0f, flexGrow);
155 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow ;
156 if (previousMaxContentFlexFraction != -1 && maxContentFlexFraction != previo usMaxContentFlexFraction)
157 UseCounter::count(document(), UseCounter::FlexboxIntrinsicSizeAlgorithmI sDifferent);
158 return maxContentFlexFraction;
159 }
160
137 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction) 161 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction)
138 { 162 {
139 if (direction == HorizontalLine) { 163 if (direction == HorizontalLine) {
140 return box.size().height() - box.borderBottom() - box.paddingBottom() - box.verticalScrollbarWidth(); 164 return box.size().height() - box.borderBottom() - box.paddingBottom() - box.verticalScrollbarWidth();
141 } 165 }
142 return box.size().width() - box.borderLeft() - box.paddingLeft() - box.horiz ontalScrollbarHeight(); 166 return box.size().width() - box.borderLeft() - box.paddingLeft() - box.horiz ontalScrollbarHeight();
143 } 167 }
144 168
145 int LayoutFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di rection, LinePositionMode mode) const 169 int LayoutFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di rection, LinePositionMode mode) const
146 { 170 {
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 ASSERT(child); 1470 ASSERT(child);
1447 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1471 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1448 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1472 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1449 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1473 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1450 adjustAlignmentForChild(*child, newOffset - originalOffset); 1474 adjustAlignmentForChild(*child, newOffset - originalOffset);
1451 } 1475 }
1452 } 1476 }
1453 } 1477 }
1454 1478
1455 } 1479 }
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