WebKit Bugzilla
Attachment 362604 Details for
Bug 194815
: SVG Image intrinsic size should be used if css style size is 'auto'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Tentative Patch
0001-bug-194815.patch (text/plain), 4.32 KB, created by
Frédéric Wang (:fredw)
on 2019-02-21 07:15:16 PST
(
hide
)
Description:
Tentative Patch
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Created:
2019-02-21 07:15:16 PST
Size:
4.32 KB
patch
obsolete
>From 41a02281ce6dd97e4da4decc64e129db8382fff0 Mon Sep 17 00:00:00 2001 >From: Frederic Wang <fwang@igalia.com> >Date: Thu, 21 Feb 2019 15:52:18 +0100 >Subject: [PATCH xserver] bug 194815 > >--- > .../WebCore/rendering/svg/RenderSVGImage.cpp | 52 +++++++++++-------- > Source/WebCore/rendering/svg/RenderSVGImage.h | 2 + > 2 files changed, 33 insertions(+), 21 deletions(-) > >diff --git a/Source/WebCore/rendering/svg/RenderSVGImage.cpp b/Source/WebCore/rendering/svg/RenderSVGImage.cpp >index 2c6f3178eeb..48ae63176dc 100644 >--- a/Source/WebCore/rendering/svg/RenderSVGImage.cpp >+++ b/Source/WebCore/rendering/svg/RenderSVGImage.cpp >@@ -68,37 +68,47 @@ SVGImageElement& RenderSVGImage::imageElement() const > return downcast<SVGImageElement>(RenderSVGModelObject::element()); > } > >+static float resolveWidthForRatio(float height, const LayoutSize& intrinsicRatio) >+{ >+ return height * intrinsicRatio.width() / intrinsicRatio.height(); >+} >+ >+static float resolveHeightForRatio(float width, const LayoutSize& intrinsicRatio) { >+ return width * intrinsicRatio.height() / intrinsicRatio.width(); >+} >+ >+FloatSize RenderSVGImage::calculateObjectSize() const >+{ >+ auto* cachedImage = imageResource().cachedImage(); >+ if (!cachedImage) >+ return m_objectBoundingBox.size(); >+ >+ LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(nullptr, style().effectiveZoom()); >+ if (style().width().isAuto() && style().height().isAuto()) >+ return intrinsicSize; >+ >+ if (style().height().isAuto()) >+ return FloatSize(m_objectBoundingBox.width(), resolveHeightForRatio(m_objectBoundingBox.width(), intrinsicSize)); >+ >+ ASSERT(style().width().isAuto()); >+ return FloatSize(resolveWidthForRatio(m_objectBoundingBox.height(), intrinsicSize), m_objectBoundingBox.height()); >+} >+ > bool RenderSVGImage::updateImageViewport() > { > FloatRect oldBoundaries = m_objectBoundingBox; >- bool updatedViewport = false; >- > SVGLengthContext lengthContext(&imageElement()); > m_objectBoundingBox = FloatRect(imageElement().x().value(lengthContext), imageElement().y().value(lengthContext), imageElement().width().value(lengthContext), imageElement().height().value(lengthContext)); > >- URL imageSourceURL = document().completeURL(imageElement().imageSourceURL()); >- >- // Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved >- // by setting the image's container size to its intrinsic size. >- // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The âpreserveAspectRatioâ attribute. >- if (imageElement().preserveAspectRatio().align() == SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_NONE) { >- if (CachedImage* cachedImage = imageResource().cachedImage()) { >- LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(nullptr, style().effectiveZoom()); >- if (intrinsicSize != imageResource().imageSize(style().effectiveZoom())) { >- imageResource().setContainerContext(roundedIntSize(intrinsicSize), imageSourceURL); >- updatedViewport = true; >- } >- } >- } >+ if (style().width().isAuto() || style().height().isAuto()) >+ m_objectBoundingBox.setSize(calculateObjectSize()); > > if (oldBoundaries != m_objectBoundingBox) { >- if (!updatedViewport) >- imageResource().setContainerContext(enclosingIntRect(m_objectBoundingBox).size(), imageSourceURL); >- updatedViewport = true; >+ URL imageSourceURL = document().completeURL(imageElement().imageSourceURL()); >+ imageResource().setContainerContext(enclosingIntRect(m_objectBoundingBox).size(), imageSourceURL); > m_needsBoundariesUpdate = true; > } >- >- return updatedViewport; >+ return oldBoundaries.size() != m_objectBoundingBox.size(); > } > > void RenderSVGImage::layout() >diff --git a/Source/WebCore/rendering/svg/RenderSVGImage.h b/Source/WebCore/rendering/svg/RenderSVGImage.h >index 2a1c8a14c6b..eb3e6510f01 100644 >--- a/Source/WebCore/rendering/svg/RenderSVGImage.h >+++ b/Source/WebCore/rendering/svg/RenderSVGImage.h >@@ -80,6 +80,8 @@ private: > AffineTransform localTransform() const override { return m_localTransform; } > void calculateImageViewport(); > >+ FloatSize calculateObjectSize() const; >+ > bool m_needsBoundariesUpdate : 1; > bool m_needsTransformUpdate : 1; > AffineTransform m_localTransform; >-- >2.20.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194815
: 362604