Changeset 89769 in webkit


Ignore:
Timestamp:
Jun 26, 2011 9:09:33 AM (13 years ago)
Author:
mitz@apple.com
Message:

With word-break: break-all, words do not break correctly before a surrogate pair
https://bugs.webkit.org/show_bug.cgi?id=63401

Reviewed by Darin Adler.

Source/WebCore:

The code to check for mid-word breaks accumulates width one character at a time. It was actually
measuring the two parts of the surrogate pair individually, so they appeared to have zero width.
Fixed by checking for surrogate pairs and measuring the pair as one unit.

Test: fast/text/midword-break-before-surrogate-pair.html

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::LineBreaker::nextLineBreak):

LayoutTests:

  • fast/text/midword-break-before-surrogate-pair.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89768 r89769  
     12011-06-26  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        With word-break: break-all, words do not break correctly before a surrogate pair
     6        https://bugs.webkit.org/show_bug.cgi?id=63401
     7
     8        * fast/text/midword-break-before-surrogate-pair.html: Added.
     9
    1102011-06-26  Adam Barth  <abarth@webkit.org>
    211
  • trunk/Source/WebCore/ChangeLog

    r89766 r89769  
     12011-06-26  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        With word-break: break-all, words do not break correctly before a surrogate pair
     6        https://bugs.webkit.org/show_bug.cgi?id=63401
     7
     8        The code to check for mid-word breaks accumulates width one character at a time. It was actually
     9        measuring the two parts of the surrogate pair individually, so they appeared to have zero width.
     10        Fixed by checking for surrogate pairs and measuring the pair as one unit.
     11
     12        Test: fast/text/midword-break-before-surrogate-pair.html
     13
     14        * rendering/RenderBlockLineLayout.cpp:
     15        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
     16
    1172011-06-26  Dirk Schulze  <krit@webkit.org>
    218
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r89704 r89769  
    21032103                currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == noBreakSpace);
    21042104
     2105                bool midWordBreakIsBeforeSurrogatePair = false;
    21052106                if ((breakAll || breakWords) && !midWordBreak) {
    21062107                    wrapW += charWidth;
    2107                     charWidth = textWidth(t, current.m_pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
     2108                    midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL(t->characters()[current.m_pos + 1]);
     2109                    charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
    21082110                    midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth();
    21092111                }
     
    22222224                        lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    22232225                        midWordBreak &= (breakWords || breakAll);
     2226                        if (midWordBreakIsBeforeSurrogatePair)
     2227                            current.fastIncrementInTextNode();
    22242228                    }
    22252229
Note: See TracChangeset for help on using the changeset viewer.