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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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 * 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 17 matching lines...) Expand all
28 #include "platform/fonts/CustomFontData.h" 28 #include "platform/fonts/CustomFontData.h"
29 #include "platform/fonts/FontBaseline.h" 29 #include "platform/fonts/FontBaseline.h"
30 #include "platform/fonts/FontData.h" 30 #include "platform/fonts/FontData.h"
31 #include "platform/fonts/FontMetrics.h" 31 #include "platform/fonts/FontMetrics.h"
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/PtrUtil.h"
39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/text/StringHash.h" 39 #include "wtf/text/StringHash.h"
40 #include <memory>
41 41
42 namespace blink { 42 namespace blink {
43 43
44 class FontDescription; 44 class FontDescription;
45 45
46 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant }; 46 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant };
47 47
48 class PLATFORM_EXPORT SimpleFontData : public FontData { 48 class PLATFORM_EXPORT SimpleFontData : public FontData {
49 public: 49 public:
50 // Used to create platform fonts. 50 // Used to create platform fonts.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void platformGlyphInit(); 137 void platformGlyphInit();
138 138
139 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t scaleFactor) const; 139 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t scaleFactor) const;
140 140
141 FontMetrics m_fontMetrics; 141 FontMetrics m_fontMetrics;
142 float m_maxCharWidth; 142 float m_maxCharWidth;
143 float m_avgCharWidth; 143 float m_avgCharWidth;
144 144
145 FontPlatformData m_platformData; 145 FontPlatformData m_platformData;
146 146
147 mutable OwnPtr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap; 147 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
148 mutable GlyphMetricsMap<float> m_glyphToWidthMap; 148 mutable GlyphMetricsMap<float> m_glyphToWidthMap;
149 149
150 bool m_isTextOrientationFallback; 150 bool m_isTextOrientationFallback;
151 RefPtr<OpenTypeVerticalData> m_verticalData; 151 RefPtr<OpenTypeVerticalData> m_verticalData;
152 bool m_hasVerticalGlyphs; 152 bool m_hasVerticalGlyphs;
153 153
154 Glyph m_spaceGlyph; 154 Glyph m_spaceGlyph;
155 float m_spaceWidth; 155 float m_spaceWidth;
156 Glyph m_zeroGlyph; 156 Glyph m_zeroGlyph;
157 157
158 GlyphData m_missingGlyphData; 158 GlyphData m_missingGlyphData;
159 159
160 struct DerivedFontData { 160 struct DerivedFontData {
161 USING_FAST_MALLOC(DerivedFontData); 161 USING_FAST_MALLOC(DerivedFontData);
162 WTF_MAKE_NONCOPYABLE(DerivedFontData); 162 WTF_MAKE_NONCOPYABLE(DerivedFontData);
163 public: 163 public:
164 static PassOwnPtr<DerivedFontData> create(bool forCustomFont); 164 static std::unique_ptr<DerivedFontData> create(bool forCustomFont);
165 ~DerivedFontData(); 165 ~DerivedFontData();
166 166
167 bool forCustomFont; 167 bool forCustomFont;
168 RefPtr<SimpleFontData> smallCaps; 168 RefPtr<SimpleFontData> smallCaps;
169 RefPtr<SimpleFontData> emphasisMark; 169 RefPtr<SimpleFontData> emphasisMark;
170 RefPtr<SimpleFontData> verticalRightOrientation; 170 RefPtr<SimpleFontData> verticalRightOrientation;
171 RefPtr<SimpleFontData> uprightOrientation; 171 RefPtr<SimpleFontData> uprightOrientation;
172 172
173 private: 173 private:
174 DerivedFontData(bool custom) 174 DerivedFontData(bool custom)
175 : forCustomFont(custom) 175 : forCustomFont(custom)
176 { 176 {
177 } 177 }
178 }; 178 };
179 179
180 mutable OwnPtr<DerivedFontData> m_derivedFontData; 180 mutable std::unique_ptr<DerivedFontData> m_derivedFontData;
181 181
182 RefPtr<CustomFontData> m_customFontData; 182 RefPtr<CustomFontData> m_customFontData;
183 }; 183 };
184 184
185 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const 185 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const
186 { 186 {
187 FloatRect bounds; 187 FloatRect bounds;
188 if (m_glyphToBoundsMap) { 188 if (m_glyphToBoundsMap) {
189 bounds = m_glyphToBoundsMap->metricsForGlyph(glyph); 189 bounds = m_glyphToBoundsMap->metricsForGlyph(glyph);
190 if (bounds.width() != cGlyphSizeUnknown) 190 if (bounds.width() != cGlyphSizeUnknown)
191 return bounds; 191 return bounds;
192 } 192 }
193 193
194 bounds = platformBoundsForGlyph(glyph); 194 bounds = platformBoundsForGlyph(glyph);
195 if (!m_glyphToBoundsMap) 195 if (!m_glyphToBoundsMap)
196 m_glyphToBoundsMap = adoptPtr(new GlyphMetricsMap<FloatRect>); 196 m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>);
197 m_glyphToBoundsMap->setMetricsForGlyph(glyph, bounds); 197 m_glyphToBoundsMap->setMetricsForGlyph(glyph, bounds);
198 return bounds; 198 return bounds;
199 } 199 }
200 200
201 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const 201 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
202 { 202 {
203 float width = m_glyphToWidthMap.metricsForGlyph(glyph); 203 float width = m_glyphToWidthMap.metricsForGlyph(glyph);
204 if (width != cGlyphSizeUnknown) 204 if (width != cGlyphSizeUnknown)
205 return width; 205 return width;
206 206
207 width = platformWidthForGlyph(glyph); 207 width = platformWidthForGlyph(glyph);
208 208
209 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 209 m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
210 return width; 210 return width;
211 } 211 }
212 212
213 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 213 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
214 214
215 } // namespace blink 215 } // namespace blink
216 #endif // SimpleFontData_h 216 #endif // SimpleFontData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698