summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Engvoldsen <morten.engvoldsen@nokia.com>2010-05-31 11:47:30 (GMT)
committerMorten Engvoldsen <morten.engvoldsen@nokia.com>2010-05-31 11:47:30 (GMT)
commit8f9ca0b3c06b6003c2a956784742d17fdb3f1af5 (patch)
tree148db5e8a8209ecd9ee2f63840e730d52d8fcf3c
parent098eec2b9ba7218f1b595743476b73b61069d701 (diff)
parentb2244174dc4e1858954d7e21cf66bd010d7a8cb4 (diff)
downloadQt-8f9ca0b3c06b6003c2a956784742d17fdb3f1af5.zip
Qt-8f9ca0b3c06b6003c2a956784742d17fdb3f1af5.tar.gz
Qt-8f9ca0b3c06b6003c2a956784742d17fdb3f1af5.tar.bz2
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
-rw-r--r--src/gui/text/qtextlayout.cpp3
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp25
2 files changed, 27 insertions, 1 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index ce7915d..3f67408 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -858,7 +858,8 @@ QRectF QTextLayout::boundingRect() const
const QScriptLine &si = d->lines[i];
xmin = qMin(xmin, si.x);
ymin = qMin(ymin, si.y);
- xmax = qMax(xmax, si.x+qMax(si.width, si.textWidth));
+ QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth;
+ xmax = qMax(xmax, si.x+lineWidth);
// ### shouldn't the ascent be used in ymin???
ymax = qMax(ymax, si.y+si.height());
}
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index caf9bd3..1a5f493 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -110,6 +110,8 @@ private slots:
void longText();
void widthOfTabs();
void columnWrapWithTabs();
+ void boundingRectForUnsetLineWidth();
+ void boundingRectForSetLineWidth();
// QTextLine stuff
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
@@ -1307,6 +1309,29 @@ void tst_QTextLayout::columnWrapWithTabs()
}
+void tst_QTextLayout::boundingRectForUnsetLineWidth()
+{
+ QTextLayout layout("FOOBAR");
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth());
+}
+
+void tst_QTextLayout::boundingRectForSetLineWidth()
+{
+ QTextLayout layout("FOOBAR");
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(QFIXED_MAX - 1);
+ layout.endLayout();
+
+ QCOMPARE(layout.boundingRect().width(), qreal(QFIXED_MAX - 1));
+}
+
void tst_QTextLayout::lineWidthFromBOM()
{
const QString string(QChar(0xfeff)); // BYTE ORDER MARK