| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ng/ng_constraint_space.h" | 5 #include "core/layout/ng/ng_constraint_space.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 10 #include "core/layout/ng/ng_layout_opportunity_iterator.h" | 10 #include "core/layout/ng/ng_layout_opportunity_iterator.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); | 47 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); |
| 48 LayoutUnit available_logical_height; | 48 LayoutUnit available_logical_height; |
| 49 if (!box.parent()) { | 49 if (!box.parent()) { |
| 50 available_logical_height = box.view()->viewLogicalHeightForPercentages(); | 50 available_logical_height = box.view()->viewLogicalHeightForPercentages(); |
| 51 } else if (box.containingBlock()) { | 51 } else if (box.containingBlock()) { |
| 52 available_logical_height = | 52 available_logical_height = |
| 53 box.containingBlock()->availableLogicalHeightForPercentageComputation(); | 53 box.containingBlock()->availableLogicalHeightForPercentageComputation(); |
| 54 } | 54 } |
| 55 NGLogicalSize percentage_size = {available_logical_width, | 55 NGLogicalSize percentage_size = {available_logical_width, |
| 56 available_logical_height}; | 56 available_logical_height}; |
| 57 NGLogicalSize available_size = percentage_size; |
| 57 // When we have an override size, the available_logical_{width,height} will be | 58 // When we have an override size, the available_logical_{width,height} will be |
| 58 // used as the final size of the box, so it has to include border and | 59 // used as the final size of the box, so it has to include border and |
| 59 // padding. | 60 // padding. |
| 60 if (box.hasOverrideLogicalContentWidth()) { | 61 if (box.hasOverrideLogicalContentWidth()) { |
| 61 available_logical_width = | 62 available_size.inline_size = |
| 62 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); | 63 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); |
| 63 fixed_inline = true; | 64 fixed_inline = true; |
| 64 } | 65 } |
| 65 if (box.hasOverrideLogicalContentHeight()) { | 66 if (box.hasOverrideLogicalContentHeight()) { |
| 66 available_logical_height = box.borderAndPaddingLogicalHeight() + | 67 available_size.block_size = box.borderAndPaddingLogicalHeight() + |
| 67 box.overrideLogicalContentHeight(); | 68 box.overrideLogicalContentHeight(); |
| 68 fixed_block = true; | 69 fixed_block = true; |
| 69 } | 70 } |
| 70 | 71 |
| 71 bool is_new_fc = | 72 bool is_new_fc = |
| 72 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); | 73 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); |
| 73 | 74 |
| 74 NGLogicalSize logical_size = {available_logical_width, | |
| 75 available_logical_height}; | |
| 76 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode()); | 75 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode()); |
| 77 return NGConstraintSpaceBuilder(writing_mode) | 76 return NGConstraintSpaceBuilder(writing_mode) |
| 78 .SetAvailableSize(logical_size) | 77 .SetAvailableSize(available_size) |
| 79 .SetPercentageResolutionSize(percentage_size) | 78 .SetPercentageResolutionSize(percentage_size) |
| 80 .SetIsInlineDirectionTriggersScrollbar( | 79 .SetIsInlineDirectionTriggersScrollbar( |
| 81 box.styleRef().overflowInlineDirection() == EOverflow::Auto) | 80 box.styleRef().overflowInlineDirection() == EOverflow::Auto) |
| 82 .SetIsBlockDirectionTriggersScrollbar( | 81 .SetIsBlockDirectionTriggersScrollbar( |
| 83 box.styleRef().overflowBlockDirection() == EOverflow::Auto) | 82 box.styleRef().overflowBlockDirection() == EOverflow::Auto) |
| 84 .SetIsFixedSizeInline(fixed_inline) | 83 .SetIsFixedSizeInline(fixed_inline) |
| 85 .SetIsFixedSizeBlock(fixed_block) | 84 .SetIsFixedSizeBlock(fixed_block) |
| 86 .SetIsShrinkToFit( | 85 .SetIsShrinkToFit( |
| 87 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth())) | 86 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth())) |
| 88 .SetIsNewFormattingContext(is_new_fc) | 87 .SetIsNewFormattingContext(is_new_fc) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 111 | 110 |
| 112 String NGConstraintSpace::ToString() const { | 111 String NGConstraintSpace::ToString() const { |
| 113 return String::format("%s,%s %sx%s", | 112 return String::format("%s,%s %sx%s", |
| 114 offset_.inline_offset.toString().ascii().data(), | 113 offset_.inline_offset.toString().ascii().data(), |
| 115 offset_.block_offset.toString().ascii().data(), | 114 offset_.block_offset.toString().ascii().data(), |
| 116 AvailableSize().inline_size.toString().ascii().data(), | 115 AvailableSize().inline_size.toString().ascii().data(), |
| 117 AvailableSize().block_size.toString().ascii().data()); | 116 AvailableSize().block_size.toString().ascii().data()); |
| 118 } | 117 } |
| 119 | 118 |
| 120 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |