Chromium Code Reviews| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 // FIXME: It's unclear if we should return the intrinsic width or the | 296 // FIXME: It's unclear if we should return the intrinsic width or the |
| 297 // preferred width. | 297 // preferred width. |
| 298 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 298 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 299 LayoutUnit marginLogicalWidth = | 299 LayoutUnit marginLogicalWidth = |
| 300 child.needsLayout() ? computeMarginLogicalSizeForChild( | 300 child.needsLayout() ? computeMarginLogicalSizeForChild( |
| 301 InlineDirection, layoutGrid(), child) | 301 InlineDirection, layoutGrid(), child) |
| 302 : child.marginLogicalWidth(); | 302 : child.marginLogicalWidth(); |
| 303 return child.minPreferredLogicalWidth() + marginLogicalWidth; | 303 return child.minPreferredLogicalWidth() + marginLogicalWidth; |
| 304 } | 304 } |
| 305 | 305 |
| 306 // All orthogonal flow boxes were already laid out during an early layout | |
| 307 // phase performed in FrameView::performLayout. | |
| 308 // 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 | |
| 310 // perform a layout during intrinsic width computation, we have to use that | |
| 311 // computed height for now. | |
| 312 if (direction() == ForColumns && | |
| 313 m_algorithm.m_sizingOperation == IntrinsicSizeComputation) { | |
| 314 DCHECK(layoutGrid()->isOrthogonalChild(child)); | |
| 315 return child.logicalHeight() + child.marginLogicalHeight(); | |
|
jfernandez
2017/02/15 22:49:58
Removing this code implies that we will mark the g
| |
| 316 } | |
| 317 | |
| 318 if (updateOverrideContainingBlockContentSizeForChild(child, | 306 if (updateOverrideContainingBlockContentSizeForChild(child, |
| 319 childInlineDirection)) | 307 childInlineDirection)) |
| 320 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 308 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 321 return logicalHeightForChild(child); | 309 return logicalHeightForChild(child); |
| 322 } | 310 } |
| 323 | 311 |
| 324 DISABLE_CFI_PERF | 312 DISABLE_CFI_PERF |
| 325 LayoutUnit GridTrackSizingAlgorithmStrategy::maxContentForChild( | 313 LayoutUnit GridTrackSizingAlgorithmStrategy::maxContentForChild( |
| 326 LayoutBox& child) const { | 314 LayoutBox& child) const { |
| 327 GridTrackSizingDirection childInlineDirection = | 315 GridTrackSizingDirection childInlineDirection = |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 339 // FIXME: It's unclear if we should return the intrinsic width or the | 327 // FIXME: It's unclear if we should return the intrinsic width or the |
| 340 // preferred width. | 328 // preferred width. |
| 341 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 329 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 342 LayoutUnit marginLogicalWidth = | 330 LayoutUnit marginLogicalWidth = |
| 343 child.needsLayout() ? computeMarginLogicalSizeForChild( | 331 child.needsLayout() ? computeMarginLogicalSizeForChild( |
| 344 InlineDirection, layoutGrid(), child) | 332 InlineDirection, layoutGrid(), child) |
| 345 : child.marginLogicalWidth(); | 333 : child.marginLogicalWidth(); |
| 346 return child.maxPreferredLogicalWidth() + marginLogicalWidth; | 334 return child.maxPreferredLogicalWidth() + marginLogicalWidth; |
| 347 } | 335 } |
| 348 | 336 |
| 349 if (direction() == ForColumns && | |
| 350 m_algorithm.m_sizingOperation == IntrinsicSizeComputation) { | |
| 351 // All orthogonal flow boxes were already laid out during an early layout | |
| 352 // phase performed in FrameView::performLayout. It's true that grid track | |
| 353 // sizing was not completed at that time and it may afffect the final height | |
| 354 // of a grid item, but since it's forbidden to perform a layout during | |
| 355 // intrinsic width computation, we have to use that computed height for now. | |
| 356 DCHECK(layoutGrid()->isOrthogonalChild(child)); | |
| 357 return child.logicalHeight() + child.marginLogicalHeight(); | |
|
jfernandez
2017/02/15 22:49:58
Ditto.
| |
| 358 } | |
| 359 | |
| 360 if (updateOverrideContainingBlockContentSizeForChild(child, | 337 if (updateOverrideContainingBlockContentSizeForChild(child, |
| 361 childInlineDirection)) | 338 childInlineDirection)) |
| 362 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 339 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 363 return logicalHeightForChild(child); | 340 return logicalHeightForChild(child); |
| 364 } | 341 } |
| 365 | 342 |
| 366 LayoutUnit GridTrackSizingAlgorithmStrategy::minSizeForChild( | 343 LayoutUnit GridTrackSizingAlgorithmStrategy::minSizeForChild( |
| 367 LayoutBox& child) const { | 344 LayoutBox& child) const { |
| 368 GridTrackSizingDirection childInlineDirection = | 345 GridTrackSizingDirection childInlineDirection = |
| 369 flowAwareDirectionForChild(layoutGrid(), child, ForColumns); | 346 flowAwareDirectionForChild(layoutGrid(), child, ForColumns); |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1425 DCHECK(m_algorithm.isValidTransition()); | 1402 DCHECK(m_algorithm.isValidTransition()); |
| 1426 DCHECK(!m_algorithm.m_needsSetup); | 1403 DCHECK(!m_algorithm.m_needsSetup); |
| 1427 } | 1404 } |
| 1428 | 1405 |
| 1429 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { | 1406 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { |
| 1430 m_algorithm.advanceNextState(); | 1407 m_algorithm.advanceNextState(); |
| 1431 m_algorithm.m_needsSetup = true; | 1408 m_algorithm.m_needsSetup = true; |
| 1432 } | 1409 } |
| 1433 | 1410 |
| 1434 } // namespace blink | 1411 } // namespace blink |
| OLD | NEW |