Chromium Code Reviews| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 // In orthogonal flow cases column track's size is determined by using the | 457 // In orthogonal flow cases column track's size is determined by using the |
| 458 // computed row track's size, which it was estimated during the first cycle of | 458 // computed row track's size, which it was estimated during the first cycle of |
| 459 // the sizing algorithm. | 459 // the sizing algorithm. |
| 460 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns | 460 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns |
| 461 // and rows, to determine the final values. | 461 // and rows, to determine the final values. |
| 462 // TODO (lajava): orthogonal flows is just one of the cases which may require | 462 // TODO (lajava): orthogonal flows is just one of the cases which may require |
| 463 // a new cycle of the sizing algorithm; there may be more. In addition, not | 463 // a new cycle of the sizing algorithm; there may be more. In addition, not |
| 464 // all the cases with orthogonal flows require this extra cycle; we need a | 464 // all the cases with orthogonal flows require this extra cycle; we need a |
| 465 // more specific condition to detect whether child's min-content contribution | 465 // more specific condition to detect whether child's min-content contribution |
| 466 // has changed or not. | 466 // has changed or not. |
| 467 if (!m_orthogonalChildren.isEmpty()) { | 467 if (m_hasAnyOrthogonalChildren) { |
| 468 computeTrackSizesForDefiniteSize(ForColumns, sizingData, | 468 computeTrackSizesForDefiniteSize(ForColumns, sizingData, |
| 469 availableSpaceForColumns); | 469 availableSpaceForColumns); |
| 470 computeTrackSizesForDefiniteSize(ForRows, sizingData, | 470 computeTrackSizesForDefiniteSize(ForRows, sizingData, |
| 471 availableSpaceForRows); | 471 availableSpaceForRows); |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 void LayoutGrid::layoutBlock(bool relayoutChildren) { | 475 void LayoutGrid::layoutBlock(bool relayoutChildren) { |
| 476 ASSERT(needsLayout()); | 476 ASSERT(needsLayout()); |
| 477 | 477 |
| 478 if (!relayoutChildren && simplifiedLayout()) | 478 if (!relayoutChildren && simplifiedLayout()) |
| 479 return; | 479 return; |
| 480 | 480 |
| 481 SubtreeLayoutScope layoutScope(*this); | 481 SubtreeLayoutScope layoutScope(*this); |
| 482 | 482 |
| 483 { | 483 { |
| 484 // LayoutState needs this deliberate scope to pop before updating scroll | 484 // LayoutState needs this deliberate scope to pop before updating scroll |
| 485 // information (which may trigger relayout). | 485 // information (which may trigger relayout). |
| 486 LayoutState state(*this, locationOffset()); | 486 LayoutState state(*this, locationOffset()); |
| 487 | 487 |
| 488 LayoutSize previousSize = size(); | 488 LayoutSize previousSize = size(); |
| 489 | 489 |
| 490 // We need to clear both own and containingBlock override sizes to | 490 // We need to clear both own and containingBlock override sizes to |
| 491 // ensure we get the same result when grid's intrinsic size is | 491 // ensure we get the same result when grid's intrinsic size is |
| 492 // computed again in the updateLogicalWidth call bellow. | 492 // computed again in the updateLogicalWidth call bellow. |
| 493 if (sizesLogicalWidthToFitContent(styleRef().logicalWidth()) || | 493 if (sizesLogicalWidthToFitContent(styleRef().logicalWidth()) || |
| 494 styleRef().logicalWidth().isIntrinsicOrAuto()) { | 494 styleRef().logicalWidth().isIntrinsicOrAuto()) { |
| 495 // We do cache orthogonal items during the placeItemsOnGrid call, which is | 495 for (LayoutBox* child = firstChildBox(); child; |
|
svillar
2016/10/17 08:28:19
for (auto* child
| |
| 496 // executed later. However, we are | 496 child = child->nextInFlowSiblingBox()) { |
| 497 // only interested on running this logic when we are performing a | 497 if (child->isOutOfFlowPositioned() || !isOrthogonalChild(*child)) |
| 498 // relayout, hence we have already cached | |
| 499 // the orthogonal items. | |
| 500 for (auto* child : m_orthogonalChildren) { | |
| 501 if (child->isOutOfFlowPositioned()) | |
| 502 continue; | 498 continue; |
| 503 child->clearOverrideSize(); | 499 child->clearOverrideSize(); |
| 504 child->clearContainingBlockOverrideSize(); | 500 child->clearContainingBlockOverrideSize(); |
| 505 child->forceLayout(); | 501 child->forceLayout(); |
| 506 } | 502 } |
| 507 } | 503 } |
| 508 | 504 |
| 509 updateLogicalWidth(); | 505 updateLogicalWidth(); |
| 510 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); | 506 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
| 511 | 507 |
| (...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1925 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | 1921 computeAutoRepeatTracksCount(ForColumns, sizingOperation); |
| 1926 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); | 1922 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); |
| 1927 | 1923 |
| 1928 populateExplicitGridAndOrderIterator(); | 1924 populateExplicitGridAndOrderIterator(); |
| 1929 | 1925 |
| 1930 // We clear the dirty bit here as the grid sizes have been updated. | 1926 // We clear the dirty bit here as the grid sizes have been updated. |
| 1931 m_gridIsDirty = false; | 1927 m_gridIsDirty = false; |
| 1932 | 1928 |
| 1933 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1929 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 1934 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1930 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 1935 m_orthogonalChildren.shrink(0); | 1931 m_hasAnyOrthogonalChildren = false; |
| 1936 for (LayoutBox* child = m_orderIterator.first(); child; | 1932 for (LayoutBox* child = m_orderIterator.first(); child; |
| 1937 child = m_orderIterator.next()) { | 1933 child = m_orderIterator.next()) { |
| 1938 if (child->isOutOfFlowPositioned()) | 1934 if (child->isOutOfFlowPositioned()) |
| 1939 continue; | 1935 continue; |
| 1940 | 1936 |
| 1941 if (isOrthogonalChild(*child)) | 1937 m_hasAnyOrthogonalChildren = |
| 1942 m_orthogonalChildren.append(child); | 1938 m_hasAnyOrthogonalChildren || isOrthogonalChild(*child); |
| 1943 | 1939 |
| 1944 GridArea area = cachedGridArea(*child); | 1940 GridArea area = cachedGridArea(*child); |
| 1945 if (!area.rows.isIndefinite()) | 1941 if (!area.rows.isIndefinite()) |
| 1946 area.rows.translate(abs(m_smallestRowStart)); | 1942 area.rows.translate(abs(m_smallestRowStart)); |
| 1947 if (!area.columns.isIndefinite()) | 1943 if (!area.columns.isIndefinite()) |
| 1948 area.columns.translate(abs(m_smallestColumnStart)); | 1944 area.columns.translate(abs(m_smallestColumnStart)); |
| 1949 m_gridItemArea.set(child, area); | 1945 m_gridItemArea.set(child, area); |
| 1950 | 1946 |
| 1951 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { | 1947 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { |
| 1952 GridSpan majorAxisPositions = | 1948 GridSpan majorAxisPositions = |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3327 if (!m_gridItemArea.isEmpty()) | 3323 if (!m_gridItemArea.isEmpty()) |
| 3328 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3324 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 3329 } | 3325 } |
| 3330 | 3326 |
| 3331 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3327 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
| 3332 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3328 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 3333 return m_hasDefiniteLogicalHeight.value(); | 3329 return m_hasDefiniteLogicalHeight.value(); |
| 3334 } | 3330 } |
| 3335 | 3331 |
| 3336 } // namespace blink | 3332 } // namespace blink |
| OLD | NEW |