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

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

Issue 1367193003: NOT FOR LANDING Allocate SVGImageForContainer on demand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some NeedsRebaseline and revived some LayoutListMarker code that turned out to be important Created 5 years, 2 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 f6da1bc6dc0161c5e9b47fcef3d879af9bf922b4..7118746d4f600518142fd978de34961c18fa0bd6 100644
--- a/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
+++ b/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "core/paint/SVGImagePainter.h"
+#include "core/html/parser/HTMLParserIdioms.h"
#include "core/layout/ImageQualityController.h"
#include "core/layout/LayoutImageResource.h"
#include "core/layout/svg/LayoutSVGImage.h"
@@ -15,6 +16,7 @@
#include "core/paint/SVGPaintContext.h"
#include "core/paint/TransformRecorder.h"
#include "core/svg/SVGImageElement.h"
+#include "core/svg/graphics/SVGImageForContainer.h"
#include "platform/graphics/GraphicsContext.h"
#include "third_party/skia/include/core/SkPicture.h"
@@ -51,11 +53,23 @@ void SVGImagePainter::paint(const PaintInfo& paintInfo)
void SVGImagePainter::paintForeground(const PaintInfo& paintInfo)
{
- RefPtr<Image> image = m_layoutSVGImage.imageResource()->image();
+ const LayoutImageResource* imageResource = m_layoutSVGImage.imageResource();
+ ImageResource* cachedImage = imageResource->cachedImage();
+ IntSize imageViewportSize;
+ if (cachedImage)
+ imageViewportSize = expandedIntSize(m_layoutSVGImage.computeImageViewportSize(*cachedImage));
+ if (imageViewportSize.isEmpty())
+ return;
+ SVGImageElement* imageElement = toSVGImageElement(m_layoutSVGImage.element());
+ KURL url;
+ AtomicString urlString = imageElement->imageSourceURL();
+ if (!urlString.isEmpty())
+ url = imageElement->document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
+
+ RefPtr<Image> image = imageResource->image(imageViewportSize, m_layoutSVGImage.style()->effectiveZoom(), url);
FloatRect destRect = m_layoutSVGImage.objectBoundingBox();
FloatRect srcRect(0, 0, image->width(), image->height());
- SVGImageElement* imageElement = toSVGImageElement(m_layoutSVGImage.element());
imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect, srcRect);
InterpolationQuality interpolationQuality = InterpolationDefault;

Powered by Google App Engine
This is Rietveld 408576698