Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: third_party/WebKit/Source/core/paint/SVGImagePainter.cpp

Issue 1720853002: Remove Image::computeIntrinsicDimensions() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-and-use-updateconcretesize-upload
Patch Set: Avoid using the size of the error image. Null-check in ImageResource saved the day in previous patc… Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp b/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
index 65e121ce7345319ceadab494cb45495067d68b47..885451b206915c0d8fe1ec0d0933be10b8758546 100644
--- a/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
+++ b/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
@@ -14,6 +14,7 @@
#include "core/paint/SVGPaintContext.h"
#include "core/paint/TransformRecorder.h"
#include "core/svg/SVGImageElement.h"
+#include "core/svg/graphics/SVGImage.h"
#include "platform/graphics/GraphicsContext.h"
#include "third_party/skia/include/core/SkPicture.h"
@@ -80,14 +81,20 @@ FloatSize SVGImagePainter::computeImageViewportSize() const
ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage();
- // Images with preserveAspectRatio=none should force non-uniform
- // scaling. This can be achieved by setting the image's container size to
- // its viewport size (i.e. if a viewBox is available - use that - else use intrinsic size.)
- // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRatio' attribute.
- FloatSize intrinsicSize;
- FloatSize intrinsicRatio;
- cachedImage->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio);
- return intrinsicRatio;
+ // Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved
+ // by setting the image's container size to its viewport size (i.e. concrete object size
+ // returned by the default sizing algorithm.) See
+ // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttribute and
+ // https://drafts.csswg.org/css-images-3/#default-sizing.
+
+ // Avoid returning the size of the broken image.
+ if (cachedImage->errorOccurred())
+ return FloatSize();
+
+ if (cachedImage->image()->isSVGImage())
+ return toSVGImage(cachedImage->image())->concreteObjectSize(m_layoutSVGImage.objectBoundingBox().size());
+
+ return FloatSize(cachedImage->image()->size());
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698