Changeset 177689 in webkit


Ignore:
Timestamp:
Dec 23, 2014 11:23:48 AM (9 years ago)
Author:
mmaxfield@apple.com
Message:

platform/mac/editing/input/devanagari-ligature.html is flaky on Yosemite, ligature fails to form
https://bugs.webkit.org/show_bug.cgi?id=138683

Reviewed by Darin Adler.

This patch changes how we check fonts for equality. In particular, this patch adds a
objectForEqualityCheck() to Cocoa's FontPlatformData, and callers should pass this object
to CFEqual() to determine if two platform fonts are equal. This patch also migrates all
call sites to using this function.

I don't want to implement operator==() because there are many cases where the same font
is compared against many others, and this solution is cleaner than caching a comparison
object inside the font object itself.

No new tests because this is covered by platform/mac/editing/input/devanagari-ligature.html.

  • platform/graphics/FontPlatformData.h:
  • platform/graphics/cocoa/FontPlatformDataCocoa.mm:

(WebCore::FontPlatformData::objectForEqualityCheck):

  • platform/graphics/mac/ComplexTextControllerCoreText.mm:

(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

  • platform/graphics/mac/GlyphPageTreeNodeMac.cpp:

(WebCore::GlyphPage::fill):

  • platform/graphics/mac/SimpleFontDataMac.mm:

(WebCore::SimpleFontData::canRenderCombiningCharacterSequence):

  • platform/spi/cocoa/CoreTextSPI.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r177688 r177689  
     12014-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
    1302014-12-23  Myles C. Maxfield  <mmaxfield@apple.com>
    231
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r177527 r177689  
    121121
    122122    CTFontRef ctFont() const;
     123    static RetainPtr<CFTypeRef> objectForEqualityCheck(CTFontRef);
     124    RetainPtr<CFTypeRef> objectForEqualityCheck() const;
    123125
    124126    bool allowsLigatures() const;
  • trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm

    r177527 r177689  
    2525#import "FontPlatformData.h"
    2626
     27#import "CoreTextSPI.h"
    2728#import "SharedBuffer.h"
    2829#import "WebCoreSystemInterface.h"
     
    290291}
    291292
     293RetainPtr<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
     307RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck() const
     308{
     309    return objectForEqualityCheck(ctFont());
     310}
     311
    292312PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
    293313{
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm

    r175379 r177689  
    250250            CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName));
    251251            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())) {
    253254                // Begin trying to see if runFont matches any of the fonts in the fallback list.
    254                 RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0));
    255255                unsigned i = 0;
    256256                for (const FontData* candidateFontData = m_font.fontDataAt(i); candidateFontData; candidateFontData = m_font.fontDataAt(++i)) {
    257257                    runFontData = candidateFontData->fontDataForCharacter(baseCharacter);
    258                     RetainPtr<CGFontRef> 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()))
    260260                        break;
    261261                    runFontData = 0;
  • trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp

    r176372 r177689  
    112112        bool done = false;
    113113
    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();
    117115
    118116        for (CFIndex r = 0; r < runCount && !done ; ++r) {
     
    124122            CFDictionaryRef attributes = CTRunGetAttributes(ctRun);
    125123            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());
    129125            if (gotBaseFont || fontData->platformData().isCompositeFontReference()) {
    130126                // This run uses the font we want. Extract glyphs.
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r177637 r177689  
    481481        return addResult.iterator->value;
    482482
    483     RetainPtr<CGFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(platformData().ctFont(), 0));
     483    RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck();
    484484
    485485    ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) };
     
    494494        CFDictionaryRef runAttributes = CTRunGetAttributes(ctRun);
    495495        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()))
    498497            return false;
    499498    }
  • trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h

    r177292 r177689  
    4949typedef void (*CTUniCharDisposeCallback)(const UniChar* chars, void* refCon);
    5050
     51extern const CFStringRef kCTFontReferenceURLAttribute;
     52
    5153#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
    5254#if !USE(APPLE_INTERNAL_SDK)
Note: See TracChangeset for help on using the changeset viewer.