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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 // XXX for orthogonal writing mode this is not right | 45 // XXX for orthogonal writing mode this is not right |
46 LayoutUnit available_logical_width = | 46 LayoutUnit available_logical_width = |
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, | |
56 available_logical_height}; | |
55 // When we have an override size, the available_logical_{width,height} will be | 57 // When we have an override size, the available_logical_{width,height} will be |
56 // used as the final size of the box, so it has to include border and | 58 // used as the final size of the box, so it has to include border and |
57 // padding. | 59 // padding. |
58 if (box.hasOverrideLogicalContentWidth()) { | 60 if (box.hasOverrideLogicalContentWidth()) { |
59 available_logical_width = | 61 available_logical_width = |
60 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); | 62 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); |
61 fixed_inline = true; | 63 fixed_inline = true; |
62 } | 64 } |
63 if (box.hasOverrideLogicalContentHeight()) { | 65 if (box.hasOverrideLogicalContentHeight()) { |
64 available_logical_height = box.borderAndPaddingLogicalHeight() + | 66 available_logical_height = box.borderAndPaddingLogicalHeight() + |
65 box.overrideLogicalContentHeight(); | 67 box.overrideLogicalContentHeight(); |
66 fixed_block = true; | 68 fixed_block = true; |
67 } | 69 } |
68 | 70 |
69 bool is_new_fc = | 71 bool is_new_fc = |
70 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); | 72 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); |
71 | 73 |
72 NGLogicalSize size = {available_logical_width, available_logical_height}; | 74 NGLogicalSize logical_size = {available_logical_width, |
cbiesinger
2017/01/10 22:00:50
available_size is better. But I also meant if you
atotic
2017/01/10 23:24:15
logical_size can't go right under percentage_size,
cbiesinger
2017/01/10 23:26:36
I'll send a followup patch once this lands, I thin
| |
75 available_logical_height}; | |
73 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode()); | 76 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode()); |
74 return NGConstraintSpaceBuilder(writing_mode) | 77 return NGConstraintSpaceBuilder(writing_mode) |
75 .SetAvailableSize(size) | 78 .SetAvailableSize(logical_size) |
76 .SetPercentageResolutionSize(size) | 79 .SetPercentageResolutionSize(percentage_size) |
77 .SetIsInlineDirectionTriggersScrollbar( | 80 .SetIsInlineDirectionTriggersScrollbar( |
78 box.styleRef().overflowInlineDirection() == EOverflow::Auto) | 81 box.styleRef().overflowInlineDirection() == EOverflow::Auto) |
79 .SetIsBlockDirectionTriggersScrollbar( | 82 .SetIsBlockDirectionTriggersScrollbar( |
80 box.styleRef().overflowBlockDirection() == EOverflow::Auto) | 83 box.styleRef().overflowBlockDirection() == EOverflow::Auto) |
81 .SetIsFixedSizeInline(fixed_inline) | 84 .SetIsFixedSizeInline(fixed_inline) |
82 .SetIsFixedSizeBlock(fixed_block) | 85 .SetIsFixedSizeBlock(fixed_block) |
83 .SetIsShrinkToFit( | 86 .SetIsShrinkToFit( |
84 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth())) | 87 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth())) |
85 .SetIsNewFormattingContext(is_new_fc) | 88 .SetIsNewFormattingContext(is_new_fc) |
86 .SetTextDirection(box.styleRef().direction()) | 89 .SetTextDirection(box.styleRef().direction()) |
(...skipping 21 matching lines...) Expand all Loading... | |
108 | 111 |
109 String NGConstraintSpace::ToString() const { | 112 String NGConstraintSpace::ToString() const { |
110 return String::format("%s,%s %sx%s", | 113 return String::format("%s,%s %sx%s", |
111 offset_.inline_offset.toString().ascii().data(), | 114 offset_.inline_offset.toString().ascii().data(), |
112 offset_.block_offset.toString().ascii().data(), | 115 offset_.block_offset.toString().ascii().data(), |
113 AvailableSize().inline_size.toString().ascii().data(), | 116 AvailableSize().inline_size.toString().ascii().data(), |
114 AvailableSize().block_size.toString().ascii().data()); | 117 AvailableSize().block_size.toString().ascii().data()); |
115 } | 118 } |
116 | 119 |
117 } // namespace blink | 120 } // namespace blink |
OLD | NEW |