Changeset 120624 in webkit


Ignore:
Timestamp:
Jun 18, 2012 1:40:28 PM (12 years ago)
Author:
mitz@apple.com
Message:

Ideographic comma and full-stops are mishandled in linebreak
https://bugs.webkit.org/show_bug.cgi?id=87041

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Test: fast/text/line-breaks-after-ideographic-comma-or-full-stop-2.html

Specifically, line breaks were always allowed after an ideographic comma or full stop, even
before a closing bracket.

  • rendering/break_lines.cpp:

(WebCore::shouldBreakAfter): Removed code that unconditionally allowed line breaks after
ideographic commas and full stops, which was added for <http://webkit.org/b/17411> to work
around an issue in Unicode 5.0. Current line break iterator implementations are based on
newer versions of Unicode, which do not have that issue, so we can use them instead of the
hardcoded approximate rule.

LayoutTests:

  • fast/text/line-breaks-after-ideographic-comma-or-full-stop-2-expected.txt: Added.
  • fast/text/line-breaks-after-ideographic-comma-or-full-stop-2.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120617 r120624  
     12012-06-18  Dan Bernstein  <mitz@apple.com>
     2
     3        Ideographic comma and full-stops are mishandled in linebreak
     4        https://bugs.webkit.org/show_bug.cgi?id=87041
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * fast/text/line-breaks-after-ideographic-comma-or-full-stop-2-expected.txt: Added.
     9        * fast/text/line-breaks-after-ideographic-comma-or-full-stop-2.html: Added.
     10
    1112012-06-18  Mike West  <mkwst@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r120623 r120624  
     12012-06-18  Dan Bernstein  <mitz@apple.com>
     2
     3        Ideographic comma and full-stops are mishandled in linebreak
     4        https://bugs.webkit.org/show_bug.cgi?id=87041
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Test: fast/text/line-breaks-after-ideographic-comma-or-full-stop-2.html
     9
     10        Specifically, line breaks were always allowed after an ideographic comma or full stop, even
     11        before a closing bracket.
     12
     13        * rendering/break_lines.cpp:
     14        (WebCore::shouldBreakAfter): Removed code that unconditionally allowed line breaks after
     15        ideographic commas and full stops, which was added for <http://webkit.org/b/17411> to work
     16        around an issue in Unicode 5.0. Current line break iterator implementations are based on
     17        newer versions of Unicode, which do not have that issue, so we can use them instead of the
     18        hardcoded approximate rule.
     19
    1202012-06-18  Martin Robinson  <mrobinson@igalia.com>
    221
  • trunk/Source/WebCore/rendering/break_lines.cpp

    r95030 r120624  
    122122static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh)
    123123{
    124     switch (ch) {
    125     case ideographicComma:
    126     case ideographicFullStop:
    127         // FIXME: cases for ideographicComma and ideographicFullStop are a workaround for an issue in Unicode 5.0
    128         // which is likely to be resolved in Unicode 5.1 <http://bugs.webkit.org/show_bug.cgi?id=17411>.
    129         // We may want to remove or conditionalize this workaround at some point.
    130         return true;
    131     case '-':
    132         if (isASCIIDigit(nextCh)) {
    133             // Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context,
    134             // while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs.
    135             return isASCIIAlphanumeric(lastCh);
    136         }
    137         // Fall through
    138     default:
    139         // If both ch and nextCh are ASCII characters, use a lookup table for enhanced speed and for compatibility
    140         // with other browsers (see comments for asciiLineBreakTable for details).
    141         if (ch >= asciiLineBreakTableFirstChar && ch <= asciiLineBreakTableLastChar
    142                 && nextCh >= asciiLineBreakTableFirstChar && nextCh <= asciiLineBreakTableLastChar) {
    143             const unsigned char* tableRow = asciiLineBreakTable[ch - asciiLineBreakTableFirstChar];
    144             int nextChIndex = nextCh - asciiLineBreakTableFirstChar;
    145             return tableRow[nextChIndex / 8] & (1 << (nextChIndex % 8));
    146         }
    147         // Otherwise defer to the Unicode algorithm by returning false.
    148         return false;
     124    // Don't allow line breaking between '-' and a digit if the '-' may mean a minus sign in the context,
     125    // while allow breaking in 'ABCD-1234' and '1234-5678' which may be in long URLs.
     126    if (ch == '-' && isASCIIDigit(nextCh))
     127        return isASCIIAlphanumeric(lastCh);
     128
     129    // If both ch and nextCh are ASCII characters, use a lookup table for enhanced speed and for compatibility
     130    // with other browsers (see comments for asciiLineBreakTable for details).
     131    if (ch >= asciiLineBreakTableFirstChar && ch <= asciiLineBreakTableLastChar
     132            && nextCh >= asciiLineBreakTableFirstChar && nextCh <= asciiLineBreakTableLastChar) {
     133        const unsigned char* tableRow = asciiLineBreakTable[ch - asciiLineBreakTableFirstChar];
     134        int nextChIndex = nextCh - asciiLineBreakTableFirstChar;
     135        return tableRow[nextChIndex / 8] & (1 << (nextChIndex % 8));
    149136    }
     137    // Otherwise defer to the Unicode algorithm by returning false.
     138    return false;
    150139}
    151140
Note: See TracChangeset for help on using the changeset viewer.