| 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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 } | 946 } |
| 947 | 947 |
| 948 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const | 948 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const |
| 949 { | 949 { |
| 950 return child.isHorizontalWritingMode() != isHorizontalWritingMode(); | 950 return child.isHorizontalWritingMode() != isHorizontalWritingMode(); |
| 951 } | 951 } |
| 952 | 952 |
| 953 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s
izingData) const | 953 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s
izingData) const |
| 954 { | 954 { |
| 955 GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(ch
ild, ForRows); | 955 GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(ch
ild, ForRows); |
| 956 SubtreeLayoutScope layoutScope(child); | |
| 957 // If |child| has a relative logical height, we shouldn't let it override it
s intrinsic height, which is | 956 // If |child| has a relative logical height, we shouldn't let it override it
s intrinsic height, which is |
| 958 // what we are interested in here. Thus we need to set the block-axis overri
de size to -1 (no possible resolution). | 957 // what we are interested in here. Thus we need to set the block-axis overri
de size to -1 (no possible resolution). |
| 959 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForRows)) { | 958 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForRows)) { |
| 960 setOverrideContainingBlockContentSizeForChild(child, childBlockDirection
, LayoutUnit(-1)); | 959 setOverrideContainingBlockContentSizeForChild(child, childBlockDirection
, LayoutUnit(-1)); |
| 961 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged
); | 960 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 962 } | 961 } |
| 963 | 962 |
| 964 // We need to clear the stretched height to properly compute logical height
during layout. | 963 // We need to clear the stretched height to properly compute logical height
during layout. |
| 965 if (child.needsLayout()) | 964 if (child.needsLayout()) |
| 966 child.clearOverrideLogicalContentHeight(); | 965 child.clearOverrideLogicalContentHeight(); |
| 967 | 966 |
| 968 child.layoutIfNeeded(); | 967 child.layoutIfNeeded(); |
| 969 return child.logicalHeight() + child.marginLogicalHeight(); | 968 return child.logicalHeight() + child.marginLogicalHeight(); |
| 970 } | 969 } |
| 971 | 970 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 | 1021 |
| 1023 // All orthogonal flow boxes were already laid out during an early layout ph
ase performed in FrameView::performLayout. | 1022 // All orthogonal flow boxes were already laid out during an early layout ph
ase performed in FrameView::performLayout. |
| 1024 // It's true that grid track sizing was not completed at that time and it ma
y afffect the final height of a | 1023 // It's true that grid track sizing was not completed at that time and it ma
y afffect the final height of a |
| 1025 // grid item, but since it's forbidden to perform a layout during intrinsic
width computation, we have to use | 1024 // grid item, but since it's forbidden to perform a layout during intrinsic
width computation, we have to use |
| 1026 // that computed height for now. | 1025 // that computed height for now. |
| 1027 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo
mputation) { | 1026 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo
mputation) { |
| 1028 DCHECK(isOrthogonalChild(child)); | 1027 DCHECK(isOrthogonalChild(child)); |
| 1029 return child.logicalHeight() + child.marginLogicalHeight(); | 1028 return child.logicalHeight() + child.marginLogicalHeight(); |
| 1030 } | 1029 } |
| 1031 | 1030 |
| 1032 SubtreeLayoutScope layouter(child); | |
| 1033 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec
tion, sizingData)) | 1031 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec
tion, sizingData)) |
| 1034 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1032 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 1035 return logicalHeightForChild(child, sizingData); | 1033 return logicalHeightForChild(child, sizingData); |
| 1036 } | 1034 } |
| 1037 | 1035 |
| 1038 DISABLE_CFI_PERF | 1036 DISABLE_CFI_PERF |
| 1039 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, GridSizingData& sizingData) const | 1037 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, GridSizingData& sizingData) const |
| 1040 { | 1038 { |
| 1041 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c
hild, ForColumns); | 1039 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(c
hild, ForColumns); |
| 1042 if (direction == childInlineDirection) { | 1040 if (direction == childInlineDirection) { |
| 1043 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is | 1041 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is |
| 1044 // what we are interested in here. Thus we need to set the inline-axis o
verride size to -1 (no possible resolution). | 1042 // what we are interested in here. Thus we need to set the inline-axis o
verride size to -1 (no possible resolution). |
| 1045 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu
mns)) | 1043 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColu
mns)) |
| 1046 setOverrideContainingBlockContentSizeForChild(child, childInlineDire
ction, LayoutUnit(-1)); | 1044 setOverrideContainingBlockContentSizeForChild(child, childInlineDire
ction, LayoutUnit(-1)); |
| 1047 | 1045 |
| 1048 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 1046 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
| 1049 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 1047 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 1050 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); | 1048 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); |
| 1051 } | 1049 } |
| 1052 | 1050 |
| 1053 // All orthogonal flow boxes were already laid out during an early layout ph
ase performed in FrameView::performLayout. | 1051 // All orthogonal flow boxes were already laid out during an early layout ph
ase performed in FrameView::performLayout. |
| 1054 // It's true that grid track sizing was not completed at that time and it ma
y afffect the final height of a | 1052 // It's true that grid track sizing was not completed at that time and it ma
y afffect the final height of a |
| 1055 // grid item, but since it's forbidden to perform a layout during intrinsic
width computation, we have to use | 1053 // grid item, but since it's forbidden to perform a layout during intrinsic
width computation, we have to use |
| 1056 // that computed height for now. | 1054 // that computed height for now. |
| 1057 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo
mputation) { | 1055 if (direction == ForColumns && sizingData.sizingOperation == IntrinsicSizeCo
mputation) { |
| 1058 DCHECK(isOrthogonalChild(child)); | 1056 DCHECK(isOrthogonalChild(child)); |
| 1059 return child.logicalHeight() + child.marginLogicalHeight(); | 1057 return child.logicalHeight() + child.marginLogicalHeight(); |
| 1060 } | 1058 } |
| 1061 | 1059 |
| 1062 SubtreeLayoutScope layouter(child); | |
| 1063 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec
tion, sizingData)) | 1060 if (updateOverrideContainingBlockContentSizeForChild(child, childInlineDirec
tion, sizingData)) |
| 1064 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1061 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 1065 return logicalHeightForChild(child, sizingData); | 1062 return logicalHeightForChild(child, sizingData); |
| 1066 } | 1063 } |
| 1067 | 1064 |
| 1068 // We're basically using a class instead of a std::pair because of accessing gri
dItem() or getGridSpan() is much more | 1065 // We're basically using a class instead of a std::pair because of accessing gri
dItem() or getGridSpan() is much more |
| 1069 // self-explanatory that using .first or .second members in the pair. Having a s
td::pair<LayoutBox*, size_t> | 1066 // self-explanatory that using .first or .second members in the pair. Having a s
td::pair<LayoutBox*, size_t> |
| 1070 // does not work either because we still need the GridSpan so we'd have to add a
n extra hash lookup for each item | 1067 // does not work either because we still need the GridSpan so we'd have to add a
n extra hash lookup for each item |
| 1071 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte
ms(). | 1068 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte
ms(). |
| 1072 class GridItemWithSpan { | 1069 class GridItemWithSpan { |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 } | 1903 } |
| 1907 | 1904 |
| 1908 // Because the grid area cannot be styled, we don't need to adjust | 1905 // Because the grid area cannot be styled, we don't need to adjust |
| 1909 // the grid breadth to account for 'box-sizing'. | 1906 // the grid breadth to account for 'box-sizing'. |
| 1910 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); | 1907 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); |
| 1911 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); | 1908 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); |
| 1912 | 1909 |
| 1913 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF
orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData); | 1910 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF
orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData); |
| 1914 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth
ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData); | 1911 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth
ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData); |
| 1915 | 1912 |
| 1916 SubtreeLayoutScope layoutScope(*child); | |
| 1917 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB
lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov
errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) | 1913 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB
lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov
errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) |
| 1918 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan
ged); | 1914 child->setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 1919 | 1915 |
| 1920 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB
lockContentLogicalWidth); | 1916 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB
lockContentLogicalWidth); |
| 1921 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining
BlockContentLogicalHeight); | 1917 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining
BlockContentLogicalHeight); |
| 1922 | 1918 |
| 1923 // Stretching logic might force a child layout, so we need to run it bef
ore the layoutIfNeeded | 1919 // Stretching logic might force a child layout, so we need to run it bef
ore the layoutIfNeeded |
| 1924 // call to avoid unnecessary relayouts. This might imply that child marg
ins, needed to correctly | 1920 // call to avoid unnecessary relayouts. This might imply that child marg
ins, needed to correctly |
| 1925 // determine the available space before stretching, are not set yet. | 1921 // determine the available space before stretching, are not set yet. |
| 1926 applyStretchAlignmentToChildIfNeeded(*child); | 1922 applyStretchAlignmentToChildIfNeeded(*child); |
| 1927 | 1923 |
| 1928 child->layoutIfNeeded(); | 1924 child->layoutIfNeeded(); |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; | 2666 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; |
| 2671 } | 2667 } |
| 2672 | 2668 |
| 2673 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2669 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2674 { | 2670 { |
| 2675 if (!m_gridItemArea.isEmpty()) | 2671 if (!m_gridItemArea.isEmpty()) |
| 2676 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2672 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2677 } | 2673 } |
| 2678 | 2674 |
| 2679 } // namespace blink | 2675 } // namespace blink |
| OLD | NEW |