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

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

Issue 289903007: Inline flexbox width is wrongly calculated when wrapping vertically (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const char* RenderFlexibleBox::renderName() const 89 const char* RenderFlexibleBox::renderName() const
90 { 90 {
91 return "RenderFlexibleBox"; 91 return "RenderFlexibleBox";
92 } 92 }
93 93
94 void RenderFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt h, LayoutUnit& maxLogicalWidth) const 94 void RenderFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidt h, LayoutUnit& maxLogicalWidth) const
95 { 95 {
96 // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start ho noring it though until 96 // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start ho noring it though until
97 // the flex shorthand stops setting it to 0. 97 // the flex shorthand stops setting it to 0.
98 // See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/2 40765. 98 // See https://bugs.webkit.org/show_bug.cgi?id=116117 and http://crbug.com/2 40765.
99 float totalChildHeight = 0;
100
99 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 101 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
100 if (child->isOutOfFlowPositioned()) 102 if (child->isOutOfFlowPositioned())
101 continue; 103 continue;
104 totalChildHeight += child->style()->height().value();
tony 2014/05/19 16:14:43 Is this correct? What about min-height? Also, it
harpreet.sk 2014/07/18 15:46:48 Sorry this is incorrect. It not correct to use hei
105 }
106
107 bool boxMightWrap = totalChildHeight > this->style()->height().value();
108
109 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
110 if (child->isOutOfFlowPositioned())
111 continue;
102 112
103 LayoutUnit margin = marginIntrinsicLogicalWidthForChild(child); 113 LayoutUnit margin = marginIntrinsicLogicalWidthForChild(child);
104 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode(); 114 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode();
105 LayoutUnit minPreferredLogicalWidth = hasOrthogonalWritingMode ? child-> logicalHeight() : child->minPreferredLogicalWidth(); 115 LayoutUnit minPreferredLogicalWidth = hasOrthogonalWritingMode ? child-> logicalHeight() : child->minPreferredLogicalWidth();
106 LayoutUnit maxPreferredLogicalWidth = hasOrthogonalWritingMode ? child-> logicalHeight() : child->maxPreferredLogicalWidth(); 116 LayoutUnit maxPreferredLogicalWidth = hasOrthogonalWritingMode ? child-> logicalHeight() : child->maxPreferredLogicalWidth();
107 minPreferredLogicalWidth += margin; 117 minPreferredLogicalWidth += margin;
108 maxPreferredLogicalWidth += margin; 118 maxPreferredLogicalWidth += margin;
109 if (!isColumnFlow()) { 119 if (!isColumnFlow()) {
110 maxLogicalWidth += maxPreferredLogicalWidth; 120 maxLogicalWidth += maxPreferredLogicalWidth;
111 if (isMultiline()) { 121 if (isMultiline()) {
112 // For multiline, the min preferred width is if you put a break between each item. 122 // For multiline, the min preferred width is if you put a break between each item.
113 minLogicalWidth = std::max(minLogicalWidth, minPreferredLogicalW idth); 123 minLogicalWidth = std::max(minLogicalWidth, minPreferredLogicalW idth);
114 } else 124 } else
115 minLogicalWidth += minPreferredLogicalWidth; 125 minLogicalWidth += minPreferredLogicalWidth;
116 } else { 126 } else {
117 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth ); 127 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth );
118 if (isMultiline()) { 128 if (isMultiline() && boxMightWrap) {
tony 2014/05/19 16:14:43 If boxMightWrap is true, then we assume that all t
harpreet.sk 2014/07/18 15:46:49 Done.
119 // For multiline, the max preferred width is if you never break between items. 129 // For multiline, the max preferred width is if you never break between items.
120 maxLogicalWidth += maxPreferredLogicalWidth; 130 maxLogicalWidth += maxPreferredLogicalWidth;
121 } else 131 } else
122 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalW idth); 132 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalW idth);
123 } 133 }
124 } 134 }
125 135
126 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 136 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
127 137
128 LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth(); 138 LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth();
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 ASSERT(child); 1421 ASSERT(child);
1412 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1422 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1413 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1423 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1414 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1424 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1415 adjustAlignmentForChild(child, newOffset - originalOffset); 1425 adjustAlignmentForChild(child, newOffset - originalOffset);
1416 } 1426 }
1417 } 1427 }
1418 } 1428 }
1419 1429
1420 } 1430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698