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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
index a4d09f3dba9e56da68d9b6b8271a45d054bf11f8..9ea5db3b28a3246390835bbd3345504d1414b48e 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
@@ -227,9 +227,12 @@ bool HarfBuzzShaper::ExtractShapeResults(
if (HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(range_data->buffer))) {
start_index = glyph_info[last_change_position].cluster;
if (glyph_index == num_glyphs) {
- num_characters = current_queue_item.start_index_ +
- current_queue_item.num_characters_ -
- glyph_info[last_change_position].cluster;
+ // Clamp the end offsets of the queue item to the offsets representing
+ // the shaping window.
+ unsigned shape_end =
+ std::min(range_data->end, current_queue_item.start_index_ +
+ current_queue_item.num_characters_);
+ num_characters = shape_end - glyph_info[last_change_position].cluster;
num_glyphs_to_insert = num_glyphs - last_change_position;
} else {
num_characters = glyph_info[glyph_index].cluster -
@@ -240,9 +243,12 @@ bool HarfBuzzShaper::ExtractShapeResults(
// Direction Backwards
start_index = glyph_info[glyph_index - 1].cluster;
if (last_change_position == 0) {
- num_characters = current_queue_item.start_index_ +
- current_queue_item.num_characters_ -
- glyph_info[glyph_index - 1].cluster;
+ // Clamp the end offsets of the queue item to the offsets representing
+ // the shaping window.
+ unsigned shape_end =
+ std::min(range_data->end, current_queue_item.start_index_ +
+ current_queue_item.num_characters_);
+ num_characters = shape_end - glyph_info[glyph_index - 1].cluster;
} else {
num_characters = glyph_info[last_change_position - 1].cluster -
glyph_info[glyph_index - 1].cluster;
« 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