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

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

Issue 815833005: [css-grid] Handle min-content/max-content with orthogonal flows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch rebased and applied the suggested changes. Created 4 years, 9 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 size_t m_columnIndex; 225 size_t m_columnIndex;
226 size_t m_childIndex; 226 size_t m_childIndex;
227 }; 227 };
228 228
229 struct LayoutGrid::GridSizingData { 229 struct LayoutGrid::GridSizingData {
230 WTF_MAKE_NONCOPYABLE(GridSizingData); 230 WTF_MAKE_NONCOPYABLE(GridSizingData);
231 STACK_ALLOCATED(); 231 STACK_ALLOCATED();
232 public: 232 public:
233 GridSizingData(size_t gridColumnCount, size_t gridRowCount) 233 GridSizingData(size_t gridColumnCount, size_t gridRowCount)
234 : columnTracks(gridColumnCount) 234 : columnTracks(gridColumnCount)
235 , rowTracks(gridRowCount) 235 , rowTracks(0)
svillar 2016/03/23 11:02:00 This is weird, you're totally ignoring the passed
jfernandez 2016/04/01 16:39:56 Yeah, not the best way to do it but since we are g
svillar 2016/04/04 07:58:28 I'd prefer to have a state machine where to track
236 { 236 {
237 } 237 }
238 238
239 Vector<GridTrack> columnTracks; 239 Vector<GridTrack> columnTracks;
240 Vector<GridTrack> rowTracks; 240 Vector<GridTrack> rowTracks;
241 Vector<size_t> contentSizedTracksIndex; 241 Vector<size_t> contentSizedTracksIndex;
242 242
243 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. 243 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free.
244 Vector<GridTrack*> filteredTracks; 244 Vector<GridTrack*> filteredTracks;
245 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; 245 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 updateLogicalWidth(); 353 updateLogicalWidth();
354 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref erredSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1); 354 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref erredSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1);
355 355
356 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); 356 TextAutosizer::LayoutScope textAutosizerLayoutScope(this);
357 357
358 placeItemsOnGrid(); 358 placeItemsOnGrid();
359 359
360 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 360 GridSizingData sizingData(gridColumnCount(), gridRowCount());
361 361
362 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns.
362 // At this point the logical width is always definite as the above call to updateLogicalWidth() 363 // At this point the logical width is always definite as the above call to updateLogicalWidth()
363 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code 364 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
364 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve 365 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve
365 // heights properly (like for positioned items for example). 366 // heights properly (like for positioned items for example).
366 computeTrackSizesForDirection(ForColumns, sizingData, availableLogicalWi dth()); 367 LayoutUnit availableSpaceForColumns = availableLogicalWidth();
368 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC olumns);
367 369
370 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro ws, using the
371 // grid column sizes calculated in the previous step.
368 if (logicalHeightWasIndefinite) 372 if (logicalHeightWasIndefinite)
369 computeIntrinsicLogicalHeight(sizingData); 373 computeIntrinsicLogicalHeight(sizingData);
370 else 374 else
371 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH eight(ExcludeMarginBorderPadding)); 375 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH eight(ExcludeMarginBorderPadding));
372 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight()); 376 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight());
373 377
374 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 378 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
375 updateLogicalHeight(); 379 updateLogicalHeight();
376 380
377 // The above call might have changed the grid's logical height depending on min|max height restrictions. 381 // The above call might have changed the grid's logical height depending on min|max height restrictions.
378 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes). 382 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes).
379 if (logicalHeightWasIndefinite) 383 if (logicalHeightWasIndefinite)
380 computeTrackSizesForDirection(ForRows, sizingData, contentLogicalHei ght()); 384 computeTrackSizesForDirection(ForRows, sizingData, contentLogicalHei ght());
381 385
386 // 3- If the min-content contribution of any grid items have changed bas ed on the row
387 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m in-content
388 // contribution (once only).
389 // TODO (lajava): is enough just verifying whether there are any orthogo nal item ?
390 // TODO (lajava): Could we find better ways to fulfill such spec stateme nt ?
391 // TODO (lajava): Could we avoid iterating over all the grid items ?"
svillar 2016/03/23 11:02:00 I think the answer is yes. You have total control
jfernandez 2016/04/01 16:39:56 Ok, we can do that.
392 if (hasAnyOrthogonalChild()) {
393 // In orthogonal flow cases column tracks size is determined based o n the computed
394 // row track sizes, hence we need to repeat computeUsedBreadthOfGrid Tracks for columns.
395 computeTrackSizesForDirection(ForColumns, sizingData, availableSpace ForColumns);
396 computeTrackSizesForDirection(ForRows, sizingData, logicalHeight());
svillar 2016/03/23 11:02:00 I guess this should be contentLogicalHeight() ?
jfernandez 2016/04/01 16:39:56 Why ? I'm not totally sure. We have just called to
svillar 2016/04/04 07:58:28 logical height includes border padding.... We cann
397 }
398
382 // Grid container should have the minimum height of a line if it's edita ble. That doesn't affect track sizing though. 399 // Grid container should have the minimum height of a line if it's edita ble. That doesn't affect track sizing though.
383 if (hasLineIfEmpty()) 400 if (hasLineIfEmpty())
384 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm ptyLine())); 401 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm ptyLine()));
385 402
386 applyStretchAlignmentToTracksIfNeeded(ForColumns, sizingData); 403 applyStretchAlignmentToTracksIfNeeded(ForColumns, sizingData);
387 applyStretchAlignmentToTracksIfNeeded(ForRows, sizingData); 404 applyStretchAlignmentToTracksIfNeeded(ForRows, sizingData);
388 405
389 layoutGridItems(sizingData); 406 layoutGridItems(sizingData);
390 407
391 if (size() != previousSize) 408 if (size() != previousSize)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 487 }
471 488
472 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization, AvailableSpaceType availableSpaceType) 489 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization, AvailableSpaceType availableSpaceType)
473 { 490 {
474 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); 491 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction);
475 const LayoutUnit initialFreeSpace = freeSpace; 492 const LayoutUnit initialFreeSpace = freeSpace;
476 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 493 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
477 Vector<size_t> flexibleSizedTracksIndex; 494 Vector<size_t> flexibleSizedTracksIndex;
478 sizingData.contentSizedTracksIndex.shrink(0); 495 sizingData.contentSizedTracksIndex.shrink(0);
479 496
497 // The row tracks vector was not initialized as part of the GridSizingData i nstantiation because we want to detect
498 // that we will have to estimate the row track's breadth to figure out an or thogonal grid item's logical height.
499 // TODO (lajava) are there better ways to do this ?
500 if (direction == ForRows && tracks.size() == 0)
501 tracks.grow(gridRowCount());
svillar 2016/03/23 11:02:00 I don't think this is the right way to do this.
jfernandez 2016/04/01 16:39:56 Remember that we only do this to be able to detect
svillar 2016/04/04 07:58:28 Again, an state machine is much better IMO.
502
480 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); 503 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace);
481 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. 504 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes.
482 if (availableSpaceType == AvailableSpaceDefinite) 505 if (availableSpaceType == AvailableSpaceDefinite)
483 maxSize += guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); 506 maxSize += guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount());
484 507
485 // 1. Initialize per Grid track variables. 508 // 1. Initialize per Grid track variables.
486 for (size_t i = 0; i < tracks.size(); ++i) { 509 for (size_t i = 0; i < tracks.size(); ++i) {
487 GridTrack& track = tracks[i]; 510 GridTrack& track = tracks[i];
488 GridTrackSize trackSize = gridTrackSize(direction, i); 511 GridTrackSize trackSize = gridTrackSize(direction, i);
489 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); 512 const GridLength& minTrackBreadth = trackSize.minTrackBreadth();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 570
548 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { 571 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) {
549 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i] ); 572 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i] );
550 while (LayoutBox* gridItem = iterator.nextGridItem()) { 573 while (LayoutBox* gridItem = iterator.nextGridItem()) {
551 const GridSpan span = cachedGridSpan(*gridItem, direction); 574 const GridSpan span = cachedGridSpan(*gridItem, direction);
552 575
553 // Do not include already processed items. 576 // Do not include already processed items.
554 if (i > 0 && span.resolvedInitialPosition() <= flexibleSizedTrac ksIndex[i - 1]) 577 if (i > 0 && span.resolvedInitialPosition() <= flexibleSizedTrac ksIndex[i - 1])
555 continue; 578 continue;
556 579
557 flexFraction = std::max(flexFraction, findFlexFactorUnitSize(tra cks, span, direction, maxContentForChild(*gridItem, direction, sizingData.column Tracks))); 580 flexFraction = std::max(flexFraction, findFlexFactorUnitSize(tra cks, span, direction, maxContentForChild(*gridItem, direction, sizingData)));
558 } 581 }
559 } 582 }
560 } 583 }
561 584
562 for (const auto& trackIndex : flexibleSizedTracksIndex) { 585 for (const auto& trackIndex : flexibleSizedTracksIndex) {
563 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); 586 GridTrackSize trackSize = gridTrackSize(direction, trackIndex);
564 587
565 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); 588 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize();
566 LayoutUnit baseSize = std::max(oldBaseSize, LayoutUnit(flexFraction * tr ackSize.maxTrackBreadth().flex())); 589 LayoutUnit baseSize = std::max(oldBaseSize, LayoutUnit(flexFraction * tr ackSize.maxTrackBreadth().flex()));
567 if (LayoutUnit increment = baseSize - oldBaseSize) { 590 if (LayoutUnit increment = baseSize - oldBaseSize) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 flexFactorSum += trackSize.maxTrackBreadth().flex(); 667 flexFactorSum += trackSize.maxTrackBreadth().flex();
645 } 668 }
646 } 669 }
647 670
648 // The function is not called if we don't have <flex> grid tracks 671 // The function is not called if we don't have <flex> grid tracks
649 ASSERT(!flexibleTracksIndexes.isEmpty()); 672 ASSERT(!flexibleTracksIndexes.isEmpty());
650 673
651 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum, leftOverS pace, flexibleTracksIndexes); 674 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum, leftOverS pace, flexibleTracksIndexes);
652 } 675 }
653 676
677 bool LayoutGrid::hasAnyOrthogonalChild() const
678 {
679 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
680 if (isOrthogonalChild(*child))
681 return true;
682 }
683 return false;
684 }
svillar 2016/03/23 11:02:00 See my comment above about not needing this method
jfernandez 2016/04/01 16:39:56 Acknowledged.
685
654 bool LayoutGrid::hasDefiniteLogicalSize(GridTrackSizingDirection direction) cons t 686 bool LayoutGrid::hasDefiniteLogicalSize(GridTrackSizingDirection direction) cons t
655 { 687 {
656 return (direction == ForRows) ? hasDefiniteLogicalHeight() : hasDefiniteLogi calWidth(); 688 return (direction == ForRows) ? hasDefiniteLogicalHeight() : hasDefiniteLogi calWidth();
657 } 689 }
658 690
691 LayoutUnit LayoutGrid::overrideContainingBlockBreadthForChild(const LayoutBox& c hild, GridTrackSizingDirection direction)
692 {
693 if (direction == ForRows)
694 return child.hasOverrideContainingBlockLogicalHeight() ? child.overrideC ontainingBlockContentLogicalHeight() : LayoutUnit();
695 return child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContai ningBlockContentLogicalWidth() : LayoutUnit();
696 }
697
698 void LayoutGrid::setOverrideContainingBlockBreadthForChild(LayoutBox& child, Gri dTrackSizingDirection direction, LayoutUnit breadth)
699 {
700 if (direction == ForRows)
701 child.setOverrideContainingBlockContentLogicalHeight(breadth);
702 else
703 child.setOverrideContainingBlockContentLogicalWidth(breadth);
704 }
705
659 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t i) const 706 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t i) const
660 { 707 {
661 bool isForColumns = direction == ForColumns; 708 bool isForColumns = direction == ForColumns;
662 const Vector<GridTrackSize>& trackStyles = isForColumns ? style()->gridTempl ateColumns() : style()->gridTemplateRows(); 709 const Vector<GridTrackSize>& trackStyles = isForColumns ? style()->gridTempl ateColumns() : style()->gridTemplateRows();
663 const GridTrackSize& autoTrackSize = isForColumns ? style()->gridAutoColumns () : style()->gridAutoRows(); 710 const GridTrackSize& autoTrackSize = isForColumns ? style()->gridAutoColumns () : style()->gridAutoRows();
664 int translatedIndex = i + (isForColumns ? m_smallestColumnStart : m_smallest RowStart); 711 int translatedIndex = i + (isForColumns ? m_smallestColumnStart : m_smallest RowStart);
665 const GridTrackSize& trackSize = (translatedIndex < 0 || translatedIndex >= static_cast<int>(trackStyles.size())) ? autoTrackSize : trackStyles[translatedIn dex]; 712 const GridTrackSize& trackSize = (translatedIndex < 0 || translatedIndex >= static_cast<int>(trackStyles.size())) ? autoTrackSize : trackStyles[translatedIn dex];
666 713
667 GridLength minTrackBreadth = trackSize.minTrackBreadth(); 714 GridLength minTrackBreadth = trackSize.minTrackBreadth();
668 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); 715 GridLength maxTrackBreadth = trackSize.maxTrackBreadth();
669 716
670 // If the logical width/height of the grid container is indefinite, percenta ge values are treated as <auto> 717 // If the logical width/height of the grid container is indefinite, percenta ge values are treated as <auto>
671 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { 718 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) {
672 if (!hasDefiniteLogicalSize(direction)) { 719 if (!hasDefiniteLogicalSize(direction)) {
673 if (minTrackBreadth.hasPercentage()) 720 if (minTrackBreadth.hasPercentage())
674 minTrackBreadth = Length(Auto); 721 minTrackBreadth = Length(Auto);
675 if (maxTrackBreadth.hasPercentage()) 722 if (maxTrackBreadth.hasPercentage())
676 maxTrackBreadth = Length(Auto); 723 maxTrackBreadth = Length(Auto);
677 } 724 }
678 } 725 }
679 726
680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 727 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
681 } 728 }
682 729
683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack> & columnTracks) 730 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const
684 { 731 {
732 return child.isHorizontalWritingMode() != isHorizontalWritingMode();
733 }
734
735 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, const GridSizingD ata& sizingData)
736 {
737 GridTrackSizingDirection childInlineDirection = isOrthogonalChild(child) ? F orRows : ForColumns;
685 SubtreeLayoutScope layoutScope(child); 738 SubtreeLayoutScope layoutScope(child);
686 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit(); 739 // Child's min-content contribution depends on the container's size along th e child's inline-axis.
687 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks); 740 LayoutUnit oldGridAreaBreadth = overrideContainingBlockBreadthForChild(child , childInlineDirection);
688 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog icalWidth != overrideContainingBlockContentLogicalWidth) { 741 LayoutUnit gridAreaBreadth = gridAreaBreadthForChild(child, childInlineDirec tion, sizingData);
742 if (child.hasRelativeLogicalHeight() || oldGridAreaBreadth != gridAreaBreadt h) {
689 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); 743 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged );
690 } 744 }
691 745
692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); 746 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight();
693 // We need to clear the stretched height to properly compute logical height during layout. 747 // We need to clear the stretched height to properly compute logical height during layout.
694 if (hasOverrideHeight && child.needsLayout()) 748 if (hasOverrideHeight && child.needsLayout())
695 child.clearOverrideLogicalContentHeight(); 749 child.clearOverrideLogicalContentHeight();
696 750
697 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); 751 setOverrideContainingBlockBreadthForChild(child, childInlineDirection, gridA reaBreadth);
698 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is 752 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is
699 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 753 // what we are interested in here. Thus we need to set the block-axis overri de breadth to -1 (no possible resolution).
700 if (child.hasRelativeLogicalHeight()) 754 if (child.hasRelativeLogicalHeight())
701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); 755 setOverrideContainingBlockBreadthForChild(child, childInlineDirection == ForColumns ? ForRows : ForColumns, LayoutUnit(-1));
702 child.layoutIfNeeded(); 756 child.layoutIfNeeded();
703 // If the child was stretched we should use its intrinsic height. 757 // If the child was stretched we should use its intrinsic height.
704 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh t()) + child.marginLogicalHeight(); 758 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh t()) + child.marginLogicalHeight();
705 } 759 }
706 760
707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, Vector<GridTrack>& columnTracks) 761 GridTrackSizingDirection LayoutGrid::flowAwareDirectionForChild(const LayoutBox& child, GridTrackSizingDirection direction) const
762 {
763 return isOrthogonalChild(child) ? (direction == ForColumns ? ForRows : ForCo lumns) : direction;
764 }
765
766 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, const GridSizingData& sizingData)
708 { 767 {
709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 768 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
710 // TODO(svillar): Properly support orthogonal writing mode. 769 bool isRowAxis = flowAwareDirection(hasOrthogonalWritingMode, direction) == ForColumns;
711 if (hasOrthogonalWritingMode)
712 return LayoutUnit();
713
714 bool isRowAxis = direction == ForColumns;
715 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); 770 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight();
716 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); 771 const Length& childMinSize = flowAwareDirection(hasOrthogonalWritingMode, di rection) == ForColumns ? child.style()->logicalMinWidth() : child.style()->logic alMinHeight();
717 if (!childSize.isAuto() || childMinSize.isAuto()) 772 if (!childSize.isAuto() || childMinSize.isAuto()) {
718 return minContentForChild(child, direction, columnTracks); 773 // TODO(svillar): Implement intrinsic aspect ratio support (transferred size in specs).
774 return minContentForChild(child, direction, sizingData);
775 }
719 776
720 if (isRowAxis) 777 if (isRowAxis)
721 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi calWidth(), this); 778 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi calWidth(), this);
722 779
723 return child.computeContentLogicalHeight(MinSize, childMinSize, child.logica lHeight()) + child.scrollbarLogicalHeight(); 780 return child.computeContentLogicalHeight(MinSize, childMinSize, child.logica lHeight()) + child.scrollbarLogicalHeight();
724 } 781 }
725 782
726 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 783 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, const GridSizingData& sizingData)
727 { 784 {
728 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 785 if (flowAwareDirectionForChild(child, direction) == ForColumns) {
729 // FIXME: Properly support orthogonal writing mode.
730 if (hasOrthogonalWritingMode)
731 return LayoutUnit();
732
733 if (direction == ForColumns) {
734 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 786 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
735 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). 787 // what we are interested in here. Thus we need to set the inline-axis o verride breadth to -1 (no possible resolution).
788 GridTrackSizingDirection childInlineDirection = isOrthogonalChild(child) ? ForRows : ForColumns;
736 if (child.hasRelativeLogicalWidth()) 789 if (child.hasRelativeLogicalWidth())
737 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); 790 setOverrideContainingBlockBreadthForChild(child, childInlineDirectio n, LayoutUnit(-1));
738 791
739 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 792 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
740 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 793 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
741 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 794 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
742 } 795 }
743 796
744 return logicalHeightForChild(child, columnTracks); 797 return logicalHeightForChild(child, sizingData);
745 } 798 }
746 799
747 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 800 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, const GridSizingData& sizingData)
748 { 801 {
749 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 802 if (flowAwareDirectionForChild(child, direction) == ForColumns) {
750 // FIXME: Properly support orthogonal writing mode.
751 if (hasOrthogonalWritingMode)
752 return LayoutUnit();
753
754 if (direction == ForColumns) {
755 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 803 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
756 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). 804 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution).
805 GridTrackSizingDirection childInlineDirection = isOrthogonalChild(child) ? ForRows : ForColumns;
757 if (child.hasRelativeLogicalWidth()) 806 if (child.hasRelativeLogicalWidth())
758 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); 807 setOverrideContainingBlockBreadthForChild(child, childInlineDirectio n, LayoutUnit(-1));
759 808
760 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 809 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
761 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 810 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
762 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 811 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
763 } 812 }
764 813
765 return logicalHeightForChild(child, columnTracks); 814 return logicalHeightForChild(child, sizingData);
766 } 815 }
767 816
768 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more 817 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more
769 // self-explanatory that using .first or .second members in the pair. Having a s td::pair<LayoutBox*, size_t> 818 // self-explanatory that using .first or .second members in the pair. Having a s td::pair<LayoutBox*, size_t>
770 // does not work either because we still need the GridSpan so we'd have to add a n extra hash lookup for each item 819 // does not work either because we still need the GridSpan so we'd have to add a n extra hash lookup for each item
771 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms(). 820 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms().
772 class GridItemWithSpan { 821 class GridItemWithSpan {
773 public: 822 public:
774 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) 823 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan)
775 : m_gridItem(&gridItem) 824 : m_gridItem(&gridItem)
(...skipping 26 matching lines...) Expand all
802 { 851 {
803 sizingData.itemsSortedByIncreasingSpan.shrink(0); 852 sizingData.itemsSortedByIncreasingSpan.shrink(0);
804 HashSet<LayoutBox*> itemsSet; 853 HashSet<LayoutBox*> itemsSet;
805 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 854 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
806 GridIterator iterator(m_grid, direction, trackIndex); 855 GridIterator iterator(m_grid, direction, trackIndex);
807 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; 856 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex];
808 while (LayoutBox* gridItem = iterator.nextGridItem()) { 857 while (LayoutBox* gridItem = iterator.nextGridItem()) {
809 if (itemsSet.add(gridItem).isNewEntry) { 858 if (itemsSet.add(gridItem).isNewEntry) {
810 const GridSpan& span = cachedGridSpan(*gridItem, direction); 859 const GridSpan& span = cachedGridSpan(*gridItem, direction);
811 if (span.integerSpan() == 1) { 860 if (span.integerSpan() == 1) {
812 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, span, *gridItem, track, sizingData.columnTracks); 861 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, span, *gridItem, track, sizingData);
813 } else if (!spanningItemCrossesFlexibleSizedTracks(span, directi on)) { 862 } else if (!spanningItemCrossesFlexibleSizedTracks(span, directi on)) {
814 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, span)); 863 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, span));
815 } 864 }
816 } 865 }
817 } 866 }
818 } 867 }
819 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end()); 868 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end());
820 869
821 auto it = sizingData.itemsSortedByIncreasingSpan.begin(); 870 auto it = sizingData.itemsSortedByIncreasingSpan.begin();
822 auto end = sizingData.itemsSortedByIncreasingSpan.end(); 871 auto end = sizingData.itemsSortedByIncreasingSpan.end();
823 while (it != end) { 872 while (it != end) {
824 GridItemsSpanGroupRange spanGroupRange = { it, std::upper_bound(it, end, *it) }; 873 GridItemsSpanGroupRange spanGroupRange = { it, std::upper_bound(it, end, *it) };
825 resolveContentBasedTrackSizingFunctionsForItems<ResolveIntrinsicMinimums >(direction, sizingData, spanGroupRange); 874 resolveContentBasedTrackSizingFunctionsForItems<ResolveIntrinsicMinimums >(direction, sizingData, spanGroupRange);
826 resolveContentBasedTrackSizingFunctionsForItems<ResolveContentBasedMinim ums>(direction, sizingData, spanGroupRange); 875 resolveContentBasedTrackSizingFunctionsForItems<ResolveContentBasedMinim ums>(direction, sizingData, spanGroupRange);
827 resolveContentBasedTrackSizingFunctionsForItems<ResolveMaxContentMinimum s>(direction, sizingData, spanGroupRange); 876 resolveContentBasedTrackSizingFunctionsForItems<ResolveMaxContentMinimum s>(direction, sizingData, spanGroupRange);
828 resolveContentBasedTrackSizingFunctionsForItems<ResolveIntrinsicMaximums >(direction, sizingData, spanGroupRange); 877 resolveContentBasedTrackSizingFunctionsForItems<ResolveIntrinsicMaximums >(direction, sizingData, spanGroupRange);
829 resolveContentBasedTrackSizingFunctionsForItems<ResolveMaxContentMaximum s>(direction, sizingData, spanGroupRange); 878 resolveContentBasedTrackSizingFunctionsForItems<ResolveMaxContentMaximum s>(direction, sizingData, spanGroupRange);
830 it = spanGroupRange.rangeEnd; 879 it = spanGroupRange.rangeEnd;
831 } 880 }
832 881
833 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 882 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
834 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; 883 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex];
835 if (track.growthLimitIsInfinite()) 884 if (track.growthLimitIsInfinite())
836 track.setGrowthLimit(track.baseSize()); 885 track.setGrowthLimit(track.baseSize());
837 } 886 }
838 } 887 }
839 888
840 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, Vector<GridTrack>& columnTracks) 889 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridSpan& span, LayoutBox& gridItem, GridT rack& track, const GridSizingData& sizingData)
841 { 890 {
842 const size_t trackPosition = span.resolvedInitialPosition(); 891 const size_t trackPosition = span.resolvedInitialPosition();
843 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); 892 GridTrackSize trackSize = gridTrackSize(direction, trackPosition);
844 893
845 if (trackSize.hasMinContentMinTrackBreadth()) 894 if (trackSize.hasMinContentMinTrackBreadth())
846 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, columnTracks))); 895 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, sizingData)));
847 else if (trackSize.hasMaxContentMinTrackBreadth()) 896 else if (trackSize.hasMaxContentMinTrackBreadth())
848 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, columnTracks))); 897 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, sizingData)));
849 else if (trackSize.hasAutoMinTrackBreadth()) 898 else if (trackSize.hasAutoMinTrackBreadth())
850 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, columnTracks))); 899 track.setBaseSize(std::max(track.baseSize(), minSizeForChild(gridItem, d irection, sizingData)));
851 900
852 if (trackSize.hasMinContentMaxTrackBreadth()) 901 if (trackSize.hasMinContentMaxTrackBreadth())
853 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, columnTracks))); 902 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, sizingData)));
854 else if (trackSize.hasMaxContentOrAutoMaxTrackBreadth()) 903 else if (trackSize.hasMaxContentOrAutoMaxTrackBreadth())
855 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, columnTracks))); 904 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, sizingData)));
856 } 905 }
857 906
858 static const LayoutUnit& trackSizeForTrackSizeComputationPhase(TrackSizeComputat ionPhase phase, const GridTrack& track, TrackSizeRestriction restriction) 907 static const LayoutUnit& trackSizeForTrackSizeComputationPhase(TrackSizeComputat ionPhase phase, const GridTrack& track, TrackSizeRestriction restriction)
859 { 908 {
860 switch (phase) { 909 switch (phase) {
861 case ResolveIntrinsicMinimums: 910 case ResolveIntrinsicMinimums:
862 case ResolveContentBasedMinimums: 911 case ResolveContentBasedMinimums:
863 case ResolveMaxContentMinimums: 912 case ResolveMaxContentMinimums:
864 case MaximizeTracks: 913 case MaximizeTracks:
865 return track.baseSize(); 914 return track.baseSize();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 track.setGrowthLimit(track.plannedSize()); 1002 track.setGrowthLimit(track.plannedSize());
954 return; 1003 return;
955 case MaximizeTracks: 1004 case MaximizeTracks:
956 ASSERT_NOT_REACHED(); 1005 ASSERT_NOT_REACHED();
957 return; 1006 return;
958 } 1007 }
959 1008
960 ASSERT_NOT_REACHED(); 1009 ASSERT_NOT_REACHED();
961 } 1010 }
962 1011
963 LayoutUnit LayoutGrid::currentItemSizeForTrackSizeComputationPhase(TrackSizeComp utationPhase phase, LayoutBox& gridItem, GridTrackSizingDirection direction, Vec tor<GridTrack>& columnTracks) 1012 LayoutUnit LayoutGrid::currentItemSizeForTrackSizeComputationPhase(TrackSizeComp utationPhase phase, LayoutBox& gridItem, GridTrackSizingDirection direction, con st GridSizingData& sizingData)
964 { 1013 {
965 switch (phase) { 1014 switch (phase) {
966 case ResolveIntrinsicMinimums: 1015 case ResolveIntrinsicMinimums:
967 return minSizeForChild(gridItem, direction, columnTracks); 1016 return minSizeForChild(gridItem, direction, sizingData);
968 case ResolveContentBasedMinimums: 1017 case ResolveContentBasedMinimums:
969 case ResolveIntrinsicMaximums: 1018 case ResolveIntrinsicMaximums:
970 return minContentForChild(gridItem, direction, columnTracks); 1019 return minContentForChild(gridItem, direction, sizingData);
971 case ResolveMaxContentMinimums: 1020 case ResolveMaxContentMinimums:
972 case ResolveMaxContentMaximums: 1021 case ResolveMaxContentMaximums:
973 return maxContentForChild(gridItem, direction, columnTracks); 1022 return maxContentForChild(gridItem, direction, sizingData);
svillar 2016/04/04 07:58:28 Perhaps you could refactor this patch as the sizin
974 case MaximizeTracks: 1023 case MaximizeTracks:
975 ASSERT_NOT_REACHED(); 1024 ASSERT_NOT_REACHED();
976 return LayoutUnit(); 1025 return LayoutUnit();
977 } 1026 }
978 1027
979 ASSERT_NOT_REACHED(); 1028 ASSERT_NOT_REACHED();
980 return LayoutUnit(); 1029 return LayoutUnit();
981 } 1030 }
982 1031
983 template <TrackSizeComputationPhase phase> 1032 template <TrackSizeComputationPhase phase>
(...skipping 24 matching lines...) Expand all
1008 1057
1009 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize)) 1058 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize))
1010 sizingData.growBeyondGrowthLimitsTracks.append(&track); 1059 sizingData.growBeyondGrowthLimitsTracks.append(&track);
1011 } 1060 }
1012 1061
1013 if (sizingData.filteredTracks.isEmpty()) 1062 if (sizingData.filteredTracks.isEmpty())
1014 continue; 1063 continue;
1015 1064
1016 spanningTracksSize += guttersSize(direction, itemSpan.integerSpan()); 1065 spanningTracksSize += guttersSize(direction, itemSpan.integerSpan());
1017 1066
1018 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData.columnTracks) - spanningTr acksSize; 1067 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize;
1019 extraSpace = extraSpace.clampNegativeToZero(); 1068 extraSpace = extraSpace.clampNegativeToZero();
1020 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks; 1069 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks;
1021 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace); 1070 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace);
1022 } 1071 }
1023 1072
1024 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 1073 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
1025 GridTrack& track = tracks[trackIndex]; 1074 GridTrack& track = tracks[trackIndex];
1026 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track); 1075 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track);
1027 updateTrackSizeForTrackSizeComputationPhase(phase, track); 1076 updateTrackSizeForTrackSizeComputationPhase(phase, track);
1028 } 1077 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 1461
1413 // Because the grid area cannot be styled, we don't need to adjust 1462 // Because the grid area cannot be styled, we don't need to adjust
1414 // the grid breadth to account for 'box-sizing'. 1463 // the grid breadth to account for 'box-sizing'.
1415 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); 1464 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit();
1416 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); 1465 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit();
1417 1466
1418 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData); 1467 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData);
1419 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData); 1468 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData);
1420 1469
1421 SubtreeLayoutScope layoutScope(*child); 1470 SubtreeLayoutScope layoutScope(*child);
1422 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) 1471 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && (child->hasRelativeLogicalHeight() || isOrthogonalChild(*child))))
1423 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged); 1472 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged);
1424 1473
1425 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); 1474 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth);
1426 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); 1475 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight);
1427 1476
1428 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded 1477 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded
1429 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly 1478 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly
1430 // determine the available space before stretching, are not set yet. 1479 // determine the available space before stretching, are not set yet.
1431 applyStretchAlignmentToChildIfNeeded(*child); 1480 applyStretchAlignmentToChildIfNeeded(*child);
1432 1481
(...skipping 27 matching lines...) Expand all
1460 childLayer->setStaticInlinePosition(borderAndPaddingStart()); 1509 childLayer->setStaticInlinePosition(borderAndPaddingStart());
1461 childLayer->setStaticBlockPosition(borderAndPaddingBefore()); 1510 childLayer->setStaticBlockPosition(borderAndPaddingBefore());
1462 } 1511 }
1463 1512
1464 void LayoutGrid::layoutPositionedObjects(bool relayoutChildren, PositionedLayout Behavior info) 1513 void LayoutGrid::layoutPositionedObjects(bool relayoutChildren, PositionedLayout Behavior info)
1465 { 1514 {
1466 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); 1515 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects();
1467 if (!positionedDescendants) 1516 if (!positionedDescendants)
1468 return; 1517 return;
1469 1518
1470 bool containerHasHorizontalWritingMode = isHorizontalWritingMode();
1471 for (auto* child : *positionedDescendants) { 1519 for (auto* child : *positionedDescendants) {
1472 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != cont ainerHasHorizontalWritingMode; 1520 if (isOrthogonalChild(*child)) {
1473 if (hasOrthogonalWritingMode) {
1474 // FIXME: Properly support orthogonal writing mode. 1521 // FIXME: Properly support orthogonal writing mode.
1475 continue; 1522 continue;
1476 } 1523 }
1477 1524
1478 LayoutUnit columnOffset = LayoutUnit(); 1525 LayoutUnit columnOffset = LayoutUnit();
1479 LayoutUnit columnBreadth = LayoutUnit(); 1526 LayoutUnit columnBreadth = LayoutUnit();
1480 offsetAndBreadthForPositionedChild(*child, ForColumns, columnOffset, col umnBreadth); 1527 offsetAndBreadthForPositionedChild(*child, ForColumns, columnOffset, col umnBreadth);
1481 LayoutUnit rowOffset = LayoutUnit(); 1528 LayoutUnit rowOffset = LayoutUnit();
1482 LayoutUnit rowBreadth = LayoutUnit(); 1529 LayoutUnit rowBreadth = LayoutUnit();
1483 offsetAndBreadthForPositionedChild(*child, ForRows, rowOffset, rowBreadt h); 1530 offsetAndBreadthForPositionedChild(*child, ForRows, rowOffset, rowBreadt h);
1484 1531
1485 child->setOverrideContainingBlockContentLogicalWidth(columnBreadth); 1532 child->setOverrideContainingBlockContentLogicalWidth(columnBreadth);
1486 child->setOverrideContainingBlockContentLogicalHeight(rowBreadth); 1533 child->setOverrideContainingBlockContentLogicalHeight(rowBreadth);
1487 child->setExtraInlineOffset(columnOffset); 1534 child->setExtraInlineOffset(columnOffset);
1488 child->setExtraBlockOffset(rowOffset); 1535 child->setExtraBlockOffset(rowOffset);
1489 } 1536 }
1490 1537
1491 LayoutBlock::layoutPositionedObjects(relayoutChildren, info); 1538 LayoutBlock::layoutPositionedObjects(relayoutChildren, info);
1492 } 1539 }
1493 1540
1494 void LayoutGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid TrackSizingDirection direction, LayoutUnit& offset, LayoutUnit& breadth) 1541 void LayoutGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid TrackSizingDirection direction, LayoutUnit& offset, LayoutUnit& breadth)
1495 { 1542 {
1496 ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode()); 1543 ASSERT(!isOrthogonalChild(child));
1497 bool isForColumns = direction == ForColumns; 1544 bool isForColumns = direction == ForColumns;
1498 1545
1499 GridSpan positions = GridPositionsResolver::resolveGridPositionsFromStyle(*s tyle(), child, direction); 1546 GridSpan positions = GridPositionsResolver::resolveGridPositionsFromStyle(*s tyle(), child, direction);
1500 if (positions.isIndefinite()) { 1547 if (positions.isIndefinite()) {
1501 offset = LayoutUnit(); 1548 offset = LayoutUnit();
1502 breadth = isForColumns ? clientLogicalWidth() : clientLogicalHeight(); 1549 breadth = isForColumns ? clientLogicalWidth() : clientLogicalHeight();
1503 return; 1550 return;
1504 } 1551 }
1505 1552
1506 // For positioned items we cannot use GridSpan::translate(). Because we coul d end up with negative values, as the positioned items do not create implicit tr acks per spec. 1553 // For positioned items we cannot use GridSpan::translate(). Because we coul d end up with negative values, as the positioned items do not create implicit tr acks per spec.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 ASSERT(m_gridItemArea.contains(&gridItem)); 1604 ASSERT(m_gridItemArea.contains(&gridItem));
1558 return m_gridItemArea.get(&gridItem); 1605 return m_gridItemArea.get(&gridItem);
1559 } 1606 }
1560 1607
1561 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const 1608 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const
1562 { 1609 {
1563 GridArea area = cachedGridArea(gridItem); 1610 GridArea area = cachedGridArea(gridItem);
1564 return direction == ForColumns ? area.columns : area.rows; 1611 return direction == ForColumns ? area.columns : area.rows;
1565 } 1612 }
1566 1613
1567 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const Vector<GridTrack>& tracks) const 1614 bool LayoutGrid::gridLengthIsIndefinite(const GridLength& length, GridTrackSizin gDirection direction) const
1568 { 1615 {
1616 return length.isContentSized() || length.isFlex() || (length.hasPercentage() && !hasDefiniteLogicalSize(direction));
svillar 2016/03/23 11:02:00 Really dangerous. We should not use hasDefiniteXXX
jfernandez 2016/04/01 16:39:56 I've just used what it's being done for the case o
svillar 2016/04/04 07:58:28 Yes, we know that gridTrackSize() is wrong. The ha
1617 }
1618
1619 LayoutUnit LayoutGrid::assumedRowsBreadthForOrthogonalChild(const LayoutBox& chi ld) const
1620 {
1621 ASSERT(isOrthogonalChild(child));
1622 const GridSpan& span = cachedGridSpan(child, ForRows);
1623 LayoutUnit gridAreaBreadth;
1624 for (auto trackPosition : span) {
1625 const GridLength& maxTrackBreadth = gridTrackSize(ForRows, trackPosition ).maxTrackBreadth();
1626 if (gridLengthIsIndefinite(maxTrackBreadth, ForRows)) {
1627 gridAreaBreadth = child.maxPreferredLogicalWidth() + marginIntrinsic LogicalWidthForChild(child);
1628 break;
1629 }
1630 gridAreaBreadth += valueForLength(maxTrackBreadth.length(), LayoutUnit() );
1631 }
1632
1633 gridAreaBreadth += guttersSize(ForRows, span.integerSpan());
1634
1635 return gridAreaBreadth;
1636 }
1637
1638 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const GridSizingData& sizingData) const
1639 {
1640 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks;
1641 // To determine the column track's breadth based on an orthogonal grid item we need it's logical height, which
1642 // may depend on the row track's breadth. It's possible that row tracks sizi ng logic has not been performed yet,
1643 // so we will need to do an estimation. We can detect this situation checkin g whether the row tracks vector is
1644 // empty or not.
1645 // TODO (lajava) are there better ways to do this ?
1646 if (isOrthogonalChild(child) && tracks.isEmpty())
1647 return assumedRowsBreadthForOrthogonalChild(child);
1569 const GridSpan& span = cachedGridSpan(child, direction); 1648 const GridSpan& span = cachedGridSpan(child, direction);
1570 LayoutUnit gridAreaBreadth; 1649 LayoutUnit gridAreaBreadth;
1571 for (const auto& trackPosition : span) 1650 for (const auto& trackPosition : span)
1572 gridAreaBreadth += tracks[trackPosition].baseSize(); 1651 gridAreaBreadth += tracks[trackPosition].baseSize();
1573 1652
1574 gridAreaBreadth += guttersSize(direction, span.integerSpan()); 1653 gridAreaBreadth += guttersSize(direction, span.integerSpan());
1575 1654
1576 return gridAreaBreadth; 1655 return gridAreaBreadth;
1577 } 1656 }
1578 1657
(...skipping 19 matching lines...) Expand all
1598 // using these positions to compute them. 1677 // using these positions to compute them.
1599 1678
1600 unsigned numberOfTracks = sizingData.columnTracks.size(); 1679 unsigned numberOfTracks = sizingData.columnTracks.size();
1601 unsigned numberOfLines = numberOfTracks + 1; 1680 unsigned numberOfLines = numberOfTracks + 1;
1602 unsigned lastLine = numberOfLines - 1; 1681 unsigned lastLine = numberOfLines - 1;
1603 unsigned nextToLastLine = numberOfLines - 2; 1682 unsigned nextToLastLine = numberOfLines - 2;
1604 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(Fo rColumns, sizingData.freeSpaceForDirection(ForColumns), numberOfTracks); 1683 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(Fo rColumns, sizingData.freeSpaceForDirection(ForColumns), numberOfTracks);
1605 LayoutUnit trackGap = guttersSize(ForColumns, 2); 1684 LayoutUnit trackGap = guttersSize(ForColumns, 2);
1606 m_columnPositions.resize(numberOfLines); 1685 m_columnPositions.resize(numberOfLines);
1607 m_columnPositions[0] = borderAndPaddingStart() + offset.positionOffset; 1686 m_columnPositions[0] = borderAndPaddingStart() + offset.positionOffset;
1608 for (unsigned i = 0; i < lastLine; ++i) 1687 for (unsigned i = 0; i < nextToLastLine; ++i)
1609 m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOff set + sizingData.columnTracks[i].baseSize() + trackGap; 1688 m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOff set + sizingData.columnTracks[i].baseSize() + trackGap;
1610 m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData .columnTracks[nextToLastLine].baseSize(); 1689 m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData .columnTracks[nextToLastLine].baseSize();
1611 1690
1612 numberOfTracks = sizingData.rowTracks.size(); 1691 numberOfTracks = sizingData.rowTracks.size();
1613 numberOfLines = numberOfTracks + 1; 1692 numberOfLines = numberOfTracks + 1;
1614 lastLine = numberOfLines - 1; 1693 lastLine = numberOfLines - 1;
1615 nextToLastLine = numberOfLines - 2; 1694 nextToLastLine = numberOfLines - 2;
1616 offset = computeContentPositionAndDistributionOffset(ForRows, sizingData.fre eSpaceForDirection(ForRows), numberOfTracks); 1695 offset = computeContentPositionAndDistributionOffset(ForRows, sizingData.fre eSpaceForDirection(ForRows), numberOfTracks);
1617 trackGap = guttersSize(ForRows, 2); 1696 trackGap = guttersSize(ForRows, 2);
1618 m_rowPositions.resize(numberOfLines); 1697 m_rowPositions.resize(numberOfLines);
1619 m_rowPositions[0] = borderAndPaddingBefore() + offset.positionOffset; 1698 m_rowPositions[0] = borderAndPaddingBefore() + offset.positionOffset;
1620 for (unsigned i = 0; i < lastLine; ++i) 1699 for (unsigned i = 0; i < nextToLastLine; ++i)
1621 m_rowPositions[i + 1] = m_rowPositions[i] + offset.distributionOffset + sizingData.rowTracks[i].baseSize() + trackGap; 1700 m_rowPositions[i + 1] = m_rowPositions[i] + offset.distributionOffset + sizingData.rowTracks[i].baseSize() + trackGap;
1622 m_rowPositions[lastLine] = m_rowPositions[nextToLastLine] + sizingData.rowTr acks[nextToLastLine].baseSize(); 1701 m_rowPositions[lastLine] = m_rowPositions[nextToLastLine] + sizingData.rowTr acks[nextToLastLine].baseSize();
1623 } 1702 }
1624 1703
1625 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay outUnit trackBreadth, LayoutUnit childBreadth) 1704 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay outUnit trackBreadth, LayoutUnit childBreadth)
1626 { 1705 {
1627 LayoutUnit offset = trackBreadth - childBreadth; 1706 LayoutUnit offset = trackBreadth - childBreadth;
1628 switch (overflow) { 1707 switch (overflow) {
1629 case OverflowAlignmentSafe: 1708 case OverflowAlignmentSafe:
1630 // If overflow is 'safe', we have to make sure we don't overflow the 'st art' 1709 // If overflow is 'safe', we have to make sure we don't overflow the 'st art'
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const 1874 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const
1796 { 1875 {
1797 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1876 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1798 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode(); 1877 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode();
1799 1878
1800 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { 1879 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) {
1801 case ItemPositionSelfStart: 1880 case ItemPositionSelfStart:
1802 // If orthogonal writing-modes, this computes to 'start'. 1881 // If orthogonal writing-modes, this computes to 'start'.
1803 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1882 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1804 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow. 1883 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow.
1805 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisStart : GridAxisEnd; 1884 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart : GridAxisEnd;
1806 case ItemPositionSelfEnd: 1885 case ItemPositionSelfEnd:
1807 // If orthogonal writing-modes, this computes to 'end'. 1886 // If orthogonal writing-modes, this computes to 'end'.
1808 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1887 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1809 // self-end is based on the child's block axis direction. That's why we need to check against the grid container's block flow. 1888 // self-end is based on the child's block axis direction. That's why we need to check against the grid container's block flow.
1810 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisEnd : GridAxisStart; 1889 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd : GridAxisStart;
1811 case ItemPositionLeft: 1890 case ItemPositionLeft:
1812 // The alignment axis (column axis) and the inline axis are parallell in 1891 // The alignment axis (column axis) and the inline axis are parallell in
1813 // orthogonal writing mode. Otherwise this this is equivalent to 'start' . 1892 // orthogonal writing mode. Otherwise this this is equivalent to 'start' .
1814 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1893 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1815 return GridAxisStart; 1894 return GridAxisStart;
1816 case ItemPositionRight: 1895 case ItemPositionRight:
1817 // The alignment axis (column axis) and the inline axis are parallell in 1896 // The alignment axis (column axis) and the inline axis are parallell in
1818 // orthogonal writing mode. Otherwise this this is equivalent to 'start' . 1897 // orthogonal writing mode. Otherwise this this is equivalent to 'start' .
1819 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1898 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1820 return hasOrthogonalWritingMode ? GridAxisEnd : GridAxisStart; 1899 return isOrthogonalChild(child) ? GridAxisEnd : GridAxisStart;
1821 case ItemPositionCenter: 1900 case ItemPositionCenter:
1822 return GridAxisCenter; 1901 return GridAxisCenter;
1823 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. 1902 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'.
1824 case ItemPositionStart: 1903 case ItemPositionStart:
1825 return GridAxisStart; 1904 return GridAxisStart;
1826 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. 1905 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'.
1827 case ItemPositionEnd: 1906 case ItemPositionEnd:
1828 return GridAxisEnd; 1907 return GridAxisEnd;
1829 case ItemPositionStretch: 1908 case ItemPositionStretch:
1830 return GridAxisStart; 1909 return GridAxisStart;
1831 case ItemPositionBaseline: 1910 case ItemPositionBaseline:
1832 case ItemPositionLastBaseline: 1911 case ItemPositionLastBaseline:
1833 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. 1912 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child.
1834 // crbug.com/234191 1913 // crbug.com/234191
1835 return GridAxisStart; 1914 return GridAxisStart;
1836 case ItemPositionAuto: 1915 case ItemPositionAuto:
1837 break; 1916 break;
1838 } 1917 }
1839 1918
1840 ASSERT_NOT_REACHED(); 1919 ASSERT_NOT_REACHED();
1841 return GridAxisStart; 1920 return GridAxisStart;
1842 } 1921 }
1843 1922
1844 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st 1923 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st
1845 { 1924 {
1846 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1847 bool hasSameDirection = child.styleRef().direction() == styleRef().direction (); 1925 bool hasSameDirection = child.styleRef().direction() == styleRef().direction ();
1848 bool isLTR = styleRef().isLeftToRightDirection(); 1926 bool isLTR = styleRef().isLeftToRightDirection();
1849 1927
1850 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) { 1928 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) {
1851 case ItemPositionSelfStart: 1929 case ItemPositionSelfStart:
1852 // For orthogonal writing-modes, this computes to 'start' 1930 // For orthogonal writing-modes, this computes to 'start'
1853 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1931 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1854 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. 1932 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction.
1855 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisStart : GridAxisEnd; 1933 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart : GridAxisEnd;
1856 case ItemPositionSelfEnd: 1934 case ItemPositionSelfEnd:
1857 // For orthogonal writing-modes, this computes to 'start' 1935 // For orthogonal writing-modes, this computes to 'start'
1858 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1936 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1859 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisEnd : Gr idAxisStart; 1937 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr idAxisStart;
1860 case ItemPositionLeft: 1938 case ItemPositionLeft:
1861 return isLTR ? GridAxisStart : GridAxisEnd; 1939 return isLTR ? GridAxisStart : GridAxisEnd;
1862 case ItemPositionRight: 1940 case ItemPositionRight:
1863 return isLTR ? GridAxisEnd : GridAxisStart; 1941 return isLTR ? GridAxisEnd : GridAxisStart;
1864 case ItemPositionCenter: 1942 case ItemPositionCenter:
1865 return GridAxisCenter; 1943 return GridAxisCenter;
1866 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. 1944 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'.
1867 case ItemPositionStart: 1945 case ItemPositionStart:
1868 return GridAxisStart; 1946 return GridAxisStart;
1869 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. 1947 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 case ContentPositionNormal: 2137 case ContentPositionNormal:
2060 break; 2138 break;
2061 } 2139 }
2062 2140
2063 ASSERT_NOT_REACHED(); 2141 ASSERT_NOT_REACHED();
2064 return {LayoutUnit(), LayoutUnit()}; 2142 return {LayoutUnit(), LayoutUnit()};
2065 } 2143 }
2066 2144
2067 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const 2145 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const
2068 { 2146 {
2147 LayoutUnit columnAxisOffset = columnAxisOffsetForChild(child, sizingData);
2069 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); 2148 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData);
2070 // We stored m_columnPosition s's data ignoring the direction, hence we migh t need now 2149 // We stored m_columnPositions's data ignoring the direction, hence we might need now
2071 // to translate positions from RTL to LTR, as it's more convenient for paint ing. 2150 // to translate positions from RTL to LTR, as it's more convenient for paint ing.
2072 if (!style()->isLeftToRightDirection()) { 2151 if (!style()->isLeftToRightDirection()) {
2073 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta rt(); 2152 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta rt();
2074 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft(); 2153 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft();
2075 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi dth()); 2154 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi dth());
2076 } 2155 }
2077 2156
2078 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2157 // "In the positioning phase [...] calculations are performed according to t he writing mode
2158 // of the containing block of the box establishing the orthogonal flow." How ever, the
2159 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's
2160 // logical position, which will only take into account the child's writing-m ode.
2161 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset);
2162 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation;
2079 } 2163 }
2080 2164
2081 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2165 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2082 { 2166 {
2083 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2167 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2084 } 2168 }
2085 2169
2086 } // namespace blink 2170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698