Commit 3ca35fa7 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Repurpose {Image,}HasRelativeSize and rename to HasIntrinsicSize

This renames:

  Image::HasRelativeSize,
  StyleImage::ImageHasRelativeSize and
  LayoutImageResource::ImageHasRelativeSize

to the common name HasIntrinsicSize.

This flips the meaning of this flag/method, but the new name is using a
term that is more relatable from a spec-perspective.

Change-Id: I2509926a186f8c81534800362becd585fb0bd024
Reviewed-on: https://chromium-review.googlesource.com/c/1488885
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635550}
parent ec3f5b0c
...@@ -714,7 +714,7 @@ FloatSize HTMLImageElement::DefaultDestinationSize( ...@@ -714,7 +714,7 @@ FloatSize HTMLImageElement::DefaultDestinationSize(
LayoutSize size(image_content->IntrinsicSize( LayoutSize size(image_content->IntrinsicSize(
LayoutObject::ShouldRespectImageOrientation(GetLayoutObject()))); LayoutObject::ShouldRespectImageOrientation(GetLayoutObject())));
if (GetLayoutObject() && GetLayoutObject()->IsLayoutImage() && if (GetLayoutObject() && GetLayoutObject()->IsLayoutImage() &&
!image->HasRelativeSize()) image->HasIntrinsicSize())
size.Scale(ToLayoutImage(GetLayoutObject())->ImageDevicePixelRatio()); size.Scale(ToLayoutImage(GetLayoutObject())->ImageDevicePixelRatio());
return FloatSize(size); return FloatSize(size);
} }
......
...@@ -413,8 +413,7 @@ void LayoutImage::ComputeIntrinsicSizingInfo( ...@@ -413,8 +413,7 @@ void LayoutImage::ComputeIntrinsicSizingInfo(
// Our intrinsicSize is empty if we're laying out generated images with // Our intrinsicSize is empty if we're laying out generated images with
// relative width/height. Figure out the right intrinsic size to use. // relative width/height. Figure out the right intrinsic size to use.
if (intrinsic_sizing_info.size.IsEmpty() && if (intrinsic_sizing_info.size.IsEmpty() &&
image_resource_->ImageHasRelativeSize() && !image_resource_->HasIntrinsicSize() && !IsLayoutNGListMarkerImage()) {
!IsLayoutNGListMarkerImage()) {
if (HasOverrideContainingBlockContentLogicalWidth() && if (HasOverrideContainingBlockContentLogicalWidth() &&
HasOverrideContainingBlockContentLogicalHeight()) { HasOverrideContainingBlockContentLogicalHeight()) {
intrinsic_sizing_info.size.SetWidth( intrinsic_sizing_info.size.SetWidth(
......
...@@ -89,8 +89,8 @@ void LayoutImageResource::ResetAnimation() { ...@@ -89,8 +89,8 @@ void LayoutImageResource::ResetAnimation() {
layout_object_->SetShouldDoFullPaintInvalidation(); layout_object_->SetShouldDoFullPaintInvalidation();
} }
bool LayoutImageResource::ImageHasRelativeSize() const { bool LayoutImageResource::HasIntrinsicSize() const {
return cached_image_ && cached_image_->GetImage()->HasRelativeSize(); return !cached_image_ || cached_image_->GetImage()->HasIntrinsicSize();
} }
FloatSize LayoutImageResource::ImageSize(float multiplier) const { FloatSize LayoutImageResource::ImageSize(float multiplier) const {
...@@ -98,7 +98,7 @@ FloatSize LayoutImageResource::ImageSize(float multiplier) const { ...@@ -98,7 +98,7 @@ FloatSize LayoutImageResource::ImageSize(float multiplier) const {
return FloatSize(); return FloatSize();
FloatSize size(cached_image_->IntrinsicSize( FloatSize size(cached_image_->IntrinsicSize(
LayoutObject::ShouldRespectImageOrientation(layout_object_))); LayoutObject::ShouldRespectImageOrientation(layout_object_)));
if (multiplier != 1 && !ImageHasRelativeSize()) { if (multiplier != 1 && HasIntrinsicSize()) {
// Don't let images that have a width/height >= 1 shrink below 1 when // Don't let images that have a width/height >= 1 shrink below 1 when
// zoomed. // zoomed.
FloatSize minimum_size(size.Width() > 0 ? 1 : 0, size.Height() > 0 ? 1 : 0); FloatSize minimum_size(size.Width() > 0 ? 1 : 0, size.Height() > 0 ? 1 : 0);
......
...@@ -66,7 +66,7 @@ class CORE_EXPORT LayoutImageResource ...@@ -66,7 +66,7 @@ class CORE_EXPORT LayoutImageResource
// the "broken image". // the "broken image".
void UseBrokenImage(); void UseBrokenImage();
virtual bool ImageHasRelativeSize() const; virtual bool HasIntrinsicSize() const;
virtual FloatSize ImageSize(float multiplier) const; virtual FloatSize ImageSize(float multiplier) const;
// Default size is effective when this is LayoutImageResourceStyleImage. // Default size is effective when this is LayoutImageResourceStyleImage.
......
...@@ -50,8 +50,8 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource { ...@@ -50,8 +50,8 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource {
scoped_refptr<Image> GetImage(const FloatSize&) const override; scoped_refptr<Image> GetImage(const FloatSize&) const override;
bool ErrorOccurred() const override { return style_image_->ErrorOccurred(); } bool ErrorOccurred() const override { return style_image_->ErrorOccurred(); }
bool ImageHasRelativeSize() const override { bool HasIntrinsicSize() const override {
return style_image_->ImageHasRelativeSize(); return style_image_->HasIntrinsicSize();
} }
FloatSize ImageSize(float multiplier) const override; FloatSize ImageSize(float multiplier) const override;
FloatSize ImageSizeWithDefaultSize(float multiplier, FloatSize ImageSizeWithDefaultSize(float multiplier,
......
...@@ -744,10 +744,11 @@ void BackgroundImageGeometry::CalculateFillTileSize( ...@@ -744,10 +744,11 @@ void BackgroundImageGeometry::CalculateFillTileSize(
StyleImage* image = fill_layer.GetImage(); StyleImage* image = fill_layer.GetImage();
EFillSizeType type = fill_layer.SizeType(); EFillSizeType type = fill_layer.SizeType();
// Tile size is snapped for relative sized images (typically generated // Tile size is snapped for images without intrinsic dimensions (typically
// content) and unsnapped for intrinsically sized content. Once we choose // generated content) and unsnapped for content that has intrinsic
// here we stop tracking whether the tile size is snapped or unsnapped. // dimensions. Once we choose here we stop tracking whether the tile size is
LayoutSize positioning_area_size = image->ImageHasRelativeSize() // snapped or unsnapped.
LayoutSize positioning_area_size = !image->HasIntrinsicSize()
? snapped_positioning_area_size ? snapped_positioning_area_size
: unsnapped_positioning_area_size; : unsnapped_positioning_area_size;
LayoutSize image_intrinsic_size(image->ImageSize( LayoutSize image_intrinsic_size(image->ImageSize(
...@@ -777,7 +778,7 @@ void BackgroundImageGeometry::CalculateFillTileSize( ...@@ -777,7 +778,7 @@ void BackgroundImageGeometry::CalculateFillTileSize(
// If one of the values is auto we have to use the appropriate // If one of the values is auto we have to use the appropriate
// scale to maintain our aspect ratio. // scale to maintain our aspect ratio.
if (layer_width.IsAuto() && !layer_height.IsAuto()) { if (layer_width.IsAuto() && !layer_height.IsAuto()) {
if (image->ImageHasRelativeSize()) { if (!image->HasIntrinsicSize()) {
// Spec says that auto should be 100% in the absence of // Spec says that auto should be 100% in the absence of
// an intrinsic ratio or size. // an intrinsic ratio or size.
tile_size_.SetWidth(positioning_area_size.Width()); tile_size_.SetWidth(positioning_area_size.Width());
...@@ -790,7 +791,7 @@ void BackgroundImageGeometry::CalculateFillTileSize( ...@@ -790,7 +791,7 @@ void BackgroundImageGeometry::CalculateFillTileSize(
tile_size_.SetWidth(LayoutUnit(adjusted_width)); tile_size_.SetWidth(LayoutUnit(adjusted_width));
} }
} else if (!layer_width.IsAuto() && layer_height.IsAuto()) { } else if (!layer_width.IsAuto() && layer_height.IsAuto()) {
if (image->ImageHasRelativeSize()) { if (!image->HasIntrinsicSize()) {
// Spec says that auto should be 100% in the absence of // Spec says that auto should be 100% in the absence of
// an intrinsic ratio or size. // an intrinsic ratio or size.
tile_size_.SetHeight(positioning_area_size.Height()); tile_size_.SetHeight(positioning_area_size.Height());
......
...@@ -374,7 +374,7 @@ void DrawTiledBackground(GraphicsContext& context, ...@@ -374,7 +374,7 @@ void DrawTiledBackground(GraphicsContext& context,
// generated image to be the tile size. // generated image to be the tile size.
FloatSize intrinsic_tile_size(image->Size()); FloatSize intrinsic_tile_size(image->Size());
FloatSize scale(1, 1); FloatSize scale(1, 1);
if (image->HasRelativeSize()) { if (!image->HasIntrinsicSize()) {
intrinsic_tile_size = tile_size; intrinsic_tile_size = tile_size;
} else { } else {
scale = FloatSize(tile_size.Width() / intrinsic_tile_size.Width(), scale = FloatSize(tile_size.Width() / intrinsic_tile_size.Width(),
...@@ -507,9 +507,9 @@ inline bool PaintFastBottomLayer(Node* node, ...@@ -507,9 +507,9 @@ inline bool PaintFastBottomLayer(Node* node,
// Generated images will be created at the desired tile size, so assume their // Generated images will be created at the desired tile size, so assume their
// intrinsic size is the requested tile size. // intrinsic size is the requested tile size.
bool is_generated_image = image->HasRelativeSize(); bool has_intrinsic_size = image->HasIntrinsicSize();
const FloatSize intrinsic_tile_size = const FloatSize intrinsic_tile_size =
is_generated_image ? image_tile.Size() : FloatSize(image->Size()); !has_intrinsic_size ? image_tile.Size() : FloatSize(image->Size());
// Subset computation needs the same location as was used with // Subset computation needs the same location as was used with
// ComputePhaseForBackground above, but needs the unsnapped destination // ComputePhaseForBackground above, but needs the unsnapped destination
// size to correctly calculate sprite subsets in the presence of zoom. But if // size to correctly calculate sprite subsets in the presence of zoom. But if
...@@ -517,8 +517,8 @@ inline bool PaintFastBottomLayer(Node* node, ...@@ -517,8 +517,8 @@ inline bool PaintFastBottomLayer(Node* node,
// snapped value), use the snapped dest rect instead. // snapped value), use the snapped dest rect instead.
FloatRect dest_rect_for_subset( FloatRect dest_rect_for_subset(
FloatPoint(geometry.SnappedDestRect().Location()), FloatPoint(geometry.SnappedDestRect().Location()),
is_generated_image ? FloatSize(geometry.SnappedDestRect().Size()) !has_intrinsic_size ? FloatSize(geometry.SnappedDestRect().Size())
: FloatSize(geometry.UnsnappedDestRect().Size())); : FloatSize(geometry.UnsnappedDestRect().Size()));
// Content providers almost always choose source pixels at integer locations, // Content providers almost always choose source pixels at integer locations,
// so snap to integers. This is particuarly important for sprite maps. // so snap to integers. This is particuarly important for sprite maps.
// Calculation up to this point, in LayoutUnits, can lead to small variations // Calculation up to this point, in LayoutUnits, can lead to small variations
......
...@@ -111,8 +111,8 @@ FloatSize StyleFetchedImage::ImageSize( ...@@ -111,8 +111,8 @@ FloatSize StyleFetchedImage::ImageSize(
return ApplyZoom(size, multiplier); return ApplyZoom(size, multiplier);
} }
bool StyleFetchedImage::ImageHasRelativeSize() const { bool StyleFetchedImage::HasIntrinsicSize() const {
return image_->GetImage()->HasRelativeSize(); return image_->GetImage()->HasIntrinsicSize();
} }
void StyleFetchedImage::AddClient(ImageResourceObserver* observer) { void StyleFetchedImage::AddClient(ImageResourceObserver* observer) {
......
...@@ -63,7 +63,7 @@ class StyleFetchedImage final : public StyleImage, ...@@ -63,7 +63,7 @@ class StyleFetchedImage final : public StyleImage,
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size) const override; const LayoutSize& default_object_size) const override;
bool ImageHasRelativeSize() const override; bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
void RemoveClient(ImageResourceObserver*) override; void RemoveClient(ImageResourceObserver*) override;
void ImageNotifyFinished(ImageResourceContent*) override; void ImageNotifyFinished(ImageResourceContent*) override;
......
...@@ -110,8 +110,8 @@ FloatSize StyleFetchedImageSet::ImageSize( ...@@ -110,8 +110,8 @@ FloatSize StyleFetchedImageSet::ImageSize(
return scaled_image_size; return scaled_image_size;
} }
bool StyleFetchedImageSet::ImageHasRelativeSize() const { bool StyleFetchedImageSet::HasIntrinsicSize() const {
return best_fit_image_->GetImage()->HasRelativeSize(); return best_fit_image_->GetImage()->HasIntrinsicSize();
} }
void StyleFetchedImageSet::AddClient(ImageResourceObserver* observer) { void StyleFetchedImageSet::AddClient(ImageResourceObserver* observer) {
......
...@@ -74,7 +74,7 @@ class StyleFetchedImageSet final : public StyleImage, ...@@ -74,7 +74,7 @@ class StyleFetchedImageSet final : public StyleImage,
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size) const override; const LayoutSize& default_object_size) const override;
bool ImageHasRelativeSize() const override; bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
void RemoveClient(ImageResourceObserver*) override; void RemoveClient(ImageResourceObserver*) override;
scoped_refptr<Image> GetImage(const ImageResourceObserver&, scoped_refptr<Image> GetImage(const ImageResourceObserver&,
......
...@@ -52,7 +52,7 @@ class CORE_EXPORT StyleGeneratedImage final : public StyleImage { ...@@ -52,7 +52,7 @@ class CORE_EXPORT StyleGeneratedImage final : public StyleImage {
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size) const override; const LayoutSize& default_object_size) const override;
bool ImageHasRelativeSize() const override { return !fixed_size_; } bool HasIntrinsicSize() const override { return fixed_size_; }
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
void RemoveClient(ImageResourceObserver*) override; void RemoveClient(ImageResourceObserver*) override;
// The |target_size| is the desired image size // The |target_size| is the desired image size
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
namespace blink { namespace blink {
FloatSize StyleImage::ApplyZoom(const FloatSize& size, float multiplier) const { FloatSize StyleImage::ApplyZoom(const FloatSize& size, float multiplier) const {
if (multiplier == 1.0f || ImageHasRelativeSize()) if (multiplier == 1.0f || !HasIntrinsicSize())
return size; return size;
float width = size.Width() * multiplier; float width = size.Width() * multiplier;
......
...@@ -89,8 +89,11 @@ class CORE_EXPORT StyleImage : public GarbageCollectedFinalized<StyleImage> { ...@@ -89,8 +89,11 @@ class CORE_EXPORT StyleImage : public GarbageCollectedFinalized<StyleImage> {
float multiplier, float multiplier,
const LayoutSize& default_object_size) const = 0; const LayoutSize& default_object_size) const = 0;
// The <image> does not have any intrinsic dimensions. // The <image> has intrinsic dimensions.
virtual bool ImageHasRelativeSize() const = 0; //
// If this returns false, then a call to ImageSize() is expected to return
// the |default_object_size| argument that it was passed unmodified.
virtual bool HasIntrinsicSize() const = 0;
virtual void AddClient(ImageResourceObserver*) = 0; virtual void AddClient(ImageResourceObserver*) = 0;
virtual void RemoveClient(ImageResourceObserver*) = 0; virtual void RemoveClient(ImageResourceObserver*) = 0;
......
...@@ -82,7 +82,7 @@ class StylePendingImage final : public StyleImage { ...@@ -82,7 +82,7 @@ class StylePendingImage final : public StyleImage {
const LayoutSize& /*defaultObjectSize*/) const override { const LayoutSize& /*defaultObjectSize*/) const override {
return FloatSize(); return FloatSize();
} }
bool ImageHasRelativeSize() const override { return false; } bool HasIntrinsicSize() const override { return true; }
void AddClient(ImageResourceObserver*) override {} void AddClient(ImageResourceObserver*) override {}
void RemoveClient(ImageResourceObserver*) override {} void RemoveClient(ImageResourceObserver*) override {}
scoped_refptr<Image> GetImage(const ImageResourceObserver&, scoped_refptr<Image> GetImage(const ImageResourceObserver&,
......
...@@ -71,7 +71,7 @@ class SVGImageForContainer final : public Image { ...@@ -71,7 +71,7 @@ class SVGImageForContainer final : public Image {
IntSize Size() const override; IntSize Size() const override;
bool HasRelativeSize() const override { return image_->HasRelativeSize(); } bool HasIntrinsicSize() const override { return image_->HasIntrinsicSize(); }
bool ApplyShader(cc::PaintFlags&, const SkMatrix& local_matrix) override; bool ApplyShader(cc::PaintFlags&, const SkMatrix& local_matrix) override;
......
...@@ -47,7 +47,7 @@ class PLATFORM_EXPORT CrossfadeGeneratedImage final : public GeneratedImage { ...@@ -47,7 +47,7 @@ class PLATFORM_EXPORT CrossfadeGeneratedImage final : public GeneratedImage {
percentage, crossfade_size, size)); percentage, crossfade_size, size));
} }
bool HasRelativeSize() const override { return false; } bool HasIntrinsicSize() const override { return true; }
IntSize Size() const override { return FlooredIntSize(crossfade_size_); } IntSize Size() const override { return FlooredIntSize(crossfade_size_); }
......
...@@ -36,7 +36,7 @@ class PLATFORM_EXPORT GeneratedImage : public Image { ...@@ -36,7 +36,7 @@ class PLATFORM_EXPORT GeneratedImage : public Image {
public: public:
bool CurrentFrameHasSingleSecurityOrigin() const override { return true; } bool CurrentFrameHasSingleSecurityOrigin() const override { return true; }
bool HasRelativeSize() const override { return true; } bool HasIntrinsicSize() const override { return false; }
IntSize Size() const override { return RoundedIntSize(size_); } IntSize Size() const override { return RoundedIntSize(size_); }
......
...@@ -106,7 +106,7 @@ class PLATFORM_EXPORT Image : public ThreadSafeRefCounted<Image> { ...@@ -106,7 +106,7 @@ class PLATFORM_EXPORT Image : public ThreadSafeRefCounted<Image> {
static Image* NullImage(); static Image* NullImage();
bool IsNull() const { return Size().IsEmpty(); } bool IsNull() const { return Size().IsEmpty(); }
virtual bool HasRelativeSize() const { return false; } virtual bool HasIntrinsicSize() const { return true; }
virtual IntSize Size() const = 0; virtual IntSize Size() const = 0;
IntRect Rect() const { return IntRect(IntPoint(), Size()); } IntRect Rect() const { return IntRect(IntPoint(), Size()); }
......
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