Changeset 177689 in webkit
- Timestamp:
- Dec 23, 2014, 11:23:48 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r177688 r177689 1 2014-12-23 Myles C. Maxfield <mmaxfield@apple.com> 2 3 platform/mac/editing/input/devanagari-ligature.html is flaky on Yosemite, ligature fails to form 4 https://bugs.webkit.org/show_bug.cgi?id=138683 5 6 Reviewed by Darin Adler. 7 8 This patch changes how we check fonts for equality. In particular, this patch adds a 9 objectForEqualityCheck() to Cocoa's FontPlatformData, and callers should pass this object 10 to CFEqual() to determine if two platform fonts are equal. This patch also migrates all 11 call sites to using this function. 12 13 I don't want to implement operator==() because there are many cases where the same font 14 is compared against many others, and this solution is cleaner than caching a comparison 15 object inside the font object itself. 16 17 No new tests because this is covered by platform/mac/editing/input/devanagari-ligature.html. 18 19 * platform/graphics/FontPlatformData.h: 20 * platform/graphics/cocoa/FontPlatformDataCocoa.mm: 21 (WebCore::FontPlatformData::objectForEqualityCheck): 22 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 23 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 24 * platform/graphics/mac/GlyphPageTreeNodeMac.cpp: 25 (WebCore::GlyphPage::fill): 26 * platform/graphics/mac/SimpleFontDataMac.mm: 27 (WebCore::SimpleFontData::canRenderCombiningCharacterSequence): 28 * platform/spi/cocoa/CoreTextSPI.h: 29 1 30 2014-12-23 Myles C. Maxfield <mmaxfield@apple.com> 2 31 -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r177527 r177689 121 121 122 122 CTFontRef ctFont() const; 123 static RetainPtr<CFTypeRef> objectForEqualityCheck(CTFontRef); 124 RetainPtr<CFTypeRef> objectForEqualityCheck() const; 123 125 124 126 bool allowsLigatures() const; -
trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
r177527 r177689 25 25 #import "FontPlatformData.h" 26 26 27 #import "CoreTextSPI.h" 27 28 #import "SharedBuffer.h" 28 29 #import "WebCoreSystemInterface.h" … … 290 291 } 291 292 293 RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck(CTFontRef ctFont) 294 { 295 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED <= 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000) 296 auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(ctFont)); 297 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=138683 This is a shallow pointer compare for web fonts 298 // because the URL contains the address of the font. This means we might erroneously get false negatives. 299 RetainPtr<CFURLRef> url = adoptCF(static_cast<CFURLRef>(CTFontDescriptorCopyAttribute(fontDescriptor.get(), kCTFontReferenceURLAttribute))); 300 ASSERT(CFGetTypeID(url.get()) == CFURLGetTypeID()); 301 return url; 302 #else 303 return adoptCF(CTFontCopyGraphicsFont(ctFont, 0)); 304 #endif 305 } 306 307 RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck() const 308 { 309 return objectForEqualityCheck(ctFont()); 310 } 311 292 312 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const 293 313 { -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r175379 r177689 250 250 CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName)); 251 251 ASSERT(CFGetTypeID(runFont) == CTFontGetTypeID()); 252 if (!CFEqual(runFont, fontData->platformData().ctFont())) { 252 RetainPtr<CFTypeRef> runFontEqualityObject = FontPlatformData::objectForEqualityCheck(runFont); 253 if (!CFEqual(runFontEqualityObject.get(), fontData->platformData().objectForEqualityCheck().get())) { 253 254 // Begin trying to see if runFont matches any of the fonts in the fallback list. 254 RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0));255 255 unsigned i = 0; 256 256 for (const FontData* candidateFontData = m_font.fontDataAt(i); candidateFontData; candidateFontData = m_font.fontDataAt(++i)) { 257 257 runFontData = candidateFontData->fontDataForCharacter(baseCharacter); 258 RetainPtr<C GFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(runFontData->platformData().ctFont(), 0));259 if (CFEqual( cgFont.get(), runCGFont.get()))258 RetainPtr<CFTypeRef> runFontEqualityObject = runFontData->platformData().objectForEqualityCheck(); 259 if (CFEqual(runFontEqualityObject.get(), runFontEqualityObject.get())) 260 260 break; 261 261 runFontData = 0; -
trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
r176372 r177689 112 112 bool done = false; 113 113 114 // For the CGFont comparison in the loop, use the CGFont that Core Text assigns to the CTFont. This may 115 // be non-CFEqual to fontData->platformData().cgFont(). 116 RetainPtr<CGFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(fontData->platformData().ctFont(), 0)); 114 RetainPtr<CFTypeRef> fontEqualityObject = fontData->platformData().objectForEqualityCheck(); 117 115 118 116 for (CFIndex r = 0; r < runCount && !done ; ++r) { … … 124 122 CFDictionaryRef attributes = CTRunGetAttributes(ctRun); 125 123 CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(attributes, kCTFontAttributeName)); 126 RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0)); 127 // Use CGFont here as CFEqual for CTFont counts all attributes for font. 128 bool gotBaseFont = CFEqual(cgFont.get(), runCGFont.get()); 124 bool gotBaseFont = CFEqual(fontEqualityObject.get(), FontPlatformData::objectForEqualityCheck(runFont).get()); 129 125 if (gotBaseFont || fontData->platformData().isCompositeFontReference()) { 130 126 // This run uses the font we want. Extract glyphs. -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r177637 r177689 481 481 return addResult.iterator->value; 482 482 483 RetainPtr<C GFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(platformData().ctFont(), 0));483 RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck(); 484 484 485 485 ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) }; … … 494 494 CFDictionaryRef runAttributes = CTRunGetAttributes(ctRun); 495 495 CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName)); 496 RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0)); 497 if (!CFEqual(runCGFont.get(), cgFont.get())) 496 if (!CFEqual(fontEqualityObject.get(), FontPlatformData::objectForEqualityCheck(runFont).get())) 498 497 return false; 499 498 } -
trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h
r177292 r177689 49 49 typedef void (*CTUniCharDisposeCallback)(const UniChar* chars, void* refCon); 50 50 51 extern const CFStringRef kCTFontReferenceURLAttribute; 52 51 53 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080) 52 54 #if !USE(APPLE_INTERNAL_SDK)
Note:
See TracChangeset
for help on using the changeset viewer.