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
+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.
--- /dev/null
+aabc4e5b15132f95a15057762a39f2fa
\ No newline at end of file
--- /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 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
--- /dev/null
+<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
+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.
static bool emptyRun = true;
static int numSpaces;
+static const unsigned short nonBreakingSpace = 0xa0;
+
static void embed(UCharDirection, BidiState&);
static void appendRun(BidiState&);
}
}
+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,
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);
return false;
}
-static const unsigned short nonBreakingSpace = 0xa0;
-
static inline bool skipNonBreakingSpace(BidiIterator &it)
{
if (it.obj->style()->nbspMode() != SPACE || it.current() != nonBreakingSpace)