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

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

Issue 1660863002: Force all LayoutUnit construction to be explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix LayoutRectTest.cpp Created 4 years, 10 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) 2002 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org)
3 * (C) 2002 Dirk Mueller (mueller@kde.org) 3 * (C) 2002 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License. 9 * version 2 of the License.
10 * 10 *
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 maxPercent = std::max(logicalWidth, maxPercent); 235 maxPercent = std::max(logicalWidth, maxPercent);
236 remainingPercent -= percent; 236 remainingPercent -= percent;
237 } else { 237 } else {
238 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; 238 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth;
239 } 239 }
240 } 240 }
241 } 241 }
242 242
243 if (scaleColumns) { 243 if (scaleColumns) {
244 maxNonPercent = maxNonPercent * 100 / std::max(remainingPercent, epsilon ); 244 maxNonPercent = maxNonPercent * 100 / std::max(remainingPercent, epsilon );
245 maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxNonPercent, static_ cast<float>(tableMaxWidth)))).floor(); 245 maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxNonPercent, static_ cast<float>(tableMaxWidth))));
246 maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxPercent, static_cas t<float>(tableMaxWidth)))).floor(); 246 maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxPercent, static_cas t<float>(tableMaxWidth))));
247 } 247 }
248 248
249 maxWidth = std::max(maxWidth.floor(), spanMaxLogicalWidth); 249 maxWidth = LayoutUnit(std::max(maxWidth.floor(), spanMaxLogicalWidth));
250 } 250 }
251 251
252 void TableLayoutAlgorithmAuto::applyPreferredLogicalWidthQuirks(LayoutUnit& minW idth, LayoutUnit& maxWidth) const 252 void TableLayoutAlgorithmAuto::applyPreferredLogicalWidthQuirks(LayoutUnit& minW idth, LayoutUnit& maxWidth) const
253 { 253 {
254 Length tableLogicalWidth = m_table->style()->logicalWidth(); 254 Length tableLogicalWidth = m_table->style()->logicalWidth();
255 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) { 255 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) {
256 // |minWidth| is the result of measuring the intrinsic content's size. K eep it to 256 // |minWidth| is the result of measuring the intrinsic content's size. K eep it to
257 // make sure we are *never* smaller than the actual content. 257 // make sure we are *never* smaller than the actual content.
258 LayoutUnit minContentWidth = minWidth; 258 LayoutUnit minContentWidth = minWidth;
259 // FIXME: This line looks REALLY suspicious as it could allow the minimu m 259 // FIXME: This line looks REALLY suspicious as it could allow the minimu m
260 // preferred logical width to be smaller than the table content. This ha s 260 // preferred logical width to be smaller than the table content. This ha s
261 // to be cross-checked against other browsers. 261 // to be cross-checked against other browsers.
262 minWidth = maxWidth = std::max<int>(minWidth.floor(), tableLogicalWidth. value()); 262 minWidth = maxWidth = LayoutUnit(std::max<int>(minWidth.floor(), tableLo gicalWidth.value()));
263 263
264 const Length& styleMaxLogicalWidth = m_table->style()->logicalMaxWidth() ; 264 const Length& styleMaxLogicalWidth = m_table->style()->logicalMaxWidth() ;
265 if (styleMaxLogicalWidth.isFixed() && !styleMaxLogicalWidth.isNegative() ) { 265 if (styleMaxLogicalWidth.isFixed() && !styleMaxLogicalWidth.isNegative() ) {
266 minWidth = std::min<int>(minWidth.floor(), styleMaxLogicalWidth.valu e()); 266 minWidth = LayoutUnit(std::min<int>(minWidth.floor(), styleMaxLogica lWidth.value()));
267 minWidth = std::max(minWidth, minContentWidth); 267 minWidth = std::max(minWidth, minContentWidth);
268 maxWidth = minWidth; 268 maxWidth = minWidth;
269 } 269 }
270 } 270 }
271 } 271 }
272 272
273 /* 273 /*
274 This method takes care of colspans. 274 This method takes care of colspans.
275 effWidth is the same as width for cells without colspans. If we have colspans, they get modified. 275 effWidth is the same as width for cells without colspans. If we have colspans, they get modified.
276 */ 276 */
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 int reduce = available * minMaxDiff / logicalWidthBeyondMin; 692 int reduce = available * minMaxDiff / logicalWidthBeyondMin;
693 m_layoutStruct[i].computedLogicalWidth += reduce; 693 m_layoutStruct[i].computedLogicalWidth += reduce;
694 available -= reduce; 694 available -= reduce;
695 logicalWidthBeyondMin -= minMaxDiff; 695 logicalWidthBeyondMin -= minMaxDiff;
696 if (available >= 0) 696 if (available >= 0)
697 break; 697 break;
698 } 698 }
699 } 699 }
700 } 700 }
701 } // namespace blink 701 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutVTTCue.cpp ('k') | third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698