2011-04-07 Ned Holbrook <nholbrook@apple.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 04:38:37 +0000 (04:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 04:38:37 +0000 (04:38 +0000)
        Reviewed by Dan Bernstein.

        CTLine objects should outlive their CTRuns
        https://bugs.webkit.org/show_bug.cgi?id=58063

        * platform/graphics/mac/ComplexTextController.h: Add m_coreTextLines, to be destroyed after m_complexTextRuns.
        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Moot m_coreTextRun.
        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Append line to m_coreTextLines.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83251 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp

index 7e6acdf..2cb7214 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-07  Ned Holbrook  <nholbrook@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        CTLine objects should outlive their CTRuns
+        https://bugs.webkit.org/show_bug.cgi?id=58063
+
+        * platform/graphics/mac/ComplexTextController.h: Add m_coreTextLines, to be destroyed after m_complexTextRuns.
+        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Moot m_coreTextRun.
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Append line to m_coreTextLines.
+
 2011-04-07  Nat Duca  <nduca@chromium.org>
 
         Reviewed by David Levin.
index 44a7994..281e49f 100644 (file)
@@ -116,9 +116,6 @@ private:
         static OSStatus overrideLayoutOperation(ATSULayoutOperationSelector, ATSULineRef, URefCon, void*, ATSULayoutOperationCallbackStatus*);
 #endif
 
-#if USE(CORE_TEXT)
-        RetainPtr<CTRunRef> m_coreTextRun;
-#endif
         unsigned m_glyphCount;
         const SimpleFontData* m_fontData;
         const UChar* m_characters;
@@ -159,6 +156,10 @@ private:
 
     Vector<UChar, 256> m_smallCapsBuffer;
 
+#if USE(CORE_TEXT)
+    // Retain lines rather than their runs for better performance.
+    Vector<RetainPtr<CTLineRef> > m_coreTextLines;
+#endif
     Vector<RefPtr<ComplexTextRun>, 16> m_complexTextRuns;
     Vector<CGSize, 256> m_adjustedAdvances;
     Vector<CGGlyph, 256> m_adjustedGlyphs;
index d2fbaf5..1473b1e 100644 (file)
@@ -43,33 +43,32 @@ extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
 namespace WebCore {
 
 ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
-    : m_coreTextRun(ctRun)
-    , m_fontData(fontData)
+    : 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();
     }
 }
@@ -159,6 +158,8 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
         line.adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
     }
 
+    m_coreTextLines.append(line.get());
+
     CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
 
     CFIndex runCount = CFArrayGetCount(runArray);