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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/CachingWordShapeIterator.h

Issue 2924263003: [LayoutNG] Initial letter-spacing and word-spacing support (Closed)
Patch Set: Cleanup Created 3 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
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 29 matching lines...) Expand all
40 STACK_ALLOCATED(); 40 STACK_ALLOCATED();
41 WTF_MAKE_NONCOPYABLE(CachingWordShapeIterator); 41 WTF_MAKE_NONCOPYABLE(CachingWordShapeIterator);
42 42
43 public: 43 public:
44 CachingWordShapeIterator(ShapeCache* cache, 44 CachingWordShapeIterator(ShapeCache* cache,
45 const TextRun& run, 45 const TextRun& run,
46 const Font* font) 46 const Font* font)
47 : shape_cache_(cache), 47 : shape_cache_(cache),
48 text_run_(run), 48 text_run_(run),
49 font_(font), 49 font_(font),
50 spacing_(run, font->GetFontDescription()), 50 spacing_(run),
51 width_so_far_(0), 51 width_so_far_(0),
52 start_index_(0) { 52 start_index_(0) {
53 DCHECK(font); 53 DCHECK(font);
54 54
55 // Shaping word by word is faster as each word is cached. If we cannot 55 // Shaping word by word is faster as each word is cached. If we cannot
56 // use the cache or if the font doesn't support word by word shaping 56 // use the cache or if the font doesn't support word by word shaping
57 // fall back on shaping the entire run. 57 // fall back on shaping the entire run.
58 shape_by_word_ = font_->CanShapeWordByWord(); 58 shape_by_word_ = font_->CanShapeWordByWord();
59
60 if (!run.SpacingDisabled())
ikilpatrick 2017/06/29 16:17:59 Can you add a comment here as to why spacing might
61 spacing_.SetSpacingAndExpansion(font->GetFontDescription());
59 } 62 }
60 63
61 bool Next(RefPtr<const ShapeResult>* word_result) { 64 bool Next(RefPtr<const ShapeResult>* word_result) {
62 if (UNLIKELY(text_run_.AllowTabs())) 65 if (UNLIKELY(text_run_.AllowTabs()))
63 return NextForAllowTabs(word_result); 66 return NextForAllowTabs(word_result);
64 67
65 if (!shape_by_word_) { 68 if (!shape_by_word_) {
66 if (start_index_) 69 if (start_index_)
67 return false; 70 return false;
68 *word_result = ShapeWord(text_run_, font_); 71 *word_result = ShapeWord(text_run_, font_);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return false; 198 return false;
196 } 199 }
197 DCHECK(*word_result); 200 DCHECK(*word_result);
198 width_so_far_ += (*word_result)->Width(); 201 width_so_far_ += (*word_result)->Width();
199 return true; 202 return true;
200 } 203 }
201 204
202 ShapeCache* shape_cache_; 205 ShapeCache* shape_cache_;
203 const TextRun& text_run_; 206 const TextRun& text_run_;
204 const Font* font_; 207 const Font* font_;
205 ShapeResultSpacing spacing_; 208 ShapeResultSpacing<TextRun> spacing_;
206 float width_so_far_; // Used only when allowTabs() 209 float width_so_far_; // Used only when allowTabs()
207 unsigned start_index_ : 31; 210 unsigned start_index_ : 31;
208 unsigned shape_by_word_ : 1; 211 unsigned shape_by_word_ : 1;
209 }; 212 };
210 213
211 } // namespace blink 214 } // namespace blink
212 215
213 #endif // CachingWordShapeIterator_h 216 #endif // CachingWordShapeIterator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698