Index: third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
index ae623aa5b06f2528997fc5596fae464094d7f11b..b7063c7228405b0614b6fa97cc31853a6154a762 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
@@ -603,7 +603,7 @@ bool HTMLImageElement::isInteractiveContent() const |
return fastHasAttribute(usemapAttr); |
} |
-PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint, SnapshotReason) const |
+PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint, SnapshotReason, const FloatSize& defaultObjectSize) const |
{ |
if (!complete() || !cachedImage()) { |
*status = IncompleteSourceImageStatus; |
@@ -617,8 +617,10 @@ PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageStatus* s |
RefPtr<Image> sourceImage; |
if (cachedImage()->image()->isSVGImage()) { |
- sourceImage = SVGImageForContainer::create(toSVGImage(cachedImage()->image()), |
- cachedImage()->image()->size(), 1, document().completeURL(imageSourceURL())); |
+ SVGImage* svgImage = toSVGImage(cachedImage()->image()); |
+ IntSize imageSize = roundedIntSize(svgImage->concreteObjectSize(defaultObjectSize)); |
+ sourceImage = SVGImageForContainer::create(svgImage, |
+ imageSize, 1, document().completeURL(imageSourceURL())); |
} else { |
sourceImage = cachedImage()->image(); |
} |
@@ -640,20 +642,27 @@ bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi |
return !image->isAccessAllowed(destinationSecurityOrigin); |
} |
-FloatSize HTMLImageElement::elementSize() const |
+FloatSize HTMLImageElement::elementSize(const FloatSize& defaultObjectSize) const |
{ |
ImageResource* image = cachedImage(); |
if (!image) |
return FloatSize(); |
+ if (image->image() && image->image()->isSVGImage()) |
+ return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObjectSize); |
+ |
return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f)); |
} |
-FloatSize HTMLImageElement::defaultDestinationSize() const |
+FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjectSize) const |
{ |
ImageResource* image = cachedImage(); |
if (!image) |
return FloatSize(); |
+ |
+ if (image->image() && image->image()->isSVGImage()) |
+ return toSVGImage(cachedImage()->image())->concreteObjectSize(defaultObjectSize); |
+ |
LayoutSize size; |
size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); |
if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !image->image()->hasRelativeSize()) |