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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly | 1915 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly |
1916 // determine the available space before stretching, are not set yet. | 1916 // determine the available space before stretching, are not set yet. |
1917 applyStretchAlignmentToChildIfNeeded(*child); | 1917 applyStretchAlignmentToChildIfNeeded(*child); |
1918 | 1918 |
1919 child->layoutIfNeeded(); | 1919 child->layoutIfNeeded(); |
1920 | 1920 |
1921 // We need pending layouts to be done in order to compute auto-margins p roperly. | 1921 // We need pending layouts to be done in order to compute auto-margins p roperly. |
1922 updateAutoMarginsInColumnAxisIfNeeded(*child); | 1922 updateAutoMarginsInColumnAxisIfNeeded(*child); |
1923 updateAutoMarginsInRowAxisIfNeeded(*child); | 1923 updateAutoMarginsInRowAxisIfNeeded(*child); |
1924 | 1924 |
1925 const GridArea& area = cachedGridArea(*child); | |
1925 #if ENABLE(ASSERT) | 1926 #if ENABLE(ASSERT) |
1926 const GridArea& area = cachedGridArea(*child); | |
1927 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); | 1927 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); |
1928 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); | 1928 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); |
1929 #endif | 1929 #endif |
1930 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); | 1930 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); |
1931 | 1931 |
1932 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is not visible. | 1932 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is not visible. |
1933 // Using physical dimensions for simplicity, so we can forget about orth ogonalty. | 1933 // Using physical dimensions for simplicity, so we can forget about orth ogonalty. |
1934 // TODO (lajava): Child's margins should account when evaluating whether it overflows its grid area (http://crbug.com/628155). | 1934 // TODO (lajava): Child's margins should account when evaluating whether it overflows its grid area (http://crbug.com/628155). |
jfernandez
2016/09/19 18:01:24
Remove the TODO, please.
svillar
2016/09/20 11:12:46
Acknowledged.
| |
1935 LayoutUnit childGridAreaHeight = isHorizontalWritingMode() ? overrideCon tainingBlockContentLogicalHeight : overrideContainingBlockContentLogicalWidth; | 1935 LayoutUnit childGridAreaHeight = isHorizontalWritingMode() ? overrideCon tainingBlockContentLogicalHeight : overrideContainingBlockContentLogicalWidth; |
1936 LayoutUnit childGridAreaWidth = isHorizontalWritingMode() ? overrideCont ainingBlockContentLogicalWidth : overrideContainingBlockContentLogicalHeight; | 1936 LayoutUnit childGridAreaWidth = isHorizontalWritingMode() ? overrideCont ainingBlockContentLogicalWidth : overrideContainingBlockContentLogicalHeight; |
1937 if (child->size().height() > childGridAreaHeight || child->size().width( ) > childGridAreaWidth) | 1937 LayoutRect gridAreaRect(gridAreaLogicalPosition(area), LayoutSize(childG ridAreaWidth, childGridAreaHeight)); |
1938 if (!gridAreaRect.contains(child->frameRect())) | |
jfernandez
2016/09/19 18:01:24
Using FrameRect should be the same than doing oper
svillar
2016/09/20 11:12:47
The main difference are not the sizes indeed, but
| |
1938 m_gridItemsOverflowingGridArea.append(child); | 1939 m_gridItemsOverflowingGridArea.append(child); |
1939 } | 1940 } |
1940 } | 1941 } |
1941 | 1942 |
1942 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) | 1943 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) |
1943 { | 1944 { |
1944 ASSERT(child.isOutOfFlowPositioned()); | 1945 ASSERT(child.isOutOfFlowPositioned()); |
1945 child.containingBlock()->insertPositionedObject(&child); | 1946 child.containingBlock()->insertPositionedObject(&child); |
1946 | 1947 |
1947 PaintLayer* childLayer = child.layer(); | 1948 PaintLayer* childLayer = child.layer(); |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2654 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - (isOrthogonalChi ld(child) ? child.logicalHeight() : child.logicalWidth()); | 2655 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - (isOrthogonalChi ld(child) ? child.logicalHeight() : child.logicalWidth()); |
2655 | 2656 |
2656 // "In the positioning phase [...] calculations are performed according to t he writing mode | 2657 // "In the positioning phase [...] calculations are performed according to t he writing mode |
2657 // of the containing block of the box establishing the orthogonal flow." How ever, the | 2658 // of the containing block of the box establishing the orthogonal flow." How ever, the |
2658 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's | 2659 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's |
2659 // logical position, which will only take into account the child's writing-m ode. | 2660 // logical position, which will only take into account the child's writing-m ode. |
2660 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); | 2661 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); |
2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2662 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
2662 } | 2663 } |
2663 | 2664 |
2665 LayoutPoint LayoutGrid::gridAreaLogicalPosition(const GridArea& area) const | |
2666 { | |
2667 LayoutUnit columnAxisOffset = m_rowPositions[area.rows.startLine()]; | |
2668 LayoutUnit rowAxisOffset = m_columnPositions[area.columns.startLine()]; | |
2669 | |
2670 // See comment in findChildLogicalPosition() about why we need sometimes to translate from RTL | |
2671 // to LTR the rowAxisOffset coordinate. | |
2672 return LayoutPoint(style()->isLeftToRightDirection() ? rowAxisOffset : trans lateRTLCoordinate(rowAxisOffset), columnAxisOffset); | |
2673 } | |
2674 | |
2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2675 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2665 { | 2676 { |
2666 if (!m_gridItemArea.isEmpty()) | 2677 if (!m_gridItemArea.isEmpty()) |
2667 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2678 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2668 } | 2679 } |
2669 | 2680 |
2670 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const | 2681 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const |
2671 { | 2682 { |
2672 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 2683 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
2673 return m_hasDefiniteLogicalHeight.value(); | 2684 return m_hasDefiniteLogicalHeight.value(); |
2674 } | 2685 } |
2675 | 2686 |
2676 } // namespace blink | 2687 } // namespace blink |
OLD | NEW |