| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2006, 2007 Apple Computer, Inc. | 2  * Copyright (C) 2006, 2007 Apple Computer, Inc. | 
| 3  * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 3  * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 
| 4  * | 4  * | 
| 5  * Redistribution and use in source and binary forms, with or without | 5  * Redistribution and use in source and binary forms, with or without | 
| 6  * modification, are permitted provided that the following conditions are | 6  * modification, are permitted provided that the following conditions are | 
| 7  * met: | 7  * met: | 
| 8  * | 8  * | 
| 9  *     * Redistributions of source code must retain the above copyright | 9  *     * Redistributions of source code must retain the above copyright | 
| 10  * notice, this list of conditions and the following disclaimer. | 10  * notice, this list of conditions and the following disclaimer. | 
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 196 { | 196 { | 
| 197     SkSafeUnref(m_typeface); | 197     SkSafeUnref(m_typeface); | 
| 198 | 198 | 
| 199     ScriptFreeCache(&m_scriptCache); | 199     ScriptFreeCache(&m_scriptCache); | 
| 200     m_scriptCache = 0; | 200     m_scriptCache = 0; | 
| 201 | 201 | 
| 202     delete m_scriptFontProperties; | 202     delete m_scriptFontProperties; | 
| 203     m_scriptFontProperties = 0; | 203     m_scriptFontProperties = 0; | 
| 204 } | 204 } | 
| 205 | 205 | 
|  | 206 bool FontPlatformData::isFixedPitch() const | 
|  | 207 { | 
|  | 208 #if ENABLE(GDI_FONTS_ON_WINDOWS) | 
|  | 209     // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that. | 
|  | 210     HWndDC dc(0); | 
|  | 211     HGDIOBJ oldFont = SelectObject(dc, hfont()); | 
|  | 212 | 
|  | 213     // Yes, this looks backwards, but the fixed pitch bit is actually set if the
      font | 
|  | 214     // is *not* fixed pitch. Unbelievable but true. | 
|  | 215     TEXTMETRIC textMetric = { 0 }; | 
|  | 216     if (!GetTextMetrics(dc, &textMetric)) { | 
|  | 217         if (ensureFontLoaded(hfont())) { | 
|  | 218             // Retry GetTextMetrics. | 
|  | 219             // FIXME: Handle gracefully the error if this call also fails. | 
|  | 220             // See http://crbug.com/6401. | 
|  | 221             if (!GetTextMetrics(dc, &textMetric)) | 
|  | 222                 LOG_ERROR("Unable to get the text metrics after second attempt")
     ; | 
|  | 223         } | 
|  | 224     } | 
|  | 225 | 
|  | 226     bool treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); | 
|  | 227 | 
|  | 228     SelectObject(dc, oldFont); | 
|  | 229 | 
|  | 230     return treatAsFixedPitch; | 
|  | 231 #else | 
|  | 232     return typeface()->isFixedPitch(); | 
|  | 233 #endif | 
|  | 234 } | 
|  | 235 | 
| 206 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() | 236 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() | 
| 207 { | 237 { | 
| 208     if (m_hfont != reinterpret_cast<HFONT>(-1)) { | 238     if (m_hfont != reinterpret_cast<HFONT>(-1)) { | 
| 209         DeleteObject(m_hfont); | 239         DeleteObject(m_hfont); | 
| 210     } | 240     } | 
| 211 } | 241 } | 
| 212 | 242 | 
| 213 FontPlatformData::RefCountedHFONT* FontPlatformData::hashTableDeletedFontValue() | 243 FontPlatformData::RefCountedHFONT* FontPlatformData::hashTableDeletedFontValue() | 
| 214 { | 244 { | 
| 215     DEFINE_STATIC_LOCAL(RefPtr<RefCountedHFONT>, deletedValue, | 245     DEFINE_STATIC_LOCAL(RefPtr<RefCountedHFONT>, deletedValue, | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 281 | 311 | 
| 282 bool FontPlatformData::ensureFontLoaded(HFONT font) | 312 bool FontPlatformData::ensureFontLoaded(HFONT font) | 
| 283 { | 313 { | 
| 284     WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
     dboxSupport(); | 314     WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
     dboxSupport(); | 
| 285     // if there is no sandbox, then we can assume the font | 315     // if there is no sandbox, then we can assume the font | 
| 286     // was able to be loaded successfully already | 316     // was able to be loaded successfully already | 
| 287     return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; | 317     return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; | 
| 288 } | 318 } | 
| 289 | 319 | 
| 290 } | 320 } | 
| OLD | NEW | 
|---|