summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2016-03-30 13:15:02 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2016-04-19 09:32:10 +0000
commit7094466f7d0c2176eb3080021a4ea5d220555df9 (patch)
treec1f633f1f3ce805a9af78c8e31e5f70ef6d29694 /src/gui/text/qtextdocument.cpp
parentb3fcaea5f2b97d3f562add97aee48cbb469c875a (diff)
Interpret fixed CSS line-height as minimum rather than absolute
The QTextBlockFormat::FixedHeight overrides the line height regardless of its calculated height. If the line contains objects or text which is higher than the specified line height, using FixedHeight will cause them to overlap with the previous line. This is not what happens in normal web browsers. The expected behavior is that the line height given in CSS is the minimum height, but that we still reserve space needed to display everything without overlaps. To make it possible for people to retain the old behavior, we introduce the -qt-line-height-type property, which allows them to override the default. This also fixes output from toHtml() to use the new property rather than set the minimum height of the paragraph or the "line-spacing" property, which does not exist in either CSS nor in Qt. [ChangeLog][QtGui][Important Behavior Changes] When line height is specified in pixels, this is now interpreted as the minimum line height rather than an absolute line height to avoid overlaps. To get the old behavior, use the -qt-line-height-type property in CSS and set it to "fixed". Task-number: QTBUG-51962 Change-Id: Ic2dde649b69209672170dad4c2de1e1c432a1078 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index f50f771c07..febd5da488 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2763,26 +2763,25 @@ void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block)
}
if (format.lineHeightType() != QTextBlockFormat::SingleHeight) {
+ html += QLatin1String(" line-height:")
+ + QString::number(format.lineHeight());
switch (format.lineHeightType()) {
case QTextBlockFormat::ProportionalHeight:
+ html += QLatin1String("%;");
+ break;
case QTextBlockFormat::FixedHeight:
- html += QLatin1String(" line-height:");
+ html += QLatin1String("; -qt-line-height-type: fixed;");
break;
case QTextBlockFormat::MinimumHeight:
- html += QLatin1String(" min-height:");
+ html += QLatin1String("px;");
break;
case QTextBlockFormat::LineDistanceHeight:
- html += QLatin1String(" line-spacing:");
+ html += QLatin1String("; -qt-line-height-type: line-distance;");
break;
- case QTextBlockFormat::SingleHeight:
default:
+ html += QLatin1String(";");
break; // Should never reach here
}
- html += QString::number(format.lineHeight());
- if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight)
- html += QLatin1String("%;");
- else
- html += QLatin1String("px;");
}
emitPageBreakPolicy(format.pageBreakPolicy());