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

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

Issue 2869893005: Clamp RunInfo::num_characters when shaping ranges with context (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaperTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 // Compute the range indices of consecutive shaped or .notdef glyphs. 221 // Compute the range indices of consecutive shaped or .notdef glyphs.
222 // Cluster information for RTL runs becomes reversed, e.g. character 0 222 // Cluster information for RTL runs becomes reversed, e.g. character 0
223 // has cluster index 5 in a run of 6 characters. 223 // has cluster index 5 in a run of 6 characters.
224 unsigned num_characters = 0; 224 unsigned num_characters = 0;
225 unsigned num_glyphs_to_insert = 0; 225 unsigned num_glyphs_to_insert = 0;
226 unsigned start_index = 0; 226 unsigned start_index = 0;
227 if (HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(range_data->buffer))) { 227 if (HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(range_data->buffer))) {
228 start_index = glyph_info[last_change_position].cluster; 228 start_index = glyph_info[last_change_position].cluster;
229 if (glyph_index == num_glyphs) { 229 if (glyph_index == num_glyphs) {
230 num_characters = current_queue_item.start_index_ + 230 // Clamp the end offsets of the queue item to the offsets representing
231 current_queue_item.num_characters_ - 231 // the shaping window.
232 glyph_info[last_change_position].cluster; 232 unsigned shape_end =
233 std::min(range_data->end, current_queue_item.start_index_ +
234 current_queue_item.num_characters_);
235 num_characters = shape_end - glyph_info[last_change_position].cluster;
233 num_glyphs_to_insert = num_glyphs - last_change_position; 236 num_glyphs_to_insert = num_glyphs - last_change_position;
234 } else { 237 } else {
235 num_characters = glyph_info[glyph_index].cluster - 238 num_characters = glyph_info[glyph_index].cluster -
236 glyph_info[last_change_position].cluster; 239 glyph_info[last_change_position].cluster;
237 num_glyphs_to_insert = glyph_index - last_change_position; 240 num_glyphs_to_insert = glyph_index - last_change_position;
238 } 241 }
239 } else { 242 } else {
240 // Direction Backwards 243 // Direction Backwards
241 start_index = glyph_info[glyph_index - 1].cluster; 244 start_index = glyph_info[glyph_index - 1].cluster;
242 if (last_change_position == 0) { 245 if (last_change_position == 0) {
243 num_characters = current_queue_item.start_index_ + 246 // Clamp the end offsets of the queue item to the offsets representing
244 current_queue_item.num_characters_ - 247 // the shaping window.
245 glyph_info[glyph_index - 1].cluster; 248 unsigned shape_end =
249 std::min(range_data->end, current_queue_item.start_index_ +
250 current_queue_item.num_characters_);
251 num_characters = shape_end - glyph_info[glyph_index - 1].cluster;
246 } else { 252 } else {
247 num_characters = glyph_info[last_change_position - 1].cluster - 253 num_characters = glyph_info[last_change_position - 1].cluster -
248 glyph_info[glyph_index - 1].cluster; 254 glyph_info[glyph_index - 1].cluster;
249 } 255 }
250 num_glyphs_to_insert = glyph_index - last_change_position; 256 num_glyphs_to_insert = glyph_index - last_change_position;
251 } 257 }
252 258
253 if (current_cluster_result == kShaped && !is_last_resort) { 259 if (current_cluster_result == kShaped && !is_last_resort) {
254 // Now it's clear that we need to continue processing. 260 // Now it's clear that we need to continue processing.
255 if (!font_cycle_queued) { 261 if (!font_cycle_queued) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 719 }
714 return result.Release(); 720 return result.Release();
715 } 721 }
716 722
717 PassRefPtr<ShapeResult> HarfBuzzShaper::Shape(const Font* font, 723 PassRefPtr<ShapeResult> HarfBuzzShaper::Shape(const Font* font,
718 TextDirection direction) const { 724 TextDirection direction) const {
719 return Shape(font, direction, 0, text_length_); 725 return Shape(font, direction, 0, text_length_);
720 } 726 }
721 727
722 } // namespace blink 728 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698