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

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

Issue 1651703002: More explicit LayoutUnit conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@evenMoarConstructors
Patch Set: Traits vs Properties vs Pandas 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) 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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1409
1410 ++seenInFlowPositionedChildren; 1410 ++seenInFlowPositionedChildren;
1411 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) 1411 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent)
1412 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp ace, style()->justifyContentDistribution(), numberOfChildrenForJustifyContent); 1412 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp ace, style()->justifyContentDistribution(), numberOfChildrenForJustifyContent);
1413 } 1413 }
1414 } 1414 }
1415 1415
1416 static LayoutUnit initialAlignContentOffset(LayoutUnit availableFreeSpace, Conte ntPosition alignContent, ContentDistributionType alignContentDistribution, unsig ned numberOfLines) 1416 static LayoutUnit initialAlignContentOffset(LayoutUnit availableFreeSpace, Conte ntPosition alignContent, ContentDistributionType alignContentDistribution, unsig ned numberOfLines)
1417 { 1417 {
1418 if (numberOfLines <= 1) 1418 if (numberOfLines <= 1)
1419 return 0; 1419 return LayoutUnit();
1420 if (alignContent == ContentPositionFlexEnd) 1420 if (alignContent == ContentPositionFlexEnd)
1421 return availableFreeSpace; 1421 return availableFreeSpace;
1422 if (alignContent == ContentPositionCenter) 1422 if (alignContent == ContentPositionCenter)
1423 return availableFreeSpace / 2; 1423 return availableFreeSpace / 2;
1424 if (alignContentDistribution == ContentDistributionSpaceAround) { 1424 if (alignContentDistribution == ContentDistributionSpaceAround) {
1425 if (availableFreeSpace > 0 && numberOfLines) 1425 if (availableFreeSpace > 0 && numberOfLines)
1426 return availableFreeSpace / (2 * numberOfLines); 1426 return availableFreeSpace / (2 * numberOfLines);
1427 if (availableFreeSpace < 0) 1427 if (availableFreeSpace < 0)
1428 return availableFreeSpace / 2; 1428 return availableFreeSpace / 2;
1429 } 1429 }
1430 return 0; 1430 return LayoutUnit();
1431 } 1431 }
1432 1432
1433 static LayoutUnit alignContentSpaceBetweenChildren(LayoutUnit availableFreeSpace , ContentDistributionType alignContentDistribution, unsigned numberOfLines) 1433 static LayoutUnit alignContentSpaceBetweenChildren(LayoutUnit availableFreeSpace , ContentDistributionType alignContentDistribution, unsigned numberOfLines)
1434 { 1434 {
1435 if (availableFreeSpace > 0 && numberOfLines > 1) { 1435 if (availableFreeSpace > 0 && numberOfLines > 1) {
1436 if (alignContentDistribution == ContentDistributionSpaceBetween) 1436 if (alignContentDistribution == ContentDistributionSpaceBetween)
1437 return availableFreeSpace / (numberOfLines - 1); 1437 return availableFreeSpace / (numberOfLines - 1);
1438 if (alignContentDistribution == ContentDistributionSpaceAround || alignC ontentDistribution == ContentDistributionStretch) 1438 if (alignContentDistribution == ContentDistributionSpaceAround || alignC ontentDistribution == ContentDistributionStretch)
1439 return availableFreeSpace / numberOfLines; 1439 return availableFreeSpace / numberOfLines;
1440 } 1440 }
1441 return 0; 1441 return LayoutUnit();
1442 } 1442 }
1443 1443
1444 void LayoutFlexibleBox::alignFlexLines(Vector<LineContext>& lineContexts) 1444 void LayoutFlexibleBox::alignFlexLines(Vector<LineContext>& lineContexts)
1445 { 1445 {
1446 // If we have a single line flexbox or a multiline line flexbox with only on e flex line, 1446 // If we have a single line flexbox or a multiline line flexbox with only on e flex line,
1447 // the line height is all the available space. 1447 // the line height is all the available space.
1448 // For flex-direction: row, this means we need to use the height, so we do t his after calling updateLogicalHeight. 1448 // For flex-direction: row, this means we need to use the height, so we do t his after calling updateLogicalHeight.
1449 if (lineContexts.size() == 1) { 1449 if (lineContexts.size() == 1) {
1450 lineContexts[0].crossAxisExtent = crossAxisContentExtent(); 1450 lineContexts[0].crossAxisExtent = crossAxisContentExtent();
1451 return; 1451 return;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 ASSERT(child); 1629 ASSERT(child);
1630 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1630 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1631 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1631 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1632 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1632 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1633 adjustAlignmentForChild(*child, newOffset - originalOffset); 1633 adjustAlignmentForChild(*child, newOffset - originalOffset);
1634 } 1634 }
1635 } 1635 }
1636 } 1636 }
1637 1637
1638 } // namespace blink 1638 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698