Title: [182192] trunk/Source/WebCore
Revision
182192
Author
[email protected]
Date
2015-03-31 11:53:25 -0700 (Tue, 31 Mar 2015)

Log Message

Crash in CGContextShowGlyphsWithAdvances when passing kCGFontIndexInvalid
https://bugs.webkit.org/show_bug.cgi?id=143114

This is a workaround for <rdar://problem/20230073>. Please remove when it is no longer necessary.

Reviewed by Alexey Proskuryakov.

Covered by:
compositing/regions/floated-region-with-transformed-child.html
compositing/regions/floated-region-with-transformed-child-expected.html
fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005.html
fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005-expected.html
fast/regions/overflow/overflow-content-transform-rotate.html
fast/regions/overflow/overflow-content-transform-rotate-expected.html

* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::shrink): Performing shaping may remove glyphs, so we need to shrink the GlyphBuffer.
* platform/graphics/WidthIterator.cpp:
(WebCore::applyFontTransforms): Filter out kCGFontIndexInvalid.
(WebCore::WidthIterator::advanceInternal): Moved code into applyFontTransforms, and trigger the
shrink of the GlyphBuffer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (182191 => 182192)


--- trunk/Source/WebCore/ChangeLog	2015-03-31 18:26:16 UTC (rev 182191)
+++ trunk/Source/WebCore/ChangeLog	2015-03-31 18:53:25 UTC (rev 182192)
@@ -1,3 +1,27 @@
+2015-03-31  Myles C. Maxfield  <[email protected]>
+
+        Crash in CGContextShowGlyphsWithAdvances when passing kCGFontIndexInvalid
+        https://bugs.webkit.org/show_bug.cgi?id=143114
+
+        This is a workaround for <rdar://problem/20230073>. Please remove when it is no longer necessary.
+
+        Reviewed by Alexey Proskuryakov.
+
+        Covered by:
+        compositing/regions/floated-region-with-transformed-child.html
+        compositing/regions/floated-region-with-transformed-child-expected.html
+        fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005.html
+        fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005-expected.html
+        fast/regions/overflow/overflow-content-transform-rotate.html
+        fast/regions/overflow/overflow-content-transform-rotate-expected.html
+
+        * platform/graphics/GlyphBuffer.h:
+        (WebCore::GlyphBuffer::shrink): Performing shaping may remove glyphs, so we need to shrink the GlyphBuffer.
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::applyFontTransforms): Filter out kCGFontIndexInvalid.
+        (WebCore::WidthIterator::advanceInternal): Moved code into applyFontTransforms, and trigger the
+        shrink of the GlyphBuffer.
+
 2015-03-31  Beth Dakin  <[email protected]>
 
         REGRESSION (r173484): Reducing content of scrollable region does not reset scroll 

Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (182191 => 182192)


--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h	2015-03-31 18:26:16 UTC (rev 182191)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h	2015-03-31 18:53:25 UTC (rev 182192)
@@ -202,6 +202,18 @@
         return (*m_offsetsInString)[index];
     }
 
+    void shrink(int truncationPoint)
+    {
+        m_font.shrink(truncationPoint);
+        m_glyphs.shrink(truncationPoint);
+        m_advances.shrink(truncationPoint);
+        if (m_offsetsInString)
+            m_offsetsInString->shrink(truncationPoint);
+#if PLATFORM(WIN)
+        m_offsets.shrink(truncationPoint);
+#endif
+    }
+
 private:
     void swap(int index1, int index2)
     {

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (182191 => 182192)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-03-31 18:26:16 UTC (rev 182191)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-03-31 18:53:25 UTC (rev 182192)
@@ -108,8 +108,10 @@
         return 0;
 
     int glyphBufferSize = glyphBuffer->size();
-    if (glyphBuffer->size() <= lastGlyphCount + 1)
+    if (glyphBuffer->size() <= lastGlyphCount + 1) {
+        lastGlyphCount = glyphBufferSize;
         return 0;
+    }
 
     GlyphBufferAdvance* advances = glyphBuffer->advances(0);
     float widthDifference = 0;
@@ -146,6 +148,19 @@
     }
     charactersTreatedAsSpace.clear();
 
+#if PLATFORM(MAC) || PLATFORM(IOS)
+    // Workaround for <rdar://problem/20230073> FIXME: Please remove this when no longer needed.
+    GlyphBufferGlyph* glyphs = glyphBuffer->glyphs(0);
+    int filteredIndex = lastGlyphCount;
+    for (int i = lastGlyphCount; i < glyphBufferSize; ++i) {
+        glyphs[filteredIndex] = glyphs[i];
+        advances[filteredIndex] = advances[i];
+        if (glyphs[filteredIndex] != kCGFontIndexInvalid)
+            ++filteredIndex;
+    }
+    glyphBufferSize = filteredIndex;
+#endif
+
     for (int i = lastGlyphCount; i < glyphBufferSize; ++i)
         widthDifference += advances[i].width();
 
@@ -207,7 +222,8 @@
         if (font != lastFontData && width) {
             if (shouldApplyFontTransforms()) {
                 m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
-                lastGlyphCount = glyphBuffer->size(); // applyFontTransforms doesn't update when there had been only one glyph.
+                if (glyphBuffer)
+                    glyphBuffer->shrink(lastGlyphCount);
             }
 
             lastFontData = font;
@@ -325,8 +341,11 @@
         }
     }
 
-    if (shouldApplyFontTransforms())
+    if (shouldApplyFontTransforms()) {
         m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
+        if (glyphBuffer)
+            glyphBuffer->shrink(lastGlyphCount);
+    }
 
     unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCharacter;
     m_currentCharacter = textIterator.currentCharacter();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to