| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/GridTrackSizingAlgorithm.h" | 5 #include "core/layout/GridTrackSizingAlgorithm.h" |
| 6 | 6 |
| 7 #include "core/layout/Grid.h" | 7 #include "core/layout/Grid.h" |
| 8 #include "core/layout/LayoutGrid.h" | 8 #include "core/layout/LayoutGrid.h" |
| 9 #include "platform/LengthFunctions.h" | 9 #include "platform/LengthFunctions.h" |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 LayoutUnit(-1)); | 268 LayoutUnit(-1)); |
| 269 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 269 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // We need to clear the stretched height to properly compute logical height | 272 // We need to clear the stretched height to properly compute logical height |
| 273 // during layout. | 273 // during layout. |
| 274 if (child.needsLayout()) | 274 if (child.needsLayout()) |
| 275 child.clearOverrideLogicalContentHeight(); | 275 child.clearOverrideLogicalContentHeight(); |
| 276 | 276 |
| 277 child.layoutIfNeeded(); | 277 child.layoutIfNeeded(); |
| 278 GridAxis baselineAxis = |
| 279 layoutGrid()->isOrthogonalChild(child) ? GridRowAxis : GridColumnAxis; |
| 280 if (layoutGrid()->isBaselineAlignmentForChild(child, baselineAxis) && |
| 281 layoutGrid()->isBaselineContextComputed(baselineAxis)) { |
| 282 auto& group = layoutGrid()->getBaselineGroupForChild(child, baselineAxis); |
| 283 return group.maxAscent() + group.maxDescent(); |
| 284 } |
| 278 return child.logicalHeight() + child.marginLogicalHeight(); | 285 return child.logicalHeight() + child.marginLogicalHeight(); |
| 279 } | 286 } |
| 280 | 287 |
| 281 DISABLE_CFI_PERF | 288 DISABLE_CFI_PERF |
| 282 LayoutUnit GridTrackSizingAlgorithmStrategy::minContentForChild( | 289 LayoutUnit GridTrackSizingAlgorithmStrategy::minContentForChild( |
| 283 LayoutBox& child) const { | 290 LayoutBox& child) const { |
| 284 GridTrackSizingDirection childInlineDirection = | 291 GridTrackSizingDirection childInlineDirection = |
| 285 flowAwareDirectionForChild(layoutGrid(), child, ForColumns); | 292 flowAwareDirectionForChild(layoutGrid(), child, ForColumns); |
| 286 if (direction() == childInlineDirection) { | 293 if (direction() == childInlineDirection) { |
| 287 // If |child| has a relative logical width, we shouldn't let it override its | 294 // If |child| has a relative logical width, we shouldn't let it override its |
| (...skipping 17 matching lines...) Expand all Loading... |
| 305 | 312 |
| 306 // All orthogonal flow boxes were already laid out during an early layout | 313 // All orthogonal flow boxes were already laid out during an early layout |
| 307 // phase performed in FrameView::performLayout. | 314 // phase performed in FrameView::performLayout. |
| 308 // It's true that grid track sizing was not completed at that time and it may | 315 // It's true that grid track sizing was not completed at that time and it may |
| 309 // afffect the final height of a grid item, but since it's forbidden to | 316 // afffect the final height of a grid item, but since it's forbidden to |
| 310 // perform a layout during intrinsic width computation, we have to use that | 317 // perform a layout during intrinsic width computation, we have to use that |
| 311 // computed height for now. | 318 // computed height for now. |
| 312 if (direction() == ForColumns && | 319 if (direction() == ForColumns && |
| 313 m_algorithm.m_sizingOperation == IntrinsicSizeComputation) { | 320 m_algorithm.m_sizingOperation == IntrinsicSizeComputation) { |
| 314 DCHECK(layoutGrid()->isOrthogonalChild(child)); | 321 DCHECK(layoutGrid()->isOrthogonalChild(child)); |
| 322 if (layoutGrid()->isBaselineAlignmentForChild(child, GridRowAxis) && |
| 323 layoutGrid()->isBaselineContextComputed(GridRowAxis)) { |
| 324 auto& group = layoutGrid()->getBaselineGroupForChild(child, GridRowAxis); |
| 325 return group.maxAscent() + group.maxDescent(); |
| 326 } |
| 315 return child.logicalHeight() + child.marginLogicalHeight(); | 327 return child.logicalHeight() + child.marginLogicalHeight(); |
| 316 } | 328 } |
| 317 | 329 |
| 318 if (updateOverrideContainingBlockContentSizeForChild(child, | 330 if (updateOverrideContainingBlockContentSizeForChild(child, |
| 319 childInlineDirection)) | 331 childInlineDirection)) |
| 320 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 332 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 321 return logicalHeightForChild(child); | 333 return logicalHeightForChild(child); |
| 322 } | 334 } |
| 323 | 335 |
| 324 DISABLE_CFI_PERF | 336 DISABLE_CFI_PERF |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 DCHECK(m_algorithm.isValidTransition()); | 1447 DCHECK(m_algorithm.isValidTransition()); |
| 1436 DCHECK(!m_algorithm.m_needsSetup); | 1448 DCHECK(!m_algorithm.m_needsSetup); |
| 1437 } | 1449 } |
| 1438 | 1450 |
| 1439 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { | 1451 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { |
| 1440 m_algorithm.advanceNextState(); | 1452 m_algorithm.advanceNextState(); |
| 1441 m_algorithm.m_needsSetup = true; | 1453 m_algorithm.m_needsSetup = true; |
| 1442 } | 1454 } |
| 1443 | 1455 |
| 1444 } // namespace blink | 1456 } // namespace blink |
| OLD | NEW |