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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@89769
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-06-26 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ With word-break: break-all, words do not break correctly before a surrogate pair
+ https://bugs.webkit.org/show_bug.cgi?id=63401
+
+ * fast/text/midword-break-before-surrogate-pair.html: Added.
+
2011-06-26 Adam Barth <abarth@webkit.org>
Note that this test ASSERTs on Linux Debug.
--- /dev/null
+<div style="word-break: break-all; border: solid blue; font-size: 36px; width: 5em;">
+ 𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐
+</div>
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 186x92 [border: (3px solid #0000FF)]
+ RenderText {#text} at (3,3) size 168x84
+ text run at (3,3) width 168: "\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}"
+ text run at (3,46) width 72: "\x{D834}\x{DD10}\x{D834}\x{DD10}\x{D834}\x{DD10}"
+2011-06-26 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ With word-break: break-all, words do not break correctly before a surrogate pair
+ https://bugs.webkit.org/show_bug.cgi?id=63401
+
+ 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):
+
2011-06-26 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == noBreakSpace);
+ bool midWordBreakIsBeforeSurrogatePair = false;
if ((breakAll || breakWords) && !midWordBreak) {
wrapW += charWidth;
- charWidth = textWidth(t, current.m_pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
+ midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL(t->characters()[current.m_pos + 1]);
+ charWidth = textWidth(t, current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth();
}
// adding the end width forces a break.
lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
midWordBreak &= (breakWords || breakAll);
+ if (midWordBreakIsBeforeSurrogatePair)
+ current.fastIncrementInTextNode();
}
if (betweenWords) {