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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 if (minTrackBreadth.hasPercentage()) | 673 if (minTrackBreadth.hasPercentage()) |
674 minTrackBreadth = Length(Auto); | 674 minTrackBreadth = Length(Auto); |
675 if (maxTrackBreadth.hasPercentage()) | 675 if (maxTrackBreadth.hasPercentage()) |
676 maxTrackBreadth = Length(Auto); | 676 maxTrackBreadth = Length(Auto); |
677 } | 677 } |
678 } | 678 } |
679 | 679 |
680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
681 } | 681 } |
682 | 682 |
683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) | 683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData, bool overrideWidthHasChanged) |
jfernandez
2016/04/04 15:23:24
We shouldn't need this new argument. We only use t
svillar
2016/04/05 08:34:29
Acknowledged.
| |
684 { | 684 { |
685 SubtreeLayoutScope layoutScope(child); | 685 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(); | 686 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh t() || child.styleRef().logicalHeight().isIntrinsicOrAuto(); |
689 if (shouldClearContainingBlockLogicalHeight || oldOverrideContainingBlockCon tentLogicalWidth != overrideContainingBlockContentLogicalWidth) | 687 if (shouldClearContainingBlockLogicalHeight || overrideWidthHasChanged) |
690 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); | 688 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); |
691 | 689 |
692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); | 690 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); |
693 // We need to clear the stretched height to properly compute logical height during layout. | 691 // We need to clear the stretched height to properly compute logical height during layout. |
694 if (hasOverrideHeight && child.needsLayout()) | 692 if (hasOverrideHeight && child.needsLayout()) |
695 child.clearOverrideLogicalContentHeight(); | 693 child.clearOverrideLogicalContentHeight(); |
696 | 694 |
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 | 695 // 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). | 696 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). |
700 if (shouldClearContainingBlockLogicalHeight) | 697 if (shouldClearContainingBlockLogicalHeight) |
701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); | 698 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); |
702 child.layoutIfNeeded(); | 699 child.layoutIfNeeded(); |
703 // If the child was stretched we should use its intrinsic height. | 700 // If the child was stretched we should use its intrinsic height. |
704 return child.logicalHeight() + child.marginLogicalHeight(); | 701 return child.logicalHeight() + child.marginLogicalHeight(); |
705 } | 702 } |
706 | 703 |
707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) | 704 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) |
708 { | 705 { |
709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 706 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
710 // TODO(svillar): Properly support orthogonal writing mode. | 707 // TODO(svillar): Properly support orthogonal writing mode. |
711 if (hasOrthogonalWritingMode) | 708 if (hasOrthogonalWritingMode) |
712 return LayoutUnit(); | 709 return LayoutUnit(); |
713 | 710 |
714 bool isRowAxis = direction == ForColumns; | 711 bool isRowAxis = direction == ForColumns; |
715 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); | 712 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); |
716 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); | 713 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); |
717 if (!childSize.isAuto() || childMinSize.isAuto()) | 714 if (!childSize.isAuto() || childMinSize.isAuto()) |
718 return minContentForChild(child, direction, sizingData); | 715 return minContentForChild(child, direction, sizingData); |
719 | 716 |
717 SubtreeLayoutScope layoutScope(child); | |
718 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingDa ta)) | |
719 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); | |
720 child.layoutIfNeeded(); | |
721 | |
722 ASSERT(child.hasOverrideContainingBlockLogicalWidth()); | |
jfernandez
2016/04/04 15:23:24
Why we need this ASSERT ?
It's already part overr
| |
720 if (isRowAxis) | 723 if (isRowAxis) |
721 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi calWidth(), this); | 724 return child.computeLogicalWidthUsing(MinSize, childMinSize, child.overr ideContainingBlockContentLogicalWidth(), this) + child.marginLogicalWidth(); |
722 | 725 |
723 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.scrollbarLogicalHeight(); | 726 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ; |
727 } | |
728 | |
729 bool LayoutGrid::updateOverrideContainingBlockContentLogicalWidthForChild(Layout Box& child, GridSizingData& sizingData) | |
730 { | |
731 LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizing Data.columnTracks); | |
732 if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContaini ngBlockContentLogicalWidth() == overrideWidth) | |
733 return false; | |
734 | |
735 child.setOverrideContainingBlockContentLogicalWidth(overrideWidth); | |
736 return true; | |
724 } | 737 } |
725 | 738 |
726 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) | 739 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) |
727 { | 740 { |
728 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 741 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
729 // FIXME: Properly support orthogonal writing mode. | 742 // FIXME: Properly support orthogonal writing mode. |
730 if (hasOrthogonalWritingMode) | 743 if (hasOrthogonalWritingMode) |
731 return LayoutUnit(); | 744 return LayoutUnit(); |
732 | 745 |
733 if (direction == ForColumns) { | 746 if (direction == ForColumns) { |
734 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is | 747 // 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). | 748 // 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()) | 749 if (child.hasRelativeLogicalWidth()) |
737 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); | 750 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
738 | 751 |
739 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 752 // 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 | 753 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
741 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 754 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
742 } | 755 } |
743 | 756 |
744 return logicalHeightForChild(child, sizingData); | 757 bool overrideWidthHasChanged = updateOverrideContainingBlockContentLogicalWi dthForChild(child, sizingData); |
jfernandez
2016/04/01 11:00:46
Why we can't call this function inside logicalHeig
svillar
2016/04/05 08:34:29
Because it's pretty weird that a function that ret
| |
758 return logicalHeightForChild(child, sizingData, overrideWidthHasChanged); | |
745 } | 759 } |
746 | 760 |
747 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) | 761 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) |
748 { | 762 { |
749 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 763 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
750 // FIXME: Properly support orthogonal writing mode. | 764 // FIXME: Properly support orthogonal writing mode. |
751 if (hasOrthogonalWritingMode) | 765 if (hasOrthogonalWritingMode) |
752 return LayoutUnit(); | 766 return LayoutUnit(); |
753 | 767 |
754 if (direction == ForColumns) { | 768 if (direction == ForColumns) { |
755 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is | 769 // 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). | 770 // 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()) | 771 if (child.hasRelativeLogicalWidth()) |
758 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); | 772 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
759 | 773 |
760 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 774 // 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 | 775 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
762 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 776 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
763 } | 777 } |
764 | 778 |
765 return logicalHeightForChild(child, sizingData); | 779 bool overrideWidthHasChanged = updateOverrideContainingBlockContentLogicalWi dthForChild(child, sizingData); |
780 return logicalHeightForChild(child, sizingData, overrideWidthHasChanged); | |
766 } | 781 } |
767 | 782 |
768 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more | 783 // 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> | 784 // 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 | 785 // 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(). | 786 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms(). |
772 class GridItemWithSpan { | 787 class GridItemWithSpan { |
773 public: | 788 public: |
774 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) | 789 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) |
775 : m_gridItem(&gridItem) | 790 : m_gridItem(&gridItem) |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const | 1576 GridSpan LayoutGrid::cachedGridSpan(const LayoutBox& gridItem, GridTrackSizingDi rection direction) const |
1562 { | 1577 { |
1563 GridArea area = cachedGridArea(gridItem); | 1578 GridArea area = cachedGridArea(gridItem); |
1564 return direction == ForColumns ? area.columns : area.rows; | 1579 return direction == ForColumns ? area.columns : area.rows; |
1565 } | 1580 } |
1566 | 1581 |
1567 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const Vector<GridTrack>& tracks) const | 1582 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const Vector<GridTrack>& tracks) const |
1568 { | 1583 { |
1569 const GridSpan& span = cachedGridSpan(child, direction); | 1584 const GridSpan& span = cachedGridSpan(child, direction); |
1570 LayoutUnit gridAreaBreadth; | 1585 LayoutUnit gridAreaBreadth; |
1571 for (const auto& trackPosition : span) | 1586 for (const auto& trackPosition : span) { |
1587 if (tracks[trackPosition].baseSize() == infinity) | |
1588 return LayoutUnit(infinity); | |
jfernandez
2016/04/01 11:00:46
Could you explain this change ?
svillar
2016/04/05 08:34:29
Sure. This function can now be called just after i
svillar
2016/04/05 08:42:33
Now that I think about it, base sizes are never in
| |
1572 gridAreaBreadth += tracks[trackPosition].baseSize(); | 1589 gridAreaBreadth += tracks[trackPosition].baseSize(); |
1590 } | |
1573 | 1591 |
1574 gridAreaBreadth += guttersSize(direction, span.integerSpan()); | 1592 gridAreaBreadth += guttersSize(direction, span.integerSpan()); |
1575 | 1593 |
1576 return gridAreaBreadth; | 1594 return gridAreaBreadth; |
1577 } | 1595 } |
1578 | 1596 |
1579 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const | 1597 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const |
1580 { | 1598 { |
1581 // We need the cached value when available because Content Distribution alig nment properties | 1599 // We need the cached value when available because Content Distribution alig nment properties |
1582 // may have some influence in the final grid area breadth. | 1600 // may have some influence in the final grid area breadth. |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2040 | 2058 |
2041 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); | 2059 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); |
2042 } | 2060 } |
2043 | 2061 |
2044 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2062 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2045 { | 2063 { |
2046 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2064 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2047 } | 2065 } |
2048 | 2066 |
2049 } // namespace blink | 2067 } // namespace blink |
OLD | NEW |