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

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

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 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ShapeResult::~ShapeResult() {} 176 ShapeResult::~ShapeResult() {}
177 177
178 size_t ShapeResult::ByteSize() const { 178 size_t ShapeResult::ByteSize() const {
179 size_t self_byte_size = sizeof(this); 179 size_t self_byte_size = sizeof(this);
180 for (unsigned i = 0; i < runs_.size(); ++i) { 180 for (unsigned i = 0; i < runs_.size(); ++i) {
181 self_byte_size += runs_[i]->ByteSize(); 181 self_byte_size += runs_[i]->ByteSize();
182 } 182 }
183 return self_byte_size; 183 return self_byte_size;
184 } 184 }
185 185
186 unsigned ShapeResult::CharacterStartIndex() const {
187 return !Rtl() ? runs_.front()->start_index_ : runs_.back()->start_index_;
188 }
189
190 unsigned ShapeResult::OffsetForPosition(float target_x,
191 OffsetOptions options) const {
192 if (options == kOutsideAsStartOrEnd && target_x <= 0)
193 return Rtl() ? num_characters_ : 0;
194 return OffsetForPosition(target_x, false);
195 }
196
186 unsigned ShapeResult::OffsetForPosition(float target_x, 197 unsigned ShapeResult::OffsetForPosition(float target_x,
187 bool include_partial_glyphs) const { 198 bool include_partial_glyphs) const {
188 unsigned characters_so_far = 0; 199 unsigned characters_so_far = 0;
189 float current_x = 0; 200 float current_x = 0;
190 201
191 if (Rtl()) { 202 if (Rtl()) {
192 characters_so_far = num_characters_; 203 characters_so_far = num_characters_;
193 for (unsigned i = 0; i < runs_.size(); ++i) { 204 for (unsigned i = 0; i < runs_.size(); ++i) {
194 if (!runs_[i]) 205 if (!runs_[i])
195 continue; 206 continue;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 result->width_ = run->width_; 482 result->width_ = run->width_;
472 result->num_glyphs_ = count; 483 result->num_glyphs_ = count;
473 DCHECK_EQ(result->num_glyphs_, count); // no overflow 484 DCHECK_EQ(result->num_glyphs_, count); // no overflow
474 result->has_vertical_offsets_ = 485 result->has_vertical_offsets_ =
475 font_data->PlatformData().IsVerticalAnyUpright(); 486 font_data->PlatformData().IsVerticalAnyUpright();
476 result->runs_.push_back(std::move(run)); 487 result->runs_.push_back(std::move(run));
477 return result.Release(); 488 return result.Release();
478 } 489 }
479 490
480 } // namespace blink 491 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698