Changeset 73116 in webkit
- Timestamp:
- Dec 2, 2010 1:54:24 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r73114 r73116 1 2010-12-02 Hironori Bono <hbono@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [Chromium] Fix possible crashes in FontFallbackFont::determinePitch(). 6 https://bugs.webkit.org/show_bug.cgi?id=25770 7 8 When all of "Arial", "Courier New", and "Times New Roman" fonts are corrupted, 9 FontCache::getLastResortFallbackFont() returns 0 and it causes this crash. To 10 avoid this crash, this change falls back to system fonts (Windows ensures they 11 are sane) as Win Safari does. Unfortunately, I don't have any ideas how I can 12 write a layout test for this issue because this crash happens on a PC some of 13 its system fonts are corrupted. 14 15 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 16 (WebCore::fontDataFromDescriptionAndLogFont): 17 (WebCore::FontCache::getLastResortFallbackFont): 18 1 19 2010-12-02 Dimitri Glazkov <dglazkov@chromium.org> 2 20 -
trunk/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r72498 r73116 422 422 } 423 423 424 // Tries the given font and save it |outFontFamilyName| if it succeeds. 425 static SimpleFontData* fontDataFromDescriptionAndLogFont(FontCache* fontCache, const FontDescription& fontDescription, const LOGFONT& font, wchar_t* outFontFamilyName) 426 { 427 SimpleFontData* fontData = fontCache->getCachedFontData(fontDescription, font.lfFaceName); 428 if (fontData) 429 memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName)); 430 return fontData; 431 } 432 424 433 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description) 425 434 { … … 439 448 fontStr = courierStr; 440 449 441 return getCachedFontData(description, fontStr); 450 SimpleFontData* simpleFont = getCachedFontData(description, fontStr); 451 if (simpleFont) 452 return simpleFont; 453 454 // Fall back to system fonts as Win Safari does because this function must 455 // return a valid font. Once we find a valid system font, we save its name 456 // to a static variable and use it to prevent trying system fonts again. 457 static wchar_t fallbackFontName[LF_FACESIZE] = {0}; 458 if (fallbackFontName[0]) 459 return getCachedFontData(description, fallbackFontName); 460 461 // Fall back to the DEFAULT_GUI_FONT if no known Unicode fonts are available. 462 if (HFONT defaultGUIFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))) { 463 LOGFONT defaultGUILogFont; 464 GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont); 465 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, defaultGUILogFont, fallbackFontName)) 466 return simpleFont; 467 } 468 469 // Fall back to Non-client metrics fonts. 470 NONCLIENTMETRICS nonClientMetrics = {0}; 471 nonClientMetrics.cbSize = sizeof(nonClientMetrics); 472 if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) { 473 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, nonClientMetrics.lfMessageFont, fallbackFontName)) 474 return simpleFont; 475 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, nonClientMetrics.lfMenuFont, fallbackFontName)) 476 return simpleFont; 477 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, nonClientMetrics.lfStatusFont, fallbackFontName)) 478 return simpleFont; 479 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, nonClientMetrics.lfCaptionFont, fallbackFontName)) 480 return simpleFont; 481 if (simpleFont = fontDataFromDescriptionAndLogFont(this, description, nonClientMetrics.lfSmCaptionFont, fallbackFontName)) 482 return simpleFont; 483 } 484 485 ASSERT_NOT_REACHED(); 486 return 0; 442 487 } 443 488
Note: See TracChangeset
for help on using the changeset viewer.