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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 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
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 flexGrow = std::max(1.0f, flexGrow); 186 flexGrow = std::max(1.0f, flexGrow);
187 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow ; 187 float maxContentFlexFraction = maxPreferredLogicalWidth.toFloat() / flexGrow ;
188 if (previousMaxContentFlexFraction != -1 && maxContentFlexFraction != previo usMaxContentFlexFraction) 188 if (previousMaxContentFlexFraction != -1 && maxContentFlexFraction != previo usMaxContentFlexFraction)
189 UseCounter::count(document(), UseCounter::FlexboxIntrinsicSizeAlgorithmI sDifferent); 189 UseCounter::count(document(), UseCounter::FlexboxIntrinsicSizeAlgorithmI sDifferent);
190 return maxContentFlexFraction; 190 return maxContentFlexFraction;
191 } 191 }
192 192
193 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction) 193 static int synthesizedBaselineFromContentBox(const LayoutBox& box, LineDirection Mode direction)
194 { 194 {
195 if (direction == HorizontalLine) { 195 if (direction == HorizontalLine) {
196 return box.size().height() - box.borderBottom() - box.paddingBottom() - box.verticalScrollbarWidth(); 196 return (box.size().height() - box.borderBottom() - box.paddingBottom() - box.verticalScrollbarWidth()).toInt();
197 } 197 }
198 return box.size().width() - box.borderLeft() - box.paddingLeft() - box.horiz ontalScrollbarHeight(); 198 return (box.size().width() - box.borderLeft() - box.paddingLeft() - box.hori zontalScrollbarHeight()).toInt();
199 } 199 }
200 200
201 int LayoutFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di rection, LinePositionMode mode) const 201 int LayoutFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di rection, LinePositionMode mode) const
202 { 202 {
203 DCHECK_EQ(mode, PositionOnContainingLine); 203 DCHECK_EQ(mode, PositionOnContainingLine);
204 int baseline = firstLineBoxBaseline(); 204 int baseline = firstLineBoxBaseline();
205 if (baseline == -1) 205 if (baseline == -1)
206 baseline = synthesizedBaselineFromContentBox(*this, direction); 206 baseline = synthesizedBaselineFromContentBox(*this, direction);
207 207
208 return beforeMarginInLineDirection(direction) + baseline; 208 return beforeMarginInLineDirection(direction) + baseline;
(...skipping 27 matching lines...) Expand all
236 236
237 ++childNumber; 237 ++childNumber;
238 if (childNumber == m_numberOfInFlowChildrenOnFirstLine) 238 if (childNumber == m_numberOfInFlowChildrenOnFirstLine)
239 break; 239 break;
240 } 240 }
241 241
242 if (!baselineChild) 242 if (!baselineChild)
243 return -1; 243 return -1;
244 244
245 if (!isColumnFlow() && hasOrthogonalFlow(*baselineChild)) 245 if (!isColumnFlow() && hasOrthogonalFlow(*baselineChild))
246 return crossAxisExtentForChild(*baselineChild) + baselineChild->logicalT op(); 246 return (crossAxisExtentForChild(*baselineChild) + baselineChild->logical Top()).toInt();
247 if (isColumnFlow() && !hasOrthogonalFlow(*baselineChild)) 247 if (isColumnFlow() && !hasOrthogonalFlow(*baselineChild))
248 return mainAxisExtentForChild(*baselineChild) + baselineChild->logicalTo p(); 248 return (mainAxisExtentForChild(*baselineChild) + baselineChild->logicalT op()).toInt();
249 249
250 int baseline = baselineChild->firstLineBoxBaseline(); 250 int baseline = baselineChild->firstLineBoxBaseline();
251 if (baseline == -1) { 251 if (baseline == -1) {
252 // FIXME: We should pass |direction| into firstLineBoxBaseline and stop bailing out if we're a writing mode root. 252 // FIXME: We should pass |direction| into firstLineBoxBaseline and stop bailing out if we're a writing mode root.
253 // This would also fix some cases where the flexbox is orthogonal to its container. 253 // This would also fix some cases where the flexbox is orthogonal to its container.
254 LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine : VerticalLine; 254 LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
255 return synthesizedBaselineFromContentBox(*baselineChild, direction) + ba selineChild->logicalTop(); 255 return (synthesizedBaselineFromContentBox(*baselineChild, direction) + b aselineChild->logicalTop()).toInt();
256 } 256 }
257 257
258 return baseline + baselineChild->logicalTop(); 258 return (baseline + baselineChild->logicalTop()).toInt();
259 } 259 }
260 260
261 int LayoutFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const 261 int LayoutFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const
262 { 262 {
263 int baseline = firstLineBoxBaseline(); 263 int baseline = firstLineBoxBaseline();
264 if (baseline != -1) 264 if (baseline != -1)
265 return baseline; 265 return baseline;
266 266
267 int marginAscent = direction == HorizontalLine ? marginTop() : marginRight() ; 267 int marginAscent = (direction == HorizontalLine ? marginTop() : marginRight( )).toInt();
268 return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; 268 return synthesizedBaselineFromContentBox(*this, direction) + marginAscent;
269 } 269 }
270 270
271 IntSize LayoutFlexibleBox::originAdjustmentForScrollbars() const 271 IntSize LayoutFlexibleBox::originAdjustmentForScrollbars() const
272 { 272 {
273 IntSize size; 273 IntSize size;
274 int adjustmentWidth = verticalScrollbarWidth(); 274 int adjustmentWidth = verticalScrollbarWidth();
275 int adjustmentHeight = horizontalScrollbarHeight(); 275 int adjustmentHeight = horizontalScrollbarHeight();
276 if (!adjustmentWidth && !adjustmentHeight) 276 if (!adjustmentWidth && !adjustmentHeight)
277 return size; 277 return size;
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 DCHECK(child); 1931 DCHECK(child);
1932 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1932 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1933 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1933 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1934 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1934 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1935 adjustAlignmentForChild(*child, newOffset - originalOffset); 1935 adjustAlignmentForChild(*child, newOffset - originalOffset);
1936 } 1936 }
1937 } 1937 }
1938 } 1938 }
1939 1939
1940 } // namespace blink 1940 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698