LayoutTests:
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Oct 2006 16:06:11 +0000 (16:06 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Oct 2006 16:06:11 +0000 (16:06 +0000)
        Reviewed by John Sullivan.

        <rdar://problem/4641262> REGRESSION: Japanese text corrupts on wrapping point

        * fast/text/international/wrap-CJK-001-expected.checksum: Added.
        * fast/text/international/wrap-CJK-001-expected.png: Added.
        * fast/text/international/wrap-CJK-001-expected.txt: Added.
        * fast/text/international/wrap-CJK-001.html: Added.

WebCore:

        Reviewed by John Sullivan.

        <rdar://problem/4641262> REGRESSION: Japanese text corrupts on wrapping point

        Problem was that the decision to trim was based only on whether the character
        is a soft hyphen, which caused pretty much any Japanese character to go.
        Changed to decide based on whether the character is ignorable whitespace.

        Test:
        * fast/text/international/wrap-CJK-001.html

        * rendering/bidi.cpp:
        (WebCore::isTrimmableChar):
        New. Checks whether character is whitespace that can be ignored
        according to the text node's style.
        trimmed from the end of wrapped line.
        (WebCore::checkMidpoints):
        Call isTrimmable() rather than checking for char != SOFT_HYPHEN.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/international/wrap-CJK-001-expected.checksum [new file with mode: 0644]
LayoutTests/fast/text/international/wrap-CJK-001-expected.png [new file with mode: 0644]
LayoutTests/fast/text/international/wrap-CJK-001-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/international/wrap-CJK-001.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/bidi.cpp

index ef848217fe074763ee74a05cb433ba3b47d48bf6..2b75977f73565de62b83da25d32dfb7d062d7a55 100644 (file)
@@ -1,3 +1,14 @@
+2006-09-30  David Harrison  <harrison@apple.com>
+
+        Reviewed by John Sullivan.
+
+        <rdar://problem/4641262> REGRESSION: Japanese text corrupts on wrapping point
+
+        * fast/text/international/wrap-CJK-001-expected.checksum: Added.
+        * fast/text/international/wrap-CJK-001-expected.png: Added.
+        * fast/text/international/wrap-CJK-001-expected.txt: Added.
+        * fast/text/international/wrap-CJK-001.html: Added.
+
 2006-10-01  Graham Dennis  <graham.dennis@gmail.com>
 
         Reviewed by Hyatt.
diff --git a/LayoutTests/fast/text/international/wrap-CJK-001-expected.checksum b/LayoutTests/fast/text/international/wrap-CJK-001-expected.checksum
new file mode 100644 (file)
index 0000000..9007d77
--- /dev/null
@@ -0,0 +1 @@
+aabc4e5b15132f95a15057762a39f2fa
\ No newline at end of file
diff --git a/LayoutTests/fast/text/international/wrap-CJK-001-expected.png b/LayoutTests/fast/text/international/wrap-CJK-001-expected.png
new file mode 100644 (file)
index 0000000..f68806f
Binary files /dev/null and b/LayoutTests/fast/text/international/wrap-CJK-001-expected.png differ
diff --git a/LayoutTests/fast/text/international/wrap-CJK-001-expected.txt b/LayoutTests/fast/text/international/wrap-CJK-001-expected.txt
new file mode 100644 (file)
index 0000000..3b0eb84
--- /dev/null
@@ -0,0 +1,13 @@
+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 784x580
+      RenderBlock (anonymous) at (0,0) size 784x14
+        RenderText {#text} at (0,0) size 345x14
+          text run at (0,0) width 345: "Tests that wrapping does not trim the last character if it is not whitespace."
+      RenderBlock {P} at (0,26) size 551x34 [border: (3px solid #FF0000)]
+        RenderText {#text} at (3,3) size 545x28
+          text run at (3,3) width 545: "\x{6700}\x{5927}2GHz\x{306E}Intel Core Duo\x{30D7}\x{30ED}\x{30BB}\x{30C3}\x{30B5}\x{306E}\x{30D1}\x{30EF}\x{30FC}\x{3001}iSight\x{30AB}\x{30E1}\x{30E9}\x{3001}Front Row\x{3001}iLife \x{2019}06\x{3001}13\x{30A4}\x{30F3}\x{30C1}\x{306E}\x{30AF}\x{30EA}\x{30A2}"
+          text run at (3,17) width 168: "\x{30EF}\x{30A4}\x{30C9}\x{30B9}\x{30AF}\x{30EA}\x{30FC}\x{30F3}\x{30C7}\x{30A3}\x{30B9}\x{30D7}\x{30EC}\x{30A4}"
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/text/international/wrap-CJK-001.html b/LayoutTests/fast/text/international/wrap-CJK-001.html
new file mode 100644 (file)
index 0000000..2fb5318
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<head><meta http-equiv="Content-Type" content="text/html; charset=x-sjis"></head>
+<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-family:'Times'; font-size:12px">
+Tests that wrapping does not trim the last character if it is not whitespace.
+<p style="border-style:solid; border-color:red; width:545px">\8dÅ\91å2GHz\82ÌIntel Core Duo\83v\83\8d\83Z\83b\83T\82Ì\83p\83\8f\81[\81AiSight\83J\83\81\83\89\81AFront Row\81AiLife \81f06\81A13\83C\83\93\83`\82Ì\83N\83\8a\83A\83\8f\83C\83h\83X\83N\83\8a\81[\83\93\83f\83B\83X\83v\83\8c\83C
+</body>
+</html>
\ No newline at end of file
index 91f53b4c54eef287181d60ebe52d25d2992a9438..d756016337bebd4ba4b9aebcd2518c9f616de89a 100644 (file)
@@ -1,3 +1,24 @@
+2006-09-30  David Harrison  <harrison@apple.com>
+
+        Reviewed by John Sullivan.
+
+        <rdar://problem/4641262> REGRESSION: Japanese text corrupts on wrapping point
+
+        Problem was that the decision to trim was based only on whether the character
+        is a soft hyphen, which caused pretty much any Japanese character to go.
+        Changed to decide based on whether the character is ignorable whitespace.
+        
+        Test:
+        * fast/text/international/wrap-CJK-001.html
+
+        * rendering/bidi.cpp:
+        (WebCore::isTrimmableChar):
+        New. Checks whether character is whitespace that can be ignored
+        according to the text node's style.
+        trimmed from the end of wrapped line.
+        (WebCore::checkMidpoints):
+        Call isTrimmable() rather than checking for char != SOFT_HYPHEN.
+
 2006-10-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Mitz Pettel.
index e31aa3256d2014942b08a664fb667de60f66aa30..71c158d114b5564d4ed6c9751e4c031cf5947a9e 100644 (file)
@@ -104,6 +104,8 @@ static bool previousLineBrokeCleanly = true;
 static bool emptyRun = true;
 static int numSpaces;
 
+static const unsigned short nonBreakingSpace = 0xa0;
+
 static void embed(UCharDirection, BidiState&);
 static void appendRun(BidiState&);
 
@@ -501,6 +503,17 @@ static void chopMidpointsAt(RenderObject* obj, unsigned pos)
     }
 }
 
+static bool isTrimmable(RenderText* textObj, unsigned int index)
+{
+    ASSERT(index < textObj->length());
+    
+    // FIXME: Also ask ICU whether character is whitespace? Seems expensive. Is it needed for correctness?
+    UChar c = textObj->text()[index];
+    return c == ' ' || c == '\t' ||
+            (c == '\n' && !textObj->style()->preserveNewline()) ||
+            (c == nonBreakingSpace && textObj->style()->nbspMode() == SPACE);
+}
+
 static void checkMidpoints(BidiIterator& lBreak, BidiState& bidi)
 {
     // Check to see if our last midpoint is a start point beyond the line break.  If so,
@@ -518,10 +531,9 @@ static void checkMidpoints(BidiIterator& lBreak, BidiState& bidi)
             sNumMidpoints--;
             if (endpoint.obj->style()->collapseWhiteSpace()) {
                 if (endpoint.obj->isText()) {
-                    // Don't shave a character off the endpoint if it was from a soft hyphen.
                     RenderText* textObj = static_cast<RenderText*>(endpoint.obj);
                     if (endpoint.pos+1 < textObj->length()) {
-                        if (textObj->text()[endpoint.pos+1] == SOFT_HYPHEN)
+                        if (!isTrimmable(textObj, endpoint.pos+1))
                             return;
                     } else if (startpoint.obj->isText()) {
                         RenderText *startText = static_cast<RenderText*>(startpoint.obj);
@@ -1895,8 +1907,6 @@ bool RenderBlock::matchedEndLine(const BidiIterator& start, const BidiStatus& st
     return false;
 }
 
-static const unsigned short nonBreakingSpace = 0xa0;
-
 static inline bool skipNonBreakingSpace(BidiIterator &it)
 {
     if (it.obj->style()->nbspMode() != SPACE || it.current() != nonBreakingSpace)