[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mitz at apple.com mitz at apple.com
Wed Dec 22 11:11:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit da36e811061044bd0f540f423a8150a6a1ce9bed
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jul 14 21:41:02 2010 +0000

    <rdar://problem/7759909> Certain text runs measure 1 pixel wider when measured as a whole than when measured piecewise
    https://bugs.webkit.org/show_bug.cgi?id=42279
    
    Reviewed by Simon Fraser.
    
    No test because the issue cannot be reproduced with standard fonts.
    
    Word- and run-rounding works by advancing ahead to the nearest integral width. As the total
    width accumulated becomes large, the float type’s low precision results in accumulated rounding
    error, sometimes crossing an integer. Consequently, word-rounding makes different decisions when
    measuring a multi-word run than when measuring its words individually. To work around this,
    word- and run-rounding are applied only to the width accumulated since the last rounding
    character.
    
    * platform/graphics/WidthIterator.cpp:
    (WebCore::WidthIterator::advance):
    * platform/graphics/mac/ComplexTextController.cpp:
    (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63357 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d071e4d..bc72488 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-07-14  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7759909> Certain text runs measure 1 pixel wider when measured as a whole than when measured piecewise
+        https://bugs.webkit.org/show_bug.cgi?id=42279
+
+        No test because the issue cannot be reproduced with standard fonts.
+
+        Word- and run-rounding works by advancing ahead to the nearest integral width. As the total
+        width accumulated becomes large, the float type’s low precision results in accumulated rounding
+        error, sometimes crossing an integer. Consequently, word-rounding makes different decisions when
+        measuring a multi-word run than when measuring its words individually. To work around this,
+        word- and run-rounding are applied only to the width accumulated since the last rounding
+        character.
+
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advance):
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+
 2010-07-14  Tony Gentilcore  <tonyg at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/WidthIterator.cpp b/WebCore/platform/graphics/WidthIterator.cpp
index 827cd10..28a6311 100644
--- a/WebCore/platform/graphics/WidthIterator.cpp
+++ b/WebCore/platform/graphics/WidthIterator.cpp
@@ -84,7 +84,10 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
     bool rtl = m_run.rtl();
     bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_padding) && !m_run.spacingDisabled();
 
-    float runWidthSoFar = m_runWidthSoFar;
+    float widthSinceLastRounding = m_runWidthSoFar;
+    m_runWidthSoFar = floorf(m_runWidthSoFar);
+    widthSinceLastRounding -= m_runWidthSoFar;
+
     float lastRoundingWidth = m_finalRoundingWidth;
     FloatRect bounds;
 
@@ -131,7 +134,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
         float width;
         if (c == '\t' && m_run.allowTabs()) {
             float tabWidth = m_font->tabWidth();
-            width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
+            width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding, tabWidth);
         } else {
             width = fontData->widthForGlyph(glyph);
 
@@ -216,11 +219,13 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
         // width so that the total run width will be on an integer boundary.
         if ((m_run.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
                 || (m_run.applyRunRounding() && currentCharacter >= m_end)) {
-            float totalWidth = runWidthSoFar + width;
-            width += ceilf(totalWidth) - totalWidth;
-        }
-
-        runWidthSoFar += width;
+            float totalWidth = widthSinceLastRounding + width;
+            widthSinceLastRounding = ceilf(totalWidth);
+            width += widthSinceLastRounding - totalWidth;
+            m_runWidthSoFar += widthSinceLastRounding;
+            widthSinceLastRounding = 0;
+        } else
+            widthSinceLastRounding += width;
 
         if (glyphBuffer)
             glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
@@ -235,7 +240,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
     }
 
     m_currentCharacter = currentCharacter;
-    m_runWidthSoFar = runWidthSoFar;
+    m_runWidthSoFar += widthSinceLastRounding;
     m_finalRoundingWidth = lastRoundingWidth;
 }
 
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp
index 61c9a59..d882ba8 100644
--- a/WebCore/platform/graphics/mac/ComplexTextController.cpp
+++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp
@@ -431,6 +431,7 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
 
 void ComplexTextController::adjustGlyphsAndAdvances()
 {
+    CGFloat widthSinceLastRounding = 0;
     size_t runCount = m_complexTextRuns.size();
     for (size_t r = 0; r < runCount; ++r) {
         ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
@@ -474,7 +475,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
             if (ch == '\t' && m_run.allowTabs()) {
                 float tabWidth = m_font.tabWidth();
-                advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth, tabWidth);
+                advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastRounding, tabWidth);
             } else if (ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
                 advance.width = 0;
                 glyph = fontData->spaceGlyph();
@@ -532,21 +533,23 @@ void ComplexTextController::adjustGlyphsAndAdvances()
             // Check to see if the next character is a "rounding hack character", if so, adjust the
             // width so that the total run width will be on an integer boundary.
             if (m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh) || m_run.applyRunRounding() && lastGlyph) {
-                CGFloat totalWidth = m_totalWidth + advance.width;
-                CGFloat extraWidth = ceilCGFloat(totalWidth) - totalWidth;
+                CGFloat totalWidth = widthSinceLastRounding + advance.width;
+                widthSinceLastRounding = ceilCGFloat(totalWidth);
+                CGFloat extraWidth = widthSinceLastRounding - totalWidth;
                 if (m_run.ltr())
                     advance.width += extraWidth;
                 else {
-                    m_totalWidth += extraWidth;
                     if (m_lastRoundingGlyph)
                         m_adjustedAdvances[m_lastRoundingGlyph - 1].width += extraWidth;
                     else
                         m_finalRoundingWidth = extraWidth;
                     m_lastRoundingGlyph = m_adjustedAdvances.size() + 1;
                 }
-            }
+                m_totalWidth += widthSinceLastRounding;
+                widthSinceLastRounding = 0;
+            } else
+                widthSinceLastRounding += advance.width;
 
-            m_totalWidth += advance.width;
             advance.height *= -1;
             m_adjustedAdvances.append(advance);
             m_adjustedGlyphs.append(glyph);
@@ -565,6 +568,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
         if (!isMonotonic)
             complexTextRun.setIsNonMonotonic();
     }
+    m_totalWidth += widthSinceLastRounding;
 }
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list