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

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

Issue 2875933006: [LayoutNG] Misc fixes in ShapingLineBreaker (Closed)
Patch Set: clang build fix Created 3 years, 7 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/inline/ng_line_breaker.h" 5 #include "core/layout/ng/inline/ng_line_breaker.h"
6 6
7 #include "core/layout/ng/inline/ng_inline_break_token.h" 7 #include "core/layout/ng/inline/ng_inline_break_token.h"
8 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" 8 #include "core/layout/ng/inline/ng_inline_layout_algorithm.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_text_fragment.h" 10 #include "core/layout/ng/inline/ng_text_fragment.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #if defined(MOCK_SHAPE_LINE) 162 #if defined(MOCK_SHAPE_LINE)
163 unsigned break_offset; 163 unsigned break_offset;
164 std::tie(break_offset, item_result->inline_size) = 164 std::tie(break_offset, item_result->inline_size) =
165 ShapeLineMock(item, offset, available_width - position, break_iterator); 165 ShapeLineMock(item, offset, available_width - position, break_iterator);
166 #else 166 #else
167 // TODO(kojii): Change constructor to take LazyLineBreakIterator. 167 // TODO(kojii): Change constructor to take LazyLineBreakIterator.
168 // TODO(kojii): We need to instantiate ShapingLineBreaker here because it 168 // TODO(kojii): We need to instantiate ShapingLineBreaker here because it
169 // has item-specific info as context. Should they be part of ShapeLine() to 169 // has item-specific info as context. Should they be part of ShapeLine() to
170 // instantiate once, or is this just fine since instatiation is not 170 // instantiate once, or is this just fine since instatiation is not
171 // expensive? 171 // expensive?
172 DCHECK_EQ(item.TextShapeResult()->CharacterStartIndex(),
173 item.StartOffset());
174 DCHECK_EQ(item.TextShapeResult()->CharacterStartIndex() +
175 item.TextShapeResult()->NumCharacters(),
176 item.EndOffset());
172 ShapingLineBreaker breaker(&shaper, &item.Style()->GetFont(), 177 ShapingLineBreaker breaker(&shaper, &item.Style()->GetFont(),
173 item.TextShapeResult(), item.Style()->Locale(), 178 item.TextShapeResult(), &break_iterator);
174 LineBreakType::kNormal);
175 // TODO(kojii): Set item.StartOffset/EndOffset() to ShapingLineBreaker, or 179 // TODO(kojii): Set item.StartOffset/EndOffset() to ShapingLineBreaker, or
176 // change ShapingLineBreaker to take the range from ShapeResult. 180 // change ShapingLineBreaker to take the range from ShapeResult.
177 // item.TextShapeResult() does not have results for outside the item offset 181 // item.TextShapeResult() does not have results for outside the item offset
178 // range. 182 // range.
179 unsigned break_offset; 183 unsigned break_offset;
180 item_result->shape_result = 184 item_result->shape_result =
181 breaker.ShapeLine(offset, available_width - position, &break_offset); 185 breaker.ShapeLine(offset, available_width - position, &break_offset);
182 item_result->inline_size = item_result->shape_result->SnappedWidth(); 186 item_result->inline_size = item_result->shape_result->SnappedWidth();
183 #endif 187 #endif
184 DCHECK_GT(break_offset, offset); 188 DCHECK_GT(break_offset, offset);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 324 }
321 325
322 RefPtr<NGInlineBreakToken> NGLineBreaker::CreateBreakToken() const { 326 RefPtr<NGInlineBreakToken> NGLineBreaker::CreateBreakToken() const {
323 const Vector<NGInlineItem>& items = node_->Items(); 327 const Vector<NGInlineItem>& items = node_->Items();
324 if (item_index_ >= items.size()) 328 if (item_index_ >= items.size())
325 return nullptr; 329 return nullptr;
326 return NGInlineBreakToken::Create(node_, item_index_, offset_); 330 return NGInlineBreakToken::Create(node_, item_index_, offset_);
327 } 331 }
328 332
329 } // namespace blink 333 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698