Changeset 76674 in webkit


Ignore:
Timestamp:
Jan 25, 2011 10:08:41 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-01-25 Ned Holbrook <nholbrook@apple.com>

Reviewed by Dan Bernstein.

ComplexTextController incorrectly conflates string length and range of indexes
https://bugs.webkit.org/show_bug.cgi?id=52760

  • fast/text/offsetForPosition-complex-fallback-expected.txt: Added.
  • fast/text/offsetForPosition-complex-fallback.html: Added.

2011-01-25 Ned Holbrook <nholbrook@apple.com>

Reviewed by Dan Bernstein.

ComplexTextController incorrectly conflates string length and range of indexes
https://bugs.webkit.org/show_bug.cgi?id=52760

Test: fast/text/offsetForPosition-complex-fallback.html

  • platform/graphics/mac/ComplexTextController.cpp: (WebCore::ComplexTextController::offsetForPosition): (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic): (WebCore::ComplexTextController::advance):
  • platform/graphics/mac/ComplexTextController.h: (WebCore::ComplexTextController::ComplexTextRun::create): (WebCore::ComplexTextController::ComplexTextRun::indexEnd):
  • platform/graphics/mac/ComplexTextControllerATSUI.cpp: (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
  • platform/graphics/mac/ComplexTextControllerCoreText.cpp: (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r76673 r76674  
     12011-01-25  Ned Holbrook  <nholbrook@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        ComplexTextController incorrectly conflates string length and range of indexes
     6        https://bugs.webkit.org/show_bug.cgi?id=52760
     7
     8        * fast/text/offsetForPosition-complex-fallback-expected.txt: Added.
     9        * fast/text/offsetForPosition-complex-fallback.html: Added.
     10
    1112011-01-25  Sam Weinig  <sam@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r76669 r76674  
     12011-01-25  Ned Holbrook  <nholbrook@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        ComplexTextController incorrectly conflates string length and range of indexes
     6        https://bugs.webkit.org/show_bug.cgi?id=52760
     7
     8        Test: fast/text/offsetForPosition-complex-fallback.html
     9
     10        * platform/graphics/mac/ComplexTextController.cpp:
     11        (WebCore::ComplexTextController::offsetForPosition):
     12        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
     13        (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
     14        (WebCore::ComplexTextController::advance):
     15        * platform/graphics/mac/ComplexTextController.h:
     16        (WebCore::ComplexTextController::ComplexTextRun::create):
     17        (WebCore::ComplexTextController::ComplexTextRun::indexEnd):
     18        * platform/graphics/mac/ComplexTextControllerATSUI.cpp:
     19        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
     20        * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
     21        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
     22        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
     23
    1242011-01-25  Sam Weinig  <sam@webkit.org>
    225
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r76170 r76674  
    119119                CFIndex hitGlyphEnd;
    120120                if (m_run.ltr())
    121                     hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.stringLength()));
     121                    hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
    122122                else
    123                     hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.stringLength()));
     123                    hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
    124124
    125125                // FIXME: Instead of dividing the glyph's advance equally between the characters, this
     
    312312    , m_stringLocation(stringLocation)
    313313    , m_stringLength(stringLength)
     314    , m_indexEnd(stringLocation + stringLength)
    314315    , m_isMonotonic(true)
    315316{
     
    336337    m_glyphEndOffsets.grow(m_glyphCount);
    337338    for (size_t i = 0; i < m_glyphCount; ++i) {
    338         CFIndex nextMappedIndex = m_stringLength;
     339        CFIndex nextMappedIndex = m_indexEnd;
    339340        for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) {
    340341            if (mappedIndices[j]) {
     
    371372            if (complexTextRun.isMonotonic()) {
    372373                if (ltr)
    373                     glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? static_cast<unsigned>(complexTextRun.indexAt(g + 1)) : complexTextRun.stringLength());
     374                    glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? static_cast<unsigned>(complexTextRun.indexAt(g + 1)) : complexTextRun.indexEnd());
    374375                else
    375                     glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? static_cast<unsigned>(complexTextRun.indexAt(g - 1)) : complexTextRun.stringLength());
     376                    glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? static_cast<unsigned>(complexTextRun.indexAt(g - 1)) : complexTextRun.indexEnd());
    376377            } else
    377378                glyphEndOffset = complexTextRun.endOffsetAt(g);
     
    387388            unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
    388389            m_characterInCurrentGlyph = min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset;
    389             // FIXME: Instead of dividing the glyph's advance equially between the characters, this
     390            // FIXME: Instead of dividing the glyph's advance equally between the characters, this
    390391            // could use the glyph's "ligature carets". However, there is no Core Text API to get the
    391392            // ligature carets.
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h

    r74169 r76674  
    7373    public:
    7474#if USE(CORE_TEXT)
    75         static PassRefPtr<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
     75        static PassRefPtr<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
    7676        {
    77             return adoptRef(new ComplexTextRun(ctRun, fontData, characters, stringLocation, stringLength));
     77            return adoptRef(new ComplexTextRun(ctRun, fontData, characters, stringLocation, stringLength, runRange));
    7878        }
    7979#endif
     
    9595        size_t stringLength() const { return m_stringLength; }
    9696        ALWAYS_INLINE CFIndex indexAt(size_t i) const;
     97        CFIndex indexEnd() const { return m_indexEnd; }
    9798        CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
    9899        const CGGlyph* glyphs() const { return m_glyphs; }
     
    103104    private:
    104105#if USE(CORE_TEXT)
    105         ComplexTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength);
     106        ComplexTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
    106107        void createTextRunFromFontDataCoreText(bool ltr);
    107108#endif
     
    134135        Vector<CFIndex, 64> m_atsuiIndices;
    135136#endif
     137        CFIndex m_indexEnd;
    136138        Vector<CFIndex, 64> m_glyphEndOffsets;
    137139        Vector<CGGlyph, 64> m_glyphsVector;
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp

    r76170 r76674  
    147147    , m_stringLocation(stringLocation)
    148148    , m_stringLength(stringLength)
     149    , m_indexEnd(stringLocation + stringLength)
    149150    , m_directionalOverride(directionalOverride)
    150151    , m_isMonotonic(true)
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp

    r76170 r76674  
    4343namespace WebCore {
    4444
    45 ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
     45ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
    4646    : m_coreTextRun(ctRun)
    4747    , m_fontData(fontData)
     
    4949    , m_stringLocation(stringLocation)
    5050    , m_stringLength(stringLength)
     51    , m_indexEnd(runRange.location + runRange.length)
    5152    , m_isMonotonic(true)
    5253{
     
    166167        CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
    167168        ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
    168         m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length));
     169        CFRange runRange = CTRunGetStringRange(ctRun);
     170        m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length, runRange));
    169171    }
    170172}
Note: See TracChangeset for help on using the changeset viewer.