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 @@
namespace blink {
class ExceptionState;
class HTMLFormElement;
class ImageCandidate;
class ExceptionState;
class LayoutSize;
class ShadowRoot;
class CORE_EXPORT HTMLImageElement final
......
......@@ -118,7 +118,7 @@ FloatSize LayoutImageResource::ImageSize(float multiplier) const {
FloatSize LayoutImageResource::ImageSizeWithDefaultSize(
float multiplier,
const LayoutSize&) const {
const FloatSize&) const {
return ImageSize(multiplier);
}
......
......@@ -67,7 +67,7 @@ class CORE_EXPORT LayoutImageResource
virtual FloatSize ImageSize(float multiplier) const;
// Default size is effective when this is LayoutImageResourceStyleImage.
virtual FloatSize ImageSizeWithDefaultSize(float multiplier,
const LayoutSize&) const;
const FloatSize&) const;
virtual WrappedImagePtr ImagePtr() const { return cached_image_.Get(); }
virtual void Trace(Visitor* visitor) const { visitor->Trace(cached_image_); }
......
......@@ -71,17 +71,17 @@ scoped_refptr<Image> LayoutImageResourceStyleImage::GetImage(
FloatSize LayoutImageResourceStyleImage::ImageSize(float multiplier) const {
// TODO(davve): Find out the correct default object size in this context.
LayoutSize default_size =
FloatSize default_size =
layout_object_->IsListMarkerImage()
? ToLayoutListMarkerImage(layout_object_)->DefaultSize()
: LayoutSize(LayoutReplaced::kDefaultWidth,
LayoutReplaced::kDefaultHeight);
? FloatSize(ToLayoutListMarkerImage(layout_object_)->DefaultSize())
: FloatSize(LayoutReplaced::kDefaultWidth,
LayoutReplaced::kDefaultHeight);
return ImageSizeWithDefaultSize(multiplier, default_size);
}
FloatSize LayoutImageResourceStyleImage::ImageSizeWithDefaultSize(
float multiplier,
const LayoutSize& default_size) const {
const FloatSize& default_size) const {
return style_image_->ImageSize(
layout_object_->GetDocument(), multiplier, default_size,
LayoutObject::ShouldRespectImageOrientation(layout_object_));
......
......@@ -52,7 +52,7 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource {
}
FloatSize ImageSize(float multiplier) const override;
FloatSize ImageSizeWithDefaultSize(float multiplier,
const LayoutSize&) const override;
const FloatSize&) const override;
WrappedImagePtr ImagePtr() const override { return style_image_->Data(); }
void Trace(Visitor*) const override;
......
......@@ -67,11 +67,10 @@ LayoutSize LayoutListMarker::ImageBulletSize() const {
// 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 box.
LayoutUnit bullet_width =
font_data->GetFontMetrics().Ascent() / LayoutUnit(2);
float bullet_width = font_data->GetFontMetrics().Ascent() / 2.0f;
return RoundedLayoutSize(
image_->ImageSize(GetDocument(), StyleRef().EffectiveZoom(),
LayoutSize(bullet_width, bullet_width),
FloatSize(bullet_width, bullet_width),
LayoutObject::ShouldRespectImageOrientation(this)));
}
......
......@@ -40,7 +40,7 @@ LayoutSize LayoutListMarkerImage::DefaultSize() const {
void LayoutListMarkerImage::ComputeIntrinsicSizingInfoByDefaultSize(
IntrinsicSizingInfo& intrinsic_sizing_info) const {
FloatSize concrete_size = ImageResource()->ImageSizeWithDefaultSize(
Style()->EffectiveZoom(), DefaultSize());
Style()->EffectiveZoom(), FloatSize(DefaultSize()));
concrete_size.Scale(ImageDevicePixelRatio());
LayoutSize image_size(RoundedLayoutSize(concrete_size));
......
......@@ -189,7 +189,7 @@ std::unique_ptr<Shape> ShapeOutsideInfo::CreateShapeForImage(
DCHECK(!style_image->IsPendingImage());
const LayoutSize& image_size = RoundedLayoutSize(style_image->ImageSize(
layout_box_.GetDocument(), layout_box_.StyleRef().EffectiveZoom(),
reference_box_logical_size_,
FloatSize(reference_box_logical_size_),
LayoutObject::ShouldRespectImageOrientation(&layout_box_)));
const LayoutRect& margin_rect =
......
......@@ -717,7 +717,7 @@ void BackgroundImageGeometry::CalculateFillTileSize(
PhysicalSize image_intrinsic_size = PhysicalSize::FromFloatSizeFloor(
image->ImageSize(positioning_box_.GetDocument(),
positioning_box_.StyleRef().EffectiveZoom(),
positioning_area_size.ToLayoutSize(),
FloatSize(positioning_area_size),
LayoutObject::ShouldRespectImageOrientation(&box_)));
switch (type) {
case EFillSizeType::kSizeLength: {
......
......@@ -178,7 +178,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context,
// are scaled to effective zoom instead so we must take care not to cause
// scale of them again.
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));
scoped_refptr<Image> image =
style_image->GetImage(observer, document, style, FloatSize(image_size));
......
......@@ -391,7 +391,7 @@ bool FillLayer::ImageIsOpaque(const Document& document,
// checking for IsEmpty.
return image_->KnownToBeOpaque(document, style) &&
!image_
->ImageSize(document, style.EffectiveZoom(), LayoutSize(),
->ImageSize(document, style.EffectiveZoom(), FloatSize(),
kRespectImageOrientation)
.IsEmpty();
}
......
......@@ -109,7 +109,7 @@ bool StyleFetchedImage::ErrorOccurred() const {
FloatSize StyleFetchedImage::ImageSize(
const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum respect_orientation) const {
Image* image = image_->GetImage();
if (image_->HasDevicePixelRatioHeaderValue()) {
......
......@@ -57,7 +57,7 @@ class StyleFetchedImage final : public StyleImage,
bool ErrorOccurred() const override;
FloatSize ImageSize(const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override;
......
......@@ -96,7 +96,7 @@ bool StyleFetchedImageSet::ErrorOccurred() const {
FloatSize StyleFetchedImageSet::ImageSize(
const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum respect_orientation) const {
Image* image = best_fit_image_->GetImage();
if (auto* svg_image = DynamicTo<SVGImage>(image)) {
......
......@@ -67,7 +67,7 @@ class StyleFetchedImageSet final : public StyleImage,
bool ErrorOccurred() const override;
FloatSize ImageSize(const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override;
void AddClient(ImageResourceObserver*) override;
......
......@@ -57,17 +57,17 @@ CSSValue* StyleGeneratedImage::ComputedCSSValue(
FloatSize StyleGeneratedImage::ImageSize(const Document& document,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum) const {
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);
return ApplyZoom(FloatSize(image_generator_value_->FixedSize(
document, unzoomed_default_object_size)),
multiplier);
}
return FloatSize(default_object_size);
return default_object_size;
}
void StyleGeneratedImage::AddClient(ImageResourceObserver* observer) {
......
......@@ -49,7 +49,7 @@ class CORE_EXPORT StyleGeneratedImage final : public StyleImage {
FloatSize ImageSize(const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum) const override;
bool HasIntrinsicSize() const override { return fixed_size_; }
void AddClient(ImageResourceObserver*) override;
......
......@@ -30,8 +30,8 @@ FloatSize StyleImage::ApplyZoom(const FloatSize& size, float multiplier) const {
FloatSize StyleImage::ImageSizeForSVGImage(
SVGImage* svg_image,
float multiplier,
const LayoutSize& default_object_size) const {
FloatSize unzoomed_default_object_size(default_object_size);
const FloatSize& default_object_size) const {
FloatSize unzoomed_default_object_size = default_object_size;
unzoomed_default_object_size.Scale(1 / multiplier);
return ApplyZoom(svg_image->ConcreteObjectSize(unzoomed_default_object_size),
multiplier);
......
......@@ -35,7 +35,6 @@ class CSSValue;
class FloatSize;
class Image;
class ImageResourceContent;
class LayoutSize;
class SVGImage;
class Document;
class ComputedStyle;
......@@ -92,7 +91,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> {
// supports it.
virtual FloatSize ImageSize(const Document&,
float multiplier,
const LayoutSize& default_object_size,
const FloatSize& default_object_size,
RespectImageOrientationEnum) const = 0;
// The <image> has intrinsic dimensions.
......@@ -168,7 +167,7 @@ class CORE_EXPORT StyleImage : public GarbageCollected<StyleImage> {
FloatSize ApplyZoom(const FloatSize&, float multiplier) const;
FloatSize ImageSizeForSVGImage(SVGImage*,
float multiplier,
const LayoutSize& default_object_size) const;
const FloatSize& default_object_size) const;
};
} // namespace blink
......
......@@ -71,8 +71,8 @@ class StylePendingImage final : public StyleImage {
}
FloatSize ImageSize(const Document&,
float /*multiplier*/,
const LayoutSize& /*defaultObjectSize*/,
float,
const FloatSize&,
RespectImageOrientationEnum) const override {
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