Changeset 295027 in webkit
- Timestamp:
- May 30, 2022 7:10:13 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
r295017 r295027 460 460 { 461 461 auto justifyContent = root().style().justifyContent(); 462 // FIXME: Make this optional. 463 auto contentLogicalWidth = [&] { 464 auto logicalWidth = LayoutUnit { }; 465 for (auto& logicalFlexItem : logicalFlexItemList) 466 logicalWidth += logicalFlexItem.rect.width(); 467 return logicalWidth; 468 }(); 462 469 463 470 auto initialOffset = [&] { 464 auto contentLogicalWidth = [&] { 465 auto logicalWidth = LayoutUnit { }; 466 for (auto& logicalFlexItem : logicalFlexItemList) 467 logicalWidth += logicalFlexItem.rect.width(); 468 return logicalWidth; 469 }; 471 switch (justifyContent.distribution()) { 472 case ContentDistribution::Default: 473 // Fall back to justifyContent.position() 474 break; 475 case ContentDistribution::SpaceBetween: 476 return LayoutUnit { }; 477 default: 478 ASSERT_NOT_IMPLEMENTED_YET(); 479 break; 480 } 470 481 471 482 switch (justifyContent.position()) { … … 478 489 case ContentPosition::FlexEnd: 479 490 case ContentPosition::Right: 480 return availableSpace - contentLogicalWidth ();491 return availableSpace - contentLogicalWidth; 481 492 case ContentPosition::Center: 482 return availableSpace / 2 - contentLogicalWidth ()/ 2;493 return availableSpace / 2 - contentLogicalWidth / 2; 483 494 default: 484 495 ASSERT_NOT_IMPLEMENTED_YET(); 485 496 break; 486 497 } 498 ASSERT_NOT_REACHED(); 487 499 return LayoutUnit { }; 488 500 }; 489 501 502 auto gapBetweenItems = [&] { 503 switch (justifyContent.distribution()) { 504 case ContentDistribution::Default: 505 return LayoutUnit { }; 506 case ContentDistribution::SpaceBetween: 507 if (logicalFlexItemList.size() == 1) 508 return LayoutUnit { }; 509 return (availableSpace - contentLogicalWidth) / (logicalFlexItemList.size() - 1); 510 default: 511 ASSERT_NOT_IMPLEMENTED_YET(); 512 break; 513 } 514 ASSERT_NOT_REACHED(); 515 return LayoutUnit { }; 516 }; 517 490 518 auto logicalLeft = initialOffset(); 519 auto gap = gapBetweenItems(); 491 520 for (auto& logicalFlexItem : logicalFlexItemList) { 492 521 logicalFlexItem.rect.setLeft(logicalLeft); 493 logicalLeft = logicalFlexItem.rect.right() ;522 logicalLeft = logicalFlexItem.rect.right() + gap; 494 523 } 495 524 }
Note: See TracChangeset
for help on using the changeset viewer.