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

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

Issue 2819953002: 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return m_customFontData && m_customFontData->shouldSkipDrawing(); 150 return m_customFontData && m_customFontData->shouldSkipDrawing();
151 } 151 }
152 152
153 const GlyphData& missingGlyphData() const { return m_missingGlyphData; } 153 const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
154 void setMissingGlyphData(const GlyphData& glyphData) { 154 void setMissingGlyphData(const GlyphData& glyphData) {
155 m_missingGlyphData = glyphData; 155 m_missingGlyphData = glyphData;
156 } 156 }
157 157
158 CustomFontData* customFontData() const { return m_customFontData.get(); } 158 CustomFontData* customFontData() const { return m_customFontData.get(); }
159 159
160 unsigned VisualOverflowInflationForAscent() const {
161 return visual_overflow_inflation_for_ascent_;
162 }
163 unsigned VisualOverflowInflationForDescent() const {
164 return visual_overflow_inflation_for_descent_;
165 }
166
160 protected: 167 protected:
161 SimpleFontData(const FontPlatformData&, 168 SimpleFontData(const FontPlatformData&,
162 PassRefPtr<CustomFontData> customData, 169 PassRefPtr<CustomFontData> customData,
163 bool isTextOrientationFallback = false, 170 bool isTextOrientationFallback = false,
164 bool subpixelAscentDescent = false); 171 bool subpixelAscentDescent = false);
165 172
166 SimpleFontData(PassRefPtr<CustomFontData> customData, 173 SimpleFontData(PassRefPtr<CustomFontData> customData,
167 float fontSize, 174 float fontSize,
168 bool syntheticBold, 175 bool syntheticBold,
169 bool syntheticItalic); 176 bool syntheticItalic);
170 177
171 private: 178 private:
172 void platformInit(bool subpixelAscentDescent); 179 void platformInit(bool subpixelAscentDescent);
173 void platformGlyphInit(); 180 void platformGlyphInit();
174 181
175 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, 182 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&,
176 float scaleFactor) const; 183 float scaleFactor) const;
177 184
178 FontMetrics m_fontMetrics; 185 FontMetrics m_fontMetrics;
179 float m_maxCharWidth; 186 float m_maxCharWidth;
180 float m_avgCharWidth; 187 float m_avgCharWidth;
181 188
182 FontPlatformData m_platformData; 189 FontPlatformData m_platformData;
183 SkPaint m_paint; 190 SkPaint m_paint;
184 191
185 bool m_isTextOrientationFallback;
186 RefPtr<OpenTypeVerticalData> m_verticalData; 192 RefPtr<OpenTypeVerticalData> m_verticalData;
187 bool m_hasVerticalGlyphs;
188 193
189 Glyph m_spaceGlyph; 194 Glyph m_spaceGlyph;
190 float m_spaceWidth; 195 float m_spaceWidth;
191 Glyph m_zeroGlyph; 196 Glyph m_zeroGlyph;
192 197
193 GlyphData m_missingGlyphData; 198 GlyphData m_missingGlyphData;
194 199
195 struct DerivedFontData { 200 struct DerivedFontData {
196 USING_FAST_MALLOC(DerivedFontData); 201 USING_FAST_MALLOC(DerivedFontData);
197 WTF_MAKE_NONCOPYABLE(DerivedFontData); 202 WTF_MAKE_NONCOPYABLE(DerivedFontData);
198 203
199 public: 204 public:
200 static std::unique_ptr<DerivedFontData> create(); 205 static std::unique_ptr<DerivedFontData> create();
201 206
202 RefPtr<SimpleFontData> smallCaps; 207 RefPtr<SimpleFontData> smallCaps;
203 RefPtr<SimpleFontData> emphasisMark; 208 RefPtr<SimpleFontData> emphasisMark;
204 RefPtr<SimpleFontData> verticalRightOrientation; 209 RefPtr<SimpleFontData> verticalRightOrientation;
205 RefPtr<SimpleFontData> uprightOrientation; 210 RefPtr<SimpleFontData> uprightOrientation;
206 211
207 private: 212 private:
208 DerivedFontData() {} 213 DerivedFontData() {}
209 }; 214 };
210 215
211 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; 216 mutable std::unique_ptr<DerivedFontData> m_derivedFontData;
212 217
213 RefPtr<CustomFontData> m_customFontData; 218 RefPtr<CustomFontData> m_customFontData;
214 219
220 unsigned m_isTextOrientationFallback : 1;
221 unsigned m_hasVerticalGlyphs : 1;
222
223 // These are set to non-zero when ascent or descent is rounded or shifted
224 // to be smaller than the actual ascent or descent. When calculating visual
225 // overflows, we should add the inflations.
226 unsigned visual_overflow_inflation_for_ascent_ : 2;
227 unsigned visual_overflow_inflation_for_descent_ : 2;
228
215 // See discussion on crbug.com/631032 and Skiaissue 229 // See discussion on crbug.com/631032 and Skiaissue
216 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 : 230 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 :
217 // On Mac we're still using path based glyph metrics, and they seem to be 231 // On Mac we're still using path based glyph metrics, and they seem to be
218 // too slow to be able to remove the caching layer we have here. 232 // too slow to be able to remove the caching layer we have here.
219 #if OS(MACOSX) 233 #if OS(MACOSX)
220 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap; 234 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
221 mutable GlyphMetricsMap<float> m_glyphToWidthMap; 235 mutable GlyphMetricsMap<float> m_glyphToWidthMap;
222 #endif 236 #endif
223 }; 237 };
224 238
(...skipping 29 matching lines...) Expand all
254 268
255 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 269 m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
256 return width; 270 return width;
257 #endif 271 #endif
258 } 272 }
259 273
260 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 274 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
261 275
262 } // namespace blink 276 } // namespace blink
263 #endif // SimpleFontData_h 277 #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