From 0279e65c25b22066d15752267a6b5d1ba660e7d9 Mon Sep 17 00:00:00 2001 From: Frederik Christiani Date: Thu, 26 Apr 2018 12:57:19 +0200 Subject: 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 Reviewed-by: Eirik Aavitsland --- src/svg/qsvgtinydocument_p.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.1