Changeset 121756 in webkit


Ignore:
Timestamp:
Jul 3, 2012 3:29:08 AM (12 years ago)
Author:
pdr@google.com
Message:

Fix text positioning with non-bmp characters.
https://bugs.webkit.org/show_bug.cgi?id=87681

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Previously when constructing metrics for tspans with non-bmp characters,
each non-bmp character treated as a skipped character in the same way that
spaces are ignored.
This made sense because the initial SVGCharacterDataMap for <text> is
indexed by character index (not string length) so the high portion of a
non-bmp character was treated as a skipped space. Unfortunately, this
led to a bug because skipped spaces lead to an offset in the positioning
values list but non-bmp characters do not.

This change switches the code to use a new offset for non-bmp characters,
surrogatePairCharacters, which does not affect the positioning values list.

Tests: svg/text/non-bmp-tspans-expected.svg

svg/text/non-bmp-tspans.svg

  • rendering/svg/SVGTextMetricsBuilder.cpp:

(WebCore::SVGTextMetricsBuilder::measureTextRenderer):

LayoutTests:

  • svg/text/non-bmp-tspans-expected.svg: Added.
  • svg/text/non-bmp-tspans.svg: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121754 r121756  
     12012-07-03  Philip Rogers  <pdr@google.com>
     2
     3        Fix text positioning with non-bmp characters.
     4        https://bugs.webkit.org/show_bug.cgi?id=87681
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        * svg/text/non-bmp-tspans-expected.svg: Added.
     9        * svg/text/non-bmp-tspans.svg: Added.
     10
    1112012-07-03  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r121754 r121756  
     12012-07-03  Philip Rogers  <pdr@google.com>
     2
     3        Fix text positioning with non-bmp characters.
     4        https://bugs.webkit.org/show_bug.cgi?id=87681
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        Previously when constructing metrics for tspans with non-bmp characters,
     9        each non-bmp character treated as a skipped character in the same way that
     10        spaces are ignored.
     11        This made sense because the initial SVGCharacterDataMap for <text> is
     12        indexed by character index (not string length) so the high portion of a
     13        non-bmp character was treated as a skipped space. Unfortunately, this
     14        led to a bug because skipped spaces lead to an offset in the positioning
     15        values list but non-bmp characters do not.
     16
     17        This change switches the code to use a new offset for non-bmp characters,
     18        surrogatePairCharacters, which does not affect the positioning values list.
     19
     20        Tests: svg/text/non-bmp-tspans-expected.svg
     21               svg/text/non-bmp-tspans.svg
     22
     23        * rendering/svg/SVGTextMetricsBuilder.cpp:
     24        (WebCore::SVGTextMetricsBuilder::measureTextRenderer):
     25
    1262012-07-03  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    227
  • trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp

    r117259 r121756  
    156156    initializeMeasurementWithTextRenderer(text);
    157157    bool preserveWhiteSpace = text->style()->whiteSpace() == PRE;
     158    int surrogatePairCharacters = 0;
    158159
    159160    while (advance()) {
     
    169170        if (data->processRenderer) {
    170171            if (data->allCharactersMap) {
    171                 const SVGCharacterDataMap::const_iterator it = data->allCharactersMap->find(data->valueListPosition + m_textPosition - data->skippedCharacters + 1);
     172                const SVGCharacterDataMap::const_iterator it = data->allCharactersMap->find(data->valueListPosition + m_textPosition - data->skippedCharacters - surrogatePairCharacters + 1);
    172173                if (it != data->allCharactersMap->end())
    173174                    attributes->characterDataMap().set(m_textPosition + 1, it->second);
     
    177178
    178179        if (data->allCharactersMap && currentCharacterStartsSurrogatePair())
    179             data->skippedCharacters += m_currentMetrics.length() - 1;
     180            surrogatePairCharacters++;
    180181
    181182        data->lastCharacter = currentCharacter;
Note: See TracChangeset for help on using the changeset viewer.