Commit a11f72c8 authored by jstenback's avatar jstenback Committed by Commit bot

Remove unnecessary zoom argument from GetImage() as its value is always...

Remove unnecessary zoom argument from GetImage() as its value is always available through the LayoutObject argument. (rebased)

BUG=716203
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2847303002
Cr-Commit-Position: refs/heads/master@{#469560}
parent 617af2a7
......@@ -114,15 +114,14 @@ void CSSImageGeneratorValue::PutImage(const IntSize& size,
PassRefPtr<Image> CSSImageGeneratorValue::GetImage(
const LayoutObject& layout_object,
const IntSize& size,
float zoom) {
const IntSize& size) {
switch (GetClassType()) {
case kCrossfadeClass:
return ToCSSCrossfadeValue(this)->GetImage(layout_object, size);
case kLinearGradientClass:
return ToCSSLinearGradientValue(this)->GetImage(layout_object, size);
case kPaintClass:
return ToCSSPaintValue(this)->GetImage(layout_object, size, zoom);
return ToCSSPaintValue(this)->GetImage(layout_object, size);
case kRadialGradientClass:
return ToCSSRadialGradientValue(this)->GetImage(layout_object, size);
case kConicGradientClass:
......
......@@ -57,7 +57,7 @@ class CORE_EXPORT CSSImageGeneratorValue : public CSSValue {
void AddClient(const LayoutObject*, const IntSize&);
void RemoveClient(const LayoutObject*);
PassRefPtr<Image> GetImage(const LayoutObject&, const IntSize&, float zoom);
PassRefPtr<Image> GetImage(const LayoutObject&, const IntSize&);
bool IsFixedSize() const;
IntSize FixedSize(const LayoutObject&, const FloatSize& default_object_size);
......
......@@ -49,7 +49,6 @@ class CORE_EXPORT CSSPaintImageGenerator
// representing an invalid image if an error occurred.
virtual PassRefPtr<Image> Paint(const LayoutObject&,
const IntSize&,
float zoom,
const CSSStyleValueVector*) = 0;
virtual const Vector<CSSPropertyID>& NativeInvalidationProperties() const = 0;
......
......@@ -43,8 +43,7 @@ String CSSPaintValue::GetName() const {
}
PassRefPtr<Image> CSSPaintValue::GetImage(const LayoutObject& layout_object,
const IntSize& size,
float zoom) {
const IntSize& size) {
if (!generator_)
generator_ =
CSSPaintImageGenerator::Create(GetName(), layout_object.GetDocument(),
......@@ -53,7 +52,7 @@ PassRefPtr<Image> CSSPaintValue::GetImage(const LayoutObject& layout_object,
if (!ParseInputArguments())
return nullptr;
return generator_->Paint(layout_object, size, zoom, parsed_input_arguments_);
return generator_->Paint(layout_object, size, parsed_input_arguments_);
}
bool CSSPaintValue::ParseInputArguments() {
......
......@@ -31,7 +31,7 @@ class CSSPaintValue : public CSSImageGeneratorValue {
String GetName() const;
PassRefPtr<Image> GetImage(const LayoutObject&, const IntSize&, float zoom);
PassRefPtr<Image> GetImage(const LayoutObject&, const IntSize&);
bool IsFixedSize() const { return false; }
IntSize FixedSize(const LayoutObject&) { return IntSize(); }
......
......@@ -94,8 +94,8 @@ LayoutSize LayoutImageResource::ImageSize(float multiplier) const {
return size;
}
PassRefPtr<Image> LayoutImageResource::GetImage(const IntSize& container_size,
float zoom) const {
PassRefPtr<Image> LayoutImageResource::GetImage(
const IntSize& container_size) const {
if (!cached_image_)
return Image::NullImage();
......@@ -109,7 +109,9 @@ PassRefPtr<Image> LayoutImageResource::GetImage(const IntSize& container_size,
const AtomicString& url_string = ToElement(node)->ImageSourceURL();
url = node->GetDocument().CompleteURL(url_string);
}
return SVGImageForContainer::Create(svg_image, container_size, zoom, url);
return SVGImageForContainer::Create(
svg_image, container_size, layout_object_->StyleRef().EffectiveZoom(),
url);
}
bool LayoutImageResource::MaybeAnimated() const {
......
......@@ -53,7 +53,7 @@ class LayoutImageResource
void ResetAnimation();
bool MaybeAnimated() const;
virtual PassRefPtr<Image> GetImage(const IntSize&, float) const;
virtual PassRefPtr<Image> GetImage(const IntSize&) const;
virtual bool ErrorOccurred() const {
return cached_image_ && cached_image_->ErrorOccurred();
}
......
......@@ -58,13 +58,13 @@ void LayoutImageResourceStyleImage::Shutdown() {
cached_image_ = nullptr;
}
PassRefPtr<Image> LayoutImageResourceStyleImage::GetImage(const IntSize& size,
float zoom) const {
PassRefPtr<Image> LayoutImageResourceStyleImage::GetImage(
const IntSize& size) const {
// Generated content may trigger calls to image() while we're still pending,
// don't assert but gracefully exit.
if (style_image_->IsPendingImage())
return nullptr;
return style_image_->GetImage(*layout_object_, size, zoom);
return style_image_->GetImage(*layout_object_, size);
}
LayoutSize LayoutImageResourceStyleImage::ImageSize(float multiplier) const {
......
......@@ -46,7 +46,7 @@ class LayoutImageResourceStyleImage final : public LayoutImageResource {
void Shutdown() override;
bool HasImage() const override { return true; }
PassRefPtr<Image> GetImage(const IntSize&, float) const override;
PassRefPtr<Image> GetImage(const IntSize&) const override;
bool ErrorOccurred() const override { return style_image_->ErrorOccurred(); }
bool ImageHasRelativeSize() const override {
......
......@@ -792,7 +792,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
bool HasLayer() const { return bitfields_.HasLayer(); }
// This may be different from styleRef().hasBoxDecorationBackground() because
// This may be different from StyleRef().hasBoxDecorationBackground() because
// some objects may have box decoration background other than from their own
// style.
bool HasBoxDecorationBackground() const {
......@@ -1341,8 +1341,8 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
const ComputedStyle* Style() const { return style_.Get(); }
ComputedStyle* MutableStyle() const { return style_.Get(); }
// m_style can only be nullptr before the first style is set, thus most
// callers will never see a nullptr style and should use styleRef().
// style_ can only be nullptr before the first style is set, thus most
// callers will never see a nullptr style and should use StyleRef().
// FIXME: It would be better if style() returned a const reference.
const ComputedStyle& StyleRef() const { return MutableStyleRef(); }
ComputedStyle& MutableStyleRef() const {
......@@ -2006,7 +2006,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
};
virtual bool IsOfType(LayoutObjectType type) const { return false; }
// Overrides should call the superclass at the end. m_style will be 0 the
// Overrides should call the superclass at the end. style_ will be 0 the
// first time this function will be called.
virtual void StyleWillChange(StyleDifference, const ComputedStyle& new_style);
// Overrides should call the superclass at the start. |oldStyle| will be 0 the
......
......@@ -170,8 +170,7 @@ std::unique_ptr<Shape> ShapeOutsideInfo::CreateShapeForImage(
DCHECK(!style_image->IsPendingImage());
RefPtr<Image> image =
style_image->GetImage(layout_box_, FlooredIntSize(image_size),
layout_box_.Style()->EffectiveZoom());
style_image->GetImage(layout_box_, FlooredIntSize(image_size));
return Shape::CreateRasterShape(image.Get(), shape_image_threshold,
image_rect, margin_rect, writing_mode,
......
......@@ -442,8 +442,7 @@ class ImagePaintContext {
const LayoutObject& image_client =
background_object ? *background_object : obj;
image_ = style_image.GetImage(image_client, FlooredIntSize(container_size),
obj.Style()->EffectiveZoom());
image_ = style_image.GetImage(image_client, FlooredIntSize(container_size));
interpolation_quality_ = BoxPainter::ChooseInterpolationQuality(
image_client, image_.Get(), &layer, container_size);
......
......@@ -143,8 +143,8 @@ void ImagePainter::PaintIntoRect(GraphicsContext& context,
if (pixel_snapped_dest_rect.IsEmpty())
return;
RefPtr<Image> image = layout_image_.ImageResource()->GetImage(
pixel_snapped_dest_rect.Size(), layout_image_.Style()->EffectiveZoom());
RefPtr<Image> image =
layout_image_.ImageResource()->GetImage(pixel_snapped_dest_rect.Size());
if (!image || image->IsNull())
return;
......
......@@ -72,12 +72,10 @@ void ListMarkerPainter::Paint(const PaintInfo& paint_info,
GraphicsContext& context = paint_info.context;
if (layout_list_marker_.IsImage()) {
context.DrawImage(
layout_list_marker_.GetImage()
->GetImage(layout_list_marker_, marker.Size(),
layout_list_marker_.StyleRef().EffectiveZoom())
.Get(),
marker);
context.DrawImage(layout_list_marker_.GetImage()
->GetImage(layout_list_marker_, marker.Size())
.Get(),
marker);
if (layout_list_marker_.GetSelectionState() != SelectionNone) {
LayoutRect sel_rect = layout_list_marker_.LocalSelectionRect();
sel_rect.MoveBy(box_origin);
......
......@@ -63,8 +63,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context,
PixelSnappedIntRect(border_image_rect),
border_widths);
RefPtr<Image> image =
style_image->GetImage(layout_object_, image_size, style.EffectiveZoom());
RefPtr<Image> image = style_image->GetImage(layout_object_, image_size);
InterpolationQuality interpolation_quality =
BoxPainter::ChooseInterpolationQuality(layout_object_, image.Get(), 0,
......
......@@ -62,8 +62,7 @@ void SVGImagePainter::PaintForeground(const PaintInfo& paint_info) {
if (image_viewport_size.IsEmpty())
return;
RefPtr<Image> image = image_resource->GetImage(
image_viewport_size, layout_svg_image_.Style()->EffectiveZoom());
RefPtr<Image> image = image_resource->GetImage(image_viewport_size);
FloatRect dest_rect = layout_svg_image_.ObjectBoundingBox();
FloatRect src_rect(0, 0, image->width(), image->height());
......
......@@ -117,14 +117,15 @@ void StyleFetchedImage::ImageNotifyFinished(ImageResourceContent*) {
document_.Clear();
}
PassRefPtr<Image> StyleFetchedImage::GetImage(const LayoutObject&,
const IntSize& container_size,
float zoom) const {
PassRefPtr<Image> StyleFetchedImage::GetImage(
const LayoutObject& obj,
const IntSize& container_size) const {
if (!image_->GetImage()->IsSVGImage())
return image_->GetImage();
return SVGImageForContainer::Create(ToSVGImage(image_->GetImage()),
container_size, zoom, url_);
container_size,
obj.StyleRef().EffectiveZoom(), url_);
}
bool StyleFetchedImage::KnownToBeOpaque(
......
......@@ -62,8 +62,7 @@ class StyleFetchedImage final : public StyleImage,
void ImageNotifyFinished(ImageResourceContent*) override;
String DebugName() const override { return "StyleFetchedImage"; }
PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize&,
float zoom) const override;
const IntSize&) const override;
bool KnownToBeOpaque(const LayoutObject&) const override;
ImageResourceContent* CachedImage() const override;
......
......@@ -115,14 +115,15 @@ void StyleFetchedImageSet::RemoveClient(LayoutObject* layout_object) {
best_fit_image_->RemoveObserver(layout_object);
}
PassRefPtr<Image> StyleFetchedImageSet::GetImage(const LayoutObject&,
const IntSize& container_size,
float zoom) const {
PassRefPtr<Image> StyleFetchedImageSet::GetImage(
const LayoutObject& obj,
const IntSize& container_size) const {
if (!best_fit_image_->GetImage()->IsSVGImage())
return best_fit_image_->GetImage();
return SVGImageForContainer::Create(ToSVGImage(best_fit_image_->GetImage()),
container_size, zoom, url_);
container_size,
obj.StyleRef().EffectiveZoom(), url_);
}
bool StyleFetchedImageSet::KnownToBeOpaque(
......
......@@ -69,8 +69,7 @@ class StyleFetchedImageSet final : public StyleImage,
void AddClient(LayoutObject*) override;
void RemoveClient(LayoutObject*) override;
PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize&,
float) const override;
const IntSize&) const override;
float ImageScaleFactor() const override { return image_scale_factor_; }
bool KnownToBeOpaque(const LayoutObject&) const override;
ImageResourceContent* CachedImage() const override;
......
......@@ -69,9 +69,8 @@ void StyleGeneratedImage::RemoveClient(LayoutObject* layout_object) {
PassRefPtr<Image> StyleGeneratedImage::GetImage(
const LayoutObject& layout_object,
const IntSize& size,
float zoom) const {
return image_generator_value_->GetImage(layout_object, size, zoom);
const IntSize& size) const {
return image_generator_value_->GetImage(layout_object, size);
}
bool StyleGeneratedImage::KnownToBeOpaque(
......
......@@ -51,8 +51,7 @@ class CORE_EXPORT StyleGeneratedImage final : public StyleImage {
void AddClient(LayoutObject*) override;
void RemoveClient(LayoutObject*) override;
PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize&,
float) const override;
const IntSize&) const override;
bool KnownToBeOpaque(const LayoutObject&) const override;
DECLARE_VIRTUAL_TRACE();
......
......@@ -63,12 +63,11 @@ class CORE_EXPORT StyleImage : public GarbageCollectedFinalized<StyleImage> {
virtual bool UsesImageContainerSize() const = 0;
virtual void AddClient(LayoutObject*) = 0;
virtual void RemoveClient(LayoutObject*) = 0;
// Note that the containerSize is assumed to be in the effective
// zoom level given by multiplier, i.e if the multiplier is the
// constant 1 the containerSize should be unzoomed.
// Note that the container_size is in the effective zoom level of
// the style that applies to the given LayoutObject, i.e if the zoom
// level is 1.0 the container_size should be unzoomed.
virtual PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize& container_size,
float multiplier) const = 0;
const IntSize& container_size) const = 0;
virtual WrappedImagePtr Data() const = 0;
virtual float ImageScaleFactor() const { return 1; }
virtual bool KnownToBeOpaque(const LayoutObject&) const = 0;
......
......@@ -34,8 +34,7 @@ class StyleInvalidImage final : public StyleImage {
void AddClient(LayoutObject*) override {}
void RemoveClient(LayoutObject*) override {}
PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize&,
float) const override {
const IntSize&) const override {
return nullptr;
}
bool KnownToBeOpaque(const LayoutObject&) const override { return false; }
......
......@@ -80,8 +80,7 @@ class StylePendingImage final : public StyleImage {
void AddClient(LayoutObject*) override {}
void RemoveClient(LayoutObject*) override {}
PassRefPtr<Image> GetImage(const LayoutObject&,
const IntSize&,
float) const override {
const IntSize&) const override {
NOTREACHED();
return nullptr;
}
......
......@@ -69,10 +69,10 @@ CSSPaintDefinition::~CSSPaintDefinition() {}
PassRefPtr<Image> CSSPaintDefinition::Paint(
const LayoutObject& layout_object,
const IntSize& size,
float zoom,
const CSSStyleValueVector* paint_arguments) {
DCHECK(paint_arguments);
float zoom = layout_object.StyleRef().EffectiveZoom();
const IntSize specified_size = GetSpecifiedSize(size, zoom);
ScriptState::Scope scope(script_state_.Get());
......
......@@ -43,7 +43,6 @@ class CSSPaintDefinition final
// throws an error.
PassRefPtr<Image> Paint(const LayoutObject&,
const IntSize&,
float zoom,
const CSSStyleValueVector*);
const Vector<CSSPropertyID>& NativeInvalidationProperties() const {
return native_invalidation_properties_;
......
......@@ -52,10 +52,8 @@ void CSSPaintImageGeneratorImpl::SetDefinition(CSSPaintDefinition* definition) {
PassRefPtr<Image> CSSPaintImageGeneratorImpl::Paint(
const LayoutObject& layout_object,
const IntSize& size,
float zoom,
const CSSStyleValueVector* data) {
return definition_ ? definition_->Paint(layout_object, size, zoom, data)
: nullptr;
return definition_ ? definition_->Paint(layout_object, size, data) : nullptr;
}
const Vector<CSSPropertyID>&
......
......@@ -28,7 +28,6 @@ class CSSPaintImageGeneratorImpl final : public CSSPaintImageGenerator {
PassRefPtr<Image> Paint(const LayoutObject&,
const IntSize&,
float zoom,
const CSSStyleValueVector*) final;
const Vector<CSSPropertyID>& NativeInvalidationProperties() const final;
const Vector<AtomicString>& CustomInvalidationProperties() const final;
......
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