Commit 188bd174 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Change StyleImage::ImageSize()'s input size type from LayoutSize to FloatSize

Normally we should avoid layout geometry types (LayoutRect, LayoutSize,
etc.) outside of layout and paint. We also plan to deprecate them by
Physical/Logical geometry types in layout/paint.

This can avoid the layout system directly passing a size in logical
coordinates to StyleImage. Also keeps consistency with other geometries
in StyleImage.

Change-Id: I8b8305e5a0377f525de9b3fbbbf288380f36119f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2294337
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787747}
parent 315f4c9d
...@@ -43,9 +43,10 @@ ...@@ -43,9 +43,10 @@
namespace blink { namespace blink {
class ExceptionState;
class HTMLFormElement; class HTMLFormElement;
class ImageCandidate; class ImageCandidate;
class ExceptionState; class LayoutSize;
class ShadowRoot; class ShadowRoot;
class CORE_EXPORT HTMLImageElement final class CORE_EXPORT HTMLImageElement final
......
...@@ -118,7 +118,7 @@ FloatSize LayoutImageResource::ImageSize(float multiplier) const { ...@@ -118,7 +118,7 @@ FloatSize LayoutImageResource::ImageSize(float multiplier) const {
FloatSize LayoutImageResource::ImageSizeWithDefaultSize( FloatSize LayoutImageResource::ImageSizeWithDefaultSize(
float multiplier, float multiplier,
const LayoutSize&) const { const FloatSize&) const {
return ImageSize(multiplier); return ImageSize(multiplier);
} }
......
...@@ -67,7 +67,7 @@ class CORE_EXPORT LayoutImageResource ...@@ -67,7 +67,7 @@ class CORE_EXPORT LayoutImageResource
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.
virtual FloatSize ImageSizeWithDefaultSize(float multiplier, virtual FloatSize ImageSizeWithDefaultSize(float multiplier,
const LayoutSize&) const; const FloatSize&) const;
virtual WrappedImagePtr ImagePtr() const { return cached_image_.Get(); } virtual WrappedImagePtr ImagePtr() const { return cached_image_.Get(); }
virtual void Trace(Visitor* visitor) const { visitor->Trace(cached_image_); } virtual void Trace(Visitor* visitor) const { visitor->Trace(cached_image_); }
......
...@@ -71,17 +71,17 @@ scoped_refptr<Image> LayoutImageResourceStyleImage::GetImage( ...@@ -71,17 +71,17 @@ scoped_refptr<Image> LayoutImageResourceStyleImage::GetImage(
FloatSize LayoutImageResourceStyleImage::ImageSize(float multiplier) const { FloatSize LayoutImageResourceStyleImage::ImageSize(float multiplier) const {
// TODO(davve): Find out the correct default object size in this context. // TODO(davve): Find out the correct default object size in this context.
LayoutSize default_size = FloatSize default_size =
layout_object_->IsListMarkerImage() layout_object_->IsListMarkerImage()
? ToLayoutListMarkerImage(layout_object_)->DefaultSize() ? FloatSize(ToLayoutListMarkerImage(layout_object_)->DefaultSize())
: LayoutSize(LayoutReplaced::kDefaultWidth, : FloatSize(LayoutReplaced::kDefaultWidth,
LayoutReplaced::kDefaultHeight); LayoutReplaced::kDefaultHeight);
return ImageSizeWithDefaultSize(multiplier, default_size); return ImageSizeWithDefaultSize(multiplier, default_size);
} }
FloatSize LayoutImageResourceStyleImage::ImageSizeWithDefaultSize( FloatSize LayoutImageResourceStyleImage::ImageSizeWithDefaultSize(
float multiplier, float multiplier,
const LayoutSize& default_size) const { const FloatSize& default_size) const {
return style_image_->ImageSize( return style_image_->ImageSize(
layout_object_->GetDocument(), multiplier, default_size, layout_object_->GetDocument(), multiplier, default_size,
LayoutObject::ShouldRespectImageOrientation(layout_object_)); LayoutObject::ShouldRespectImageOrientation(layout_object_));
......
...@@ -52,7 +52,7 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource { ...@@ -52,7 +52,7 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource {
} }
FloatSize ImageSize(float multiplier) const override; FloatSize ImageSize(float multiplier) const override;
FloatSize ImageSizeWithDefaultSize(float multiplier, FloatSize ImageSizeWithDefaultSize(float multiplier,
const LayoutSize&) const override; const FloatSize&) const override;
WrappedImagePtr ImagePtr() const override { return style_image_->Data(); } WrappedImagePtr ImagePtr() const override { return style_image_->Data(); }
void Trace(Visitor*) const override; void Trace(Visitor*) const override;
......
...@@ -67,11 +67,10 @@ LayoutSize LayoutListMarker::ImageBulletSize() const { ...@@ -67,11 +67,10 @@ LayoutSize LayoutListMarker::ImageBulletSize() const {
// markers really won't become particularly useful until we support the CSS3 // markers really won't become particularly useful until we support the CSS3
// marker pseudoclass to allow control over the width and height of the // marker pseudoclass to allow control over the width and height of the
// marker box. // marker box.
LayoutUnit bullet_width = float bullet_width = font_data->GetFontMetrics().Ascent() / 2.0f;
font_data->GetFontMetrics().Ascent() / LayoutUnit(2);
return RoundedLayoutSize( return RoundedLayoutSize(
image_->ImageSize(GetDocument(), StyleRef().EffectiveZoom(), image_->ImageSize(GetDocument(), StyleRef().EffectiveZoom(),
LayoutSize(bullet_width, bullet_width), FloatSize(bullet_width, bullet_width),
LayoutObject::ShouldRespectImageOrientation(this))); LayoutObject::ShouldRespectImageOrientation(this)));
} }
......
...@@ -40,7 +40,7 @@ LayoutSize LayoutListMarkerImage::DefaultSize() const { ...@@ -40,7 +40,7 @@ LayoutSize LayoutListMarkerImage::DefaultSize() const {
void LayoutListMarkerImage::ComputeIntrinsicSizingInfoByDefaultSize( void LayoutListMarkerImage::ComputeIntrinsicSizingInfoByDefaultSize(
IntrinsicSizingInfo& intrinsic_sizing_info) const { IntrinsicSizingInfo& intrinsic_sizing_info) const {
FloatSize concrete_size = ImageResource()->ImageSizeWithDefaultSize( FloatSize concrete_size = ImageResource()->ImageSizeWithDefaultSize(
Style()->EffectiveZoom(), DefaultSize()); Style()->EffectiveZoom(), FloatSize(DefaultSize()));
concrete_size.Scale(ImageDevicePixelRatio()); concrete_size.Scale(ImageDevicePixelRatio());
LayoutSize image_size(RoundedLayoutSize(concrete_size)); LayoutSize image_size(RoundedLayoutSize(concrete_size));
......
...@@ -189,7 +189,7 @@ std::unique_ptr<Shape> ShapeOutsideInfo::CreateShapeForImage( ...@@ -189,7 +189,7 @@ std::unique_ptr<Shape> ShapeOutsideInfo::CreateShapeForImage(
DCHECK(!style_image->IsPendingImage()); DCHECK(!style_image->IsPendingImage());
const LayoutSize& image_size = RoundedLayoutSize(style_image->ImageSize( const LayoutSize& image_size = RoundedLayoutSize(style_image->ImageSize(
layout_box_.GetDocument(), layout_box_.StyleRef().EffectiveZoom(), layout_box_.GetDocument(), layout_box_.StyleRef().EffectiveZoom(),
reference_box_logical_size_, FloatSize(reference_box_logical_size_),
LayoutObject::ShouldRespectImageOrientation(&layout_box_))); LayoutObject::ShouldRespectImageOrientation(&layout_box_)));
const LayoutRect& margin_rect = const LayoutRect& margin_rect =
......
...@@ -717,7 +717,7 @@ void BackgroundImageGeometry::CalculateFillTileSize( ...@@ -717,7 +717,7 @@ void BackgroundImageGeometry::CalculateFillTileSize(
PhysicalSize image_intrinsic_size = PhysicalSize::FromFloatSizeFloor( PhysicalSize image_intrinsic_size = PhysicalSize::FromFloatSizeFloor(
image->ImageSize(positioning_box_.GetDocument(), image->ImageSize(positioning_box_.GetDocument(),
positioning_box_.StyleRef().EffectiveZoom(), positioning_box_.StyleRef().EffectiveZoom(),
positioning_area_size.ToLayoutSize(), FloatSize(positioning_area_size),
LayoutObject::ShouldRespectImageOrientation(&box_))); LayoutObject::ShouldRespectImageOrientation(&box_)));
switch (type) { switch (type) {
case EFillSizeType::kSizeLength: { case EFillSizeType::kSizeLength: {
......
...@@ -178,7 +178,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context, ...@@ -178,7 +178,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context,
// are scaled to effective zoom instead so we must take care not to cause // are scaled to effective zoom instead so we must take care not to cause
// scale of them again. // scale of them again.
IntSize image_size = RoundedIntSize( IntSize image_size = RoundedIntSize(
style_image->ImageSize(document, 1, border_image_rect.size.ToLayoutSize(), style_image->ImageSize(document, 1, FloatSize(border_image_rect.size),
kRespectImageOrientation)); kRespectImageOrientation));
scoped_refptr<Image> image = scoped_refptr<Image> image =
style_image->GetImage(observer, document, style, FloatSize(image_size)); style_image->GetImage(observer, document, style, FloatSize(image_size));
......
...@@ -391,7 +391,7 @@ bool FillLayer::ImageIsOpaque(const Document& document, ...@@ -391,7 +391,7 @@ bool FillLayer::ImageIsOpaque(const Document& document,
// checking for IsEmpty. // checking for IsEmpty.
return image_->KnownToBeOpaque(document, style) && return image_->KnownToBeOpaque(document, style) &&
!image_ !image_
->ImageSize(document, style.EffectiveZoom(), LayoutSize(), ->ImageSize(document, style.EffectiveZoom(), FloatSize(),
kRespectImageOrientation) kRespectImageOrientation)
.IsEmpty(); .IsEmpty();
} }
......
...@@ -109,7 +109,7 @@ bool StyleFetchedImage::ErrorOccurred() const { ...@@ -109,7 +109,7 @@ bool StyleFetchedImage::ErrorOccurred() const {
FloatSize StyleFetchedImage::ImageSize( FloatSize StyleFetchedImage::ImageSize(
const Document&, const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum respect_orientation) const { RespectImageOrientationEnum respect_orientation) const {
Image* image = image_->GetImage(); Image* image = image_->GetImage();
if (image_->HasDevicePixelRatioHeaderValue()) { if (image_->HasDevicePixelRatioHeaderValue()) {
......
...@@ -57,7 +57,7 @@ class StyleFetchedImage final : public StyleImage, ...@@ -57,7 +57,7 @@ class StyleFetchedImage final : public StyleImage,
bool ErrorOccurred() const override; bool ErrorOccurred() const override;
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum) const override; RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override; bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
......
...@@ -96,7 +96,7 @@ bool StyleFetchedImageSet::ErrorOccurred() const { ...@@ -96,7 +96,7 @@ bool StyleFetchedImageSet::ErrorOccurred() const {
FloatSize StyleFetchedImageSet::ImageSize( FloatSize StyleFetchedImageSet::ImageSize(
const Document&, const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum respect_orientation) const { RespectImageOrientationEnum respect_orientation) const {
Image* image = best_fit_image_->GetImage(); Image* image = best_fit_image_->GetImage();
if (auto* svg_image = DynamicTo<SVGImage>(image)) { if (auto* svg_image = DynamicTo<SVGImage>(image)) {
......
...@@ -67,7 +67,7 @@ class StyleFetchedImageSet final : public StyleImage, ...@@ -67,7 +67,7 @@ class StyleFetchedImageSet final : public StyleImage,
bool ErrorOccurred() const override; bool ErrorOccurred() const override;
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum) const override; RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override; bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
......
...@@ -57,17 +57,17 @@ CSSValue* StyleGeneratedImage::ComputedCSSValue( ...@@ -57,17 +57,17 @@ CSSValue* StyleGeneratedImage::ComputedCSSValue(
FloatSize StyleGeneratedImage::ImageSize(const Document& document, FloatSize StyleGeneratedImage::ImageSize(const Document& document,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum) const { RespectImageOrientationEnum) const {
if (fixed_size_) { if (fixed_size_) {
FloatSize unzoomed_default_object_size(default_object_size); FloatSize unzoomed_default_object_size = default_object_size;
unzoomed_default_object_size.Scale(1 / multiplier); unzoomed_default_object_size.Scale(1 / multiplier);
return ApplyZoom(FloatSize(image_generator_value_->FixedSize( return ApplyZoom(FloatSize(image_generator_value_->FixedSize(
document, unzoomed_default_object_size)), document, unzoomed_default_object_size)),
multiplier); multiplier);
} }
return FloatSize(default_object_size); return default_object_size;
} }
void StyleGeneratedImage::AddClient(ImageResourceObserver* observer) { void StyleGeneratedImage::AddClient(ImageResourceObserver* observer) {
......
...@@ -49,7 +49,7 @@ class CORE_EXPORT StyleGeneratedImage final : public StyleImage { ...@@ -49,7 +49,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 FloatSize& default_object_size,
RespectImageOrientationEnum) const override; RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override { return fixed_size_; } bool HasIntrinsicSize() const override { return fixed_size_; }
void AddClient(ImageResourceObserver*) override; void AddClient(ImageResourceObserver*) override;
......
...@@ -30,8 +30,8 @@ FloatSize StyleImage::ApplyZoom(const FloatSize& size, float multiplier) const { ...@@ -30,8 +30,8 @@ FloatSize StyleImage::ApplyZoom(const FloatSize& size, float multiplier) const {
FloatSize StyleImage::ImageSizeForSVGImage( FloatSize StyleImage::ImageSizeForSVGImage(
SVGImage* svg_image, SVGImage* svg_image,
float multiplier, float multiplier,
const LayoutSize& default_object_size) const { const FloatSize& default_object_size) const {
FloatSize unzoomed_default_object_size(default_object_size); FloatSize unzoomed_default_object_size = default_object_size;
unzoomed_default_object_size.Scale(1 / multiplier); unzoomed_default_object_size.Scale(1 / multiplier);
return ApplyZoom(svg_image->ConcreteObjectSize(unzoomed_default_object_size), return ApplyZoom(svg_image->ConcreteObjectSize(unzoomed_default_object_size),
multiplier); multiplier);
......
...@@ -35,7 +35,6 @@ class CSSValue; ...@@ -35,7 +35,6 @@ class CSSValue;
class FloatSize; class FloatSize;
class Image; class Image;
class ImageResourceContent; class ImageResourceContent;
class LayoutSize;
class SVGImage; class SVGImage;
class Document; class Document;
class ComputedStyle; class ComputedStyle;
...@@ -92,7 +91,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> { ...@@ -92,7 +91,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> {
// supports it. // supports it.
virtual FloatSize ImageSize(const Document&, virtual FloatSize ImageSize(const Document&,
float multiplier, float multiplier,
const LayoutSize& default_object_size, const FloatSize& default_object_size,
RespectImageOrientationEnum) const = 0; RespectImageOrientationEnum) const = 0;
// The <image> has intrinsic dimensions. // The <image> has intrinsic dimensions.
...@@ -168,7 +167,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> { ...@@ -168,7 +167,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> {
FloatSize ApplyZoom(const FloatSize&, float multiplier) const; FloatSize ApplyZoom(const FloatSize&, float multiplier) const;
FloatSize ImageSizeForSVGImage(SVGImage*, FloatSize ImageSizeForSVGImage(SVGImage*,
float multiplier, float multiplier,
const LayoutSize& default_object_size) const; const FloatSize& default_object_size) const;
}; };
} // namespace blink } // namespace blink
......
...@@ -71,8 +71,8 @@ class StylePendingImage final : public StyleImage { ...@@ -71,8 +71,8 @@ class StylePendingImage final : public StyleImage {
} }
FloatSize ImageSize(const Document&, FloatSize ImageSize(const Document&,
float /*multiplier*/, float,
const LayoutSize& /*defaultObjectSize*/, const FloatSize&,
RespectImageOrientationEnum) const override { RespectImageOrientationEnum) const override {
return FloatSize(); return FloatSize();
} }
......
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