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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapingLineBreaker.cpp

Issue 2957513002: Removed calls to RefPtr::Release in return statements with auto move. (Closed)
Patch Set: rebased Created 3 years, 5 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 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 "platform/fonts/shaping/ShapingLineBreaker.h" 5 #include "platform/fonts/shaping/ShapingLineBreaker.h"
6 6
7 #include "platform/fonts/Font.h" 7 #include "platform/fonts/Font.h"
8 #include "platform/fonts/shaping/HarfBuzzShaper.h" 8 #include "platform/fonts/shaping/HarfBuzzShaper.h"
9 #include "platform/fonts/shaping/ShapeResult.h" 9 #include "platform/fonts/shaping/ShapeResult.h"
10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" 10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 inline PassRefPtr<ShapeResult> ShapingLineBreaker::Shape( 80 inline PassRefPtr<ShapeResult> ShapingLineBreaker::Shape(
81 TextDirection direction, 81 TextDirection direction,
82 unsigned start, 82 unsigned start,
83 unsigned end) { 83 unsigned end) {
84 if (!spacing_ || !spacing_->HasSpacing()) 84 if (!spacing_ || !spacing_->HasSpacing())
85 return shaper_->Shape(font_, direction, start, end); 85 return shaper_->Shape(font_, direction, start, end);
86 86
87 RefPtr<ShapeResult> result = shaper_->Shape(font_, direction, start, end); 87 RefPtr<ShapeResult> result = shaper_->Shape(font_, direction, start, end);
88 result->ApplySpacing(*spacing_, direction); 88 result->ApplySpacing(*spacing_, direction);
89 return result.Release(); 89 return result;
90 } 90 }
91 91
92 // Shapes a line of text by finding a valid and appropriate break opportunity 92 // Shapes a line of text by finding a valid and appropriate break opportunity
93 // based on the shaping results for the entire paragraph. Re-shapes the start 93 // based on the shaping results for the entire paragraph. Re-shapes the start
94 // and end of the line as needed. 94 // and end of the line as needed.
95 // 95 //
96 // Definitions: 96 // Definitions:
97 // Candidate break opportunity: Ideal point to break, disregarding line 97 // Candidate break opportunity: Ideal point to break, disregarding line
98 // breaking rules. May be in the middle of a word 98 // breaking rules. May be in the middle of a word
99 // or inside a ligature. 99 // or inside a ligature.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (last_safe > first_safe) 237 if (last_safe > first_safe)
238 result_->CopyRange(first_safe, last_safe, line_result.Get()); 238 result_->CopyRange(first_safe, last_safe, line_result.Get());
239 if (line_end_result) 239 if (line_end_result)
240 line_end_result->CopyRange(last_safe, max_length, line_result.Get()); 240 line_end_result->CopyRange(last_safe, max_length, line_result.Get());
241 241
242 DCHECK_GT(break_opportunity, start); 242 DCHECK_GT(break_opportunity, start);
243 DCHECK_EQ(std::min(break_opportunity, range_end) - start, 243 DCHECK_EQ(std::min(break_opportunity, range_end) - start,
244 line_result->NumCharacters()); 244 line_result->NumCharacters());
245 245
246 *break_offset = break_opportunity; 246 *break_offset = break_opportunity;
247 return line_result.Release(); 247 return line_result;
248 } 248 }
249 249
250 // Shape from the specified offset to the end of the ShapeResult. 250 // Shape from the specified offset to the end of the ShapeResult.
251 // If |start| is safe-to-break, this copies the subset of the result. 251 // If |start| is safe-to-break, this copies the subset of the result.
252 PassRefPtr<ShapeResult> ShapingLineBreaker::ShapeToEnd( 252 PassRefPtr<ShapeResult> ShapingLineBreaker::ShapeToEnd(
253 unsigned start, 253 unsigned start,
254 LayoutUnit start_position, 254 LayoutUnit start_position,
255 unsigned range_end) { 255 unsigned range_end) {
256 unsigned first_safe = 256 unsigned first_safe =
257 NextSafeToBreakBefore(shaper_->GetText(), shaper_->TextLength(), start); 257 NextSafeToBreakBefore(shaper_->GetText(), shaper_->TextLength(), start);
258 DCHECK_GE(first_safe, start); 258 DCHECK_GE(first_safe, start);
259 259
260 RefPtr<ShapeResult> line_result; 260 RefPtr<ShapeResult> line_result;
261 TextDirection direction = result_->Direction(); 261 TextDirection direction = result_->Direction();
262 if (first_safe == start) { 262 if (first_safe == start) {
263 // If |start| is safe-to-break, reshape is not needed. 263 // If |start| is safe-to-break, reshape is not needed.
264 line_result = ShapeResult::Create(font_, 0, direction); 264 line_result = ShapeResult::Create(font_, 0, direction);
265 result_->CopyRange(start, range_end, line_result.Get()); 265 result_->CopyRange(start, range_end, line_result.Get());
266 } else if (first_safe < range_end) { 266 } else if (first_safe < range_end) {
267 // Otherwise reshape to the first safe, then copy the rest. 267 // Otherwise reshape to the first safe, then copy the rest.
268 line_result = Shape(direction, start, first_safe); 268 line_result = Shape(direction, start, first_safe);
269 result_->CopyRange(first_safe, range_end, line_result.Get()); 269 result_->CopyRange(first_safe, range_end, line_result.Get());
270 } else { 270 } else {
271 // If no safe-to-break in the ragne, reshape the whole range. 271 // If no safe-to-break in the ragne, reshape the whole range.
272 line_result = Shape(direction, start, range_end); 272 line_result = Shape(direction, start, range_end);
273 } 273 }
274 return line_result.Release(); 274 return line_result;
275 } 275 }
276 276
277 } // namespace blink 277 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698