Commit e525a767 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Chromium LUCI CQ

Drop SVGImage::HasIntrinsicDimensions

This method is a bit special and only has a single user, so inline it
into that user. Clean up the related expression to make it a bit easier
to read and comprehend.

Bug: 789511

Change-Id: Ib0299a47f17b8c4b7381005a20a9c8d57f676ea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2579783
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#834821}
parent 1f786ddb
......@@ -120,6 +120,18 @@ IntSize ImageElementBase::BitmapSourceSize() const {
return image->IntrinsicSize(kDoNotRespectImageOrientation);
}
static bool HasDimensionsForImage(SVGImage* svg_image,
base::Optional<IntRect> crop_rect,
const ImageBitmapOptions* options) {
if (!svg_image->ConcreteObjectSize(FloatSize()).IsEmpty())
return true;
if (crop_rect)
return true;
if (options->hasResizeWidth() && options->hasResizeHeight())
return true;
return false;
}
ScriptPromise ImageElementBase::CreateImageBitmap(
ScriptState* script_state,
base::Optional<IntRect> crop_rect,
......@@ -132,11 +144,8 @@ ScriptPromise ImageElementBase::CreateImageBitmap(
"No image can be retrieved from the provided element.");
return ScriptPromise();
}
Image* image = image_content->GetImage();
if (auto* svg_image = DynamicTo<SVGImage>(image)) {
if (!svg_image->HasIntrinsicDimensions() &&
(!crop_rect &&
(!options->hasResizeWidth() || !options->hasResizeHeight()))) {
if (auto* svg_image = DynamicTo<SVGImage>(image_content->GetImage())) {
if (!HasDimensionsForImage(svg_image, crop_rect, options)) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidStateError,
"The image element contains an SVG image without intrinsic "
......
......@@ -282,10 +282,6 @@ static float ResolveHeightForRatio(float width,
return width * intrinsic_ratio.Height() / intrinsic_ratio.Width();
}
bool SVGImage::HasIntrinsicDimensions() const {
return !ConcreteObjectSize(FloatSize()).IsEmpty();
}
bool SVGImage::HasIntrinsicSizingInfo() const {
return LayoutRoot();
}
......
......@@ -109,12 +109,6 @@ class CORE_EXPORT SVGImage final : public Image {
// returns true if GetIntrinsicSizingInfo would.)
bool HasIntrinsicSizingInfo() const;
// Unlike the above (HasIntrinsicSizingInfo) - which only indicates that
// dimensions can be read - this returns true if those dimensions are not
// empty (i.e if the concrete object size resolved using an empty default
// object size is non-empty.)
bool HasIntrinsicDimensions() const;
PaintImage PaintImageForCurrentFrame() override;
protected:
......
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