Add contentWidth and contentHeight properties to Text elements.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Tue, 7 Feb 2012 01:57:42 +0000 (11:57 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 7 Feb 2012 05:36:05 +0000 (06:36 +0100)
For Text and TextEdit this is a rename of paintedWidth and paintedHeight
both of which remain as synonyms of the content properties for
compatability.  For TextInput this is a new property.

Task-number: QTBUG-23691
Task-number: QTBUG-15160
Change-Id: Idbdc72fad34922be21b649ca45fc39b5e533ed1a
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
src/quick/items/qquicktext.cpp
src/quick/items/qquicktext_p.h
src/quick/items/qquicktext_p_p.h
src/quick/items/qquicktextedit.cpp
src/quick/items/qquicktextedit_p.h
src/quick/items/qquicktextedit_p_p.h
src/quick/items/qquicktextinput.cpp
src/quick/items/qquicktextinput_p.h
tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp

index f5d1996..acf2d17 100644 (file)
@@ -377,8 +377,8 @@ void QQuickTextPrivate::updateSize()
     if (text.isEmpty()) {
         qreal fontHeight = fm.height();
         q->setImplicitSize(0, fontHeight);
-        paintedSize = QSize(0, fontHeight);
-        emit q->paintedSizeChanged();
+        contentSize = QSize(0, fontHeight);
+        emit q->contentSizeChanged();
         updateType = UpdatePaintNode;
         q->update();
         return;
@@ -449,9 +449,9 @@ void QQuickTextPrivate::updateSize()
 
     if (iWidth == -1)
         q->setImplicitHeight(size.height());
-    if (paintedSize != size) {
-        paintedSize = size;
-        emit q->paintedSizeChanged();
+    if (contentSize != size) {
+        contentSize = size;
+        emit q->contentSizeChanged();
     }
     updateType = UpdatePaintNode;
     q->update();
@@ -1487,8 +1487,8 @@ void QQuickText::setVAlign(VAlignment align)
     wrap if an explicit width has been set.  wrapMode can be one of:
 
     \list
-    \o Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l paintedWidth will exceed a set width.
-    \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l paintedWidth will exceed a set width.
+    \o Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l contentWidth will exceed a set width.
+    \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l contentWidth will exceed a set width.
     \o Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
     \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
     \endlist
@@ -1914,27 +1914,27 @@ void QQuickText::updatePolish()
 }
 
 /*!
-    \qmlproperty real QtQuick2::Text::paintedWidth
+    \qmlproperty real QtQuick2::Text::contentWidth
 
     Returns the width of the text, including width past the width
     which is covered due to insufficient wrapping if WrapMode is set.
 */
-qreal QQuickText::paintedWidth() const
+qreal QQuickText::contentWidth() const
 {
     Q_D(const QQuickText);
-    return d->paintedSize.width();
+    return d->contentSize.width();
 }
 
 /*!
-    \qmlproperty real QtQuick2::Text::paintedHeight
+    \qmlproperty real QtQuick2::Text::contentHeight
 
     Returns the height of the text, including height past the height
     which is covered due to there being more text than fits in the set height.
 */
-qreal QQuickText::paintedHeight() const
+qreal QQuickText::contentHeight() const
 {
     Q_D(const QQuickText);
-    return d->paintedSize.height();
+    return d->contentSize.height();
 }
 
 /*!
index 74339e3..ff1f45e 100644 (file)
@@ -80,8 +80,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem
 
     Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
     Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
-    Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
-    Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
+    Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
+    Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
+    Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged)  // Compatibility
+    Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
     Q_PROPERTY(qreal lineHeight READ lineHeight WRITE setLineHeight NOTIFY lineHeightChanged)
     Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged)
     Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
@@ -188,8 +190,8 @@ public:
 
     int resourcesLoading() const; // mainly for testing
 
-    qreal paintedWidth() const;
-    qreal paintedHeight() const;
+    qreal contentWidth() const;
+    qreal contentHeight() const;
 
     QRectF boundingRect() const;
     Q_INVOKABLE void doLayout();
@@ -209,7 +211,7 @@ Q_SIGNALS:
     void maximumLineCountChanged();
     void textFormatChanged(TextFormat textFormat);
     void elideModeChanged(TextElideMode mode);
-    void paintedSizeChanged();
+    void contentSizeChanged();
     void lineHeightChanged(qreal lineHeight);
     void lineHeightModeChanged(LineHeightMode mode);
     void fontSizeModeChanged();
index db84754..6c9f22d 100644 (file)
@@ -124,7 +124,7 @@ public:
     bool needToUpdateLayout:1;
 
     QRect layedOutTextRect;
-    QSize paintedSize;
+    QSize contentSize;
     qreal naturalWidth;
     virtual qreal getImplicitWidth() const;
 
index 0ebe5de..85480cf 100644 (file)
@@ -271,7 +271,6 @@ void QQuickTextEdit::setText(const QString &text)
     } else {
         d->control->setPlainText(text);
     }
-    q_textChanged();
 }
 
 /*!
@@ -663,27 +662,27 @@ int QQuickTextEdit::length() const
 }
 
 /*!
-    \qmlproperty real QtQuick2::TextEdit::paintedWidth
+    \qmlproperty real QtQuick2::TextEdit::contentWidth
 
     Returns the width of the text, including the width past the width
     which is covered due to insufficient wrapping if \l wrapMode is set.
 */
-qreal QQuickTextEdit::paintedWidth() const
+qreal QQuickTextEdit::contentWidth() const
 {
     Q_D(const QQuickTextEdit);
-    return d->paintedSize.width();
+    return d->contentSize.width();
 }
 
 /*!
-    \qmlproperty real QtQuick2::TextEdit::paintedHeight
+    \qmlproperty real QtQuick2::TextEdit::contentHeight
 
     Returns the height of the text, including the height past the height
     that is covered if the text does not fit within the set height.
 */
-qreal QQuickTextEdit::paintedHeight() const
+qreal QQuickTextEdit::contentHeight() const
 {
     Q_D(const QQuickTextEdit);
-    return d->paintedSize.height();
+    return d->contentSize.height();
 }
 
 /*!
@@ -1966,8 +1965,11 @@ void QQuickTextEdit::updateSize()
         else
             setImplicitHeight(newHeight);
 
-        d->paintedSize = QSize(newWidth, newHeight);
-        emit paintedSizeChanged();
+        QSize size(newWidth, newHeight);
+        if (d->contentSize != size) {
+            d->contentSize = size;
+            emit contentSizeChanged();
+        }
     } else {
         d->dirty = true;
     }
index d74c489..d4aeaa5 100644 (file)
@@ -72,8 +72,10 @@ class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
     Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
     Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
     Q_PROPERTY(int length READ length NOTIFY textChanged)
-    Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
-    Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
+    Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
+    Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
+    Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged)  // Compatibility
+    Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
     Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
     Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
     Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
@@ -212,8 +214,8 @@ public:
 
     QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
 
-    qreal paintedWidth() const;
-    qreal paintedHeight() const;
+    qreal contentWidth() const;
+    qreal contentHeight() const;
 
     QUrl baseUrl() const;
     void setBaseUrl(const QUrl &url);
@@ -233,7 +235,7 @@ public:
 
 Q_SIGNALS:
     void textChanged();
-    void paintedSizeChanged();
+    void contentSizeChanged();
     void cursorPositionChanged();
     void cursorRectangleChanged();
     void selectionStartChanged();
index 41b64cc..ead74a2 100644 (file)
@@ -133,7 +133,7 @@ public:
     QQuickTextEdit::SelectionMode mouseSelectionMode;
     int lineCount;
     int yoff;
-    QSize paintedSize;
+    QSize contentSize;
 
     enum NodeType {
         NodeIsNull,
index 39dcc11..f888228 100644 (file)
@@ -2251,6 +2251,32 @@ bool QQuickTextInput::canRedo() const
     return d->canRedo;
 }
 
+/*!
+    \qmlproperty real QtQuick2::TextInput::contentWidth
+
+    Returns the width of the text, including the width past the width
+    which is covered due to insufficient wrapping if \l wrapMode is set.
+*/
+
+qreal QQuickTextInput::contentWidth() const
+{
+    Q_D(const QQuickTextInput);
+    return d->boundingRect.width();
+}
+
+/*!
+    \qmlproperty real QtQuick2::TextInput::contentHeight
+
+    Returns the height of the text, including the height past the height
+    that is covered if the text does not fit within the set height.
+*/
+
+qreal QQuickTextInput::contentHeight() const
+{
+    Q_D(const QQuickTextInput);
+    return d->boundingRect.height();
+}
+
 void QQuickTextInput::moveCursorSelection(int position)
 {
     Q_D(QQuickTextInput);
@@ -2675,6 +2701,8 @@ void QQuickTextInputPrivate::updateLayout()
     if (!q->isComponentComplete())
         return;
 
+    const QRectF previousRect = boundingRect;
+
     QTextOption option = m_textLayout.textOption();
     option.setTextDirection(layoutDirection());
     option.setFlags(QTextOption::IncludeTrailingSpaces);
@@ -2709,6 +2737,8 @@ void QQuickTextInputPrivate::updateLayout()
     q->update();
     q->setImplicitSize(qCeil(boundingRect.width()), qCeil(boundingRect.height()));
 
+    if (previousRect != boundingRect)
+        emit q->contentSizeChanged();
 }
 
 #ifndef QT_NO_CLIPBOARD
index 70a2f0a..b5b3d0f 100644 (file)
@@ -103,6 +103,8 @@ class Q_AUTOTEST_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
     Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
     Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
     Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
+    Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
+    Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
 
 public:
     QQuickTextInput(QQuickItem * parent=0);
@@ -254,6 +256,9 @@ public:
 
     Q_INVOKABLE QString getText(int start, int end) const;
 
+    qreal contentWidth() const;
+    qreal contentHeight() const;
+
 Q_SIGNALS:
     void textChanged();
     void cursorPositionChanged();
@@ -289,6 +294,7 @@ Q_SIGNALS:
     void canRedoChanged();
     void inputMethodComposingChanged();
     void effectiveHorizontalAlignmentChanged();
+    void contentSizeChanged();
 
 protected:
     virtual void geometryChanged(const QRectF &newGeometry,
index f59df3d..96449c0 100644 (file)
@@ -104,6 +104,7 @@ private slots:
 
     void implicitSize_data();
     void implicitSize();
+    void contentSize();
 
     void lineLaidOut();
 
@@ -462,7 +463,7 @@ void tst_qquicktext::multilineElide()
     QCOMPARE(myText->lineCount(), 3);
     QCOMPARE(myText->truncated(), true);
 
-    qreal lineHeight = myText->paintedHeight() / 3.;
+    qreal lineHeight = myText->contentHeight() / 3.;
 
     // reduce size and ensure fewer lines are drawn
     myText->setHeight(lineHeight * 2);
@@ -1474,6 +1475,49 @@ void tst_qquicktext::implicitSize()
     delete textObject;
 }
 
+void tst_qquicktext::contentSize()
+{
+    QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }";
+    QDeclarativeComponent textComponent(&engine);
+    textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+    QScopedPointer<QObject> object(textComponent.create());
+    QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
+
+    QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+    textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() < textObject->height());
+    QCOMPARE(spy.count(), 1);
+
+    textObject->setWrapMode(QQuickText::WordWrap);
+    QVERIFY(textObject->contentWidth() <= textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), 2);
+
+    textObject->setElideMode(QQuickText::ElideRight);
+    QVERIFY(textObject->contentWidth() <= textObject->width());
+    QVERIFY(textObject->contentHeight() < textObject->height());
+    QCOMPARE(spy.count(), 3);
+    int spyCount = 3;
+    qreal elidedWidth = textObject->contentWidth();
+
+    textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+    QVERIFY(textObject->contentWidth() <= textObject->width());
+    QVERIFY(textObject->contentHeight() < textObject->height());
+    // this text probably won't have the same elided width, but it's not guaranteed.
+    if (textObject->contentWidth() != elidedWidth)
+        QCOMPARE(spy.count(), ++spyCount);
+    else
+        QCOMPARE(spy.count(), spyCount);
+
+    textObject->setElideMode(QQuickText::ElideNone);
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), ++spyCount);
+}
+
 void tst_qquicktext::lineLaidOut()
 {
     QQuickView *canvas = createView(testFile("lineLayout.qml"));
@@ -1585,7 +1629,7 @@ void tst_qquicktext::imgTagsUpdates()
     QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
     QVERIFY(myText != 0);
 
-    QSignalSpy spy(myText, SIGNAL(paintedSizeChanged()));
+    QSignalSpy spy(myText, SIGNAL(contentSizeChanged()));
 
     QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
     QVERIFY(textPrivate != 0);
@@ -1641,8 +1685,8 @@ void tst_qquicktext::fontSizeMode()
     myText->setText(text);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
 
-    qreal originalWidth = myText->paintedWidth();
-    qreal originalHeight = myText->paintedHeight();
+    qreal originalWidth = myText->contentWidth();
+    qreal originalHeight = myText->contentHeight();
 
     // The original text unwrapped should exceed the width of the item.
     QVERIFY(originalWidth > myText->width());
@@ -1655,8 +1699,8 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::HorizontalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Font size reduced to fit within the width of the item.
-    qreal horizontalFitWidth = myText->paintedWidth();
-    qreal horizontalFitHeight = myText->paintedHeight();
+    qreal horizontalFitWidth = myText->contentWidth();
+    qreal horizontalFitHeight = myText->contentHeight();
     QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
     QVERIFY(horizontalFitHeight <= myText->height() + 2);
 
@@ -1665,20 +1709,20 @@ void tst_qquicktext::fontSizeMode()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1687,8 +1731,8 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Font size increased to fill the height of the item.
-    qreal verticalFitHeight = myText->paintedHeight();
-    QVERIFY(myText->paintedWidth() > myText->width());
+    qreal verticalFitHeight = myText->contentHeight();
+    QVERIFY(myText->contentWidth() > myText->width());
     QVERIFY(verticalFitHeight <= myText->height() + 2);
     QVERIFY(verticalFitHeight > originalHeight);
 
@@ -1697,20 +1741,20 @@ void tst_qquicktext::fontSizeMode()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1719,28 +1763,28 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as HorizontalFit with no wrapping.
-    QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-    QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+    QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+    QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1750,8 +1794,8 @@ void tst_qquicktext::fontSizeMode()
     myText->setWrapMode(QQuickText::Wrap);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
 
-    originalWidth = myText->paintedWidth();
-    originalHeight = myText->paintedHeight();
+    originalWidth = myText->contentWidth();
+    originalHeight = myText->contentHeight();
 
     // The original text wrapped should exceed the height of the item.
     QVERIFY(originalWidth <= myText->width() + 2);
@@ -1761,16 +1805,16 @@ void tst_qquicktext::fontSizeMode()
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
     // same size as without text wrapping.
-    QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-    QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+    QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+    QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with HorizontalFit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1779,9 +1823,9 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // VerticalFit should reduce the size to the wrapped text within the vertical height.
-    verticalFitHeight = myText->paintedHeight();
-    qreal verticalFitWidth = myText->paintedWidth();
-    QVERIFY(myText->paintedWidth() <= myText->width() + 2);
+    verticalFitHeight = myText->contentHeight();
+    qreal verticalFitWidth = myText->contentWidth();
+    QVERIFY(myText->contentWidth() <= myText->width() + 2);
     QVERIFY(verticalFitHeight <= myText->height() + 2);
     QVERIFY(verticalFitHeight < originalHeight);
 
@@ -1790,8 +1834,8 @@ void tst_qquicktext::fontSizeMode()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1800,16 +1844,16 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as VerticalFit with wrapping.
-    QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-    QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+    QCOMPARE(myText->contentWidth(), verticalFitWidth);
+    QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1827,16 +1871,16 @@ void tst_qquicktext::fontSizeMode()
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
     // same size as without text wrapping.
-    QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-    QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+    QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+    QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with HorizontalFit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1845,9 +1889,9 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // VerticalFit should reduce the size to the wrapped text within the vertical height.
-    verticalFitHeight = myText->paintedHeight();
-    verticalFitWidth = myText->paintedWidth();
-    QVERIFY(myText->paintedWidth() <= myText->width() + 2);
+    verticalFitHeight = myText->contentHeight();
+    verticalFitWidth = myText->contentWidth();
+    QVERIFY(myText->contentWidth() <= myText->width() + 2);
     QVERIFY(verticalFitHeight <= myText->height() + 2);
     QVERIFY(verticalFitHeight < originalHeight);
 
@@ -1856,8 +1900,8 @@ void tst_qquicktext::fontSizeMode()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1866,16 +1910,16 @@ void tst_qquicktext::fontSizeMode()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as VerticalFit with wrapping.
-    QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-    QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+    QCOMPARE(myText->contentWidth(), verticalFitWidth);
+    QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1904,8 +1948,8 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setText(text);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
 
-    qreal originalWidth = myText->paintedWidth();
-    qreal originalHeight = myText->paintedHeight();
+    qreal originalWidth = myText->contentWidth();
+    qreal originalHeight = myText->contentHeight();
     QCOMPARE(myText->lineCount(), 2);
 
     // The original text unwrapped should exceed the width and height of the item.
@@ -1920,8 +1964,8 @@ void tst_qquicktext::fontSizeModeMultiline()
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Font size reduced to fit within the width of the item.
     QCOMPARE(myText->lineCount(), 2);
-    qreal horizontalFitWidth = myText->paintedWidth();
-    qreal horizontalFitHeight = myText->paintedHeight();
+    qreal horizontalFitWidth = myText->contentWidth();
+    qreal horizontalFitHeight = myText->contentHeight();
     QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
     QVERIFY(horizontalFitHeight > myText->height());
 
@@ -1931,21 +1975,21 @@ void tst_qquicktext::fontSizeModeMultiline()
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
         QCOMPARE(myText->lineCount(), 1);
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QVERIFY(myText->paintedHeight() <= myText->height() + 2);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QVERIFY(myText->contentHeight() <= myText->height() + 2);
 
         // Left or middle eliding wont have any effect.
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-        QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+        QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+        QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1954,8 +1998,8 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Font size reduced to fit within the height of the item.
-    qreal verticalFitWidth = myText->paintedWidth();
-    qreal verticalFitHeight = myText->paintedHeight();
+    qreal verticalFitWidth = myText->contentWidth();
+    qreal verticalFitHeight = myText->contentHeight();
     QVERIFY(verticalFitWidth <= myText->width() + 2);
     QVERIFY(verticalFitHeight <= myText->height() + 2);
 
@@ -1964,21 +2008,21 @@ void tst_qquicktext::fontSizeModeMultiline()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1987,28 +2031,28 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as VerticalFit with no wrapping.
-    QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-    QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+    QCOMPARE(myText->contentWidth(), verticalFitWidth);
+    QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideLeft);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideMiddle);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2018,8 +2062,8 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setWrapMode(QQuickText::Wrap);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
 
-    originalWidth = myText->paintedWidth();
-    originalHeight = myText->paintedHeight();
+    originalWidth = myText->contentWidth();
+    originalHeight = myText->contentHeight();
 
     // The original text wrapped should exceed the height of the item.
     QVERIFY(originalWidth <= myText->width() + 2);
@@ -2029,16 +2073,16 @@ void tst_qquicktext::fontSizeModeMultiline()
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
     // same size as without text wrapping.
-    QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-    QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+    QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+    QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
     if (canElide) {
         // Text will be elided vertically with HorizontalFit
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QVERIFY(myText->paintedHeight() <= myText->height() + 2);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QVERIFY(myText->contentHeight() <= myText->height() + 2);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2047,9 +2091,9 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // VerticalFit should reduce the size to the wrapped text within the vertical height.
-    verticalFitHeight = myText->paintedHeight();
-    verticalFitWidth = myText->paintedWidth();
-    QVERIFY(myText->paintedWidth() <= myText->width() + 2);
+    verticalFitHeight = myText->contentHeight();
+    verticalFitWidth = myText->contentWidth();
+    QVERIFY(myText->contentWidth() <= myText->width() + 2);
     QVERIFY(verticalFitHeight <= myText->height() + 2);
     QVERIFY(verticalFitHeight < originalHeight);
 
@@ -2058,8 +2102,8 @@ void tst_qquicktext::fontSizeModeMultiline()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2068,16 +2112,16 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as VerticalFit with wrapping.
-    QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-    QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+    QCOMPARE(myText->contentWidth(), verticalFitWidth);
+    QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2095,16 +2139,16 @@ void tst_qquicktext::fontSizeModeMultiline()
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
     // same size as without text wrapping.
-    QCOMPARE(myText->paintedWidth(), horizontalFitWidth);
-    QCOMPARE(myText->paintedHeight(), horizontalFitHeight);
+    QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+    QCOMPARE(myText->contentHeight(), horizontalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with HorizontalFit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(myText->truncated());
-        QVERIFY(myText->paintedWidth() <= myText->width() + 2);
-        QVERIFY(myText->paintedHeight() <= myText->height() + 2);
+        QVERIFY(myText->contentWidth() <= myText->width() + 2);
+        QVERIFY(myText->contentHeight() <= myText->height() + 2);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2113,9 +2157,9 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::VerticalFit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // VerticalFit should reduce the size to the wrapped text within the vertical height.
-    verticalFitHeight = myText->paintedHeight();
-    verticalFitWidth = myText->paintedWidth();
-    QVERIFY(myText->paintedWidth() <= myText->width() + 2);
+    verticalFitHeight = myText->contentHeight();
+    verticalFitWidth = myText->contentWidth();
+    QVERIFY(myText->contentWidth() <= myText->width() + 2);
     QVERIFY(verticalFitHeight <= myText->height() + 2);
     QVERIFY(verticalFitHeight < originalHeight);
 
@@ -2124,8 +2168,8 @@ void tst_qquicktext::fontSizeModeMultiline()
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2134,16 +2178,16 @@ void tst_qquicktext::fontSizeModeMultiline()
     myText->setFontSizeMode(QQuickText::Fit);
     QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
     // Should be the same as VerticalFit with wrapping.
-    QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-    QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+    QCOMPARE(myText->contentWidth(), verticalFitWidth);
+    QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
     if (canElide) {
         // Elide won't affect the size with Fit.
         myText->setElideMode(QQuickText::ElideRight);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
         QVERIFY(!myText->truncated());
-        QCOMPARE(myText->paintedWidth(), verticalFitWidth);
-        QCOMPARE(myText->paintedHeight(), verticalFitHeight);
+        QCOMPARE(myText->contentWidth(), verticalFitWidth);
+        QCOMPARE(myText->contentHeight(), verticalFitHeight);
 
         myText->setElideMode(QQuickText::ElideNone);
         QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
index 05ebfb8..a16f622 100644 (file)
@@ -150,6 +150,7 @@ private slots:
     void pastingRichText_QTBUG_14003();
     void implicitSize_data();
     void implicitSize();
+    void contentSize();
 
     void preeditCursorRectangle();
     void inputMethodComposing();
@@ -2420,6 +2421,34 @@ void tst_qquicktextedit::implicitSize()
     QVERIFY(textObject->height() == textObject->implicitHeight());
 }
 
+void tst_qquicktextedit::contentSize()
+{
+    QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }";
+    QDeclarativeComponent textComponent(&engine);
+    textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+    QScopedPointer<QObject> object(textComponent.create());
+    QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data());
+
+    QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+    textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() < textObject->height());
+    QCOMPARE(spy.count(), 1);
+
+    textObject->setWrapMode(QQuickTextEdit::WordWrap);
+    QVERIFY(textObject->contentWidth() <= textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), 2);
+
+    textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), 3);
+}
+
 void tst_qquicktextedit::preeditCursorRectangle()
 {
     QString preeditText = "super";
index 1be49a1..8cc8971 100644 (file)
@@ -156,6 +156,7 @@ private slots:
     void passwordEchoDelay();
 #endif
     void geometrySignals();
+    void contentSize();
 
     void preeditAutoScroll();
     void preeditCursorRectangle();
@@ -2842,6 +2843,34 @@ void tst_qquicktextinput::geometrySignals()
     delete o;
 }
 
+void tst_qquicktextinput::contentSize()
+{
+    QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }";
+    QDeclarativeComponent textComponent(&engine);
+    textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+    QScopedPointer<QObject> object(textComponent.create());
+    QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data());
+
+    QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+    textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() < textObject->height());
+    QCOMPARE(spy.count(), 1);
+
+    textObject->setWrapMode(QQuickTextInput::WordWrap);
+    QVERIFY(textObject->contentWidth() <= textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), 2);
+
+    textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+    QVERIFY(textObject->contentWidth() > textObject->width());
+    QVERIFY(textObject->contentHeight() > textObject->height());
+    QCOMPARE(spy.count(), 3);
+}
+
 static void sendPreeditText(const QString &text, int cursor)
 {
     QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()