OLD | NEW |
---|---|
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; |
246 Vector<GridTrack*> growBeyondGrowthLimitsTracks; | 246 Vector<GridTrack*> growBeyondGrowthLimitsTracks; |
247 | 247 |
248 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } | 248 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } |
249 | 249 |
250 enum SizingOperation { TrackSizing, IntrinsicSizeComputation }; | |
251 SizingOperation sizingOperation { TrackSizing }; | |
252 | |
250 private: | 253 private: |
251 LayoutUnit freeSpaceForColumns { }; | 254 LayoutUnit freeSpaceForColumns { }; |
252 LayoutUnit freeSpaceForRows { }; | 255 LayoutUnit freeSpaceForRows { }; |
253 }; | 256 }; |
254 | 257 |
255 struct GridItemsSpanGroupRange { | 258 struct GridItemsSpanGroupRange { |
256 Vector<GridItemWithSpan>::iterator rangeStart; | 259 Vector<GridItemWithSpan>::iterator rangeStart; |
257 Vector<GridItemWithSpan>::iterator rangeEnd; | 260 Vector<GridItemWithSpan>::iterator rangeEnd; |
258 }; | 261 }; |
259 | 262 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 326 |
324 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); | 327 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); |
325 | 328 |
326 return logicalHeight; | 329 return logicalHeight; |
327 } | 330 } |
328 | 331 |
329 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) | 332 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) |
330 { | 333 { |
331 ASSERT(freeSpace >= 0); | 334 ASSERT(freeSpace >= 0); |
332 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); | 335 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); |
336 sizingData.sizingOperation = GridSizingData::TrackSizing; | |
333 | 337 |
334 LayoutUnit baseSizes, growthLimits; | 338 LayoutUnit baseSizes, growthLimits; |
335 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s, AvailableSpaceDefinite); | 339 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s, AvailableSpaceDefinite); |
336 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 340 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); |
337 } | 341 } |
338 | 342 |
339 void LayoutGrid::layoutBlock(bool relayoutChildren) | 343 void LayoutGrid::layoutBlock(bool relayoutChildren) |
340 { | 344 { |
341 ASSERT(needsLayout()); | 345 ASSERT(needsLayout()); |
342 | 346 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); | 416 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); |
413 return valueForLength(trackGap, LayoutUnit()) * (span - 1); | 417 return valueForLength(trackGap, LayoutUnit()) * (span - 1); |
414 } | 418 } |
415 | 419 |
416 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const | 420 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const |
417 { | 421 { |
418 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | 422 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); |
419 | 423 |
420 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 424 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
421 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 425 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); |
426 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; | |
422 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite); | 427 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite); |
423 | 428 |
424 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); | 429 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); |
425 minLogicalWidth += totalGuttersSize; | 430 minLogicalWidth += totalGuttersSize; |
426 maxLogicalWidth += totalGuttersSize; | 431 maxLogicalWidth += totalGuttersSize; |
427 | 432 |
428 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); | 433 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); |
429 minLogicalWidth += scrollbarWidth; | 434 minLogicalWidth += scrollbarWidth; |
430 maxLogicalWidth += scrollbarWidth; | 435 maxLogicalWidth += scrollbarWidth; |
431 } | 436 } |
432 | 437 |
433 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 438 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) |
434 { | 439 { |
435 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 440 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
436 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); | 441 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); |
442 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; | |
437 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight, AvailableSpaceIndefinite); | 443 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight, AvailableSpaceIndefinite); |
438 | 444 |
439 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); | 445 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); |
440 m_minContentHeight += totalGuttersSize; | 446 m_minContentHeight += totalGuttersSize; |
441 m_maxContentHeight += totalGuttersSize; | 447 m_maxContentHeight += totalGuttersSize; |
442 | 448 |
443 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 449 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); |
444 } | 450 } |
445 | 451 |
446 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const | 452 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 maxTrackBreadth = Length(Auto); | 682 maxTrackBreadth = Length(Auto); |
677 } | 683 } |
678 } | 684 } |
679 | 685 |
680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 686 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
681 } | 687 } |
682 | 688 |
683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) | 689 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) |
684 { | 690 { |
685 SubtreeLayoutScope layoutScope(child); | 691 SubtreeLayoutScope layoutScope(child); |
686 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit(); | |
687 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, sizingData.columnTracks); | |
688 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh t() || child.styleRef().logicalHeight().isIntrinsicOrAuto(); | 692 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh t() || child.styleRef().logicalHeight().isIntrinsicOrAuto(); |
689 if (shouldClearContainingBlockLogicalHeight || oldOverrideContainingBlockCon tentLogicalWidth != overrideContainingBlockContentLogicalWidth) | 693 if (shouldClearContainingBlockLogicalHeight) |
jfernandez
2016/04/06 12:22:23
We only use the TreeScope for the setNeedsForLayo
svillar
2016/04/06 14:55:09
As you can see in the SubtreeLayoutScope, that cla
jfernandez
2016/04/07 07:49:39
Yes, you're right. The change is equivalent to the
| |
690 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); | 694 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); |
691 | 695 |
692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); | 696 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); |
693 // We need to clear the stretched height to properly compute logical height during layout. | 697 // We need to clear the stretched height to properly compute logical height during layout. |
694 if (hasOverrideHeight && child.needsLayout()) | 698 if (hasOverrideHeight && child.needsLayout()) |
695 child.clearOverrideLogicalContentHeight(); | 699 child.clearOverrideLogicalContentHeight(); |
696 | 700 |
697 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); | |
698 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is | 701 // 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). | 702 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). |
700 if (shouldClearContainingBlockLogicalHeight) | 703 if (shouldClearContainingBlockLogicalHeight) |
701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); | 704 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); |
702 child.layoutIfNeeded(); | 705 child.layoutIfNeeded(); |
703 // If the child was stretched we should use its intrinsic height. | 706 // If the child was stretched we should use its intrinsic height. |
704 return child.logicalHeight() + child.marginLogicalHeight(); | 707 return child.logicalHeight() + child.marginLogicalHeight(); |
705 } | 708 } |
706 | 709 |
707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) | 710 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) |
708 { | 711 { |
709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 712 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
710 // TODO(svillar): Properly support orthogonal writing mode. | 713 // TODO(svillar): Properly support orthogonal writing mode. |
711 if (hasOrthogonalWritingMode) | 714 if (hasOrthogonalWritingMode) |
712 return LayoutUnit(); | 715 return LayoutUnit(); |
713 | 716 |
714 bool isRowAxis = direction == ForColumns; | 717 bool isRowAxis = direction == ForColumns; |
715 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); | 718 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); |
716 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); | 719 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); |
717 if (!childSize.isAuto() || childMinSize.isAuto()) | 720 if (!childSize.isAuto() || childMinSize.isAuto()) |
718 return minContentForChild(child, direction, sizingData); | 721 return minContentForChild(child, direction, sizingData); |
719 | 722 |
720 if (isRowAxis) | 723 bool overrideLogicalWidthHasChanged = updateOverrideContainingBlockContentLo gicalWidthForChild(child, sizingData); |
721 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi calWidth(), this); | 724 if (isRowAxis) { |
725 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizing Data::TrackSizing ? computeMarginLogicalSizeForChild(InlineDirection, child) : m arginIntrinsicLogicalWidthForChild(child); | |
726 return child.computeLogicalWidthUsing(MinSize, childMinSize, child.overr ideContainingBlockContentLogicalWidth(), this) + marginLogicalWidth; | |
727 } | |
722 | 728 |
723 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.scrollbarLogicalHeight(); | 729 if (overrideLogicalWidthHasChanged) |
730 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | |
731 child.layoutIfNeeded(); | |
732 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ; | |
733 } | |
734 | |
735 bool LayoutGrid::updateOverrideContainingBlockContentLogicalWidthForChild(Layout Box& child, GridSizingData& sizingData) | |
736 { | |
737 LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizing Data.columnTracks); | |
738 if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContaini ngBlockContentLogicalWidth() == overrideWidth) | |
739 return false; | |
740 | |
741 child.setOverrideContainingBlockContentLogicalWidth(overrideWidth); | |
742 return true; | |
724 } | 743 } |
725 | 744 |
726 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) | 745 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) |
727 { | 746 { |
728 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 747 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
729 // FIXME: Properly support orthogonal writing mode. | 748 // FIXME: Properly support orthogonal writing mode. |
730 if (hasOrthogonalWritingMode) | 749 if (hasOrthogonalWritingMode) |
731 return LayoutUnit(); | 750 return LayoutUnit(); |
732 | 751 |
733 if (direction == ForColumns) { | 752 if (direction == ForColumns) { |
734 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is | 753 // 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). | 754 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). |
736 if (child.hasRelativeLogicalWidth()) | 755 if (child.hasRelativeLogicalWidth()) |
737 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); | 756 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
738 | 757 |
739 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 758 // 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 | 759 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
741 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 760 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
742 } | 761 } |
743 | 762 |
763 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingDa ta)) | |
764 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | |
jfernandez
2016/04/06 12:22:23
Shouldn't we use the SubtreeLayoutScope here ?
svillar
2016/04/06 14:55:09
We know that logicalHeightForChild() is going to c
jfernandez
2016/04/07 07:49:39
The SubtreeLAyoutScope approach is used in other p
| |
744 return logicalHeightForChild(child, sizingData); | 765 return logicalHeightForChild(child, sizingData); |
745 } | 766 } |
746 | 767 |
747 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) | 768 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) |
748 { | 769 { |
749 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 770 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
750 // FIXME: Properly support orthogonal writing mode. | 771 // FIXME: Properly support orthogonal writing mode. |
751 if (hasOrthogonalWritingMode) | 772 if (hasOrthogonalWritingMode) |
752 return LayoutUnit(); | 773 return LayoutUnit(); |
753 | 774 |
754 if (direction == ForColumns) { | 775 if (direction == ForColumns) { |
755 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is | 776 // 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). | 777 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). |
757 if (child.hasRelativeLogicalWidth()) | 778 if (child.hasRelativeLogicalWidth()) |
758 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); | 779 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
759 | 780 |
760 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 781 // 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 | 782 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
762 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 783 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
763 } | 784 } |
764 | 785 |
786 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingDa ta)) | |
787 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | |
jfernandez
2016/04/06 12:22:23
Shouldn't we use the SubtreeLayoutScope here ?
| |
765 return logicalHeightForChild(child, sizingData); | 788 return logicalHeightForChild(child, sizingData); |
766 } | 789 } |
767 | 790 |
768 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more | 791 // 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> | 792 // 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 | 793 // 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(). | 794 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms(). |
772 class GridItemWithSpan { | 795 class GridItemWithSpan { |
773 public: | 796 public: |
774 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) | 797 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1641 ASSERT_NOT_REACHED(); | 1664 ASSERT_NOT_REACHED(); |
1642 return LayoutUnit(); | 1665 return LayoutUnit(); |
1643 } | 1666 } |
1644 | 1667 |
1645 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. | 1668 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. |
1646 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const | 1669 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const |
1647 { | 1670 { |
1648 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth( ); | 1671 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth( ); |
1649 } | 1672 } |
1650 | 1673 |
1651 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child ) const | 1674 LayoutUnit LayoutGrid::computeMarginLogicalSizeForChild(MarginDirection forDirec tion, const LayoutBox& child) const |
1652 { | 1675 { |
1653 if (!child.styleRef().hasMargin()) | 1676 if (!child.styleRef().hasMargin()) |
1654 return LayoutUnit(); | 1677 return LayoutUnit(); |
1655 | 1678 |
1656 LayoutUnit marginBefore; | 1679 bool isRowAxis = forDirection == InlineDirection; |
1657 LayoutUnit marginAfter; | 1680 LayoutUnit marginStart; |
1658 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, | 1681 LayoutUnit marginEnd; |
1659 child.style()->marginBeforeUsing(style()), | 1682 LayoutUnit logicalSize = isRowAxis ? child.logicalWidth() : child.logicalHei ght(); |
1660 child.style()->marginAfterUsing(style())); | 1683 Length marginStartLength = isRowAxis ? child.styleRef().marginStart() : chil d.styleRef().marginBeforeUsing(style()); |
1684 Length marginEndLength = isRowAxis ? child.styleRef().marginEnd() : child.st yleRef().marginAfterUsing(style()); | |
1685 child.computeMarginsForDirection(forDirection, this, child.containingBlockLo gicalWidthForContent(), logicalSize, | |
1686 marginStart, marginEnd, marginStartLength, marginEndLength); | |
1661 | 1687 |
1662 return marginBefore + marginAfter; | 1688 return marginStart + marginEnd; |
1663 } | 1689 } |
1664 | 1690 |
1665 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const | 1691 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const |
1666 { | 1692 { |
1667 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before | 1693 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before |
1668 // children are laid out, so we can't use the child cached values. Hence, we need to | 1694 // children are laid out, so we can't use the child cached values. Hence, we need to |
1669 // compute margins in order to determine the available height before stretch ing. | 1695 // compute margins in order to determine the available height before stretch ing. |
1670 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical HeightForChild(child) : marginLogicalHeightForChild(child)); | 1696 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical SizeForChild(BlockDirection, child) : marginLogicalHeightForChild(child)); |
1671 } | 1697 } |
1672 | 1698 |
1673 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. | 1699 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. |
1674 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) | 1700 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) |
1675 { | 1701 { |
1676 // We clear height override values because we will decide now whether it's a llowed or | 1702 // We clear height override values because we will decide now whether it's a llowed or |
1677 // not, evaluating the conditions which might have changed since the old val ues were set. | 1703 // not, evaluating the conditions which might have changed since the old val ues were set. |
1678 child.clearOverrideLogicalContentHeight(); | 1704 child.clearOverrideLogicalContentHeight(); |
1679 | 1705 |
1680 auto& childStyle = child.styleRef(); | 1706 auto& childStyle = child.styleRef(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2040 | 2066 |
2041 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); | 2067 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); |
2042 } | 2068 } |
2043 | 2069 |
2044 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2070 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2045 { | 2071 { |
2046 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2072 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2047 } | 2073 } |
2048 | 2074 |
2049 } // namespace blink | 2075 } // namespace blink |
OLD | NEW |