Changeset 219215 in webkit
- Timestamp:
- Jul 6, 2017 2:07:19 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r219213 r219215 1 2017-07-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Unify FontCascadeFonts::glyphDataForVariant() and FontCascadeFonts::glyphDataForNormalVariant() 4 https://bugs.webkit.org/show_bug.cgi?id=174213 5 6 Reviewed by Zalan Bujtas. 7 8 They have almost identical code. This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=173962 9 10 No new tests because there is no behavior change. 11 12 * platform/graphics/FontCascadeFonts.cpp: 13 (WebCore::FontCascadeFonts::glyphDataForVariant): 14 (WebCore::FontCascadeFonts::glyphDataForCharacter): 15 (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Deleted. 16 * platform/graphics/FontCascadeFonts.h: 17 1 18 2017-07-06 Don Olmstead <don.olmstead@sony.com> 2 19 -
trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp
r218372 r219215 357 357 } 358 358 359 GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 c , const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)359 GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex) 360 360 { 361 361 ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow; 362 362 GlyphData loadingResult; 363 while (true) {364 auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex ++);363 for (; ; ++fallbackIndex) { 364 auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex); 365 365 if (fontRanges.isNull()) 366 366 break; 367 GlyphData data = fontRanges.glyphDataForCharacter(c, policy); 367 368 GlyphData data = fontRanges.glyphDataForCharacter(character, policy); 368 369 if (!data.font) 369 370 continue; 371 370 372 if (data.font->isInterstitial()) { 371 373 policy = ExternalResourceDownloadPolicy::Forbid; … … 374 376 continue; 375 377 } 376 // The variantFont function should not normally return 0. 377 // But if it does, we will just render the capital letter big. 378 if (const Font* variantFont = data.font->variantFont(description, variant)) 379 return variantFont->glyphDataForCharacter(c); 378 379 if (variant == NormalVariant) { 380 if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) { 381 if (!FontCascade::isCJKIdeographOrSymbol(character)) 382 return glyphDataForNonCJKCharacterWithGlyphOrientation(character, description.nonCJKGlyphOrientation(), data); 383 384 if (!data.font->hasVerticalGlyphs()) { 385 // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs 386 // to make sure you get a square (even for broken glyphs like symbols used for punctuation). 387 return glyphDataForVariant(character, description, BrokenIdeographVariant, fallbackIndex); 388 } 389 } 390 } else { 391 // The variantFont function should not normally return 0. 392 // But if it does, we will just render the capital letter big. 393 if (const Font* variantFont = data.font->variantFont(description, variant)) 394 return variantFont->glyphDataForCharacter(character); 395 } 396 380 397 return data; 381 398 } … … 383 400 if (loadingResult.font) 384 401 return loadingResult; 385 return glyphDataForSystemFallback(c, description, variant); 386 } 387 388 GlyphData FontCascadeFonts::glyphDataForNormalVariant(UChar32 c, const FontCascadeDescription& description) 389 { 390 ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow; 391 GlyphData loadingResult; 392 for (unsigned fallbackIndex = 0; ; ++fallbackIndex) { 393 auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex); 394 if (fontRanges.isNull()) 395 break; 396 GlyphData data = fontRanges.glyphDataForCharacter(c, policy); 397 if (!data.font) 398 continue; 399 if (data.font->isInterstitial()) { 400 policy = ExternalResourceDownloadPolicy::Forbid; 401 if (!loadingResult.font) 402 loadingResult = data; 403 continue; 404 } 405 if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) { 406 if (!FontCascade::isCJKIdeographOrSymbol(c)) 407 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data); 408 409 if (!data.font->hasVerticalGlyphs()) { 410 // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs 411 // to make sure you get a square (even for broken glyphs like symbols used for punctuation). 412 return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackIndex); 413 } 414 } 415 return data; 416 } 417 418 if (loadingResult.font) 419 return loadingResult; 420 return glyphDataForSystemFallback(c, description, NormalVariant); 402 return glyphDataForSystemFallback(character, description, variant); 421 403 } 422 404 … … 453 435 454 436 if (variant != NormalVariant) 455 return glyphDataForVariant(c, description, variant , 0);437 return glyphDataForVariant(c, description, variant); 456 438 457 439 const unsigned pageNumber = GlyphPage::pageNumberForCodePoint(c); … … 466 448 if (!glyphData.glyph) { 467 449 // No glyph, resolve per-character. 468 glyphData = glyphDataForNormalVariant(c, description); 450 ASSERT(variant == NormalVariant); 451 glyphData = glyphDataForVariant(c, description, variant); 469 452 // Cache the results. 470 453 cacheEntry.setGlyphDataForCharacter(c, glyphData); -
trunk/Source/WebCore/platform/graphics/FontCascadeFonts.h
r194496 r219215 78 78 79 79 GlyphData glyphDataForSystemFallback(UChar32, const FontCascadeDescription&, FontVariant); 80 GlyphData glyphDataForNormalVariant(UChar32, const FontCascadeDescription&); 81 GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex); 80 GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex = 0); 82 81 83 82 Vector<FontRanges, 1> m_realizedFallbackRanges;
Note: See TracChangeset
for help on using the changeset viewer.