Qt Quick: Fix bug for selections with line wraps and breaks
This fixes yet another bug where the selection spans both line wraps and explicit line breaks. Offsetting the log clusters by the text position in 342c909b340cb1bfbb95480fc79dcea21a470c83 was not entirely correct, because in some cases the script item will refer to a specific part of the string, as indicated by si.position, while iterator.itemStart is in the context of the full string. In this case, the log cluster array pointer we use refers to the script item's part of the array, i.e. it is already offset by si.position. Therefore, we must offset the logClusters pointer by the text position *relative* to the current script item. Previously we would actually offset by si.position twice in cases where si.position != 0. We want the text range to refer to the full string, though, so it can be compared to other text ranges later. However, in some cases when we are requesting only part of a script item, then iterator.itemStart does not correspond to relativeFrom, so in order for the text range search to work, we must pass in the text positions we are using [relativeFrom, relativeTo], though offset by si.position so that it refers to the full string and not just the part addressed by the script item. Task-number: QTBUG-51759 Change-Id: Ib69856d6d3bc1dd501db94c9d295623f436d122c Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
parent
f6eadcd601
commit
24914b1acb
@ -2141,7 +2141,6 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine,
|
||||
QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun);
|
||||
|
||||
int rangeStart = textPosition;
|
||||
logClusters += textPosition;
|
||||
while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) {
|
||||
++logClusters;
|
||||
++rangeStart;
|
||||
@ -2350,9 +2349,9 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
|
||||
width,
|
||||
glyphsStart + start,
|
||||
glyphsStart + end,
|
||||
logClusters,
|
||||
iterator.itemStart,
|
||||
iterator.itemLength));
|
||||
logClusters + relativeFrom,
|
||||
relativeFrom + si.position,
|
||||
relativeTo - relativeFrom + 1));
|
||||
for (int i = 0; i < subLayout.numGlyphs; ++i) {
|
||||
QFixed justification = QFixed::fromFixed(subLayout.justifications[i].space_18d6);
|
||||
pos.rx() += (subLayout.advances[i] + justification).toReal();
|
||||
@ -2380,9 +2379,9 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
|
||||
width,
|
||||
glyphsStart + start,
|
||||
glyphsStart + end,
|
||||
logClusters,
|
||||
iterator.itemStart,
|
||||
iterator.itemLength);
|
||||
logClusters + relativeFrom,
|
||||
relativeFrom + si.position,
|
||||
relativeTo - relativeFrom + 1);
|
||||
if (!glyphRun.isEmpty())
|
||||
glyphRuns.append(glyphRun);
|
||||
} else {
|
||||
@ -2396,9 +2395,9 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
|
||||
width,
|
||||
glyphsStart,
|
||||
glyphsEnd,
|
||||
logClusters,
|
||||
iterator.itemStart,
|
||||
iterator.itemLength);
|
||||
logClusters + relativeFrom,
|
||||
relativeFrom + si.position,
|
||||
relativeTo - relativeFrom + 1);
|
||||
if (!glyphRun.isEmpty())
|
||||
glyphRuns.append(glyphRun);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user