aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r--src/quick/items/qquicktextedit.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index f27b537302..4471d6e4b9 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -707,6 +707,7 @@ void QQuickTextEdit::setHAlign(HAlignment align)
if (d->setHAlign(align, true) && isComponentComplete()) {
d->updateDefaultTextOption();
updateSize();
+ updateWholeDocument();
}
}
@@ -814,6 +815,7 @@ void QQuickTextEditPrivate::mirrorChange()
if (!hAlignImplicit && (hAlign == QQuickTextEdit::AlignRight || hAlign == QQuickTextEdit::AlignLeft)) {
updateDefaultTextOption();
q->updateSize();
+ q->updateWholeDocument();
emit q->effectiveHorizontalAlignmentChanged();
}
}
@@ -1512,7 +1514,7 @@ void QQuickTextEdit::itemChange(ItemChange change, const ItemChangeData &value)
Q_UNUSED(value);
switch (change) {
case ItemDevicePixelRatioHasChanged:
- if (d->renderType == NativeRendering) {
+ if (d->containsUnscalableGlyphs) {
// Native rendering optimizes for a given pixel grid, so its results must not be scaled.
// Text layout code respects the current device pixel ratio automatically, we only need
// to rerun layout after the ratio changed.
@@ -2138,6 +2140,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
return oldNode;
}
+ d->containsUnscalableGlyphs = false;
if (!oldNode || d->updateType == QQuickTextEditPrivate::UpdateAll) {
delete oldNode;
oldNode = nullptr;
@@ -2216,14 +2219,17 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
d->firstBlockInViewport = -1;
d->firstBlockPastViewport = -1;
+ int frameCount = -1;
while (!frames.isEmpty()) {
QTextFrame *textFrame = frames.takeFirst();
+ ++frameCount;
+ if (frameCount > 0)
+ firstDirtyPos = 0;
+ qCDebug(lcVP) << "frame" << frameCount << textFrame
+ << "from" << positionToRectangle(textFrame->firstPosition()).topLeft()
+ << "to" << positionToRectangle(textFrame->lastPosition()).bottomRight();
frames.append(textFrame->childFrames());
frameDecorationsEngine.addFrameDecorations(d->document, textFrame);
-
- if (textFrame->lastPosition() < firstDirtyPos
- || textFrame->firstPosition() >= firstCleanNode.startPos())
- continue;
resetEngine(&engine, d->color, d->selectedTextColor, d->selectionColor);
if (textFrame->firstPosition() > textFrame->lastPosition()
@@ -2307,16 +2313,25 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
break; // skip rest of blocks in this frame
}
- if (inView && !block.text().isEmpty() && coveredRegion.isValid())
+ if (inView && !block.text().isEmpty() && coveredRegion.isValid()) {
d->renderedRegion = d->renderedRegion.united(coveredRegion);
+ // In case we're going to visit more (nested) frames after this, ensure that we
+ // don't omit any blocks that fit within the region that we claim as fully rendered.
+ if (!frames.isEmpty())
+ viewport = viewport.united(d->renderedRegion);
+ }
}
}
bool createdNodeInView = false;
if (inView) {
if (!engine.hasContents()) {
- if (node && !node->parent())
- d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
+ if (node) {
+ d->containsUnscalableGlyphs = d->containsUnscalableGlyphs
+ || node->containsUnscalableGlyphs();
+ if (!node->parent())
+ d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
+ }
node = d->createTextNode();
createdNodeInView = true;
updateNodeTransform(node, nodeOffset);
@@ -2331,6 +2346,8 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
QList<int>::const_iterator lowerBound = std::lower_bound(frameBoundaries.constBegin(), frameBoundaries.constEnd(), block.next().position());
if (node && (currentNodeSize > nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart)) {
currentNodeSize = 0;
+ d->containsUnscalableGlyphs = d->containsUnscalableGlyphs
+ || node->containsUnscalableGlyphs();
if (!node->parent())
d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
if (!createdNodeInView)
@@ -2341,8 +2358,12 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
++it;
} // loop over blocks in frame
}
- if (Q_LIKELY(node && !node->parent()))
- d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
+ if (Q_LIKELY(node)) {
+ d->containsUnscalableGlyphs = d->containsUnscalableGlyphs
+ || node->containsUnscalableGlyphs();
+ if (Q_LIKELY(!node->parent()))
+ d->addCurrentTextNodeToRoot(&engine, rootNode, node, nodeIterator, nodeStart);
+ }
}
frameDecorationsEngine.addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor());
// Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front.
@@ -2943,6 +2964,7 @@ void QQuickTextEditPrivate::addCurrentTextNodeToRoot(QQuickTextNodeEngine *engin
it = textNodeMap.insert(it, TextNode(startPos, node));
++it;
root->appendChildNode(node);
+ ++renderedBlockCount;
}
QQuickTextNode *QQuickTextEditPrivate::createTextNode()