[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

evan at chromium.org evan at chromium.org
Fri Jan 21 15:16:14 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit cd356303c6d0a4b682875e48d855601f9a991203
Author: evan at chromium.org <evan at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 10 19:58:05 2011 +0000

    2011-01-10  Evan Martin  <evan at chromium.org>
    
            Reviewed by Tony Chang.
    
            [chromium] simplify complex glyph positioning code
            https://bugs.webkit.org/show_bug.cgi?id=52159
    
            Before, we had roughly same code duplicated for RTL and LTR.
            Now, use the same code for both directions by being careful about
            flipping signs where appropriate.
    
            * platform/graphics/chromium/ComplexTextControllerLinux.cpp:
            (WebCore::ComplexTextController::shapeGlyphs):
            (WebCore::ComplexTextController::setGlyphXPositions):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75400 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 133a499..44f57a1 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-10  Evan Martin  <evan at chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [chromium] simplify complex glyph positioning code
+        https://bugs.webkit.org/show_bug.cgi?id=52159
+
+        Before, we had roughly same code duplicated for RTL and LTR.
+        Now, use the same code for both directions by being careful about
+        flipping signs where appropriate.
+
+        * platform/graphics/chromium/ComplexTextControllerLinux.cpp:
+        (WebCore::ComplexTextController::shapeGlyphs):
+        (WebCore::ComplexTextController::setGlyphXPositions):
+
 2011-01-10  Alejandro G. Castro  <alex at igalia.com>
 
         Reviewed by Xan Lopez.
diff --git a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp
index b5eda93..e9adcc3 100644
--- a/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp
+++ b/Source/WebCore/platform/graphics/chromium/ComplexTextControllerLinux.cpp
@@ -273,7 +273,7 @@ void ComplexTextController::shapeGlyphs()
 {
     // HB_ShapeItem() resets m_item.num_glyphs. If the previous call to
     // HB_ShapeItem() used less space than was available, the capacity of
-    // the array may be larger than the current value of m_item.num_glyphs. 
+    // the array may be larger than the current value of m_item.num_glyphs.
     // So, we need to reset the num_glyphs to the capacity of the array.
     m_item.num_glyphs = m_glyphsArrayCapacity;
     resetGlyphArrays();
@@ -291,62 +291,49 @@ void ComplexTextController::shapeGlyphs()
 
 void ComplexTextController::setGlyphXPositions(bool isRTL)
 {
+    const double rtlFlip = isRTL ? -1 : 1;
     double position = 0;
-    // logClustersIndex indexes logClusters for the first (or last when
-    // RTL) codepoint of the current glyph.  Each time we advance a glyph,
-    // we skip over all the codepoints that contributed to the current
-    // glyph.
+
+    // logClustersIndex indexes logClusters for the first codepoint of the current glyph.
+    // Each time we advance a glyph, we skip over all the codepoints that contributed to the current glyph.
     int logClustersIndex = 0;
 
-    if (isRTL) {
-        logClustersIndex = m_item.num_glyphs - 1;
-
-        // Glyphs are stored in logical order, but for layout purposes we
-        // always go left to right.
-        for (int i = m_item.num_glyphs - 1; i >= 0; --i) {
-            if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) {
-                // Whitespace must be laid out in logical order, so when inserting
-                // spaces in RTL (but iterating in LTR order) we must insert spaces
-                // _before_ the next glyph.
-                if (static_cast<unsigned>(i + 1) >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart)
-                    position += m_letterSpacing;
-
-                position += determineWordBreakSpacing(logClustersIndex);
-            }
-
-            m_glyphs16[i] = m_item.glyphs[i];
-            double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
-            m_xPositions[i] = m_offsetX + position + offsetX;
-
-            while (logClustersIndex > 0 && logClusters()[logClustersIndex] == i)
-                logClustersIndex--;
-
-            if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i]))
-                position += truncateFixedPointToInteger(m_item.advances[i]);
-        }
-    } else {
-        for (size_t i = 0; i < m_item.num_glyphs; ++i) {
-            m_glyphs16[i] = m_item.glyphs[i];
-            double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
-            m_xPositions[i] = m_offsetX + position + offsetX;
+    // Iterate through the glyphs in logical order, flipping for RTL where necessary.
+    // In RTL mode all variables are positive except m_xPositions, which starts from m_offsetX and runs negative.
+    // It is fixed up in a second pass below.
+    for (size_t i = 0; i < m_item.num_glyphs; ++i) {
+        while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] < i)
+            logClustersIndex++;
 
-            if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i]))
-                continue;
+        // If the current glyph is just after a space, add in the word spacing.
+        position += determineWordBreakSpacing(logClustersIndex);
 
-            double advance = truncateFixedPointToInteger(m_item.advances[i]);
+        m_glyphs16[i] = m_item.glyphs[i];
+        double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
+        double advance = truncateFixedPointToInteger(m_item.advances[i]);
+        if (isRTL)
+            offsetX -= advance;
 
-            advance += determineWordBreakSpacing(logClustersIndex);
+        m_xPositions[i] = m_offsetX + (position * rtlFlip) + offsetX;
 
-            if (m_item.attributes[i].clusterStart)
-                advance += m_letterSpacing;
+        if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i]))
+            continue;
 
-            while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] == i)
-                logClustersIndex++;
+        // At the end of each cluster, add in the letter spacing.
+        if (i + 1 == m_item.num_glyphs || m_item.attributes[i + 1].clusterStart)
+            position += m_letterSpacing;
 
-            position += advance;
-        }
+        position += advance;
     }
-    m_pixelWidth = std::max(position, 0.0);
+    const double width = position;
+
+    // Now that we've computed the total width, do another pass to fix positioning for RTL.
+    if (isRTL) {
+        for (size_t i = 0; i < m_item.num_glyphs; ++i)
+            m_xPositions[i] += width;
+    }
+
+    m_pixelWidth = std::max(width, 0.0);
     m_offsetX += m_pixelWidth;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list