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

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

Issue 1268753002: [css-flexbox] Implementing new CSS Box Alignment values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch rebased and applied suggested changes. Created 5 years 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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 case ItemPositionAuto: 1411 case ItemPositionAuto:
1412 ASSERT_NOT_REACHED(); 1412 ASSERT_NOT_REACHED();
1413 break; 1413 break;
1414 case ItemPositionStretch: { 1414 case ItemPositionStretch: {
1415 applyStretchAlignmentToChild(*child, lineCrossAxisExtent); 1415 applyStretchAlignmentToChild(*child, lineCrossAxisExtent);
1416 // Since wrap-reverse flips cross start and cross end, strech ch ildren should be aligned with the cross end. 1416 // Since wrap-reverse flips cross start and cross end, strech ch ildren should be aligned with the cross end.
1417 if (style()->flexWrap() == FlexWrapReverse) 1417 if (style()->flexWrap() == FlexWrapReverse)
1418 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child)); 1418 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child));
1419 break; 1419 break;
1420 } 1420 }
1421 case ItemPositionStart:
1421 case ItemPositionFlexStart: 1422 case ItemPositionFlexStart:
1423 // We treat flex-start the same as start because alignmentForChi ld fixed
1424 // it up appropriately
1422 break; 1425 break;
1426 case ItemPositionEnd:
1423 case ItemPositionFlexEnd: 1427 case ItemPositionFlexEnd:
1428 // We treat flex-end the same as end because alignmentForChild f ixed
1429 // it up appropriately
1424 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild( lineCrossAxisExtent, *child)); 1430 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild( lineCrossAxisExtent, *child));
1425 break; 1431 break;
1426 case ItemPositionCenter: 1432 case ItemPositionCenter:
1427 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild( lineCrossAxisExtent, *child) / 2); 1433 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild( lineCrossAxisExtent, *child) / 2);
1428 break; 1434 break;
1429 case ItemPositionBaseline: { 1435 case ItemPositionBaseline: {
1430 // FIXME: If we get here in columns, we want the use the descent , except we currently can't get the ascent/descent of orthogonal children. 1436 // FIXME: If we get here in columns, we want the use the descent , except we currently can't get the ascent/descent of orthogonal children.
1431 // https://bugs.webkit.org/show_bug.cgi?id=98076 1437 // https://bugs.webkit.org/show_bug.cgi?id=98076
1432 LayoutUnit ascent = marginBoxAscentForChild(*child); 1438 LayoutUnit ascent = marginBoxAscentForChild(*child);
1433 LayoutUnit startOffset = maxAscent - ascent; 1439 LayoutUnit startOffset = maxAscent - ascent;
1434 adjustAlignmentForChild(*child, startOffset); 1440 adjustAlignmentForChild(*child, startOffset);
1435 1441
1436 if (style()->flexWrap() == FlexWrapReverse) 1442 if (style()->flexWrap() == FlexWrapReverse)
1437 minMarginAfterBaseline = std::min(minMarginAfterBaseline, av ailableAlignmentSpaceForChild(lineCrossAxisExtent, *child) - startOffset); 1443 minMarginAfterBaseline = std::min(minMarginAfterBaseline, av ailableAlignmentSpaceForChild(lineCrossAxisExtent, *child) - startOffset);
1438 break; 1444 break;
1439 } 1445 }
1440 case ItemPositionLastBaseline: 1446 case ItemPositionSelfStart: {
1441 case ItemPositionSelfStart: 1447 bool hasSameCrossStartEdges = hasOrthogonalFlow(*child) ? child- >styleRef().isLeftToRightDirection() == styleRef().isLeftToRightDirection() : ch ild->styleRef().isFlippedBlocksWritingMode() == styleRef().isFlippedBlocksWritin gMode();
1442 case ItemPositionSelfEnd: 1448 if (!hasSameCrossStartEdges)
1443 case ItemPositionStart: 1449 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child));
1444 case ItemPositionEnd: 1450 break;
1451 }
1452 case ItemPositionSelfEnd: {
1453 bool hasSameCrossStartEdges = hasOrthogonalFlow(*child) ? child- >styleRef().isLeftToRightDirection() == styleRef().isLeftToRightDirection() : ch ild->styleRef().isFlippedBlocksWritingMode() == styleRef().isFlippedBlocksWritin gMode();
1454 if (hasSameCrossStartEdges)
1455 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child));
1456 break;
1457 }
1445 case ItemPositionLeft: 1458 case ItemPositionLeft:
1459 // Cross-axis is only parallel to container's inline-axis when c olumn-flow is used.
1460 if (isColumnFlow() && !style()->isLeftToRightDirection())
cbiesinger 2015/12/01 00:12:49 is that true? shouldn't it be if (!isHorizontalFlo
1461 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child));
1462 break;
1446 case ItemPositionRight: 1463 case ItemPositionRight:
1447 // FIXME: Implement these (https://crbug.com/507690). The extend ed grammar 1464 // Cross-axis is only parallel to container's inline-axis when c olumn-flow is used.
1448 // is not enabled by default so we shouldn't hit this codepath. 1465 if (isColumnFlow() && style()->isLeftToRightDirection())
1466 adjustAlignmentForChild(*child, availableAlignmentSpaceForCh ild(lineCrossAxisExtent, *child));
1467 break;
1468 case ItemPositionLastBaseline: // TODO (lajava): This feature is at- risk of being dropped during the CR period.
cbiesinger 2015/12/01 00:12:49 if we're still parsing it, it seems better not to
1469 default:
1449 ASSERT_NOT_REACHED(); 1470 ASSERT_NOT_REACHED();
1450 break; 1471 break;
1451 } 1472 }
1452 } 1473 }
1453 minMarginAfterBaselines.append(minMarginAfterBaseline); 1474 minMarginAfterBaselines.append(minMarginAfterBaseline);
1454 } 1475 }
1455 1476
1456 if (style()->flexWrap() != FlexWrapReverse) 1477 if (style()->flexWrap() != FlexWrapReverse)
1457 return; 1478 return;
1458 1479
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 ASSERT(child); 1548 ASSERT(child);
1528 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1549 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1529 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1550 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1530 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1551 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1531 adjustAlignmentForChild(*child, newOffset - originalOffset); 1552 adjustAlignmentForChild(*child, newOffset - originalOffset);
1532 } 1553 }
1533 } 1554 }
1534 } 1555 }
1535 1556
1536 } 1557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698