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_absolute_utils.h" | 5 #include "core/layout/ng/ng_absolute_utils.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space_builder.h" | 7 #include "core/layout/ng/ng_constraint_space_builder.h" |
8 #include "core/layout/ng/ng_length_utils.h" | 8 #include "core/layout/ng/ng_length_utils.h" |
9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 LayoutUnit border_left(9); | 100 LayoutUnit border_left(9); |
101 LayoutUnit padding_left(11); | 101 LayoutUnit padding_left(11); |
102 LayoutUnit right(13); | 102 LayoutUnit right(13); |
103 LayoutUnit margin_right(15); | 103 LayoutUnit margin_right(15); |
104 LayoutUnit border_right(17); | 104 LayoutUnit border_right(17); |
105 LayoutUnit padding_right(19); | 105 LayoutUnit padding_right(19); |
106 | 106 |
107 LayoutUnit width = | 107 LayoutUnit width = |
108 container_size_.inline_size - left - margin_left - right - margin_right; | 108 container_size_.inline_size - left - margin_left - right - margin_right; |
109 | 109 |
110 Optional<MinAndMaxContentSizes> estimated_inline; | 110 Optional<MinMaxContentSize> estimated_inline; |
111 MinAndMaxContentSizes minmax_60{LayoutUnit(60), LayoutUnit(60)}; | 111 MinMaxContentSize minmax_60{LayoutUnit(60), LayoutUnit(60)}; |
112 | 112 |
113 style_->setBorderLeftWidth(border_left.toInt()); | 113 style_->setBorderLeftWidth(border_left.toInt()); |
114 style_->setBorderRightWidth(border_right.toInt()); | 114 style_->setBorderRightWidth(border_right.toInt()); |
115 style_->setPaddingLeft(Length(padding_left.toInt(), LengthType::Fixed)); | 115 style_->setPaddingLeft(Length(padding_left.toInt(), LengthType::Fixed)); |
116 style_->setPaddingRight(Length(padding_right.toInt(), LengthType::Fixed)); | 116 style_->setPaddingRight(Length(padding_right.toInt(), LengthType::Fixed)); |
117 | 117 |
118 // These default to 3 which is not what we want. | 118 // These default to 3 which is not what we want. |
119 style_->setBorderBottomWidth(0); | 119 style_->setBorderBottomWidth(0); |
120 style_->setBorderTopWidth(0); | 120 style_->setBorderTopWidth(0); |
121 | 121 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 LayoutUnit min{50}; | 423 LayoutUnit min{50}; |
424 LayoutUnit max{150}; | 424 LayoutUnit max{150}; |
425 | 425 |
426 style_->setMinWidth(Length(min.toInt(), LengthType::Fixed)); | 426 style_->setMinWidth(Length(min.toInt(), LengthType::Fixed)); |
427 style_->setMaxWidth(Length(max.toInt(), LengthType::Fixed)); | 427 style_->setMaxWidth(Length(max.toInt(), LengthType::Fixed)); |
428 style_->setMinHeight(Length(min.toInt(), LengthType::Fixed)); | 428 style_->setMinHeight(Length(min.toInt(), LengthType::Fixed)); |
429 style_->setMaxHeight(Length(max.toInt(), LengthType::Fixed)); | 429 style_->setMaxHeight(Length(max.toInt(), LengthType::Fixed)); |
430 | 430 |
431 NGStaticPosition static_position{NGStaticPosition::kTopLeft, | 431 NGStaticPosition static_position{NGStaticPosition::kTopLeft, |
432 {LayoutUnit(), LayoutUnit()}}; | 432 {LayoutUnit(), LayoutUnit()}}; |
433 MinAndMaxContentSizes estimated_inline{LayoutUnit(20), LayoutUnit(20)}; | 433 MinMaxContentSize estimated_inline{LayoutUnit(20), LayoutUnit(20)}; |
434 NGAbsolutePhysicalPosition p; | 434 NGAbsolutePhysicalPosition p; |
435 | 435 |
436 // WIDTH TESTS | 436 // WIDTH TESTS |
437 | 437 |
438 // width < min gets set to min. | 438 // width < min gets set to min. |
439 SetHorizontalStyle(NGAuto, NGAuto, LayoutUnit(5), NGAuto, NGAuto); | 439 SetHorizontalStyle(NGAuto, NGAuto, LayoutUnit(5), NGAuto, NGAuto); |
440 p = ComputePartialAbsoluteWithChildInlineSize( | 440 p = ComputePartialAbsoluteWithChildInlineSize( |
441 *ltr_space_, *style_, static_position, estimated_inline); | 441 *ltr_space_, *style_, static_position, estimated_inline); |
442 EXPECT_EQ(min, p.size.width); | 442 EXPECT_EQ(min, p.size.width); |
443 | 443 |
(...skipping 28 matching lines...) Expand all Loading... |
472 // // Unspecified height becomes estimated, gets clamped to min. | 472 // // Unspecified height becomes estimated, gets clamped to min. |
473 SetVerticalStyle(NGAuto, NGAuto, NGAuto, NGAuto, NGAuto); | 473 SetVerticalStyle(NGAuto, NGAuto, NGAuto, NGAuto, NGAuto); |
474 auto_height = LayoutUnit(20); | 474 auto_height = LayoutUnit(20); |
475 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, static_position, | 475 ComputeFullAbsoluteWithChildBlockSize(*ltr_space_, *style_, static_position, |
476 auto_height, &p); | 476 auto_height, &p); |
477 EXPECT_EQ(min, p.size.width); | 477 EXPECT_EQ(min, p.size.width); |
478 } | 478 } |
479 | 479 |
480 } // namespace | 480 } // namespace |
481 } // namespace blink | 481 } // namespace blink |
OLD | NEW |