2010-11-08 Ned Holbrook <nholbrook@apple.com>

        Reviewed by Adam Barth.

        Avoid CFAttributedString creation in ComplexTextController by adopting UniChar provider SPI.
        https://bugs.webkit.org/show_bug.cgi?id=48886

        * WebCore.exp.in:
        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
        (WebCore::provideStringAndAttributes):
        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
        * platform/mac/WebCoreSystemInterface.h:
        * platform/mac/WebCoreSystemInterface.mm:
2010-11-08  Ned Holbrook  <nholbrook@apple.com>

        Reviewed by Adam Barth.

        Avoid CFAttributedString creation in ComplexTextController by adopting UniChar provider SPI.
        https://bugs.webkit.org/show_bug.cgi?id=48886

        * WebCoreSupport/WebSystemInterface.mm:
        (InitWebCoreSystemInterface):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1ff04429
2010-11-08 Ned Holbrook <nholbrook@apple.com>
Reviewed by Adam Barth.
Avoid CFAttributedString creation in ComplexTextController by adopting UniChar provider SPI.
https://bugs.webkit.org/show_bug.cgi?id=48886
* WebCore.exp.in:
* platform/graphics/mac/ComplexTextControllerCoreText.cpp:
(WebCore::provideStringAndAttributes):
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
2010-11-08 David Hyatt <hyatt@apple.com>
Reviewed by Simon Fraser.
......@@ -1158,6 +1158,7 @@ _wkCGContextGetShouldSmoothFonts
_wkCopyCFLocalizationPreferredName
_wkCopyCONNECTProxyResponse
_wkCopyNSURLResponseStatusLine
_wkCreateCTLineWithUniCharProvider
_wkCreateCustomCFReadStream
_wkCreateNSURLConnectionDelegateProxy
_wkCreateURLNPasteboardFlavorTypeName
......@@ -1213,6 +1214,10 @@ _wkSignalCFReadStreamEnd
_wkSignalCFReadStreamError
_wkSignalCFReadStreamHasBytes
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
_wkCreateCTTypesetterWithUniCharProviderAndOptions
#endif
#if ENABLE(3D_RENDERING)
_WebCoreHas3DRendering
#endif
......
......@@ -24,6 +24,7 @@
#include "config.h"
#include "ComplexTextController.h"
#include "WebCoreSystemInterface.h"
#if USE(CORE_TEXT)
......@@ -101,6 +102,23 @@ void ComplexTextController::ComplexTextRun::createTextRunFromFontDataCoreText(bo
m_advances = m_advancesVector.data();
}
struct ProviderInfo {
const UChar* cp;
unsigned length;
CFDictionaryRef attributes;
};
static const UniChar* provideStringAndAttributes(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void* refCon)
{
ProviderInfo* info = static_cast<struct ProviderInfo*>(refCon);
if (stringIndex >= info->length)
return 0;
*charCount = info->length - stringIndex;
*attributes = info->attributes;
return info->cp + stringIndex;
}
void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UChar* cp, unsigned length, unsigned stringLocation, const SimpleFontData* fontData)
{
if (!fontData) {
......@@ -112,10 +130,6 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
if (m_fallbackFonts && fontData != m_font.primaryFont())
m_fallbackFonts->add(fontData);
RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(NULL, cp, length, kCFAllocatorNull));
RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures())));
RetainPtr<CTLineRef> line;
if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) {
......@@ -126,11 +140,22 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
static const void* rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) };
static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures()) };
RetainPtr<CTTypesetterRef> typesetter(AdoptCF, wkCreateCTTypesetterWithUniCharProviderAndOptions(&provideStringAndAttributes, 0, &info, m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
#else
RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, cp, length, kCFAllocatorNull));
RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(kCFAllocatorDefault, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures())));
RetainPtr<CTTypesetterRef> typesetter(AdoptCF, CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
#endif
line.adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
} else
line.adoptCF(CTLineCreateWithAttributedString(attributedString.get()));
} else {
ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures()) };
line.adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
}
CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
......
......@@ -176,6 +176,11 @@ extern void* wkGetHyphenationLocationBeforeIndex;
extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
#endif
extern CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
#endif
}
#endif
......@@ -118,3 +118,8 @@ void* wkGetHyphenationLocationBeforeIndex;
#else
CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
#endif
CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
#endif
2010-11-08 Ned Holbrook <nholbrook@apple.com>
Reviewed by Adam Barth.
Avoid CFAttributedString creation in ComplexTextController by adopting UniChar provider SPI.
https://bugs.webkit.org/show_bug.cgi?id=48886
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
2010-11-08 Nate Chapin <japhet@chromium.org>
Unreviewed, build fix.
......
......@@ -118,5 +118,10 @@ void InitWebCoreSystemInterface(void)
INIT(GetHyphenationLocationBeforeIndex);
#endif
INIT(CreateCTLineWithUniCharProvider);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
INIT(CreateCTTypesetterWithUniCharProviderAndOptions);
#endif
didInit = true;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment