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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGFilterPrimitiveStandardAttributes.cpp

Issue 2313583002: Revert of Revamp filter primitive region calculations for Filter Effects (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 void SVGFilterPrimitiveStandardAttributes::childrenChanged(const ChildrenChange& change) 91 void SVGFilterPrimitiveStandardAttributes::childrenChanged(const ChildrenChange& change)
92 { 92 {
93 SVGElement::childrenChanged(change); 93 SVGElement::childrenChanged(change);
94 94
95 if (!change.byParser) 95 if (!change.byParser)
96 invalidate(); 96 invalidate();
97 } 97 }
98 98
99 static FloatRect defaultFilterPrimitiveSubregion(FilterEffect* filterEffect) 99 void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(FilterEffect* f ilterEffect) const
100 {
101 // https://drafts.fxtf.org/filters/#FilterPrimitiveSubRegion
102 DCHECK(filterEffect->getFilter());
103
104 // <feTurbulence>, <feFlood> and <feImage> don't have input effects, so use
105 // the filter region as default subregion. <feTile> does have an input
106 // reference, but due to its function (and special-cases) its default
107 // resolves to the filter region.
108 if (filterEffect->getFilterEffectType() == FilterEffectTypeTile
109 || !filterEffect->numberOfEffectInputs())
110 return filterEffect->getFilter()->filterRegion();
111
112 // "x, y, width and height default to the union (i.e., tightest fitting
113 // bounding box) of the subregions defined for all referenced nodes."
114 FloatRect subregionUnion;
115 for (const auto& inputEffect : filterEffect->inputEffects()) {
116 // "If ... one or more of the referenced nodes is a standard input
117 // ... the default subregion is 0%, 0%, 100%, 100%, where as a
118 // special-case the percentages are relative to the dimensions of the
119 // filter region..."
120 if (inputEffect->getFilterEffectType() == FilterEffectTypeSourceInput)
121 return filterEffect->getFilter()->filterRegion();
122 subregionUnion.unite(inputEffect->filterPrimitiveSubregion());
123 }
124 return subregionUnion;
125 }
126
127 void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(
128 FilterEffect* filterEffect,
129 SVGUnitTypes::SVGUnitType primitiveUnits,
130 const FloatRect& referenceBox) const
131 { 100 {
132 DCHECK(filterEffect); 101 DCHECK(filterEffect);
133 102
134 FloatRect subregion = defaultFilterPrimitiveSubregion(filterEffect);
135 FloatRect primitiveBoundaries =
136 SVGLengthContext::resolveRectangle(this, primitiveUnits, referenceBox);
137
138 if (x()->isSpecified()) 103 if (x()->isSpecified())
139 subregion.setX(primitiveBoundaries.x()); 104 filterEffect->setHasX(true);
140 if (y()->isSpecified()) 105 if (y()->isSpecified())
141 subregion.setY(primitiveBoundaries.y()); 106 filterEffect->setHasY(true);
142 if (width()->isSpecified()) 107 if (width()->isSpecified())
143 subregion.setWidth(primitiveBoundaries.width()); 108 filterEffect->setHasWidth(true);
144 if (height()->isSpecified()) 109 if (height()->isSpecified())
145 subregion.setHeight(primitiveBoundaries.height()); 110 filterEffect->setHasHeight(true);
146
147 filterEffect->setFilterPrimitiveSubregion(subregion);
148 } 111 }
149 112
150 LayoutObject* SVGFilterPrimitiveStandardAttributes::createLayoutObject(const Com putedStyle&) 113 LayoutObject* SVGFilterPrimitiveStandardAttributes::createLayoutObject(const Com putedStyle&)
151 { 114 {
152 return new LayoutSVGResourceFilterPrimitive(this); 115 return new LayoutSVGResourceFilterPrimitive(this);
153 } 116 }
154 117
155 bool SVGFilterPrimitiveStandardAttributes::layoutObjectIsNeeded(const ComputedSt yle& style) 118 bool SVGFilterPrimitiveStandardAttributes::layoutObjectIsNeeded(const ComputedSt yle& style)
156 { 119 {
157 if (isSVGFilterElement(parentNode())) 120 if (isSVGFilterElement(parentNode()))
(...skipping 25 matching lines...) Expand all
183 return; 146 return;
184 147
185 LayoutObject* layoutObject = parent->layoutObject(); 148 LayoutObject* layoutObject = parent->layoutObject();
186 if (!layoutObject || !layoutObject->isSVGResourceFilterPrimitive()) 149 if (!layoutObject || !layoutObject->isSVGResourceFilterPrimitive())
187 return; 150 return;
188 151
189 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou tObject, false); 152 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou tObject, false);
190 } 153 }
191 154
192 } // namespace blink 155 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698