Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_text_layout_algorithm.cc

Issue 2739683006: Use Opportunity Iterator to position text fragments in NGLineBuilder (Closed)
Patch Set: add font-family Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_text_layout_algorithm.h" 5 #include "core/layout/ng/ng_text_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_box_fragment.h" 7 #include "core/layout/ng/ng_box_fragment.h"
8 #include "core/layout/ng/ng_break_token.h" 8 #include "core/layout/ng/ng_break_token.h"
9 #include "core/layout/ng/ng_constraint_space.h" 9 #include "core/layout/ng/ng_constraint_space.h"
10 #include "core/layout/ng/ng_fragment_builder.h" 10 #include "core/layout/ng/ng_fragment_builder.h"
11 #include "core/layout/ng/ng_inline_node.h" 11 #include "core/layout/ng/ng_inline_node.h"
12 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
12 #include "core/layout/ng/ng_line_builder.h" 13 #include "core/layout/ng/ng_line_builder.h"
13 #include "core/layout/ng/ng_text_fragment.h" 14 #include "core/layout/ng/ng_text_fragment.h"
14 #include "core/style/ComputedStyle.h" 15 #include "core/style/ComputedStyle.h"
15 #include "platform/text/TextBreakIterator.h" 16 #include "platform/text/TextBreakIterator.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 NGTextLayoutAlgorithm::NGTextLayoutAlgorithm( 20 NGTextLayoutAlgorithm::NGTextLayoutAlgorithm(
20 NGInlineNode* inline_box, 21 NGInlineNode* inline_box,
21 NGConstraintSpace* constraint_space, 22 NGConstraintSpace* constraint_space,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 unsigned start_of_hangables = current_offset; 66 unsigned start_of_hangables = current_offset;
66 while (current_offset < end_offset && 67 while (current_offset < end_offset &&
67 IsHangable(text_content[current_offset])) 68 IsHangable(text_content[current_offset]))
68 current_offset++; 69 current_offset++;
69 70
70 // Set the end to the next break opportunity. 71 // Set the end to the next break opportunity.
71 line_builder->SetEnd(current_offset); 72 line_builder->SetEnd(current_offset);
72 73
73 // If there are more available spaces, mark the break opportunity and fetch 74 // If there are more available spaces, mark the break opportunity and fetch
74 // more text. 75 // more text.
76 // TODO(layout-ng): check if the height of the linebox can fit within
77 // the current opportunity.
75 if (line_builder->CanFitOnLine()) { 78 if (line_builder->CanFitOnLine()) {
76 line_builder->SetBreakOpportunity(); 79 line_builder->SetBreakOpportunity();
77 continue; 80 continue;
78 } 81 }
79 82
80 // Compute hangable characters if exists. 83 // Compute hangable characters if exists.
81 if (current_offset != start_of_hangables) { 84 if (current_offset != start_of_hangables) {
82 line_builder->SetStartOfHangables(start_of_hangables); 85 line_builder->SetStartOfHangables(start_of_hangables);
83 // If text before hangables can fit, include it in the current line. 86 // If text before hangables can fit, include it in the current line.
84 if (line_builder->CanFitOnLine()) 87 if (line_builder->CanFitOnLine())
(...skipping 19 matching lines...) Expand all
104 } 107 }
105 } 108 }
106 109
107 // If inline children ended with items left in the line builder, create a line 110 // If inline children ended with items left in the line builder, create a line
108 // for them. 111 // for them.
109 if (line_builder->HasItems()) 112 if (line_builder->HasItems())
110 line_builder->CreateLine(); 113 line_builder->CreateLine();
111 } 114 }
112 115
113 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698