[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

mitz at apple.com mitz at apple.com
Fri Feb 26 22:18:54 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 2e9ecf342bb740f4573dac4508da90f2ec0e7fde
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 12 19:20:34 2010 +0000

    <rdar://problem/7609268> REGRESSION (r50301): Problem selecting text in a Devanagari website
    https://bugs.webkit.org/show_bug.cgi?id=34865
    
    Reviewed by Simon Fraser.
    
    WebCore:
    
    Test: fast/text/glyph-reordering.html
    
    * platform/graphics/mac/ComplexTextController.cpp:
    (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
    (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic): Added. Sets m_isMonotonic
    and populates m_glyphEndOffsets with the end offsets of each glyph’s corresponding character range.
    (WebCore::ComplexTextController::advance): For non-monotonic runs, use endOffsetAt() to get
    glyphs’ end offsets.
    (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Check for monotonicity and call
    setIsNonMonotonic() if needed.
    * platform/graphics/mac/ComplexTextController.h:
    (WebCore::ComplexTextController::ComplexTextRun::lastIndexAt): Added this getter.
    (WebCore::ComplexTextController::ComplexTextRun::isMonotonic): Ditto.
    * platform/graphics/mac/ComplexTextControllerATSUI.cpp:
    (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Initialize m_isMonotonic.
    * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
    (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Ditto.
    
    LayoutTests:
    
    * fast/text/glyph-reordering-expected.txt: Added.
    * fast/text/glyph-reordering.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9d4ee49..419576f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-12  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7609268> REGRESSION (r50301): Problem selecting text in a Devanagari website
+        https://bugs.webkit.org/show_bug.cgi?id=34865
+
+        * fast/text/glyph-reordering-expected.txt: Added.
+        * fast/text/glyph-reordering.html: Added.
+
 2010-02-12  Fumitoshi Ukai  <ukai at chromium.org>
 
         Unreviewed trivial fix.
diff --git a/LayoutTests/fast/text/glyph-reordering-expected.txt b/LayoutTests/fast/text/glyph-reordering-expected.txt
new file mode 100644
index 0000000..a05a78c
--- /dev/null
+++ b/LayoutTests/fast/text/glyph-reordering-expected.txt
@@ -0,0 +1,5 @@
+This tests text selection in complex scripts where glyph reordering occurs.
+
+हिन्दी
+ि‌हन्दी
+PASS
diff --git a/LayoutTests/fast/text/glyph-reordering.html b/LayoutTests/fast/text/glyph-reordering.html
new file mode 100644
index 0000000..5001bd5
--- /dev/null
+++ b/LayoutTests/fast/text/glyph-reordering.html
@@ -0,0 +1,26 @@
+<p>
+    This tests text selection in complex scripts where glyph reordering occurs.
+</p>
+<div id="target" style="font-size: 48px;">&#x0939;&#x093F;&#x0928;&#x094D;&#x0926;&#x0940;</div>
+<div id="reference" style="font-size: 48px;">&#x093F;&#x200C;&#x0939;&#x0928;&#x094D;&#x0926;&#x0940;</div>
+<p id="result">Test did not run</p>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var target = document.getElementById("target");
+
+    var textNode = target.firstChild;
+    var range = document.createRange();
+    range.setStart(textNode, 0);
+    range.setEnd(textNode, 2);
+    var width = range.getClientRects()[0].width;
+
+    var reference = document.getElementById("reference");
+    textNode = reference.firstChild;
+    range.setStart(textNode, 0);
+    range.setEnd(textNode, 3);
+    var referenceWidth = range.getClientRects()[0].width;
+
+    document.getElementById("result").innerText = width === referenceWidth ? "PASS" : "FAIL: width was " + width + " instead of " + referenceWidth;
+</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2aa47d0..5a13318 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-02-12  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        <rdar://problem/7609268> REGRESSION (r50301): Problem selecting text in a Devanagari website
+        https://bugs.webkit.org/show_bug.cgi?id=34865
+
+        Test: fast/text/glyph-reordering.html
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+        (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic): Added. Sets m_isMonotonic
+        and populates m_glyphEndOffsets with the end offsets of each glyph’s corresponding character range.
+        (WebCore::ComplexTextController::advance): For non-monotonic runs, use endOffsetAt() to get
+        glyphs’ end offsets.
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Check for monotonicity and call
+        setIsNonMonotonic() if needed.
+        * platform/graphics/mac/ComplexTextController.h:
+        (WebCore::ComplexTextController::ComplexTextRun::lastIndexAt): Added this getter.
+        (WebCore::ComplexTextController::ComplexTextRun::isMonotonic): Ditto.
+        * platform/graphics/mac/ComplexTextControllerATSUI.cpp:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Initialize m_isMonotonic.
+        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Ditto.
+
 2010-02-12  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by David Levin.
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp
index 7d12b61..543d885 100644
--- a/WebCore/platform/graphics/mac/ComplexTextController.cpp
+++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp
@@ -316,6 +316,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font
     , m_characters(characters)
     , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
+    , m_isMonotonic(true)
 {
 #if USE(CORE_TEXT) && USE(ATSUI)
     shouldUseATSUIAPI() ? createTextRunFromFontDataATSUI(ltr) : createTextRunFromFontDataCoreText(ltr);
@@ -326,6 +327,30 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font
 #endif
 }
 
+void ComplexTextController::ComplexTextRun::setIsNonMonotonic()
+{
+    ASSERT(m_isMonotonic);
+    m_isMonotonic = false;
+
+    Vector<bool, 64> mappedIndices(m_stringLength);
+    for (size_t i = 0; i < m_glyphCount; ++i) {
+        ASSERT(indexAt(i) < static_cast<CFIndex>(m_stringLength));
+        mappedIndices[indexAt(i)] = true;
+    }
+
+    m_glyphEndOffsets.grow(m_glyphCount);
+    for (size_t i = 0; i < m_glyphCount; ++i) {
+        CFIndex nextMappedIndex = m_stringLength;
+        for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) {
+            if (mappedIndices[j]) {
+                nextMappedIndex = j;
+                break;
+            }
+        }
+        m_glyphEndOffsets[i] = nextMappedIndex;
+    }
+}
+
 void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
 {
     if (static_cast<int>(offset) > m_end)
@@ -348,10 +373,13 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
         while (m_glyphInCurrentRun < glyphCount) {
             unsigned glyphStartOffset = complexTextRun.indexAt(g);
             unsigned glyphEndOffset;
-            if (ltr)
-                glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? complexTextRun.indexAt(g + 1) : complexTextRun.stringLength());
-            else
-                glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? complexTextRun.indexAt(g - 1) : complexTextRun.stringLength());
+            if (complexTextRun.isMonotonic()) {
+                if (ltr)
+                    glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? complexTextRun.indexAt(g + 1) : complexTextRun.stringLength());
+                else
+                    glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? complexTextRun.indexAt(g - 1) : complexTextRun.stringLength());
+            } else
+                glyphEndOffset = complexTextRun.endOffsetAt(g);
 
             CGSize adjustedAdvance = m_adjustedAdvances[k];
 
@@ -393,7 +421,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 {
     size_t runCount = m_complexTextRuns.size();
     for (size_t r = 0; r < runCount; ++r) {
-        const ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
+        ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
         unsigned glyphCount = complexTextRun.glyphCount();
         const SimpleFontData* fontData = complexTextRun.fontData();
 
@@ -405,10 +433,18 @@ void ComplexTextController::adjustGlyphsAndAdvances()
         CGFloat roundedSpaceWidth = roundCGFloat(fontData->spaceWidth());
         bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
         bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_padding) && !m_run.spacingDisabled();
-
+        CFIndex lastCharacterIndex = m_run.ltr() ? numeric_limits<CFIndex>::min() : numeric_limits<CFIndex>::max();
+        bool isMonotonic = true;
 
         for (unsigned i = 0; i < glyphCount; i++) {
             CFIndex characterIndex = complexTextRun.indexAt(i);
+            if (m_run.ltr()) {
+                if (characterIndex < lastCharacterIndex)
+                    isMonotonic = false;
+            } else {
+                if (characterIndex > lastCharacterIndex)
+                    isMonotonic = false;
+            }
             UChar ch = *(cp + characterIndex);
             bool lastGlyph = lastRun && i + 1 == glyphCount;
             UChar nextCh;
@@ -500,7 +536,10 @@ void ComplexTextController::adjustGlyphsAndAdvances()
             advance.height *= -1;
             m_adjustedAdvances.append(advance);
             m_adjustedGlyphs.append(glyph);
+            lastCharacterIndex = characterIndex;
         }
+        if (!isMonotonic)
+            complexTextRun.setIsNonMonotonic();
     }
 }
 
diff --git a/WebCore/platform/graphics/mac/ComplexTextController.h b/WebCore/platform/graphics/mac/ComplexTextController.h
index 3fec18a..53e8f7a 100644
--- a/WebCore/platform/graphics/mac/ComplexTextController.h
+++ b/WebCore/platform/graphics/mac/ComplexTextController.h
@@ -88,8 +88,11 @@ private:
         unsigned stringLocation() const { return m_stringLocation; }
         size_t stringLength() const { return m_stringLength; }
         ALWAYS_INLINE CFIndex indexAt(size_t i) const;
+        CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
         const CGGlyph* glyphs() const { return m_glyphs; }
         const CGSize* advances() const { return m_advances; }
+        bool isMonotonic() const { return m_isMonotonic; }
+        void setIsNonMonotonic();
 
     private:
 #if USE(CORE_TEXT)
@@ -124,14 +127,15 @@ private:
 #if USE(ATSUI)
         Vector<CFIndex, 64> m_atsuiIndices;
 #endif
+        Vector<CFIndex, 64> m_glyphEndOffsets;
         Vector<CGGlyph, 64> m_glyphsVector;
         const CGGlyph* m_glyphs;
         Vector<CGSize, 64> m_advancesVector;
         const CGSize* m_advances;
 #if USE(ATSUI)
-        bool m_ltr;
         bool m_directionalOverride;
 #endif
+        bool m_isMonotonic;
     };
 
     void collectComplexTextRuns();
diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp
index 48aa174..1656854 100644
--- a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp
+++ b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp
@@ -145,8 +145,8 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(ATSUTextLayout atsuTextLay
     , m_characters(characters)
     , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
-    , m_ltr(ltr)
     , m_directionalOverride(directionalOverride)
+    , m_isMonotonic(true)
 {
     OSStatus status;
 
diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp
index dd5e96a..9f20b68 100644
--- a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp
+++ b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp
@@ -46,6 +46,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp
     , m_characters(characters)
     , m_stringLocation(stringLocation)
     , m_stringLength(stringLength)
+    , m_isMonotonic(true)
 {
     m_glyphCount = CTRunGetGlyphCount(m_coreTextRun.get());
     m_coreTextIndices = CTRunGetStringIndicesPtr(m_coreTextRun.get());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list