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

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

Issue 2020863002: Guard against invalid glyph shaping results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments Created 4 years, 6 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 | « third_party/WebKit/Source/platform/fonts/Font.cpp ('k') | no next file » | 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) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return buffer.getCharacterRange(run.direction(), totalWidth, from, to); 116 return buffer.getCharacterRange(run.direction(), totalWidth, from, to);
117 } 117 }
118 118
119 Vector<CharacterRange> CachingWordShaper::individualCharacterRanges( 119 Vector<CharacterRange> CachingWordShaper::individualCharacterRanges(
120 const Font* font, const TextRun& run) 120 const Font* font, const TextRun& run)
121 { 121 {
122 ShapeResultBuffer buffer; 122 ShapeResultBuffer buffer;
123 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, 123 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
124 &buffer); 124 &buffer);
125 125
126 return buffer.individualCharacterRanges(run.direction(), totalWidth); 126 auto ranges = buffer.individualCharacterRanges(run.direction(), totalWidth);
127 // The shaper can fail to return glyph metrics for all characters (see
128 // crbug.com/613915 and crbug.com/615661) so add empty ranges to ensure all
129 // characters have an associated range.
130 while (ranges.size() < static_cast<unsigned>(run.length()))
131 ranges.append(CharacterRange(0, 0));
132 return ranges;
127 } 133 }
128 134
129 }; // namespace blink 135 }; // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698