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_hasAnyOrthogonalChild) { | 467 if (!m_orthogonalChildren.isEmpty()) { |
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 |
| 491 // ensure we get the same result when grid's intrinsic size is |
| 492 // computed again in the updateLogicalWidth call bellow. |
| 493 if (sizesLogicalWidthToFitContent(styleRef().logicalWidth()) || |
| 494 styleRef().logicalWidth().isIntrinsicOrAuto()) { |
| 495 // We do cache orthogonal items during the placeItemsOnGrid call, which is |
| 496 // executed later. However, we are |
| 497 // only interested on running this logic when we are performing a |
| 498 // relayout, hence we have already cached |
| 499 // the orthogonal items. |
| 500 for (auto* child : m_orthogonalChildren) { |
| 501 if (child->isOutOfFlowPositioned()) |
| 502 continue; |
| 503 child->clearOverrideSize(); |
| 504 child->clearContainingBlockOverrideSize(); |
| 505 child->forceLayout(); |
| 506 } |
| 507 } |
| 508 |
490 updateLogicalWidth(); | 509 updateLogicalWidth(); |
491 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); | 510 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
492 | 511 |
493 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 512 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
494 | 513 |
495 // TODO(svillar): we won't need to do this once the intrinsic width | 514 // TODO(svillar): we won't need to do this once the intrinsic width |
496 // computation is isolated from the LayoutGrid object state (it should not | 515 // computation is isolated from the LayoutGrid object state (it should not |
497 // touch any attribute) (see crbug.com/627812) | 516 // touch any attribute) (see crbug.com/627812) |
498 if (m_autoRepeatColumns && | 517 if (m_autoRepeatColumns && |
499 m_autoRepeatColumns != | 518 m_autoRepeatColumns != |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | 1925 computeAutoRepeatTracksCount(ForColumns, sizingOperation); |
1907 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); | 1926 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); |
1908 | 1927 |
1909 populateExplicitGridAndOrderIterator(); | 1928 populateExplicitGridAndOrderIterator(); |
1910 | 1929 |
1911 // We clear the dirty bit here as the grid sizes have been updated. | 1930 // We clear the dirty bit here as the grid sizes have been updated. |
1912 m_gridIsDirty = false; | 1931 m_gridIsDirty = false; |
1913 | 1932 |
1914 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1933 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
1915 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1934 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
1916 m_hasAnyOrthogonalChild = false; | 1935 m_orthogonalChildren.shrink(0); |
1917 for (LayoutBox* child = m_orderIterator.first(); child; | 1936 for (LayoutBox* child = m_orderIterator.first(); child; |
1918 child = m_orderIterator.next()) { | 1937 child = m_orderIterator.next()) { |
1919 if (child->isOutOfFlowPositioned()) | 1938 if (child->isOutOfFlowPositioned()) |
1920 continue; | 1939 continue; |
1921 | 1940 |
1922 m_hasAnyOrthogonalChild = | 1941 if (isOrthogonalChild(*child)) |
1923 m_hasAnyOrthogonalChild || isOrthogonalChild(*child); | 1942 m_orthogonalChildren.append(child); |
1924 | 1943 |
1925 GridArea area = cachedGridArea(*child); | 1944 GridArea area = cachedGridArea(*child); |
1926 if (!area.rows.isIndefinite()) | 1945 if (!area.rows.isIndefinite()) |
1927 area.rows.translate(abs(m_smallestRowStart)); | 1946 area.rows.translate(abs(m_smallestRowStart)); |
1928 if (!area.columns.isIndefinite()) | 1947 if (!area.columns.isIndefinite()) |
1929 area.columns.translate(abs(m_smallestColumnStart)); | 1948 area.columns.translate(abs(m_smallestColumnStart)); |
1930 m_gridItemArea.set(child, area); | 1949 m_gridItemArea.set(child, area); |
1931 | 1950 |
1932 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { | 1951 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { |
1933 GridSpan majorAxisPositions = | 1952 GridSpan majorAxisPositions = |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3308 if (!m_gridItemArea.isEmpty()) | 3327 if (!m_gridItemArea.isEmpty()) |
3309 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3328 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
3310 } | 3329 } |
3311 | 3330 |
3312 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3331 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
3313 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3332 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
3314 return m_hasDefiniteLogicalHeight.value(); | 3333 return m_hasDefiniteLogicalHeight.value(); |
3315 } | 3334 } |
3316 | 3335 |
3317 } // namespace blink | 3336 } // namespace blink |
OLD | NEW |