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

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: 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
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 // Determine whether the new version of the intrinsic size algorithm of the flexbox
131 // spec would produce a different result than our above algorithm.
leviw_travelin_and_unemployed 2015/08/20 21:45:49 Could we maybe extract this into a function?
cbiesinger 2015/08/20 22:00:44 Done
132 // The algorithm produces a different result iff the max-content flex fr action
133 // (as defined in the new algorithm) is not identical for each flex item .
134 if (isColumnFlow())
135 continue;
136 Length flexBasis = child->styleRef().flexBasis();
137 float flexGrow = child->styleRef().flexGrow();
138 // A flex-basis of auto will lead to a max-content flex fraction of zero , so just like
139 // an inflexible item it would compute to a size of max-content, so we i gnore it here.
140 if (flexBasis.isAuto() || flexGrow == 0)
141 continue;
142 flexGrow = std::max(1.0f, flexGrow);
143 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flex Grow;
144 if (previousMaxContentFlexFraction != -1 && maxContentFlexFraction != pr eviousMaxContentFlexFraction)
145 UseCounter::count(document(), UseCounter::FlexboxIntrinsicSizeAlgori thmIsDifferent);
146 previousMaxContentFlexFraction = maxContentFlexFraction;
128 } 147 }
129 148
130 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 149 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
131 150
132 LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth(); 151 LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
133 maxLogicalWidth += scrollbarWidth; 152 maxLogicalWidth += scrollbarWidth;
134 minLogicalWidth += scrollbarWidth; 153 minLogicalWidth += scrollbarWidth;
135 } 154 }
136 155
137 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction) 156 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction)
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 ASSERT(child); 1465 ASSERT(child);
1447 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1466 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1448 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1467 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1449 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1468 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1450 adjustAlignmentForChild(*child, newOffset - originalOffset); 1469 adjustAlignmentForChild(*child, newOffset - originalOffset);
1451 } 1470 }
1452 } 1471 }
1453 } 1472 }
1454 1473
1455 } 1474 }
OLDNEW
« Source/core/frame/UseCounter.h ('K') | « Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698