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

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

Issue 2816243004: Adjust visual overflow rect for rounded/shifted ascent/descent (Closed)
Patch Set: Created 3 years, 8 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 * This file is part of the internal font implementation. 2 * This file is part of the internal font implementation.
3 * 3 *
4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2007-2008 Torch Mobile, Inc. 5 * Copyright (C) 2007-2008 Torch Mobile, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return custom_font_data_ && custom_font_data_->ShouldSkipDrawing(); 157 return custom_font_data_ && custom_font_data_->ShouldSkipDrawing();
158 } 158 }
159 159
160 const GlyphData& MissingGlyphData() const { return missing_glyph_data_; } 160 const GlyphData& MissingGlyphData() const { return missing_glyph_data_; }
161 void SetMissingGlyphData(const GlyphData& glyph_data) { 161 void SetMissingGlyphData(const GlyphData& glyph_data) {
162 missing_glyph_data_ = glyph_data; 162 missing_glyph_data_ = glyph_data;
163 } 163 }
164 164
165 CustomFontData* GetCustomFontData() const { return custom_font_data_.Get(); } 165 CustomFontData* GetCustomFontData() const { return custom_font_data_.Get(); }
166 166
167 unsigned VisualOverflowInflationForAscent() const {
168 return visual_overflow_inflation_for_ascent_;
169 }
170 unsigned VisualOverflowInflationForDescent() const {
171 return visual_overflow_inflation_for_descent_;
172 }
173
167 protected: 174 protected:
168 SimpleFontData(const FontPlatformData&, 175 SimpleFontData(const FontPlatformData&,
169 PassRefPtr<CustomFontData> custom_data, 176 PassRefPtr<CustomFontData> custom_data,
170 bool is_text_orientation_fallback = false, 177 bool is_text_orientation_fallback = false,
171 bool subpixel_ascent_descent = false); 178 bool subpixel_ascent_descent = false);
172 179
173 // Only used for testing. 180 // Only used for testing.
174 SimpleFontData(const FontPlatformData&, PassRefPtr<OpenTypeVerticalData>); 181 SimpleFontData(const FontPlatformData&, PassRefPtr<OpenTypeVerticalData>);
175 182
176 private: 183 private:
177 void PlatformInit(bool subpixel_ascent_descent); 184 void PlatformInit(bool subpixel_ascent_descent);
178 void PlatformGlyphInit(); 185 void PlatformGlyphInit();
179 186
180 PassRefPtr<SimpleFontData> CreateScaledFontData(const FontDescription&, 187 PassRefPtr<SimpleFontData> CreateScaledFontData(const FontDescription&,
181 float scale_factor) const; 188 float scale_factor) const;
182 189
183 FontMetrics font_metrics_; 190 FontMetrics font_metrics_;
184 float max_char_width_; 191 float max_char_width_;
185 float avg_char_width_; 192 float avg_char_width_;
186 193
187 FontPlatformData platform_data_; 194 FontPlatformData platform_data_;
188 SkPaint paint_; 195 SkPaint paint_;
189 196
190 bool is_text_orientation_fallback_;
191 RefPtr<OpenTypeVerticalData> vertical_data_; 197 RefPtr<OpenTypeVerticalData> vertical_data_;
192 bool has_vertical_glyphs_;
193 198
194 Glyph space_glyph_; 199 Glyph space_glyph_;
195 float space_width_; 200 float space_width_;
196 Glyph zero_glyph_; 201 Glyph zero_glyph_;
197 202
198 GlyphData missing_glyph_data_; 203 GlyphData missing_glyph_data_;
199 204
200 struct DerivedFontData { 205 struct DerivedFontData {
201 USING_FAST_MALLOC(DerivedFontData); 206 USING_FAST_MALLOC(DerivedFontData);
202 WTF_MAKE_NONCOPYABLE(DerivedFontData); 207 WTF_MAKE_NONCOPYABLE(DerivedFontData);
203 208
204 public: 209 public:
205 static std::unique_ptr<DerivedFontData> Create(); 210 static std::unique_ptr<DerivedFontData> Create();
206 211
207 RefPtr<SimpleFontData> small_caps; 212 RefPtr<SimpleFontData> small_caps;
208 RefPtr<SimpleFontData> emphasis_mark; 213 RefPtr<SimpleFontData> emphasis_mark;
209 RefPtr<SimpleFontData> vertical_right_orientation; 214 RefPtr<SimpleFontData> vertical_right_orientation;
210 RefPtr<SimpleFontData> upright_orientation; 215 RefPtr<SimpleFontData> upright_orientation;
211 216
212 private: 217 private:
213 DerivedFontData() {} 218 DerivedFontData() {}
214 }; 219 };
215 220
216 mutable std::unique_ptr<DerivedFontData> derived_font_data_; 221 mutable std::unique_ptr<DerivedFontData> derived_font_data_;
217 222
218 RefPtr<CustomFontData> custom_font_data_; 223 RefPtr<CustomFontData> custom_font_data_;
219 224
225 unsigned is_text_orientation_fallback_ : 1;
226 unsigned has_vertical_glyphs_ : 1;
227
228 // These are set to non-zero when ascent or descent is rounded or shifted
229 // to be smaller than the actual ascent or descent. When calculating visual
230 // overflows, we should add the inflations.
231 unsigned visual_overflow_inflation_for_ascent_ : 2;
232 unsigned visual_overflow_inflation_for_descent_ : 2;
233
220 // See discussion on crbug.com/631032 and Skiaissue 234 // See discussion on crbug.com/631032 and Skiaissue
221 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 : 235 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 :
222 // On Mac we're still using path based glyph metrics, and they seem to be 236 // On Mac we're still using path based glyph metrics, and they seem to be
223 // too slow to be able to remove the caching layer we have here. 237 // too slow to be able to remove the caching layer we have here.
224 #if OS(MACOSX) 238 #if OS(MACOSX)
225 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> glyph_to_bounds_map_; 239 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> glyph_to_bounds_map_;
226 mutable GlyphMetricsMap<float> glyph_to_width_map_; 240 mutable GlyphMetricsMap<float> glyph_to_width_map_;
227 #endif 241 #endif
228 }; 242 };
229 243
(...skipping 29 matching lines...) Expand all
259 273
260 glyph_to_width_map_.SetMetricsForGlyph(glyph, width); 274 glyph_to_width_map_.SetMetricsForGlyph(glyph, width);
261 return width; 275 return width;
262 #endif 276 #endif
263 } 277 }
264 278
265 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 279 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
266 280
267 } // namespace blink 281 } // namespace blink
268 #endif // SimpleFontData_h 282 #endif // SimpleFontData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.cpp ('k') | third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698