summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextobject.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-06-01 15:33:38 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-19 10:18:04 +0200
commitb9224af92c128f7cc66bef11849db046f10dc81f (patch)
tree6cbf656d70aebeaffddda5c256840f952907a0d6 /src/gui/text/qtextobject.cpp
parent1e0d1c5f2996da33db1e3e4c1f7c6ef3e1f29416 (diff)
Enablers for using QGlyphRun in SceneGraph
Several required fixes and changes to fix problems that arose when porting SceneGraph's QSGTextInput and QSGTextEdit to use QSGTextNode, especially related to having selections on the text. Also fixes crashes with the threaded renderer on Mac OS X when using the TextEdit or TextInput elements. Task-number: QTBUG-18019, QTBUG-20017 Change-Id: I67f24465352daa1d2cb12b6d2f378feb676c9804 Reviewed-on: http://codereview.qt.nokia.com/2864 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/gui/text/qtextobject.cpp')
-rw-r--r--src/gui/text/qtextobject.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index cea5eac465..d641266367 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1667,21 +1667,24 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
\sa QGlyphRun, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphRun()
*/
#if !defined(QT_NO_RAWFONT)
-QList<QGlyphRun> QTextFragment::glyphRuns() const
+QList<QGlyphRun> QTextFragment::glyphRuns(int pos, int len) const
{
if (!p || !n)
return QList<QGlyphRun>();
- int pos = position();
- int len = length();
- if (len == 0)
- return QList<QGlyphRun>();
-
- int blockNode = p->blockMap().findNode(pos);
+ int blockNode = p->blockMap().findNode(position());
const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
QTextLayout *layout = blockData->layout;
+ int blockPosition = p->blockMap().position(blockNode);
+ if (pos < 0)
+ pos = position() - blockPosition;
+ if (len < 0)
+ len = length();
+ if (len == 0)
+ return QList<QGlyphRun>();
+
QList<QGlyphRun> ret;
for (int i=0; i<layout->lineCount(); ++i) {
QTextLine textLine = layout->lineAt(i);