Source/WebCore/ChangeLog

 12014-10-16 Gyuyoung Kim <gyuyoung.kim@samsung.com>
 2
 3 Apply std::unique_ptr to FooFont classes
 4 https://bugs.webkit.org/show_bug.cgi?id=137769
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 As a step to use std::unique_ptr, this patch applies std::unique_ptr to Font classes.
 9
 10 No new tests, no behavior changes.
 11
 12 * platform/graphics/Font.cpp:
 13 (WebCore::retrieveOrAddCachedFontGlyphs):
 14 (WebCore::Font::createLayout):
 15 * platform/graphics/SimpleFontData.cpp:
 16 (WebCore::SimpleFontData::DerivedFontData::create):
 17 * platform/graphics/SimpleFontData.h:
 18 Remove create() factory function because public ctor and std::make_unique<> can replace it.
 19 * platform/graphics/mac/ComplexTextController.cpp:
 20 (WebCore::Font::createLayout):
 21
1222014-10-15 Andrei Bucur <abucur@adobe.com>
223
324 ASSERTION FAILED in WebCore::RenderFlowThread::getRegionRangeForBox

Source/WebCore/platform/graphics/Font.cpp

@@public:
220220 Ref<FontGlyphs> glyphs;
221221};
222222
223 typedef HashMap<unsigned, OwnPtr<FontGlyphsCacheEntry>, AlreadyHashed> FontGlyphsCache;
 223typedef HashMap<unsigned, std::unique_ptr<FontGlyphsCacheEntry>, AlreadyHashed> FontGlyphsCache;
224224
225225static bool operator==(const FontGlyphsCacheKey& a, const FontGlyphsCacheKey& b)
226226{

@@static PassRef<FontGlyphs> retrieveOrAddCachedFontGlyphs(const FontDescription&
302302 makeFontGlyphsCacheKey(key, fontDescription, fontSelector.get());
303303
304304 unsigned hash = computeFontGlyphsCacheHash(key);
305  FontGlyphsCache::AddResult addResult = fontGlyphsCache().add(hash, PassOwnPtr<FontGlyphsCacheEntry>());
 305 FontGlyphsCache::AddResult addResult = fontGlyphsCache().add(hash, std::unique_ptr<FontGlyphsCacheEntry>());
306306 if (!addResult.isNewEntry && addResult.iterator->value->key == key)
307307 return addResult.iterator->value->glyphs.get();
308308
309  OwnPtr<FontGlyphsCacheEntry>& newEntry = addResult.iterator->value;
310  newEntry = adoptPtr(new FontGlyphsCacheEntry(WTF::move(key), FontGlyphs::create(fontSelector)));
 309 std::unique_ptr<FontGlyphsCacheEntry>& newEntry = addResult.iterator->value;
 310 newEntry = std::make_unique<FontGlyphsCacheEntry>(WTF::move(key), FontGlyphs::create(fontSelector));
311311 PassRef<FontGlyphs> glyphs = newEntry->glyphs.get();
312312
313313 static const unsigned unreferencedPruneInterval = 50;

Source/WebCore/platform/graphics/SimpleFontData.cpp

@@bool SimpleFontData::isSegmented() const
181181PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() const
182182{
183183 if (!m_derivedFontData)
184  m_derivedFontData = DerivedFontData::create(isCustomFont());
 184 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
185185 if (!m_derivedFontData->verticalRightOrientation) {
186186 FontPlatformData verticalRightPlatformData(m_platformData);
187187 verticalRightPlatformData.setOrientation(Horizontal);

@@PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() co
193193PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const
194194{
195195 if (!m_derivedFontData)
196  m_derivedFontData = DerivedFontData::create(isCustomFont());
 196 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
197197 if (!m_derivedFontData->uprightOrientation)
198198 m_derivedFontData->uprightOrientation = create(m_platformData, isCustomFont(), false, true);
199199 return m_derivedFontData->uprightOrientation;

@@PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const
202202PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
203203{
204204 if (!m_derivedFontData)
205  m_derivedFontData = DerivedFontData::create(isCustomFont());
 205 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
206206 if (!m_derivedFontData->smallCaps)
207207 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFontSizeMultiplier);
208208

@@PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescripti
212212PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
213213{
214214 if (!m_derivedFontData)
215  m_derivedFontData = DerivedFontData::create(isCustomFont());
 215 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
216216 if (!m_derivedFontData->emphasisMark)
217217 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFontSizeMultiplier);
218218

@@PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescri
222222PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const
223223{
224224 if (!m_derivedFontData)
225  m_derivedFontData = DerivedFontData::create(isCustomFont());
 225 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
226226 if (!m_derivedFontData->brokenIdeograph) {
227227 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont(), false);
228228 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true;

@@PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const
233233PassRefPtr<SimpleFontData> SimpleFontData::nonSyntheticItalicFontData() const
234234{
235235 if (!m_derivedFontData)
236  m_derivedFontData = DerivedFontData::create(isCustomFont());
 236 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
237237 if (!m_derivedFontData->nonSyntheticItalic) {
238238 FontPlatformData nonSyntheticItalicFontPlatformData(m_platformData);
239239#if PLATFORM(COCOA)

@@const OpenTypeMathData* SimpleFontData::mathData() const
268268 return m_mathData.get();
269269}
270270
271 PassOwnPtr<SimpleFontData::DerivedFontData> SimpleFontData::DerivedFontData::create(bool forCustomFont)
272 {
273  return adoptPtr(new DerivedFontData(forCustomFont));
274 }
275 
276271SimpleFontData::DerivedFontData::~DerivedFontData()
277272{
278273 if (!forCustomFont)

Source/WebCore/platform/graphics/SimpleFontData.h

3838#endif
3939#include "TypesettingFeatures.h"
4040#include <wtf/OwnPtr.h>
41 #include <wtf/PassOwnPtr.h>
4241#include <wtf/TypeCasts.h>
4342#include <wtf/text/StringHash.h>
4443

@@private:
302301 GlyphData m_missingGlyphData;
303302
304303 struct DerivedFontData {
305  static PassOwnPtr<DerivedFontData> create(bool forCustomFont);
 304 explicit DerivedFontData(bool custom)
 305 : forCustomFont(custom)
 306 {
 307 }
306308 ~DerivedFontData();
307309
308310 bool forCustomFont;

@@private:
315317#if PLATFORM(COCOA)
316318 mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;
317319#endif
318 
319  private:
320  DerivedFontData(bool custom)
321  : forCustomFont(custom)
322  {
323  }
324320 };
325321
326  mutable OwnPtr<DerivedFontData> m_derivedFontData;
 322 mutable std::unique_ptr<DerivedFontData> m_derivedFontData;
327323
328324#if USE(CG) || USE(CAIRO)
329325 float m_syntheticBoldOffset;

Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

@@public:
5252 TextLayout(RenderText* text, const Font& font, float xPos)
5353 : m_font(font)
5454 , m_run(constructTextRun(text, font, xPos))
55  , m_controller(adoptPtr(new ComplexTextController(&m_font, m_run, true)))
 55 , m_controller(std::make_unique<ComplexTextController>(&m_font, m_run, true)))
5656 {
5757 }
5858

@@private:
8181 // ComplexTextController has only references to its Font and TextRun so they must be kept alive here.
8282 Font m_font;
8383 TextRun m_run;
84  OwnPtr<ComplexTextController> m_controller;
 84 std::unique_ptr<ComplexTextController> m_controller;
8585};
8686
8787PassOwnPtr<TextLayout> Font::createLayout(RenderText* text, float xPos, bool collapseWhiteSpace) const

Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

@@const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *
9999{
100100 if (key && !CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) {
101101 if (!m_derivedFontData)
102  m_derivedFontData = DerivedFontData::create(isCustomFont());
 102 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont());
103103 if (!m_derivedFontData->compositeFontReferences)
104104 m_derivedFontData->compositeFontReferences = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL));
105105 else {