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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontDataCache.cpp

Issue 2392033002: Correcting text baseline for tiny fonts (Closed)
Patch Set: Fixing flaky layout tests. Created 4 years, 2 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 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #if !OS(ANDROID) 39 #if !OS(ANDROID)
40 const unsigned cMaxInactiveFontData = 250; 40 const unsigned cMaxInactiveFontData = 250;
41 const unsigned cTargetInactiveFontData = 200; 41 const unsigned cTargetInactiveFontData = 200;
42 #else 42 #else
43 const unsigned cMaxInactiveFontData = 225; 43 const unsigned cMaxInactiveFontData = 225;
44 const unsigned cTargetInactiveFontData = 200; 44 const unsigned cTargetInactiveFontData = 200;
45 #endif 45 #endif
46 46
47 PassRefPtr<SimpleFontData> FontDataCache::get( 47 PassRefPtr<SimpleFontData> FontDataCache::get(
48 const FontPlatformData* platformData, 48 const FontPlatformData* platformData,
49 ShouldRetain shouldRetain) { 49 ShouldRetain shouldRetain,
50 bool subpixelAscentDescent) {
50 if (!platformData) 51 if (!platformData)
51 return nullptr; 52 return nullptr;
52 53
53 // TODO: crbug.com/446376 - This should not happen, but we currently 54 // TODO: crbug.com/446376 - This should not happen, but we currently
54 // do not have a reproduction for the crash that an empty typeface() 55 // do not have a reproduction for the crash that an empty typeface()
55 // causes downstream from here. 56 // causes downstream from here.
56 if (!platformData->typeface()) { 57 if (!platformData->typeface()) {
57 DLOG(ERROR) 58 DLOG(ERROR)
58 << "Empty typeface() in FontPlatformData when accessing FontDataCache."; 59 << "Empty typeface() in FontPlatformData when accessing FontDataCache.";
59 return nullptr; 60 return nullptr;
60 } 61 }
61 62
62 Cache::iterator result = m_cache.find(platformData); 63 Cache::iterator result = m_cache.find(platformData);
63 if (result == m_cache.end()) { 64 if (result == m_cache.end()) {
64 std::pair<RefPtr<SimpleFontData>, unsigned> newValue( 65 std::pair<RefPtr<SimpleFontData>, unsigned> newValue(
65 SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0); 66 SimpleFontData::create(*platformData, nullptr, false,
67 subpixelAscentDescent),
68 shouldRetain == Retain ? 1 : 0);
66 // The new SimpleFontData takes a copy of the incoming FontPlatformData 69 // The new SimpleFontData takes a copy of the incoming FontPlatformData
67 // object. The incoming key may be temporary. So, for cache storage, take 70 // object. The incoming key may be temporary. So, for cache storage, take
68 // the address of the newly created FontPlatformData that is copied an owned 71 // the address of the newly created FontPlatformData that is copied an owned
69 // by SimpleFontData. 72 // by SimpleFontData.
70 m_cache.set(&newValue.first->platformData(), newValue); 73 m_cache.set(&newValue.first->platformData(), newValue);
71 if (shouldRetain == DoNotRetain) 74 if (shouldRetain == DoNotRetain)
72 m_inactiveFontData.add(newValue.first); 75 m_inactiveFontData.add(newValue.first);
73 return newValue.first.release(); 76 return newValue.first.release();
74 } 77 }
75 78
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bool didWork = fontDataToDelete.size(); 163 bool didWork = fontDataToDelete.size();
161 164
162 fontDataToDelete.clear(); 165 fontDataToDelete.clear();
163 166
164 isPurging = false; 167 isPurging = false;
165 168
166 return didWork; 169 return didWork;
167 } 170 }
168 171
169 } // namespace blink 172 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698