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 } | 1915 } |
1916 } | 1916 } |
1917 return emptyTrackIndexes; | 1917 return emptyTrackIndexes; |
1918 } | 1918 } |
1919 | 1919 |
1920 void LayoutGrid::placeItemsOnGrid() { | 1920 void LayoutGrid::placeItemsOnGrid() { |
1921 if (!m_gridIsDirty) | 1921 if (!m_gridIsDirty) |
1922 return; | 1922 return; |
1923 | 1923 |
1924 DCHECK(m_gridItemArea.isEmpty()); | 1924 DCHECK(m_gridItemArea.isEmpty()); |
1925 DCHECK(m_gridItemsIndexesMap.isEmpty()); | |
1926 | 1925 |
1927 populateExplicitGridAndOrderIterator(); | 1926 populateExplicitGridAndOrderIterator(); |
1928 | 1927 |
1929 // We clear the dirty bit here as the grid sizes have been updated. | 1928 // We clear the dirty bit here as the grid sizes have been updated. |
1930 m_gridIsDirty = false; | 1929 m_gridIsDirty = false; |
1931 | 1930 |
1932 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1931 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
1933 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1932 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 1933 DCHECK(m_gridItemsIndexesMap.isEmpty()); |
| 1934 size_t childIndex = 0; |
1934 m_hasAnyOrthogonalChildren = false; | 1935 m_hasAnyOrthogonalChildren = false; |
1935 for (LayoutBox* child = m_orderIterator.first(); child; | 1936 for (LayoutBox* child = m_orderIterator.first(); child; |
1936 child = m_orderIterator.next()) { | 1937 child = m_orderIterator.next()) { |
1937 if (child->isOutOfFlowPositioned()) | 1938 if (child->isOutOfFlowPositioned()) |
1938 continue; | 1939 continue; |
1939 | 1940 |
| 1941 m_gridItemsIndexesMap.set(child, childIndex++); |
| 1942 |
1940 m_hasAnyOrthogonalChildren = | 1943 m_hasAnyOrthogonalChildren = |
1941 m_hasAnyOrthogonalChildren || isOrthogonalChild(*child); | 1944 m_hasAnyOrthogonalChildren || isOrthogonalChild(*child); |
1942 | 1945 |
1943 GridArea area = cachedGridArea(*child); | 1946 GridArea area = cachedGridArea(*child); |
1944 if (!area.rows.isIndefinite()) | 1947 if (!area.rows.isIndefinite()) |
1945 area.rows.translate(abs(m_smallestRowStart)); | 1948 area.rows.translate(abs(m_smallestRowStart)); |
1946 if (!area.columns.isIndefinite()) | 1949 if (!area.columns.isIndefinite()) |
1947 area.columns.translate(abs(m_smallestColumnStart)); | 1950 area.columns.translate(abs(m_smallestColumnStart)); |
1948 m_gridItemArea.set(child, area); | 1951 m_gridItemArea.set(child, area); |
1949 | 1952 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 void LayoutGrid::populateExplicitGridAndOrderIterator() { | 1993 void LayoutGrid::populateExplicitGridAndOrderIterator() { |
1991 OrderIteratorPopulator populator(m_orderIterator); | 1994 OrderIteratorPopulator populator(m_orderIterator); |
1992 | 1995 |
1993 m_smallestRowStart = m_smallestColumnStart = 0; | 1996 m_smallestRowStart = m_smallestColumnStart = 0; |
1994 | 1997 |
1995 size_t maximumRowIndex = | 1998 size_t maximumRowIndex = |
1996 GridPositionsResolver::explicitGridRowCount(*style(), m_autoRepeatRows); | 1999 GridPositionsResolver::explicitGridRowCount(*style(), m_autoRepeatRows); |
1997 size_t maximumColumnIndex = GridPositionsResolver::explicitGridColumnCount( | 2000 size_t maximumColumnIndex = GridPositionsResolver::explicitGridColumnCount( |
1998 *style(), m_autoRepeatColumns); | 2001 *style(), m_autoRepeatColumns); |
1999 | 2002 |
2000 ASSERT(m_gridItemsIndexesMap.isEmpty()); | |
2001 size_t childIndex = 0; | |
2002 for (LayoutBox* child = firstInFlowChildBox(); child; | 2003 for (LayoutBox* child = firstInFlowChildBox(); child; |
2003 child = child->nextInFlowSiblingBox()) { | 2004 child = child->nextInFlowSiblingBox()) { |
2004 populator.collectChild(child); | 2005 populator.collectChild(child); |
2005 m_gridItemsIndexesMap.set(child, childIndex++); | |
2006 | 2006 |
2007 // This function bypasses the cache (cachedGridArea()) as it is used to | 2007 // This function bypasses the cache (cachedGridArea()) as it is used to |
2008 // build it. | 2008 // build it. |
2009 GridSpan rowPositions = | 2009 GridSpan rowPositions = |
2010 GridPositionsResolver::resolveGridPositionsFromStyle( | 2010 GridPositionsResolver::resolveGridPositionsFromStyle( |
2011 *style(), *child, ForRows, m_autoRepeatRows); | 2011 *style(), *child, ForRows, m_autoRepeatRows); |
2012 GridSpan columnPositions = | 2012 GridSpan columnPositions = |
2013 GridPositionsResolver::resolveGridPositionsFromStyle( | 2013 GridPositionsResolver::resolveGridPositionsFromStyle( |
2014 *style(), *child, ForColumns, m_autoRepeatColumns); | 2014 *style(), *child, ForColumns, m_autoRepeatColumns); |
2015 m_gridItemArea.set(child, GridArea(rowPositions, columnPositions)); | 2015 m_gridItemArea.set(child, GridArea(rowPositions, columnPositions)); |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 if (!m_gridItemArea.isEmpty()) | 3323 if (!m_gridItemArea.isEmpty()) |
3324 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3324 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
3325 } | 3325 } |
3326 | 3326 |
3327 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3327 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
3328 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3328 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
3329 return m_hasDefiniteLogicalHeight.value(); | 3329 return m_hasDefiniteLogicalHeight.value(); |
3330 } | 3330 } |
3331 | 3331 |
3332 } // namespace blink | 3332 } // namespace blink |
OLD | NEW |