<rdar://problem/9971293> Mid-word breaks can occur in the middle of a surrogate pair
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Aug 2011 20:52:31 +0000 (20:52 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Aug 2011 20:52:31 +0000 (20:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66402

Reviewed by Dave Hyatt.

Source/WebCore:

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

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::nextLineBreak): Just never allow a mid-word
break before a trailing surrogate.

LayoutTests:

* fast/text/midword-break-before-surrogate-pair-2.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93237 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/midword-break-before-surrogate-pair-2.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 5efd86762e68e8ff913009624418ad822439cdd4..ae745f99211bac27b45d138d8b7501037d3070bd 100644 (file)
@@ -1,3 +1,12 @@
+2011-08-17  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/9971293> Mid-word breaks can occur in the middle of a surrogate pair
+        https://bugs.webkit.org/show_bug.cgi?id=66402
+
+        Reviewed by Dave Hyatt.
+
+        * fast/text/midword-break-before-surrogate-pair-2.html: Added.
+
 2011-08-17  Ryosuke Niwa  <rniwa@webkit.org>
 
         Rebaseline for Windows, Chromium Windows, and Chromium Linux after r93221.
diff --git a/LayoutTests/fast/text/midword-break-before-surrogate-pair-2.html b/LayoutTests/fast/text/midword-break-before-surrogate-pair-2.html
new file mode 100644 (file)
index 0000000..c895b90
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="word-break: break-all; border: solid blue; font-size: 36px; width: 5em;">
+    &#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;&#x1f1ef;&#x1f1f5;
+</div>
diff --git a/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.png b/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.png
new file mode 100644 (file)
index 0000000..10669b3
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.txt b/LayoutTests/platform/mac/fast/text/midword-break-before-surrogate-pair-2-expected.txt
new file mode 100644 (file)
index 0000000..77e3297
--- /dev/null
@@ -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 186x100 [border: (3px solid #0000FF)]
+        RenderText {#text} at (3,7) size 145x88
+          text run at (3,7) width 145: "\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}"
+          text run at (3,54) width 145: "\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}\x{D83C}\x{DDEF}\x{D83C}\x{DDF5}"
index 14aac239e8873d58c2cef433bd1b202a4fb1c871..50ab8864b7cc25ed47f110f15ad08451a852064d 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/9971293> Mid-word breaks can occur in the middle of a surrogate pair
+        https://bugs.webkit.org/show_bug.cgi?id=66402
+
+        Reviewed by Dave Hyatt.
+
+        Test: fast/text/midword-break-before-surrogate-pair-2.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak): Just never allow a mid-word
+        break before a trailing surrogate.
+
 2011-08-16  Chang Shu  <cshu@webkit.org>
 
         Support reset in WebCore::Internals
index 61a527d31bb86b7fc88b2a0cc431b1ad370dbc0c..0c2e6e105df260fdb62653070132f05b34d9b553 100644 (file)
@@ -2184,10 +2184,9 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
 
                 currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c == noBreakSpace);
 
-                bool midWordBreakIsBeforeSurrogatePair = false;
                 if ((breakAll || breakWords) && !midWordBreak) {
                     wrapW += charWidth;
-                    midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && current.m_pos + 1 < t->textLength() && U16_IS_TRAIL(t->characters()[current.m_pos + 1]);
+                    bool 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();
                 }
@@ -2300,13 +2299,11 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
                         breakWords = false;
                     }
 
-                    if (midWordBreak) {
+                    if (midWordBreak && !U16_IS_TRAIL(c)) {
                         // Remember this as a breakable position in case
                         // 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) {