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

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

Issue 1524913003: Account for total glyph overflow in CachingWordShaper::width (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ace of rebase Created 5 years 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) 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 25 matching lines...) Expand all
36 36
37 float CachingWordShaper::width(const Font* font, const TextRun& run, 37 float CachingWordShaper::width(const Font* font, const TextRun& run,
38 HashSet<const SimpleFontData*>* fallbackFonts, 38 HashSet<const SimpleFontData*>* fallbackFonts,
39 FloatRect* glyphBounds) 39 FloatRect* glyphBounds)
40 { 40 {
41 float width = 0; 41 float width = 0;
42 RefPtr<ShapeResult> wordResult; 42 RefPtr<ShapeResult> wordResult;
43 CachingWordShapeIterator iterator(m_shapeCache, run, font); 43 CachingWordShapeIterator iterator(m_shapeCache, run, font);
44 while (iterator.next(&wordResult)) { 44 while (iterator.next(&wordResult)) {
45 if (wordResult) { 45 if (wordResult) {
46 if (glyphBounds) {
47 FloatRect adjustedBounds = wordResult->bounds();
48 // Translate glyph bounds to the current glyph position which
49 // is the total width before this glyph.
50 adjustedBounds.setX(adjustedBounds.x() + width);
51 glyphBounds->unite(adjustedBounds);
52 }
46 width += wordResult->width(); 53 width += wordResult->width();
47 if (glyphBounds)
48 glyphBounds->unite(wordResult->bounds());
49 if (fallbackFonts) 54 if (fallbackFonts)
50 wordResult->fallbackFonts(fallbackFonts); 55 wordResult->fallbackFonts(fallbackFonts);
51 } 56 }
52 } 57 }
53 58
54 return width; 59 return width;
55 } 60 }
56 61
57 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, 62 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font,
58 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, 63 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 { 111 {
107 Vector<RefPtr<ShapeResult>> results; 112 Vector<RefPtr<ShapeResult>> results;
108 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, 113 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
109 &results); 114 &results);
110 115
111 return ShapeResult::selectionRect(results, run.direction(), totalWidth, 116 return ShapeResult::selectionRect(results, run.direction(), totalWidth,
112 point, height, from, to); 117 point, height, from, to);
113 } 118 }
114 119
115 }; // namespace blink 120 }; // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698