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

Unified Diff: third_party/WebKit/Source/core/html/HTMLImageElement.cpp

Issue 1767633002: Support canvas size as default object size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-default-object-size
Patch Set: Save image size on stack Created 4 years, 10 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/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())
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLImageElement.h ('k') | third_party/WebKit/Source/core/html/HTMLVideoElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698