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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaperTest.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
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.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 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/fonts/shaping/CachingWordShaper.h" 6 #include "platform/fonts/shaping/CachingWordShaper.h"
7 7
8 #include "platform/fonts/FontCache.h" 8 #include "platform/fonts/FontCache.h"
9 #include "platform/fonts/GlyphBuffer.h" 9 #include "platform/fonts/GlyphBuffer.h"
10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 verticalMixedFont.update(nullptr); 196 verticalMixedFont.update(nullptr);
197 ASSERT_TRUE(verticalMixedFont.canShapeWordByWord()); 197 ASSERT_TRUE(verticalMixedFont.canShapeWordByWord());
198 198
199 CachingWordShaper shaper(cache.get()); 199 CachingWordShaper shaper(cache.get());
200 FloatRect glyphBounds; 200 FloatRect glyphBounds;
201 HashSet<const SimpleFontData*> fallbackFonts; 201 HashSet<const SimpleFontData*> fallbackFonts;
202 ASSERT_GT(shaper.width(&verticalMixedFont, textRun, &fallbackFonts, &glyphBo unds), 0); 202 ASSERT_GT(shaper.width(&verticalMixedFont, textRun, &fallbackFonts, &glyphBo unds), 0);
203 EXPECT_EQ(0u, fallbackFonts.size()); 203 EXPECT_EQ(0u, fallbackFonts.size());
204 } 204 }
205 205
206 TEST_F(CachingWordShaperTest, GlyphBoundsWithSpaces)
207 {
208 CachingWordShaper shaper(cache.get());
209
210 TextRun periods(reinterpret_cast<const LChar*>(".........."), 10);
211 FloatRect periodsGlyphBounds;
212 float periodsWidth = shaper.width(&font, periods, nullptr, &periodsGlyphBoun ds);
213
214 TextRun periodsAndSpaces(reinterpret_cast<const LChar*>(". . . . . . . . . . "), 19);
215 FloatRect periodsAndSpacesGlyphBounds;
216 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr, &periodsAndSpacesGlyphBounds);
217
218 // The total width of periods and spaces should be longer than the width of periods alone.
219 ASSERT_GT(periodsAndSpacesWidth, periodsWidth);
220
221 // The glyph bounds of periods and spaces should be longer than the glyph bo unds of periods alone.
222 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width());
223 }
224
206 } // namespace blink 225 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698