- Revision
- 89769
- Author
- [email protected]
- Date
- 2011-06-26 09:09:33 -0700 (Sun, 26 Jun 2011)
Log 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (89768 => 89769)
--- trunk/LayoutTests/ChangeLog 2011-06-26 14:22:13 UTC (rev 89768)
+++ trunk/LayoutTests/ChangeLog 2011-06-26 16:09:33 UTC (rev 89769)
@@ -1,3 +1,12 @@
+2011-06-26 Dan Bernstein <[email protected]>
+
+ 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 <[email protected]>
Note that this test ASSERTs on Linux Debug.
Added: trunk/LayoutTests/fast/text/midword-break-before-surrogate-pair.html (0 => 89769)
--- trunk/LayoutTests/fast/text/midword-break-before-surrogate-pair.html (rev 0)
+++ trunk/LayoutTests/fast/text/midword-break-before-surrogate-pair.html 2011-06-26 16:09:33 UTC (rev 89769)
@@ -0,0 +1,3 @@
+<div style="word-break: break-all; border: solid blue; font-size: 36px; width: 5em;">
+ 𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐𝄐
+</div>
Added: trunk/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-expected.png
(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-expected.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-expected.txt (0 => 89769)
--- trunk/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-expected.txt 2011-06-26 16:09:33 UTC (rev 89769)
@@ -0,0 +1,9 @@
+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}"
Modified: trunk/Source/WebCore/ChangeLog (89768 => 89769)
--- trunk/Source/WebCore/ChangeLog 2011-06-26 14:22:13 UTC (rev 89768)
+++ trunk/Source/WebCore/ChangeLog 2011-06-26 16:09:33 UTC (rev 89769)
@@ -1,3 +1,19 @@
+2011-06-26 Dan Bernstein <[email protected]>
+
+ 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 <[email protected]>
Reviewed by Nikolas Zimmermann.
Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (89768 => 89769)
--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2011-06-26 14:22:13 UTC (rev 89768)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2011-06-26 16:09:33 UTC (rev 89769)
@@ -2102,9 +2102,11 @@
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();
}
@@ -2221,6 +2223,8 @@
// 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) {