| 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). | |
| 1935 LayoutUnit childGridAreaHeight = isHorizontalWritingMode() ? overrideCon
tainingBlockContentLogicalHeight : overrideContainingBlockContentLogicalWidth; | 1934 LayoutUnit childGridAreaHeight = isHorizontalWritingMode() ? overrideCon
tainingBlockContentLogicalHeight : overrideContainingBlockContentLogicalWidth; |
| 1936 LayoutUnit childGridAreaWidth = isHorizontalWritingMode() ? overrideCont
ainingBlockContentLogicalWidth : overrideContainingBlockContentLogicalHeight; | 1935 LayoutUnit childGridAreaWidth = isHorizontalWritingMode() ? overrideCont
ainingBlockContentLogicalWidth : overrideContainingBlockContentLogicalHeight; |
| 1937 if (child->size().height() > childGridAreaHeight || child->size().width(
) > childGridAreaWidth) | 1936 LayoutRect gridAreaRect(gridAreaLogicalPosition(area), LayoutSize(childG
ridAreaWidth, childGridAreaHeight)); |
| 1937 if (!gridAreaRect.contains(child->frameRect())) |
| 1938 m_gridItemsOverflowingGridArea.append(child); | 1938 m_gridItemsOverflowingGridArea.append(child); |
| 1939 } | 1939 } |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) | 1942 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) |
| 1943 { | 1943 { |
| 1944 ASSERT(child.isOutOfFlowPositioned()); | 1944 ASSERT(child.isOutOfFlowPositioned()); |
| 1945 child.containingBlock()->insertPositionedObject(&child); | 1945 child.containingBlock()->insertPositionedObject(&child); |
| 1946 | 1946 |
| 1947 PaintLayer* childLayer = child.layer(); | 1947 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()); | 2654 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - (isOrthogonalChi
ld(child) ? child.logicalHeight() : child.logicalWidth()); |
| 2655 | 2655 |
| 2656 // "In the positioning phase [...] calculations are performed according to t
he writing mode | 2656 // "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 | 2657 // 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 | 2658 // 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. | 2659 // logical position, which will only take into account the child's writing-m
ode. |
| 2660 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); | 2660 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); |
| 2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; | 2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; |
| 2662 } | 2662 } |
| 2663 | 2663 |
| 2664 LayoutPoint LayoutGrid::gridAreaLogicalPosition(const GridArea& area) const |
| 2665 { |
| 2666 LayoutUnit columnAxisOffset = m_rowPositions[area.rows.startLine()]; |
| 2667 LayoutUnit rowAxisOffset = m_columnPositions[area.columns.startLine()]; |
| 2668 |
| 2669 // See comment in findChildLogicalPosition() about why we need sometimes to
translate from RTL |
| 2670 // to LTR the rowAxisOffset coordinate. |
| 2671 return LayoutPoint(style()->isLeftToRightDirection() ? rowAxisOffset : trans
lateRTLCoordinate(rowAxisOffset), columnAxisOffset); |
| 2672 } |
| 2673 |
| 2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2674 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2665 { | 2675 { |
| 2666 if (!m_gridItemArea.isEmpty()) | 2676 if (!m_gridItemArea.isEmpty()) |
| 2667 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2677 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2668 } | 2678 } |
| 2669 | 2679 |
| 2670 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const | 2680 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const |
| 2671 { | 2681 { |
| 2672 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 2682 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 2673 return m_hasDefiniteLogicalHeight.value(); | 2683 return m_hasDefiniteLogicalHeight.value(); |
| 2674 } | 2684 } |
| 2675 | 2685 |
| 2676 } // namespace blink | 2686 } // namespace blink |
| OLD | NEW |