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

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

Issue 1732563007: [NOT FOR COMMIT] Pass defaultObjectSize to get image size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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..df90cfc039467bb72bf03e177e01fefd06e07805 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
@@ -439,7 +439,7 @@ int HTMLImageElement::width()
// if the image is available, use its width
if (imageLoader().image())
- return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), 1.0f).width();
+ return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::shouldRespectImageOrientation(nullptr), 1.0f).width();
}
LayoutBox* box = layoutBox();
@@ -460,7 +460,7 @@ int HTMLImageElement::height()
// if the image is available, use its height
if (imageLoader().image())
- return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), 1.0f).height();
+ return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::shouldRespectImageOrientation(nullptr), 1.0f).height();
}
LayoutBox* box = layoutBox();
@@ -472,7 +472,7 @@ int HTMLImageElement::naturalWidth() const
if (!imageLoader().image())
return 0;
- return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).width();
+ return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).width();
}
int HTMLImageElement::naturalHeight() const
@@ -480,7 +480,7 @@ int HTMLImageElement::naturalHeight() const
if (!imageLoader().image())
return 0;
- return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).height();
+ return imageLoader().image()->defaultConcreteObjectSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).height();
}
const String& HTMLImageElement::currentSrc() const
@@ -489,7 +489,7 @@ const String& HTMLImageElement::currentSrc() const
// The currentSrc IDL attribute must return the img element's current request's current URL.
// Initially, the pending request turns into current request when it is either available or broken.
// We use the image's dimensions as a proxy to it being in any of these states.
- if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoader().image()->image()->width())
+ if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoader().image()->image()->defaultConcreteObjectSizeWidth())
return emptyAtom;
return imageLoader().image()->url().string();
@@ -618,7 +618,7 @@ 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()));
+ cachedImage()->image()->defaultConcreteObjectSize(), 1, document().completeURL(imageSourceURL()));
} else {
sourceImage = cachedImage()->image();
}
@@ -640,22 +640,22 @@ 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();
- return FloatSize(image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f));
+ return FloatSize(image->concreteObjectSize(defaultObjectSize, LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f));
}
-FloatSize HTMLImageElement::defaultDestinationSize() const
+FloatSize HTMLImageElement::defaultDestinationSize(const FloatSize& defaultObjectSize) const
{
ImageResource* image = cachedImage();
if (!image)
return FloatSize();
LayoutSize size;
- size = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f);
+ size = image->concreteObjectSize(defaultObjectSize, LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f);
if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !image->image()->hasRelativeSize())
size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio());
return FloatSize(size);
@@ -813,7 +813,7 @@ IntSize HTMLImageElement::bitmapSourceSize() const
ImageResource* image = cachedImage();
if (!image)
return IntSize();
- LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f);
+ LayoutSize lSize = image->defaultConcreteObjectSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f);
ASSERT(lSize.fraction().isZero());
return IntSize(lSize.width(), lSize.height());
}
« 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