diff options
Diffstat (limited to 'WebCore/platform/graphics/mac/ComplexTextController.cpp')
-rw-r--r-- | WebCore/platform/graphics/mac/ComplexTextController.cpp | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index 265b2c3..7d12b61 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -29,6 +29,13 @@ #include "Font.h" #include "TextBreakIterator.h" +#include <wtf/StdLibExtras.h> + +#if defined(BUILDING_ON_LEOPARD) +// Undefined when compiling agains the 10.5 SDK. +#define kCTVersionNumber10_6 0x00030000 +#endif + using namespace std; namespace WebCore { @@ -106,7 +113,7 @@ int ComplexTextController::offsetForPosition(int h, bool includePartialGlyphs) else hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : complexTextRun.stringLength()); - // FIXME: Instead of dividing the glyph's advance equially between the characters, this + // FIXME: Instead of dividing the glyph's advance equally between the characters, this // could use the glyph's "ligature carets". However, there is no Core Text API to get the // ligature carets. CFIndex hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance); @@ -263,6 +270,62 @@ void ComplexTextController::collectComplexTextRuns() collectComplexTextRunsForCharacters(&hyphen, 1, m_end - 1, m_font.glyphDataForCharacter(hyphen, false).fontData); } +#if USE(CORE_TEXT) && USE(ATSUI) +static inline bool shouldUseATSUIAPI() +{ + enum TypeRenderingAPIToUse { UnInitialized, UseATSUI, UseCoreText }; + DEFINE_STATIC_LOCAL(TypeRenderingAPIToUse, apiToUse, (UnInitialized)); + + if (UNLIKELY(apiToUse == UnInitialized)) { + if (&CTGetCoreTextVersion != 0 && CTGetCoreTextVersion() >= kCTVersionNumber10_6) + apiToUse = UseCoreText; + else + apiToUse = UseATSUI; + } + + return apiToUse == UseATSUI; +} +#endif + +CFIndex ComplexTextController::ComplexTextRun::indexAt(size_t i) const +{ +#if USE(CORE_TEXT) && USE(ATSUI) + return shouldUseATSUIAPI() ? m_atsuiIndices[i] : m_coreTextIndices[i]; +#elif USE(ATSUI) + return m_atsuiIndices[i]; +#elif USE(CORE_TEXT) + return m_coreTextIndices[i]; +#endif +} + +void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp, unsigned length, unsigned stringLocation, const SimpleFontData* fontData) +{ +#if USE(CORE_TEXT) && USE(ATSUI) + if (shouldUseATSUIAPI()) + return collectComplexTextRunsForCharactersATSUI(cp, length, stringLocation, fontData); + return collectComplexTextRunsForCharactersCoreText(cp, length, stringLocation, fontData); +#elif USE(ATSUI) + return collectComplexTextRunsForCharactersATSUI(cp, length, stringLocation, fontData); +#elif USE(CORE_TEXT) + return collectComplexTextRunsForCharactersCoreText(cp, length, stringLocation, fontData); +#endif +} + +ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr) + : m_fontData(fontData) + , m_characters(characters) + , m_stringLocation(stringLocation) + , m_stringLength(stringLength) +{ +#if USE(CORE_TEXT) && USE(ATSUI) + shouldUseATSUIAPI() ? createTextRunFromFontDataATSUI(ltr) : createTextRunFromFontDataCoreText(ltr); +#elif USE(ATSUI) + createTextRunFromFontDataATSUI(ltr); +#elif USE(CORE_TEXT) + createTextRunFromFontDataCoreText(ltr); +#endif +} + void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer) { if (static_cast<int>(offset) > m_end) |