[wx] Unreviewed build fixes after recent trunk changes.
[WebKit-https.git] / Source / WebCore / platform / graphics / mac / ComplexTextControllerCoreText.cpp
index 42e7897..6e71a85 100644 (file)
  */
 
 #include "config.h"
-#include "ComplexTextController.h"
-#include "WebCoreSystemInterface.h"
 
 #if USE(CORE_TEXT)
 
+#include "ComplexTextController.h"
+
 #include "Font.h"
+#include "TextRun.h"
+#include "WebCoreSystemInterface.h"
+
+#if PLATFORM(WX)
+#include <ApplicationServices/ApplicationServices.h>
+#else
+#include <CoreText/CoreText.h>
+#endif
 
 #if defined(BUILDING_ON_LEOPARD)
 // The following symbols are SPI in 10.5.
@@ -41,33 +49,33 @@ extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
 
 namespace WebCore {
 
-ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
-    : m_coreTextRun(ctRun)
-    , m_fontData(fontData)
+ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
+    : m_fontData(fontData)
     , m_characters(characters)
     , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
+    , m_indexEnd(runRange.location + runRange.length)
     , m_isMonotonic(true)
 {
-    m_glyphCount = CTRunGetGlyphCount(m_coreTextRun.get());
-    m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get());
+    m_glyphCount = CTRunGetGlyphCount(ctRun);
+    m_coreTextIndices = CTRunGetStringIndicesPtr(ctRun);
     if (!m_coreTextIndices) {
         m_coreTextIndicesVector.grow(m_glyphCount);
-        CTRunGetStringIndices(m_coreTextRun.get(), CFRangeMake(0, 0), m_coreTextIndicesVector.data());
+        CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), m_coreTextIndicesVector.data());
         m_coreTextIndices = m_coreTextIndicesVector.data();
     }
 
-    m_glyphs = CTRunGetGlyphsPtr(m_coreTextRun.get());
+    m_glyphs = CTRunGetGlyphsPtr(ctRun);
     if (!m_glyphs) {
         m_glyphsVector.grow(m_glyphCount);
-        CTRunGetGlyphs(m_coreTextRun.get(), CFRangeMake(0, 0), m_glyphsVector.data());
+        CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), m_glyphsVector.data());
         m_glyphs = m_glyphsVector.data();
     }
 
-    m_advances = CTRunGetAdvancesPtr(m_coreTextRun.get());
+    m_advances = CTRunGetAdvancesPtr(ctRun);
     if (!m_advances) {
         m_advancesVector.grow(m_glyphCount);
-        CTRunGetAdvances(m_coreTextRun.get(), CFRangeMake(0, 0), m_advancesVector.data());
+        CTRunGetAdvances(ctRun, CFRangeMake(0, 0), m_advancesVector.data());
         m_advances = m_advancesVector.data();
     }
 }
@@ -141,22 +149,24 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
         static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
         static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, WTF_ARRAY_LENGTH(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()) };
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+        ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation()) };
         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<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(kCFAllocatorDefault, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation())));
         RetainPtr<CTTypesetterRef> typesetter(AdoptCF, CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
 #endif
 
         line.adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
     } else {
-        ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures()) };
+        ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation()) };
 
         line.adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
     }
 
+    m_coreTextLines.append(line.get());
+
     CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
 
     CFIndex runCount = CFArrayGetCount(runArray);
@@ -164,7 +174,8 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
     for (CFIndex r = 0; r < runCount; r++) {
         CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
         ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
-        m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length));
+        CFRange runRange = CTRunGetStringRange(ctRun);
+        m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length, runRange));
     }
 }