Commit 5c30dee8 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Include filter region in the crop rect for a filter effect

Since filters applied to HTML content do not explicitly clip to the
filter region, apply (clip with) the filter region to the crop rect.
In future we'll also need this when applying filters to SVG content.

Remove Filter::AbsoluteFilterRegion() since it unused.

Bug: 109224, 512453

Change-Id: I86ad620ead2a8a184431975891565a6fc0e64b35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390909Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#804554}
parent 987a7c16
......@@ -55,10 +55,6 @@ class PLATFORM_EXPORT Filter final : public GarbageCollected<Filter> {
FloatPoint3D Resolve3dPoint(const FloatPoint3D&) const;
FloatRect AbsoluteFilterRegion() const {
return MapLocalRectToAbsoluteRect(filter_region_);
}
const FloatRect& FilterRegion() const { return filter_region_; }
const FloatRect& ReferenceBox() const { return reference_box_; }
......
......@@ -141,13 +141,17 @@ sk_sp<PaintFilter> FilterEffect::CreateTransparentBlack() const {
}
PaintFilter::CropRect FilterEffect::GetCropRect() const {
if (!FilterPrimitiveSubregion().IsEmpty()) {
FloatRect rect =
GetFilter()->MapLocalRectToAbsoluteRect(FilterPrimitiveSubregion());
return PaintFilter::CropRect(rect);
} else {
if (!ClipsToBounds())
return PaintFilter::CropRect(SkRect::MakeEmpty(), 0);
}
FloatRect computed_bounds = FilterPrimitiveSubregion();
// This and the filter region check is a workaround for crbug.com/512453.
if (computed_bounds.IsEmpty())
return PaintFilter::CropRect(SkRect::MakeEmpty(), 0);
FloatRect filter_region = GetFilter()->FilterRegion();
if (!filter_region.IsEmpty())
computed_bounds.Intersect(filter_region);
return PaintFilter::CropRect(
GetFilter()->MapLocalRectToAbsoluteRect(computed_bounds));
}
static int GetImageFilterIndex(InterpolationSpace interpolation_space,
......
......@@ -48,8 +48,8 @@ div {
.sample2Expected {
left: 25px;
top: 35px;
width: 50px;
height: 40px;
width: 45px;
height: 35px;
}
.sample3Expected {
left: 20px;
......@@ -65,14 +65,14 @@ div {
}
.sample5Expected {
left: 20px;
top: 10px;
top: 30px;
width: 50px;
height: 40px;
height: 20px;
}
.sample6Expected {
left: 10px;
left: 20px;
top: 30px;
width: 50px;
width: 40px;
height: 40px;
}
.sample2_0Expected {
......@@ -108,8 +108,8 @@ div {
.sample2_5Expected {
left: 40px;
top: 50px;
width: 50px;
height: 10px;
width: 0px;
height: 0px;
}
.sample3_1Expected {
left: 20px;
......
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