Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Unified Diff: third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp

Issue 2303703002: Revamp filter primitive region calculations for Filter Effects (Closed)
Patch Set: Baselines again; Manual for mac10.11-retina Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp b/third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp
index aa3c99c4f1d854389c589f63c55a5ffabe0bf87f..46dcce71c9b952ad18e9c160af9ff19233f5f717 100644
--- a/third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp
@@ -96,18 +96,55 @@ void SVGFilterPrimitiveStandardAttributes::childrenChanged(const ChildrenChange&
invalidate();
}
-void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(FilterEffect* filterEffect) const
+static FloatRect defaultFilterPrimitiveSubregion(FilterEffect* filterEffect)
+{
+ // https://drafts.fxtf.org/filters/#FilterPrimitiveSubRegion
+ DCHECK(filterEffect->getFilter());
+
+ // <feTurbulence>, <feFlood> and <feImage> don't have input effects, so use
+ // the filter region as default subregion. <feTile> does have an input
+ // reference, but due to its function (and special-cases) its default
+ // resolves to the filter region.
+ if (filterEffect->getFilterEffectType() == FilterEffectTypeTile
+ || !filterEffect->numberOfEffectInputs())
+ return filterEffect->getFilter()->filterRegion();
+
+ // "x, y, width and height default to the union (i.e., tightest fitting
+ // bounding box) of the subregions defined for all referenced nodes."
+ FloatRect subregionUnion;
+ for (const auto& inputEffect : filterEffect->inputEffects()) {
+ // "If ... one or more of the referenced nodes is a standard input
+ // ... the default subregion is 0%, 0%, 100%, 100%, where as a
+ // special-case the percentages are relative to the dimensions of the
+ // filter region..."
+ if (inputEffect->getFilterEffectType() == FilterEffectTypeSourceInput)
+ return filterEffect->getFilter()->filterRegion();
+ subregionUnion.unite(inputEffect->filterPrimitiveSubregion());
+ }
+ return subregionUnion;
+}
+
+void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(
+ FilterEffect* filterEffect,
+ SVGUnitTypes::SVGUnitType primitiveUnits,
+ const FloatRect& referenceBox) const
{
DCHECK(filterEffect);
+ FloatRect subregion = defaultFilterPrimitiveSubregion(filterEffect);
+ FloatRect primitiveBoundaries =
+ SVGLengthContext::resolveRectangle(this, primitiveUnits, referenceBox);
+
if (x()->isSpecified())
- filterEffect->setHasX(true);
+ subregion.setX(primitiveBoundaries.x());
if (y()->isSpecified())
- filterEffect->setHasY(true);
+ subregion.setY(primitiveBoundaries.y());
if (width()->isSpecified())
- filterEffect->setHasWidth(true);
+ subregion.setWidth(primitiveBoundaries.width());
if (height()->isSpecified())
- filterEffect->setHasHeight(true);
+ subregion.setHeight(primitiveBoundaries.height());
+
+ filterEffect->setFilterPrimitiveSubregion(subregion);
}
LayoutObject* SVGFilterPrimitiveStandardAttributes::createLayoutObject(const ComputedStyle&)

Powered by Google App Engine
This is Rietveld 408576698