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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 } | 467 } |
463 | 468 |
464 box_states_.OnEndPlaceItems(&line_box); | 469 box_states_.OnEndPlaceItems(&line_box); |
465 | 470 |
466 // The baselines are always placed at pixel boundaries. Not doing so results | 471 // The baselines are always placed at pixel boundaries. Not doing so results |
467 // in incorrect layout of text decorations, most notably underlines. | 472 // in incorrect layout of text decorations, most notably underlines. |
468 LayoutUnit baseline = content_size_ + line_box.Metrics().ascent; | 473 LayoutUnit baseline = content_size_ + line_box.Metrics().ascent; |
469 baseline = LayoutUnit(baseline.Round()); | 474 baseline = LayoutUnit(baseline.Round()); |
470 | 475 |
471 // Check if the line fits into the constraint space in block direction. | 476 // Check if the line fits into the constraint space in block direction. |
472 LayoutUnit line_bottom = baseline + line_box.Metrics().descent; | 477 LayoutUnit line_bottom = baseline; |
478 | |
479 if (!Node()->Text().IsAllSpecialCharacters<IsObjectReplacementCharacter>()) | |
kojii
2017/04/26 00:51:34
This doesn't look correct, but I admit ascent/desc
| |
480 line_bottom += line_box.Metrics().descent; | |
481 | |
473 if (!container_builder_.Children().IsEmpty() && | 482 if (!container_builder_.Children().IsEmpty() && |
474 ConstraintSpace().AvailableSize().block_size != NGSizeIndefinite && | 483 ConstraintSpace().AvailableSize().block_size != NGSizeIndefinite && |
475 line_bottom > ConstraintSpace().AvailableSize().block_size) { | 484 line_bottom > ConstraintSpace().AvailableSize().block_size) { |
476 return false; | 485 return false; |
477 } | 486 } |
478 | 487 |
479 // If there are more content to consume, create an unfinished break token. | 488 // If there are more content to consume, create an unfinished break token. |
480 if (last_break_opportunity_index_ != items.size() - 1 || | 489 if (last_break_opportunity_index_ != items.size() - 1 || |
481 last_break_opportunity_offset_ != Node()->Text().length()) { | 490 last_break_opportunity_offset_ != Node()->Text().length()) { |
482 line_box.SetBreakToken(NGInlineBreakToken::Create( | 491 line_box.SetBreakToken(NGInlineBreakToken::Create( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 | 594 |
586 // max-content is the width without any line wrapping. | 595 // max-content is the width without any line wrapping. |
587 // TODO(kojii): Implement hard breaks (<br> etc.) to break. | 596 // TODO(kojii): Implement hard breaks (<br> etc.) to break. |
588 for (const auto& item : Node()->Items()) | 597 for (const auto& item : Node()->Items()) |
589 sizes.max_content += InlineSize(item); | 598 sizes.max_content += InlineSize(item); |
590 | 599 |
591 return sizes; | 600 return sizes; |
592 } | 601 } |
593 | 602 |
594 } // namespace blink | 603 } // namespace blink |
OLD | NEW |