summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextcursor.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-04-14 15:34:08 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-04-15 11:07:44 +0000
commitba5af03a5a505d4ef19ccea1c0170e50abf3db8c (patch)
tree0fdee2d3af719f25cd344ab29be6c4ea87e80a5d /src/gui/text/qtextcursor.cpp
parentc586f958b30c32176487133e76d5cf65b15d6166 (diff)
[QTextCursor] Better use of the cached whiteSpace attribute
In compare to QTextEngine::atSpace(), this also handles the less-common "white spaces" and the exceptional control codes. Change-Id: I52878932926b7f9fe36c9dd01007963b9691fbf0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qtextcursor.cpp')
-rw-r--r--src/gui/text/qtextcursor.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index a151c515a3..eb51447105 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -424,9 +424,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
// skip if already at word start
QTextEngine *engine = layout->engine();
- engine->attributes();
+ const QCharAttributes *attributes = engine->attributes();
if ((relativePos == blockIt.length() - 1)
- && (engine->atSpace(relativePos - 1) || engine->atWordSeparator(relativePos - 1)))
+ && (attributes[relativePos - 1].whiteSpace || engine->atWordSeparator(relativePos - 1)))
return false;
if (relativePos < blockIt.length()-1)
@@ -499,7 +499,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
}
case QTextCursor::EndOfWord: {
QTextEngine *engine = layout->engine();
- engine->attributes();
+ const QCharAttributes *attributes = engine->attributes();
const int len = blockIt.length() - 1;
if (relativePos >= len)
return false;
@@ -508,7 +508,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
while (relativePos < len && engine->atWordSeparator(relativePos))
++relativePos;
} else {
- while (relativePos < len && !engine->atSpace(relativePos) && !engine->atWordSeparator(relativePos))
+ while (relativePos < len && !attributes[relativePos].whiteSpace && !engine->atWordSeparator(relativePos))
++relativePos;
}
newPosition = blockIt.position() + relativePos;