From 19e8786bac018b8e3aca72f348038b4fea19011b Mon Sep 17 00:00:00 2001 From: darin Date: Fri, 27 May 2005 01:17:32 +0000 Subject: [PATCH] Reviewed by me, patch by Mitz Pettel. - fixed bidi algorithm bug fixed for KHTML should be fixed in WebCore too * khtml/rendering/bidi.cpp: (khtml::RenderBlock::bidiReorderLine): Integrated the patch that Mitz did for the KDE bug, details at . Test cases added: * layout-tests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt: Added. * layout-tests/fast/text/international/bidi-neutral-directionality-paragraph-start.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9222 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- ...irectionality-paragraph-start-expected.txt | 35 +++++++++++++++++++ ...eutral-directionality-paragraph-start.html | 17 +++++++++ WebCore/ChangeLog-2005-08-23 | 13 +++++++ WebCore/khtml/rendering/bidi.cpp | 33 ++++++++--------- 4 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt create mode 100644 LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start.html diff --git a/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt b/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt new file mode 100644 index 000000000000..a67a162a4b78 --- /dev/null +++ b/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt @@ -0,0 +1,35 @@ +layer at (0,0) size 800x600 + RenderCanvas at (0,0) size 800x600 +layer at (0,0) size 800x600 + RenderBlock {HTML} at (0,0) size 800x600 + RenderBody {BODY} at (8,8) size 784x576 + RenderBlock {P} at (0,0) size 784x18 + RenderText {TEXT} at (0,0) size 569x18 + text run at (0,0) width 569: "Mitz Pettel contributed this fix to KDE, and now we're rolling it in. Here's his explanation:" + RenderBlock {P} at (0,34) size 784x72 + RenderText {TEXT} at (0,0) size 777x72 + text run at (0,0) width 766: "The directionality of a neutral character at the beginning of a paragraph (or after a hard line break) is decided incorrectly if" + text run at (0,18) width 777: "the first non-neutral character in the paragraph has directionality opposite to the paragraph directionality. For example, if the" + text run at (0,36) width 768: "paragraph direction is LTR, the first character on the paragraph is a question mark and the next one is a Hebrew character," + text run at (0,54) width 643: "then the question mark will is considered right-to-left and appears to the right of the Hebrew character." + RenderBlock {P} at (0,122) size 784x36 + RenderText {TEXT} at (0,0) size 508x18 + text run at (0,0) width 508: "The rule to follow is 3.3.4.N2 in the Unicode Standard's Bidirectional Algorithm" + RenderInline {A} at (0,0) size 397x18 [color=#0000EE] + RenderText {TEXT} at (0,18) size 397x18 + text run at (0,18) width 397: "http://www.unicode.org/reports/tr9/#Resolving_Neutral_Types" + RenderText {TEXT} at (397,18) size 4x18 + text run at (397,18) width 4: "." + RenderBlock {P} at (0,174) size 784x18 + RenderText {TEXT} at (0,0) size 676x18 + text run at (0,0) width 676: "If the test is successful, the question marks should be on the far left and far right of the next two paragraphs." + RenderBlock {P} at (0,208) size 784x18 + RenderText {TEXT} at (0,0) size 65x18 + text run at (0,0) width 11: "? " + text run at (11,0) width 23: "\x{FEB2} \x{FEED}" + text run at (34,0) width 31: "hello" + RenderBlock {P} at (0,242) size 784x18 + RenderText {TEXT} at (715,0) size 69x18 + text run at (715,0) width 27: " \x{FEB2} \x{FEED}" + text run at (742,0) width 31: "hello" + text run at (773,0) width 11: "? " diff --git a/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start.html b/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start.html new file mode 100644 index 000000000000..4c56c77b97d6 --- /dev/null +++ b/LayoutTests/fast/text/international/bidi-neutral-directionality-paragraph-start.html @@ -0,0 +1,17 @@ + + + + + +

Mitz Pettel contributed this fix to KDE, and now we're rolling it in. Here's his explanation:

+

The directionality of a neutral character at the beginning of a paragraph (or after a hard line break) is decided incorrectly if the first non-neutral character in the paragraph has directionality opposite to the paragraph directionality. For example, if the paragraph direction is LTR, the first character on the paragraph is a question mark and the next one is a Hebrew character, then the question mark will is considered right-to-left and appears to the right of the Hebrew character.

+

The rule to follow is 3.3.4.N2 in the Unicode Standard's Bidirectional Algorithm http://www.unicode.org/reports/tr9/#Resolving_Neutral_Types.

+

If the test is successful, the question marks should be on the far left and far right of the next two paragraphs.

+

+? ﺲ ﻭhello +

+

+? hello ﺲ ﻭ +

+ + diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index c9f3c0eae814..322f4737d028 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,16 @@ +2005-05-26 Darin Adler + + Reviewed by me, patch by Mitz Pettel. + + - fixed bidi algorithm bug fixed for KHTML should be fixed in WebCore too + + * khtml/rendering/bidi.cpp: (khtml::RenderBlock::bidiReorderLine): Integrated the patch that Mitz did + for the KDE bug, details at . + + Test cases added: + * layout-tests/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt: Added. + * layout-tests/fast/text/international/bidi-neutral-directionality-paragraph-start.html: Added. + 2005-05-26 Darin Adler Reviewed by Richard and Dave Harrison. diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp index 921af1209e27..016bbb54a515 100644 --- a/WebCore/khtml/rendering/bidi.cpp +++ b/WebCore/khtml/rendering/bidi.cpp @@ -943,26 +943,25 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator case QChar::DirS: case QChar::DirWS: case QChar::DirON: - if(dir != QChar::DirL) { + if( bidi.status.eor != QChar::DirL ) { //last stuff takes embedding dir - if( bidi.context->dir == QChar::DirR ) { - if(!(bidi.status.eor == QChar::DirR)) { - // AN or EN - appendRun( bidi ); - dir = QChar::DirR; - } - else - bidi.eor = bidi.last; + if(bidi.context->dir == QChar::DirL || bidi.status.lastStrong == QChar::DirL) { + if ( bidi.status.eor != QChar::DirEN && bidi.status.eor != QChar::DirAN && bidi.status.eor != QChar::DirON ) appendRun( bidi ); dir = QChar::DirL; + bidi.eor = bidi.current; bidi.status.eor = QChar::DirL; } else { - if(bidi.status.eor == QChar::DirR) { + if ( bidi.status.eor == QChar::DirEN || bidi.status.eor == QChar::DirAN ) + { + dir = bidi.status.eor; appendRun( bidi ); - dir = QChar::DirL; - } else { - bidi.eor = bidi.current; bidi.status.eor = QChar::DirL; break; } + dir = QChar::DirR; + bidi.eor = bidi.last; + appendRun( bidi ); + dir = QChar::DirL; + bidi.status.eor = QChar::DirL; } } else { bidi.eor = bidi.current; bidi.status.eor = QChar::DirL; @@ -998,12 +997,14 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator case QChar::DirON: if( !(bidi.status.eor == QChar::DirR) && !(bidi.status.eor == QChar::DirAL) ) { //last stuff takes embedding dir - if(bidi.context->dir == QChar::DirR || bidi.status.lastStrong == QChar::DirR) { + if(bidi.context->dir == QChar::DirR || bidi.status.lastStrong == QChar::DirR + || bidi.status.lastStrong == QChar::DirAL) { appendRun( bidi ); dir = QChar::DirR; bidi.eor = bidi.current; bidi.status.eor = QChar::DirR; } else { + dir = QChar::DirL; bidi.eor = bidi.last; appendRun( bidi ); dir = QChar::DirR; @@ -1027,9 +1028,6 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator if(!(bidi.status.lastStrong == QChar::DirAL)) { // if last strong was AL change EN to AN if(dir == QChar::DirON) { - if(bidi.status.lastStrong == QChar::DirAL) - dir = QChar::DirAN; - else dir = QChar::DirL; } switch(bidi.status.last) @@ -1202,7 +1200,6 @@ void RenderBlock::bidiReorderLine(const BidiIterator &start, const BidiIterator break; case QChar::DirEN: if ( bidi.status.last == QChar::DirL ) { - bidi.status.last = QChar::DirL; break; } // fall through -- 2.36.0