Title: [205382] trunk

Diff

Modified: trunk/LayoutTests/ChangeLog (205381 => 205382)


--- trunk/LayoutTests/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/LayoutTests/ChangeLog	2016-09-02 23:18:48 UTC (rev 205382)
@@ -1,3 +1,15 @@
+2016-09-02  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r205373.
+
+        This change causes LayoutTest crashes under GuardMalloc
+
+        Reverted changeset:
+
+        "[Cocoa] Distinguish between paint advances and base advances"
+        https://bugs.webkit.org/show_bug.cgi?id=160892
+        http://trac.webkit.org/changeset/205373
+
 2016-09-02  Beth Dakin  <[email protected]>
 
         Need to updateEditorState if an element change edit-ability without changing 

Modified: trunk/LayoutTests/platform/mac/css2.1/t051202-c26-psudo-nest-00-c-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/css2.1/t051202-c26-psudo-nest-00-c-expected.txt (205381 => 205382)


--- trunk/LayoutTests/platform/mac/css2.1/t051202-c26-psudo-nest-00-c-expected.txt	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/LayoutTests/platform/mac/css2.1/t051202-c26-psudo-nest-00-c-expected.txt	2016-09-02 23:18:48 UTC (rev 205382)
@@ -56,13 +56,13 @@
         RenderInline {STRONG} at (0,0) size 111x18
           RenderText {#text} at (130,15) size 111x18
             text run at (130,15) width 111: "two characters"
-        RenderText {#text} at (240,15) size 451x18
-          text run at (240,15) width 120: " in this paragraph "
-          text run at (359,15) width 332: "(a double-quote mark and a capital 'T') should be "
-        RenderInline {STRONG} at (0,0) size 90x18
-          RenderText {#text} at (690,15) size 90x18
-            text run at (690,15) width 45: "200% "
-            text run at (734,15) width 46: "bigger"
+        RenderText {#text} at (240,15) size 452x18
+          text run at (240,15) width 121: " in this paragraph "
+          text run at (360,15) width 332: "(a double-quote mark and a capital 'T') should be "
+        RenderInline {STRONG} at (0,0) size 89x18
+          RenderText {#text} at (691,15) size 89x18
+            text run at (691,15) width 45: "200% "
+            text run at (735,15) width 45: "bigger"
         RenderText {#text} at (0,37) size 223x18
           text run at (0,37) width 223: "than the rest of the paragraph, and "
         RenderInline {STRONG} at (0,0) size 34x18

Modified: trunk/LayoutTests/platform/mac/css2.1/t1508-c527-font-00-b-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/css2.1/t1508-c527-font-00-b-expected.txt (205381 => 205382)


--- trunk/LayoutTests/platform/mac/css2.1/t1508-c527-font-00-b-expected.txt	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/LayoutTests/platform/mac/css2.1/t1508-c527-font-00-b-expected.txt	2016-09-02 23:18:48 UTC (rev 205382)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x101
-  RenderBlock {HTML} at (0,0) size 800x101
-    RenderBody {BODY} at (8,13) size 784x75 [color=#000080]
-      RenderBlock {P} at (0,0) size 784x75
-        RenderText {#text} at (0,0) size 616x15
-          text run at (0,0) width 616: "This text should be 13px Helvetica in small-caps and italicized. There should be a small gap between each line. "
-        RenderInline {SPAN} at (0,0) size 781x75 [color=#C0C0C0]
-          RenderText {#text} at (615,0) size 781x75
-            text run at (615,0) width 166: "dummy text dummy text dummy"
-            text run at (0,15) width 195: "text dummy text dummy text dummy "
-            text run at (194,15) width 390: "text dummy text dummy text dummy text dummy text dummy text dummy "
-            text run at (583,15) width 192: "text dummy text dummy text dummy"
-            text run at (0,30) width 195: "text dummy text dummy text dummy "
-            text run at (194,30) width 390: "text dummy text dummy text dummy text dummy text dummy text dummy "
-            text run at (583,30) width 192: "text dummy text dummy text dummy"
-            text run at (0,45) width 195: "text dummy text dummy text dummy "
-            text run at (194,45) width 390: "text dummy text dummy text dummy text dummy text dummy text dummy "
-            text run at (583,45) width 192: "text dummy text dummy text dummy"
-            text run at (0,60) width 195: "text dummy text dummy text dummy "
-            text run at (194,60) width 349: "text dummy text dummy text dummy text dummy text dummy text"
-        RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac/fast/inline/absolute-positioned-inline-in-centred-block-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/inline/absolute-positioned-inline-in-centred-block-expected.txt (205381 => 205382)


--- trunk/LayoutTests/platform/mac/fast/inline/absolute-positioned-inline-in-centred-block-expected.txt	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/LayoutTests/platform/mac/fast/inline/absolute-positioned-inline-in-centred-block-expected.txt	2016-09-02 23:18:48 UTC (rev 205382)
@@ -6,5 +6,5 @@
       RenderBlock {DIV} at (0,0) size 784x0
 layer at (250,562) size 303x28
   RenderBlock (positioned) {FONT} at (250,562) size 303x28
-    RenderText {#text} at (0,0) size 302x28
-      text run at (0,0) width 302: "Hello World, And Stuff!"
+    RenderText {#text} at (0,0) size 303x28
+      text run at (0,0) width 303: "Hello World, And Stuff!"

Modified: trunk/Source/WebCore/ChangeLog (205381 => 205382)


--- trunk/Source/WebCore/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/ChangeLog	2016-09-02 23:18:48 UTC (rev 205382)
@@ -1,3 +1,14 @@
+2016-09-02  Ryan Haddad  <[email protected]>
+        Unreviewed, rolling out r205373.
+
+        This change causes LayoutTest crashes under GuardMalloc
+
+        Reverted changeset:
+
+        "[Cocoa] Distinguish between paint advances and base advances"
+        https://bugs.webkit.org/show_bug.cgi?id=160892
+        http://trac.webkit.org/changeset/205373
+
 2016-09-02  Beth Dakin  <[email protected]>
 
         Need to updateEditorState if an element change edit-ability without changing 

Modified: trunk/Source/WebCore/platform/graphics/GlyphBuffer.h (205381 => 205382)


--- trunk/Source/WebCore/platform/graphics/GlyphBuffer.h	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/graphics/GlyphBuffer.h	2016-09-02 23:18:48 UTC (rev 205382)
@@ -67,7 +67,6 @@
     }
 
     void setWidth(CGFloat width) { this->CGSize::width = width; }
-    void setHeight(CGFloat height) { this->CGSize::height = height; }
     CGFloat width() const { return this->CGSize::width; }
     CGFloat height() const { return this->CGSize::height; }
 };

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (205381 => 205382)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2016-09-02 23:18:48 UTC (rev 205382)
@@ -514,7 +514,7 @@
     float afterWidth = controller.runWidthSoFar();
 
     if (run.rtl()) {
-        initialAdvance = controller.totalWidth() - afterWidth + controller.leadingExpansion();
+        initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth + controller.leadingExpansion();
         glyphBuffer.reverse(0, glyphBuffer.size());
     } else
         initialAdvance = beforeWidth;

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (205381 => 205382)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2016-09-02 23:18:48 UTC (rev 205382)
@@ -107,13 +107,28 @@
 }
 
 ComplexTextController::ComplexTextController(const FontCascade& font, const TextRun& run, bool mayUseNaturalWritingDirection, HashSet<const Font*>* fallbackFonts, bool forTextEmphasis)
-    : m_fallbackFonts(fallbackFonts)
-    , m_font(font)
+    : m_font(font)
     , m_run(run)
+    , m_isLTROnly(true)
+    , m_mayUseNaturalWritingDirection(mayUseNaturalWritingDirection)
+    , m_forTextEmphasis(forTextEmphasis)
+    , m_currentCharacter(0)
     , m_end(run.length())
+    , m_totalWidth(0)
+    , m_runWidthSoFar(0)
+    , m_numGlyphsSoFar(0)
+    , m_currentRun(0)
+    , m_glyphInCurrentRun(0)
+    , m_characterInCurrentGlyph(0)
+    , m_finalRoundingWidth(0)
     , m_expansion(run.expansion())
-    , m_mayUseNaturalWritingDirection(mayUseNaturalWritingDirection)
-    , m_forTextEmphasis(forTextEmphasis)
+    , m_leadingExpansion(0)
+    , m_fallbackFonts(fallbackFonts)
+    , m_minGlyphBoundingBoxX(std::numeric_limits<float>::max())
+    , m_maxGlyphBoundingBoxX(std::numeric_limits<float>::min())
+    , m_minGlyphBoundingBoxY(std::numeric_limits<float>::max())
+    , m_maxGlyphBoundingBoxY(std::numeric_limits<float>::min())
+    , m_lastRoundingGlyph(0)
 {
     if (!m_expansion)
         m_expansionPerOpportunity = 0;
@@ -143,7 +158,7 @@
     m_runWidthSoFar = m_leadingExpansion;
 }
 
-unsigned ComplexTextController::offsetForPosition(float h, bool includePartialGlyphs)
+int ComplexTextController::offsetForPosition(float h, bool includePartialGlyphs)
 {
     if (h >= m_totalWidth)
         return m_run.ltr() ? m_end : 0;
@@ -161,7 +176,7 @@
         const ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
         for (unsigned j = 0; j < complexTextRun.glyphCount(); ++j) {
             size_t index = offsetIntoAdjustedGlyphs + j;
-            CGFloat adjustedAdvance = m_adjustedBaseAdvances[index].width;
+            CGFloat adjustedAdvance = m_adjustedAdvances[index].width;
             if (!index)
                 adjustedAdvance += complexTextRun.initialAdvance().width;
             if (x < adjustedAdvance) {
@@ -173,7 +188,8 @@
                     hitGlyphEnd = std::max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
 
                 // FIXME: Instead of dividing the glyph's advance equally between the characters, this
-                // could use the glyph's "ligature carets". This is available in CoreText via CTFontGetLigatureCaretPositions().
+                // 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);
                 int stringLength = complexTextRun.stringLength();
                 TextBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength));
@@ -201,7 +217,7 @@
                     clusterWidth = adjustedAdvance;
                     int firstGlyphBeforeCluster = j - 1;
                     while (firstGlyphBeforeCluster >= 0 && complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) {
-                        CGFloat width = m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width;
+                        CGFloat width = m_adjustedAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width;
                         clusterWidth += width;
                         x += width;
                         firstGlyphBeforeCluster--;
@@ -208,7 +224,7 @@
                     }
                     unsigned firstGlyphAfterCluster = j + 1;
                     while (firstGlyphAfterCluster < complexTextRun.glyphCount() && complexTextRun.indexAt(firstGlyphAfterCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphAfterCluster) < clusterEnd) {
-                        clusterWidth += m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width;
+                        clusterWidth += m_adjustedAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width;
                         firstGlyphAfterCluster++;
                     }
                 } else {
@@ -307,11 +323,10 @@
     // We break up glyph run generation for the string by Font.
     const UChar* cp;
 
-    Vector<String> stringsFor8BitRuns;
     if (m_run.is8Bit()) {
         String stringFor8BitRun = String::make16BitFrom8BitSource(m_run.characters8(), m_run.length());
-        stringsFor8BitRuns.append(WTFMove(stringFor8BitRun));
-        cp = stringsFor8BitRuns.last().characters16();
+        cp = stringFor8BitRun.characters16();
+        m_stringsFor8BitRuns.append(stringFor8BitRun);
     } else
         cp = m_run.characters16();
 
@@ -413,7 +428,6 @@
         }
     }
 
-    ASSERT(m_end >= indexOfFontTransition);
     unsigned itemLength = m_end - indexOfFontTransition;
     if (itemLength) {
         unsigned itemStart = indexOfFontTransition;
@@ -449,7 +463,7 @@
     }
 
     m_glyphEndOffsets.grow(m_glyphCount);
-    for (unsigned i = 0; i < m_glyphCount; ++i) {
+    for (size_t i = 0; i < m_glyphCount; ++i) {
         CFIndex nextMappedIndex = m_indexEnd;
         for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) {
             if (mappedIndices[j]) {
@@ -516,28 +530,9 @@
     return indexOfCurrentRun(leftmostGlyph);
 }
 
-float ComplexTextController::runWidthSoFarFraction(unsigned glyphStartOffset, unsigned glyphEndOffset, unsigned oldCharacterInCurrentGlyph, GlyphIterationStyle iterationStyle) const
-{
-    // FIXME: Instead of dividing the glyph's advance equally between the characters, this
-    // could use the glyph's "ligature carets". This is available in CoreText via CTFontGetLigatureCaretPositions().
-    if (glyphStartOffset == glyphEndOffset) {
-        // When there are multiple glyphs per character we need to advance by the full width of the glyph.
-        ASSERT(m_characterInCurrentGlyph == oldCharacterInCurrentGlyph);
-        return 1;
-    }
-
-    if (iterationStyle == ByWholeGlyphs) {
-        if (!oldCharacterInCurrentGlyph)
-            return 1;
-        return 0;
-    }
-
-    return static_cast<float>(m_characterInCurrentGlyph - oldCharacterInCurrentGlyph) / (glyphEndOffset - glyphStartOffset);
-}
-
 void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, GlyphIterationStyle iterationStyle, HashSet<const Font*>* fallbackFonts)
 {
-    if (offset > m_end)
+    if (static_cast<int>(offset) > m_end)
         offset = m_end;
 
     if (offset <= m_currentCharacter) {
@@ -567,14 +562,7 @@
         // When leftmostGlyph is 0, it represents the first glyph to draw, taking into
         // account the text direction.
         if (glyphBuffer && !leftmostGlyph) {
-            CGSize initialAdvance = complexTextRun.initialAdvance();
-#if USE_LAYOUT_SPECIFIC_ADVANCES
-            unsigned index = ltr ? 0 : m_glyphOrigins.size() - 1;
-            initialAdvance.width += m_glyphOrigins[index].x;
-            initialAdvance.height += m_glyphOrigins[index].y;
-#endif
-            glyphBuffer->setInitialAdvance(initialAdvance);
-
+            glyphBuffer->setInitialAdvance(complexTextRun.initialAdvance());
             glyphBuffer->setLeadingExpansion(m_leadingExpansion);
         }
 
@@ -589,25 +577,28 @@
             } else
                 glyphEndOffset = complexTextRun.endOffsetAt(g);
 
-            CGSize adjustedBaseAdvance = m_adjustedBaseAdvances[k];
+            CGSize adjustedAdvance = m_adjustedAdvances[k];
 
             if (glyphStartOffset + complexTextRun.stringLocation() >= m_currentCharacter)
                 return;
 
-            if (glyphBuffer && !m_characterInCurrentGlyph) {
-                GlyphBufferAdvance paintAdvance = adjustedBaseAdvance;
-#if USE_LAYOUT_SPECIFIC_ADVANCES
-                if (k + 1 < m_adjustedBaseAdvances.size()) {
-                    paintAdvance.setWidth(paintAdvance.width() + m_glyphOrigins[k + 1].x - m_glyphOrigins[k].x);
-                    paintAdvance.setHeight(paintAdvance.height() - m_glyphOrigins[k + 1].y + m_glyphOrigins[k].y);
-                }
-#endif
-                glyphBuffer->add(m_adjustedGlyphs[k], &complexTextRun.font(), paintAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
-            }
+            if (glyphBuffer && !m_characterInCurrentGlyph)
+                glyphBuffer->add(m_adjustedGlyphs[k], &complexTextRun.font(), adjustedAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
 
             unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
             m_characterInCurrentGlyph = std::min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset;
-            m_runWidthSoFar += adjustedBaseAdvance.width * runWidthSoFarFraction(glyphStartOffset, glyphEndOffset, oldCharacterInCurrentGlyph, iterationStyle);
+            // 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.
+            if (glyphStartOffset == glyphEndOffset) {
+                // When there are multiple glyphs per character we need to advance by the full width of the glyph.
+                ASSERT(m_characterInCurrentGlyph == oldCharacterInCurrentGlyph);
+                m_runWidthSoFar += adjustedAdvance.width;
+            } else if (iterationStyle == ByWholeGlyphs) {
+                if (!oldCharacterInCurrentGlyph)
+                    m_runWidthSoFar += adjustedAdvance.width;
+            } else
+                m_runWidthSoFar += adjustedAdvance.width * (m_characterInCurrentGlyph - oldCharacterInCurrentGlyph) / (glyphEndOffset - glyphStartOffset);
 
             if (glyphEndOffset + complexTextRun.stringLocation() > m_currentCharacter)
                 return;
@@ -626,6 +617,8 @@
         currentRunIndex = incrementCurrentRun(leftmostGlyph);
         m_glyphInCurrentRun = 0;
     }
+    if (!m_run.ltr() && m_numGlyphsSoFar == m_adjustedAdvances.size())
+        m_runWidthSoFar += m_finalRoundingWidth;
 }
 
 static inline std::pair<bool, bool> expansionLocation(bool ideograph, bool treatAsSpace, bool ltr, bool isAfterExpansion, bool forbidLeadingExpansion, bool forbidTrailingExpansion, bool forceLeadingExpansion, bool forceTrailingExpansion)
@@ -663,7 +656,6 @@
     bool runForcesTrailingExpansion = (m_run.expansionBehavior() & TrailingExpansionMask) == ForceTrailingExpansion;
     bool runForbidsLeadingExpansion = (m_run.expansionBehavior() & LeadingExpansionMask) == ForbidLeadingExpansion;
     bool runForbidsTrailingExpansion = (m_run.expansionBehavior() & TrailingExpansionMask) == ForbidTrailingExpansion;
-
     // We are iterating in glyph order, not string order. Compare this to WidthIterator::advanceInternal()
     for (size_t r = 0; r < runCount; ++r) {
         ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
@@ -672,11 +664,11 @@
 
         // Represent the initial advance for a text run by adjusting the advance
         // of the last glyph of the previous text run in the glyph buffer.
-        if (r && m_adjustedBaseAdvances.size()) {
-            CGSize previousAdvance = m_adjustedBaseAdvances.last();
+        if (r && m_adjustedAdvances.size()) {
+            CGSize previousAdvance = m_adjustedAdvances.last();
             previousAdvance.width += complexTextRun.initialAdvance().width;
             previousAdvance.height -= complexTextRun.initialAdvance().height;
-            m_adjustedBaseAdvances[m_adjustedBaseAdvances.size() - 1] = previousAdvance;
+            m_adjustedAdvances[m_adjustedAdvances.size() - 1] = previousAdvance;
         }
         widthSinceLastCommit += complexTextRun.initialAdvance().width;
 
@@ -684,7 +676,7 @@
             m_isLTROnly = false;
 
         const CGGlyph* glyphs = complexTextRun.glyphs();
-        const CGSize* advances = complexTextRun.baseAdvances();
+        const CGSize* advances = complexTextRun.advances();
 
         bool lastRun = r + 1 == runCount;
         float spaceWidth = font.spaceWidth() - font.syntheticBoldOffset();
@@ -758,10 +750,10 @@
                             // Increase previous width
                             m_expansion -= m_expansionPerOpportunity;
                             m_totalWidth += m_expansionPerOpportunity;
-                            if (m_adjustedBaseAdvances.isEmpty())
+                            if (m_adjustedAdvances.isEmpty())
                                 m_leadingExpansion = m_expansionPerOpportunity;
                             else
-                                m_adjustedBaseAdvances.last().width += m_expansionPerOpportunity;
+                                m_adjustedAdvances.last().width += m_expansionPerOpportunity;
                         }
                         if (expandRight) {
                             m_expansion -= m_expansionPerOpportunity;
@@ -785,10 +777,7 @@
                 glyph = 0;
 
             advance.height *= -1;
-            m_adjustedBaseAdvances.append(advance);
-#if USE_LAYOUT_SPECIFIC_ADVANCES
-            m_glyphOrigins.append(complexTextRun.glyphOrigins()[i]);
-#endif
+            m_adjustedAdvances.append(advance);
             m_adjustedGlyphs.append(glyph);
             
             FloatRect glyphBounds = font.boundsForGlyph(glyph);

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h (205381 => 205382)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2016-09-02 23:18:48 UTC (rev 205382)
@@ -32,8 +32,6 @@
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
-#define USE_LAYOUT_SPECIFIC_ADVANCES ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000))
-
 typedef unsigned short CGGlyph;
 
 typedef const struct __CTRun * CTRunRef;
@@ -58,7 +56,7 @@
     void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet<const Font*>* fallbackFonts = nullptr);
 
     // Compute the character offset for a given x coordinate.
-    unsigned offsetForPosition(float x, bool includePartialGlyphs);
+    int offsetForPosition(float x, bool includePartialGlyphs);
 
     // Returns the width of everything we've consumed so far.
     float runWidthSoFar() const { return m_runWidthSoFar; }
@@ -65,6 +63,8 @@
 
     float totalWidth() const { return m_totalWidth; }
 
+    float finalRoundingWidth() const { return m_finalRoundingWidth; }
+
     float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; }
     float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; }
     float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; }
@@ -95,20 +95,8 @@
         CFIndex indexEnd() const { return m_indexEnd; }
         CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
         const CGGlyph* glyphs() const { return m_glyphs; }
-
-        /*
-         *                                              X (Paint glyph position)   X (Paint glyph position)   X (Paint glyph position)
-         *                                             7                          7                          7
-         *                                            /                          /                          /
-         *                                           / (Glyph origin)           / (Glyph origin)           / (Glyph origin)
-         *                                          /                          /                          /
-         *                                         /                          /                          /
-         *                X-----------------------X--------------------------X--------------------------X---->...
-         * (text position ^)  (initial advance)          (base advance)             (base advance)
-         */
         CGSize initialAdvance() const { return m_initialAdvance; }
-        const CGSize* baseAdvances() const { return m_baseAdvances; }
-        const CGPoint* glyphOrigins() const { return m_glyphOrigins.data(); }
+        const CGSize* advances() const { return m_advances; }
         bool isLTR() const { return m_isLTR; }
         bool isMonotonic() const { return m_isMonotonic; }
         void setIsNonMonotonic();
@@ -117,22 +105,21 @@
         ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
         ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
 
-        Vector<CGSize, 64> m_baseAdvancesVector;
-        Vector<CGPoint, 64> m_glyphOrigins;
-        Vector<CGGlyph, 64> m_glyphsVector;
-        Vector<CFIndex, 64> m_glyphEndOffsets;
-        Vector<CFIndex, 64> m_coreTextIndicesVector;
-        CGSize m_initialAdvance;
+        unsigned m_glyphCount;
         const Font& m_font;
         const UChar* m_characters;
+        unsigned m_stringLocation;
         size_t m_stringLength;
+        Vector<CFIndex, 64> m_coreTextIndicesVector;
         const CFIndex* m_coreTextIndices;
-        const CGGlyph* m_glyphs;
-        const CGSize* m_baseAdvances;
         CFIndex m_indexBegin;
         CFIndex m_indexEnd;
-        unsigned m_glyphCount;
-        unsigned m_stringLocation;
+        Vector<CFIndex, 64> m_glyphEndOffsets;
+        Vector<CGGlyph, 64> m_glyphsVector;
+        const CGGlyph* m_glyphs;
+        CGSize m_initialAdvance;
+        Vector<CGSize, 64> m_advancesVector;
+        const CGSize* m_advances;
         bool m_isLTR;
         bool m_isMonotonic;
     };
@@ -148,12 +135,18 @@
     unsigned indexOfCurrentRun(unsigned& leftmostGlyph);
     unsigned incrementCurrentRun(unsigned& leftmostGlyph);
 
-    float runWidthSoFarFraction(unsigned glyphStartOffset, unsigned glyphEndOffset, unsigned oldCharacterInCurrentGlyph, GlyphIterationStyle) const;
+    // The initial capacity of these vectors was selected as being the smallest power of two greater than
+    // the average (3.5) plus one standard deviation (7.5) of nonzero sizes used on Arabic Wikipedia.
+    Vector<unsigned, 16> m_runIndices;
+    Vector<unsigned, 16> m_glyphCountFromStartToIndex;
 
-    Vector<CGSize, 256> m_adjustedBaseAdvances;
-    Vector<CGPoint, 256> m_glyphOrigins;
-    Vector<CGGlyph, 256> m_adjustedGlyphs;
+    const FontCascade& m_font;
+    const TextRun& m_run;
+    bool m_isLTROnly;
+    bool m_mayUseNaturalWritingDirection;
+    bool m_forTextEmphasis;
 
+    Vector<String> m_stringsFor8BitRuns;
     Vector<UChar, 256> m_smallCapsBuffer;
 
     // There is a 3-level hierarchy here. At the top, we are interested in m_run.string(). We partition that string
@@ -163,41 +156,34 @@
     // relative to m_run.string(). ComplexTextRun::indexAt() returns to the offset of a codepoint relative to
     // its Line. ComplexTextRun::glyphs() and ComplexTextRun::advances() refer to glyphs relative to the ComplexTextRun.
     // The length of the entire TextRun is m_run.length()
+    Vector<RetainPtr<CTLineRef>> m_coreTextLines;
     Vector<RefPtr<ComplexTextRun>, 16> m_complexTextRuns;
+    Vector<CGSize, 256> m_adjustedAdvances;
+    Vector<CGGlyph, 256> m_adjustedGlyphs;
+ 
+    unsigned m_currentCharacter;
+    int m_end;
 
-    // The initial capacity of these vectors was selected as being the smallest power of two greater than
-    // the average (3.5) plus one standard deviation (7.5) of nonzero sizes used on Arabic Wikipedia.
-    Vector<unsigned, 16> m_runIndices;
-    Vector<unsigned, 16> m_glyphCountFromStartToIndex;
+    CGFloat m_totalWidth;
 
-    Vector<RetainPtr<CTLineRef>> m_coreTextLines;
+    float m_runWidthSoFar;
+    unsigned m_numGlyphsSoFar;
+    size_t m_currentRun;
+    unsigned m_glyphInCurrentRun;
+    unsigned m_characterInCurrentGlyph;
+    float m_finalRoundingWidth;
+    float m_expansion;
+    float m_expansionPerOpportunity;
+    float m_leadingExpansion;
 
-    HashSet<const Font*>* m_fallbackFonts { nullptr };
+    HashSet<const Font*>* m_fallbackFonts;
 
-    const FontCascade& m_font;
-    const TextRun& m_run;
- 
-    unsigned m_currentCharacter { 0 };
-    unsigned m_end { 0 };
+    float m_minGlyphBoundingBoxX;
+    float m_maxGlyphBoundingBoxX;
+    float m_minGlyphBoundingBoxY;
+    float m_maxGlyphBoundingBoxY;
 
-    float m_totalWidth { 0 };
-    float m_runWidthSoFar { 0 };
-    unsigned m_numGlyphsSoFar { 0 };
-    unsigned m_currentRun { 0 };
-    unsigned m_glyphInCurrentRun { 0 };
-    unsigned m_characterInCurrentGlyph { 0 };
-    float m_expansion { 0 };
-    float m_expansionPerOpportunity { 0 };
-    float m_leadingExpansion { 0 };
-
-    float m_minGlyphBoundingBoxX { std::numeric_limits<float>::max() };
-    float m_maxGlyphBoundingBoxX { std::numeric_limits<float>::min() };
-    float m_minGlyphBoundingBoxY { std::numeric_limits<float>::max() };
-    float m_maxGlyphBoundingBoxY { std::numeric_limits<float>::min() };
-
-    bool m_isLTROnly { true };
-    bool m_mayUseNaturalWritingDirection { false };
-    bool m_forTextEmphasis { false };
+    unsigned m_lastRoundingGlyph;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (205381 => 205382)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2016-09-02 23:18:48 UTC (rev 205382)
@@ -29,7 +29,6 @@
 #include "CoreTextSPI.h"
 #include "FontCache.h"
 #include "FontCascade.h"
-#include "SoftLinking.h"
 #include "TextRun.h"
 #include "WebCoreSystemInterface.h"
 #include <wtf/WeakPtr.h>
@@ -40,12 +39,6 @@
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 90000)
-SOFT_LINK_FRAMEWORK(CoreText);
-SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange range, CGSize baseAdvances[], CGPoint origins[]), (run, range, baseAdvances, origins))
-#endif
-
-
 // Note: CTFontDescriptorRefs can live forever in caches inside CoreText, so this object can too.
 @interface WebCascadeList : NSArray {
     @private
@@ -107,13 +100,13 @@
 namespace WebCore {
 
 ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
-    : m_initialAdvance(CTRunGetInitialAdvance(ctRun))
-    , m_font(font)
+    : m_font(font)
     , m_characters(characters)
+    , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
     , m_indexBegin(runRange.location)
     , m_indexEnd(runRange.location + runRange.length)
-    , m_stringLocation(stringLocation)
+    , m_initialAdvance(CTRunGetInitialAdvance(ctRun))
     , m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft))
     , m_isMonotonic(true)
 {
@@ -132,31 +125,24 @@
         m_glyphs = m_glyphsVector.data();
     }
 
-#if USE_LAYOUT_SPECIFIC_ADVANCES
-    m_baseAdvancesVector.grow(m_glyphCount);
-    m_glyphOrigins.grow(m_glyphCount);
-    CTRunGetBaseAdvancesAndOrigins(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data(), m_glyphOrigins.data());
-    m_baseAdvances = m_baseAdvancesVector.data();
-#else
-    m_baseAdvances = CTRunGetAdvancesPtr(ctRun);
-    if (!m_baseAdvances) {
-        m_baseAdvancesVector.grow(m_glyphCount);
-        CTRunGetAdvances(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data());
-        m_baseAdvances = m_baseAdvancesVector.data();
+    m_advances = CTRunGetAdvancesPtr(ctRun);
+    if (!m_advances) {
+        m_advancesVector.grow(m_glyphCount);
+        CTRunGetAdvances(ctRun, CFRangeMake(0, 0), m_advancesVector.data());
+        m_advances = m_advancesVector.data();
     }
-#endif
 }
 
 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
-    : m_initialAdvance(CGSizeZero)
-    , m_font(font)
+    : m_font(font)
     , m_characters(characters)
+    , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
     , m_indexBegin(0)
     , m_indexEnd(stringLength)
-    , m_stringLocation(stringLocation)
+    , m_initialAdvance(CGSizeZero)
     , m_isLTR(ltr)
     , m_isMonotonic(true)
 {
@@ -164,8 +150,10 @@
     unsigned r = 0;
     while (r < m_stringLength) {
         m_coreTextIndicesVector.uncheckedAppend(r);
-        UChar32 character;
-        U16_NEXT(m_characters, r, m_stringLength, character);
+        if (U_IS_LEAD(m_characters[r]) && r + 1 < m_stringLength && U_IS_TRAIL(m_characters[r + 1]))
+            r += 2;
+        else
+            r++;
     }
     m_glyphCount = m_coreTextIndicesVector.size();
     if (!ltr) {
@@ -177,8 +165,8 @@
     // Synthesize a run of missing glyphs.
     m_glyphsVector.fill(0, m_glyphCount);
     m_glyphs = m_glyphsVector.data();
-    m_baseAdvancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount);
-    m_baseAdvances = m_baseAdvancesVector.data();
+    m_advancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount);
+    m_advances = m_advancesVector.data();
 }
 
 struct ProviderInfo {

Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (205381 => 205382)


--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2016-09-02 23:14:34 UTC (rev 205381)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2016-09-02 23:18:48 UTC (rev 205382)
@@ -68,7 +68,6 @@
 
 CGSize CTRunGetInitialAdvance(CTRunRef run);
 CTLineRef CTLineCreateWithUniCharProvider(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon);
-void CTRunGetBaseAdvancesAndOrigins(CTRunRef, CFRange, CGSize baseAdvances[], CGPoint origins[]);
 CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon, CFDictionaryRef options);
 bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar characters[], CGGlyph glyphs[], CFIndex count);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to