summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-04-27 15:21:25 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2010-06-11 13:33:57 (GMT)
commite6ac173991223dbf3b1b6f7213550ebca4608cb6 (patch)
tree5012808a81d16f953e4a3733f84e2f0d4c7d5d6e /src
parent073d04f1c2c5dc7020469bfc92708dce634f4779 (diff)
downloadQt-e6ac173991223dbf3b1b6f7213550ebca4608cb6.zip
Qt-e6ac173991223dbf3b1b6f7213550ebca4608cb6.tar.gz
Qt-e6ac173991223dbf3b1b6f7213550ebca4608cb6.tar.bz2
Fix incorrect line breaking in QtWebKit.
QTextBoundaryFinder was not consistent with ICU. See also: https://bugs.webkit.org/show_bug.cgi?id=31076 The previous definition of a line break was that the index in the string after which the line break should occur. Now it is the index of the boundary at which the break should occur (hence one more). Task-number: QT-3495 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qtextboundaryfinder.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp
index 7c40e35..ca4d3c3 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/tools/qtextboundaryfinder.cpp
@@ -130,6 +130,11 @@ static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int
Line break boundaries give possible places where a line break
might happen and sentence boundaries will show the beginning and
end of whole sentences.
+
+ The first position in a string is always a valid boundary and
+ refers to the position before the first character. The last
+ position at the length of the string is also valid and refers
+ to the position after the last character.
*/
/*!
@@ -362,7 +367,8 @@ int QTextBoundaryFinder::toNextBoundary()
++pos;
break;
case Line:
- while (pos < length && d->attributes[pos].lineBreakType < HB_Break)
+ Q_ASSERT(pos);
+ while (pos < length && d->attributes[pos-1].lineBreakType < HB_Break)
++pos;
break;
}
@@ -404,7 +410,7 @@ int QTextBoundaryFinder::toPreviousBoundary()
--pos;
break;
case Line:
- while (pos > 0 && d->attributes[pos].lineBreakType < HB_Break)
+ while (pos > 0 && d->attributes[pos-1].lineBreakType < HB_Break)
--pos;
break;
}
@@ -429,7 +435,7 @@ bool QTextBoundaryFinder::isAtBoundary() const
case Word:
return d->attributes[pos].wordBoundary;
case Line:
- return d->attributes[pos].lineBreakType >= HB_Break;
+ return (pos > 0) ? d->attributes[pos-1].lineBreakType >= HB_Break : true;
case Sentence:
return d->attributes[pos].sentenceBoundary;
}