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/ng/ng_base_layout_algorithm_test.h" | 5 #include "core/layout/ng/ng_base_layout_algorithm_test.h" |
6 | 6 |
7 #include "core/dom/TagCollection.h" | 7 #include "core/dom/TagCollection.h" |
8 #include "core/layout/line/InlineTextBox.h" | 8 #include "core/layout/line/InlineTextBox.h" |
9 #include "core/layout/ng/layout_ng_block_flow.h" | 9 #include "core/layout/ng/layout_ng_block_flow.h" |
10 #include "core/layout/ng/ng_block_break_token.h" | 10 #include "core/layout/ng/ng_block_break_token.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 EXPECT_EQ(8, wide_float->offsetLeft()); | 263 EXPECT_EQ(8, wide_float->offsetLeft()); |
264 | 264 |
265 Element* narrow_float = document().getElementById("left-narrow"); | 265 Element* narrow_float = document().getElementById("left-narrow"); |
266 // 160 float-wide's width + 8 body's margin. | 266 // 160 float-wide's width + 8 body's margin. |
267 EXPECT_EQ(160 + 8, narrow_float->offsetLeft()); | 267 EXPECT_EQ(160 + 8, narrow_float->offsetLeft()); |
268 | 268 |
269 // On the same line. | 269 // On the same line. |
270 EXPECT_EQ(wide_float->offsetTop(), narrow_float->offsetTop()); | 270 EXPECT_EQ(wide_float->offsetTop(), narrow_float->offsetTop()); |
271 } | 271 } |
272 | 272 |
| 273 // Verifies that InlineLayoutAlgorithm positions floats with respect to their |
| 274 // margins. |
| 275 TEST_F(NGInlineLayoutAlgorithmTest, PositionFloatsWithMargins) { |
| 276 setBodyInnerHTML(R"HTML( |
| 277 <!DOCTYPE html> |
| 278 <style> |
| 279 #container { |
| 280 height: 200px; width: 200px; outline: solid orange; |
| 281 } |
| 282 #left { |
| 283 float: left; width: 5px; height: 30px; background-color: blue; |
| 284 margin: 10%; |
| 285 } |
| 286 </style> |
| 287 <div id="container"> |
| 288 <span id="text"> |
| 289 The quick <div id="left"></div> brown fox jumps over the lazy dog |
| 290 </span> |
| 291 </div> |
| 292 )HTML"); |
| 293 LayoutText* layout_text = |
| 294 toLayoutText(getLayoutObjectByElementId("text")->slowFirstChild()); |
| 295 ASSERT(layout_text->hasTextBoxes()); |
| 296 |
| 297 InlineTextBox* inline_text_box1 = layout_text->firstTextBox(); |
| 298 // 45 = sum of left's inline margins: 40 + left's width: 5 |
| 299 EXPECT_EQ(LayoutUnit(45), inline_text_box1->x()); |
| 300 } |
| 301 |
273 } // namespace | 302 } // namespace |
274 } // namespace blink | 303 } // namespace blink |
OLD | NEW |