diff options
author | Frederik Christiani <frederik@vikingsoftware.com> | 2018-04-26 12:57:19 +0200 |
---|---|---|
committer | Frederik Juul Christiani <frederik@vikingsoftware.com> | 2018-04-30 10:37:22 +0000 |
commit | 0279e65c25b22066d15752267a6b5d1ba660e7d9 (patch) | |
tree | 1518b50abadb260a7d1fb2110e68248b678f16ad /src | |
parent | 1fd6226d52b8d3d201b117902ff1ecd84cc1a1e5 (diff) | |
download | qtsvg-0279e65c25b22066d15752267a6b5d1ba660e7d9.tar.gz |
Interpret width or height specified in percent as relative to viewport
When width or height is specified in percent, it is supposed to be
relative to the viewport.
https://www.w3.org/TR/SVG/coords.html#Units
Task-number: QTBUG-2279
Change-Id: Ia1597b88d4e1c705a6755db788a18cf790d5ee97
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/svg/qsvgtinydocument_p.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/svg/qsvgtinydocument_p.h b/src/svg/qsvgtinydocument_p.h index c69c5de..aa51751 100644 --- a/src/svg/qsvgtinydocument_p.h +++ b/src/svg/qsvgtinydocument_p.h @@ -141,11 +141,14 @@ private: inline QSize QSvgTinyDocument::size() const { - if (m_size.isEmpty()) { + if (m_size.isEmpty()) return viewBox().size().toSize(); - } else { - return m_size; + if (m_widthPercent || m_heightPercent) { + const int width = m_widthPercent ? qRound(0.01 * m_size.width() * viewBox().size().width()) : m_size.width(); + const int height = m_heightPercent ? qRound(0.01 * m_size.height() * viewBox().size().height()) : m_size.height(); + return QSize(width, height); } + return m_size; } inline int QSvgTinyDocument::width() const |