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

Side by Side Diff: sky/engine/platform/fonts/SimpleFontData.h

Issue 709603006: Remove a bunch of OS(MACOSX) code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Even more Created 6 years, 1 month 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 21 matching lines...) Expand all
32 #include "platform/fonts/FontPlatformData.h" 32 #include "platform/fonts/FontPlatformData.h"
33 #include "platform/fonts/GlyphMetricsMap.h" 33 #include "platform/fonts/GlyphMetricsMap.h"
34 #include "platform/fonts/GlyphPageTreeNode.h" 34 #include "platform/fonts/GlyphPageTreeNode.h"
35 #include "platform/fonts/TypesettingFeatures.h" 35 #include "platform/fonts/TypesettingFeatures.h"
36 #include "platform/fonts/opentype/OpenTypeVerticalData.h" 36 #include "platform/fonts/opentype/OpenTypeVerticalData.h"
37 #include "platform/geometry/FloatRect.h" 37 #include "platform/geometry/FloatRect.h"
38 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
39 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/text/StringHash.h" 40 #include "wtf/text/StringHash.h"
41 41
42 #if OS(MACOSX)
43 #include "wtf/RetainPtr.h"
44 #endif
45
46 namespace blink { 42 namespace blink {
47 43
48 class FontDescription; 44 class FontDescription;
49 45
50 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant, BrokenIdeographVariant }; 46 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant, BrokenIdeographVariant };
51 enum Pitch { UnknownPitch, FixedPitch, VariablePitch }; 47 enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
52 48
53 class PLATFORM_EXPORT SimpleFontData : public FontData { 49 class PLATFORM_EXPORT SimpleFontData : public FontData {
54 public: 50 public:
55 // Used to create platform fonts. 51 // Used to create platform fonts.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; } 107 void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; }
112 108
113 FloatRect boundsForGlyph(Glyph) const; 109 FloatRect boundsForGlyph(Glyph) const;
114 float widthForGlyph(Glyph glyph) const; 110 float widthForGlyph(Glyph glyph) const;
115 FloatRect platformBoundsForGlyph(Glyph) const; 111 FloatRect platformBoundsForGlyph(Glyph) const;
116 float platformWidthForGlyph(Glyph) const; 112 float platformWidthForGlyph(Glyph) const;
117 113
118 float spaceWidth() const { return m_spaceWidth; } 114 float spaceWidth() const { return m_spaceWidth; }
119 void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; } 115 void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; }
120 116
121 #if OS(MACOSX)
122 float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
123 #endif
124
125 Glyph spaceGlyph() const { return m_spaceGlyph; } 117 Glyph spaceGlyph() const { return m_spaceGlyph; }
126 void setSpaceGlyph(Glyph spaceGlyph) { m_spaceGlyph = spaceGlyph; } 118 void setSpaceGlyph(Glyph spaceGlyph) { m_spaceGlyph = spaceGlyph; }
127 Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; } 119 Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; }
128 void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spac eGlyph; } 120 void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spac eGlyph; }
129 bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthS paceGlyph && glyph; } 121 bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthS paceGlyph && glyph; }
130 Glyph zeroGlyph() const { return m_zeroGlyph; } 122 Glyph zeroGlyph() const { return m_zeroGlyph; }
131 void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; } 123 void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; }
132 124
133 virtual const SimpleFontData* fontDataForCharacter(UChar32) const override; 125 virtual const SimpleFontData* fontDataForCharacter(UChar32) const override;
134 126
135 Glyph glyphForCharacter(UChar32) const; 127 Glyph glyphForCharacter(UChar32) const;
136 128
137 void determinePitch(); 129 void determinePitch();
138 Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitc h; } 130 Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitc h; }
139 131
140 bool isSVGFont() const { return m_customFontData && m_customFontData->isSVGF ont(); } 132 bool isSVGFont() const { return m_customFontData && m_customFontData->isSVGF ont(); }
141 virtual bool isCustomFont() const override { return m_customFontData; } 133 virtual bool isCustomFont() const override { return m_customFontData; }
142 virtual bool isLoading() const override { return m_customFontData ? m_custom FontData->isLoading() : false; } 134 virtual bool isLoading() const override { return m_customFontData ? m_custom FontData->isLoading() : false; }
143 virtual bool isLoadingFallback() const override { return m_customFontData ? m_customFontData->isLoadingFallback() : false; } 135 virtual bool isLoadingFallback() const override { return m_customFontData ? m_customFontData->isLoadingFallback() : false; }
144 virtual bool isSegmented() const override; 136 virtual bool isSegmented() const override;
145 virtual bool shouldSkipDrawing() const override { return m_customFontData && m_customFontData->shouldSkipDrawing(); } 137 virtual bool shouldSkipDrawing() const override { return m_customFontData && m_customFontData->shouldSkipDrawing(); }
146 138
147 const GlyphData& missingGlyphData() const { return m_missingGlyphData; } 139 const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
148 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; } 140 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; }
149 141
150 #ifndef NDEBUG 142 #ifndef NDEBUG
151 virtual String description() const override; 143 virtual String description() const override;
152 #endif 144 #endif
153 145
154 #if OS(MACOSX)
155 const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const;
156 NSFont* getNSFont() const { return m_platformData.font(); }
157 #endif
158
159 #if OS(MACOSX)
160 CFDictionaryRef getCFStringAttributes(TypesettingFeatures, FontOrientation) const;
161 #endif
162
163 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const; 146 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
164 147
165 PassRefPtr<CustomFontData> customFontData() const { return m_customFontData; } 148 PassRefPtr<CustomFontData> customFontData() const { return m_customFontData; }
166 149
167 // Implemented by the platform. 150 // Implemented by the platform.
168 virtual bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const; 151 virtual bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const;
169 152
170 protected: 153 protected:
171 SimpleFontData(const FontPlatformData&, PassRefPtr<CustomFontData> customDat a, bool isTextOrientationFallback = false); 154 SimpleFontData(const FontPlatformData&, PassRefPtr<CustomFontData> customDat a, bool isTextOrientationFallback = false);
172 155
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 struct DerivedFontData { 195 struct DerivedFontData {
213 static PassOwnPtr<DerivedFontData> create(bool forCustomFont); 196 static PassOwnPtr<DerivedFontData> create(bool forCustomFont);
214 ~DerivedFontData(); 197 ~DerivedFontData();
215 198
216 bool forCustomFont; 199 bool forCustomFont;
217 RefPtr<SimpleFontData> smallCaps; 200 RefPtr<SimpleFontData> smallCaps;
218 RefPtr<SimpleFontData> emphasisMark; 201 RefPtr<SimpleFontData> emphasisMark;
219 RefPtr<SimpleFontData> brokenIdeograph; 202 RefPtr<SimpleFontData> brokenIdeograph;
220 RefPtr<SimpleFontData> verticalRightOrientation; 203 RefPtr<SimpleFontData> verticalRightOrientation;
221 RefPtr<SimpleFontData> uprightOrientation; 204 RefPtr<SimpleFontData> uprightOrientation;
222 #if OS(MACOSX)
223 mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;
224 #endif
225 205
226 private: 206 private:
227 DerivedFontData(bool custom) 207 DerivedFontData(bool custom)
228 : forCustomFont(custom) 208 : forCustomFont(custom)
229 { 209 {
230 } 210 }
231 }; 211 };
232 212
233 mutable OwnPtr<DerivedFontData> m_derivedFontData; 213 mutable OwnPtr<DerivedFontData> m_derivedFontData;
234 214
235 RefPtr<CustomFontData> m_customFontData; 215 RefPtr<CustomFontData> m_customFontData;
236 216
237 #if OS(MACOSX)
238 float m_syntheticBoldOffset;
239
240 mutable HashMap<unsigned, RetainPtr<CFDictionaryRef> > m_CFStringAttributes;
241 #endif
242
243 mutable OwnPtr<HashMap<String, bool> > m_combiningCharacterSequenceSupport; 217 mutable OwnPtr<HashMap<String, bool> > m_combiningCharacterSequenceSupport;
244 }; 218 };
245 219
246 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const 220 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const
247 { 221 {
248 if (isZeroWidthSpaceGlyph(glyph)) 222 if (isZeroWidthSpaceGlyph(glyph))
249 return FloatRect(); 223 return FloatRect();
250 224
251 FloatRect bounds; 225 FloatRect bounds;
252 if (m_glyphToBoundsMap) { 226 if (m_glyphToBoundsMap) {
(...skipping 13 matching lines...) Expand all
266 { 240 {
267 if (isZeroWidthSpaceGlyph(glyph)) 241 if (isZeroWidthSpaceGlyph(glyph))
268 return 0; 242 return 0;
269 243
270 float width = m_glyphToWidthMap.metricsForGlyph(glyph); 244 float width = m_glyphToWidthMap.metricsForGlyph(glyph);
271 if (width != cGlyphSizeUnknown) 245 if (width != cGlyphSizeUnknown)
272 return width; 246 return width;
273 247
274 #if ENABLE(OPENTYPE_VERTICAL) 248 #if ENABLE(OPENTYPE_VERTICAL)
275 if (m_verticalData) 249 if (m_verticalData)
276 #if OS(MACOSX)
277 width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffs et;
278 #else
279 width = m_verticalData->advanceHeight(this, glyph); 250 width = m_verticalData->advanceHeight(this, glyph);
280 #endif
281 else 251 else
282 #endif 252 #endif
283 width = platformWidthForGlyph(glyph); 253 width = platformWidthForGlyph(glyph);
284 254
285 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 255 m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
286 return width; 256 return width;
287 } 257 }
288 258
289 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 259 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
290 260
291 } // namespace blink 261 } // namespace blink
292 #endif // SimpleFontData_h 262 #endif // SimpleFontData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698