Commit 0f254514 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Replace trivial uses of ImageResourceContent::IntrinsicSize

For the cases where an Image has already been extracted from the
ImageResourceContent, call Image::Size(...) directly rather than calling
ImageResourceContent::IntrinsicSize since the latter only adds a null-
check.
De-duplicate ImageElementBase::DefaultDestinationSize() since it is
identical to ImageElementBase::ElementSize().
In ImageResourceContent::GetCompressionFormat(), there's no need to use
the Image::Size overload that takes a RespectImageOrientationEnum since
we only need to compute the area of the image - which is the same
regardless of orientation.

Bug: 773272
Change-Id: I9395ce9304827917d97d6e3cab209f09b4645b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010776Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#733935}
parent 5aa2f608
......@@ -81,31 +81,18 @@ bool ImageElementBase::WouldTaintOrigin() const {
FloatSize ImageElementBase::ElementSize(
const FloatSize& default_object_size) const {
ImageResourceContent* image_content = CachedImage();
if (!image_content)
if (!image_content || !image_content->HasImage())
return FloatSize();
Image* image = image_content->GetImage();
if (image->IsSVGImage())
return ToSVGImage(image)->ConcreteObjectSize(default_object_size);
return FloatSize(
image_content->IntrinsicSize(LayoutObject::ShouldRespectImageOrientation(
GetElement().GetLayoutObject())));
return FloatSize(image->Size(LayoutObject::ShouldRespectImageOrientation(
GetElement().GetLayoutObject())));
}
FloatSize ImageElementBase::DefaultDestinationSize(
const FloatSize& default_object_size) const {
ImageResourceContent* image_content = CachedImage();
if (!image_content)
return FloatSize();
Image* image = image_content->GetImage();
if (image->IsSVGImage())
return ToSVGImage(image)->ConcreteObjectSize(default_object_size);
return FloatSize(
image_content->IntrinsicSize(LayoutObject::ShouldRespectImageOrientation(
GetElement().GetLayoutObject())));
return ElementSize(default_object_size);
}
bool ImageElementBase::IsAccelerated() const {
......
......@@ -658,14 +658,14 @@ bool HTMLImageElement::IsInteractiveContent() const {
FloatSize HTMLImageElement::DefaultDestinationSize(
const FloatSize& default_object_size) const {
ImageResourceContent* image_content = CachedImage();
if (!image_content)
if (!image_content || !image_content->HasImage())
return FloatSize();
Image* image = image_content->GetImage();
if (image->IsSVGImage())
return ToSVGImage(image)->ConcreteObjectSize(default_object_size);
LayoutSize size(image_content->IntrinsicSize(
LayoutSize size(image->Size(
LayoutObject::ShouldRespectImageOrientation(GetLayoutObject())));
if (GetLayoutObject() && GetLayoutObject()->IsLayoutImage() &&
image->HasIntrinsicSize())
......
......@@ -514,7 +514,7 @@ bool ImageResourceContent::IsAcceptableCompressionRatio(
if (!image_)
return true;
uint64_t pixels = IntrinsicSize(kRespectImageOrientation).Area();
uint64_t pixels = image_->Size().Area();
if (!pixels)
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment