| 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/inline/ng_inline_layout_algorithm.h" | 5 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/inline/ng_bidi_paragraph.h" | 7 #include "core/layout/ng/inline/ng_bidi_paragraph.h" |
| 8 #include "core/layout/ng/inline/ng_inline_break_token.h" | 8 #include "core/layout/ng/inline/ng_inline_break_token.h" |
| 9 #include "core/layout/ng/inline/ng_inline_node.h" | 9 #include "core/layout/ng/inline/ng_inline_node.h" |
| 10 #include "core/layout/ng/inline/ng_line_box_fragment.h" | 10 #include "core/layout/ng/inline/ng_line_box_fragment.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 .SetIsShrinkToFit(ShouldShrinkToFit(parent_style, style)) | 42 .SetIsShrinkToFit(ShouldShrinkToFit(parent_style, style)) |
| 43 .ToConstraintSpace(FromPlatformWritingMode(style.GetWritingMode())); | 43 .ToConstraintSpace(FromPlatformWritingMode(style.GetWritingMode())); |
| 44 } | 44 } |
| 45 | 45 |
| 46 NGLogicalOffset GetOriginPointForFloats(const NGConstraintSpace& space, | 46 NGLogicalOffset GetOriginPointForFloats(const NGConstraintSpace& space, |
| 47 LayoutUnit content_size) { | 47 LayoutUnit content_size) { |
| 48 NGLogicalOffset origin_point = space.BfcOffset(); | 48 NGLogicalOffset origin_point = space.BfcOffset(); |
| 49 origin_point.block_offset += content_size; | 49 origin_point.block_offset += content_size; |
| 50 return origin_point; | 50 return origin_point; |
| 51 } | 51 } |
| 52 |
| 53 inline bool IsObjectReplacementCharacter(UChar character) { |
| 54 return character == kObjectReplacementCharacter; |
| 55 } |
| 56 |
| 52 } // namespace | 57 } // namespace |
| 53 | 58 |
| 54 NGInlineLayoutAlgorithm::NGInlineLayoutAlgorithm( | 59 NGInlineLayoutAlgorithm::NGInlineLayoutAlgorithm( |
| 55 NGInlineNode* inline_node, | 60 NGInlineNode* inline_node, |
| 56 NGConstraintSpace* space, | 61 NGConstraintSpace* space, |
| 57 NGInlineBreakToken* break_token) | 62 NGInlineBreakToken* break_token) |
| 58 : NGLayoutAlgorithm(inline_node, space, break_token), | 63 : NGLayoutAlgorithm(inline_node, space, break_token), |
| 59 is_horizontal_writing_mode_( | 64 is_horizontal_writing_mode_( |
| 60 blink::IsHorizontalWritingMode(space->WritingMode())), | 65 blink::IsHorizontalWritingMode(space->WritingMode())), |
| 61 disallow_first_line_rules_(false), | 66 disallow_first_line_rules_(false), |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 472 } |
| 468 | 473 |
| 469 box_states_.OnEndPlaceItems(&line_box); | 474 box_states_.OnEndPlaceItems(&line_box); |
| 470 | 475 |
| 471 // The baselines are always placed at pixel boundaries. Not doing so results | 476 // The baselines are always placed at pixel boundaries. Not doing so results |
| 472 // in incorrect layout of text decorations, most notably underlines. | 477 // in incorrect layout of text decorations, most notably underlines. |
| 473 LayoutUnit baseline = content_size_ + line_box.Metrics().ascent; | 478 LayoutUnit baseline = content_size_ + line_box.Metrics().ascent; |
| 474 baseline = LayoutUnit(baseline.Round()); | 479 baseline = LayoutUnit(baseline.Round()); |
| 475 | 480 |
| 476 // Check if the line fits into the constraint space in block direction. | 481 // Check if the line fits into the constraint space in block direction. |
| 477 LayoutUnit line_bottom = baseline + line_box.Metrics().descent; | 482 LayoutUnit line_bottom = baseline; |
| 483 |
| 484 // See http://crrev.com/2840883002 |
| 485 if (!Node()->Text().IsAllSpecialCharacters<IsObjectReplacementCharacter>()) |
| 486 line_bottom += line_box.Metrics().descent; |
| 487 |
| 478 if (!container_builder_.Children().IsEmpty() && | 488 if (!container_builder_.Children().IsEmpty() && |
| 479 ConstraintSpace().AvailableSize().block_size != NGSizeIndefinite && | 489 ConstraintSpace().AvailableSize().block_size != NGSizeIndefinite && |
| 480 line_bottom > ConstraintSpace().AvailableSize().block_size) { | 490 line_bottom > ConstraintSpace().AvailableSize().block_size) { |
| 481 return false; | 491 return false; |
| 482 } | 492 } |
| 483 | 493 |
| 484 // If there are more content to consume, create an unfinished break token. | 494 // If there are more content to consume, create an unfinished break token. |
| 485 if (last_break_opportunity_index_ != items.size() - 1 || | 495 if (last_break_opportunity_index_ != items.size() - 1 || |
| 486 last_break_opportunity_offset_ != Node()->Text().length()) { | 496 last_break_opportunity_offset_ != Node()->Text().length()) { |
| 487 line_box.SetBreakToken(NGInlineBreakToken::Create( | 497 line_box.SetBreakToken(NGInlineBreakToken::Create( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 586 |
| 577 // max-content is the width without any line wrapping. | 587 // max-content is the width without any line wrapping. |
| 578 // TODO(kojii): Implement hard breaks (<br> etc.) to break. | 588 // TODO(kojii): Implement hard breaks (<br> etc.) to break. |
| 579 for (const auto& item : Node()->Items()) | 589 for (const auto& item : Node()->Items()) |
| 580 sizes.max_content += InlineSize(item); | 590 sizes.max_content += InlineSize(item); |
| 581 | 591 |
| 582 return sizes; | 592 return sizes; |
| 583 } | 593 } |
| 584 | 594 |
| 585 } // namespace blink | 595 } // namespace blink |
| OLD | NEW |