| OLD | NEW |
| 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 Loading... |
| 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 void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(FilterEffect* f
ilterEffect) const | 99 static FloatRect defaultFilterPrimitiveSubregion(FilterEffect* filterEffect) |
| 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 |
| 100 { | 131 { |
| 101 DCHECK(filterEffect); | 132 DCHECK(filterEffect); |
| 102 | 133 |
| 134 FloatRect subregion = defaultFilterPrimitiveSubregion(filterEffect); |
| 135 FloatRect primitiveBoundaries = |
| 136 SVGLengthContext::resolveRectangle(this, primitiveUnits, referenceBox); |
| 137 |
| 103 if (x()->isSpecified()) | 138 if (x()->isSpecified()) |
| 104 filterEffect->setHasX(true); | 139 subregion.setX(primitiveBoundaries.x()); |
| 105 if (y()->isSpecified()) | 140 if (y()->isSpecified()) |
| 106 filterEffect->setHasY(true); | 141 subregion.setY(primitiveBoundaries.y()); |
| 107 if (width()->isSpecified()) | 142 if (width()->isSpecified()) |
| 108 filterEffect->setHasWidth(true); | 143 subregion.setWidth(primitiveBoundaries.width()); |
| 109 if (height()->isSpecified()) | 144 if (height()->isSpecified()) |
| 110 filterEffect->setHasHeight(true); | 145 subregion.setHeight(primitiveBoundaries.height()); |
| 146 |
| 147 filterEffect->setFilterPrimitiveSubregion(subregion); |
| 111 } | 148 } |
| 112 | 149 |
| 113 LayoutObject* SVGFilterPrimitiveStandardAttributes::createLayoutObject(const Com
putedStyle&) | 150 LayoutObject* SVGFilterPrimitiveStandardAttributes::createLayoutObject(const Com
putedStyle&) |
| 114 { | 151 { |
| 115 return new LayoutSVGResourceFilterPrimitive(this); | 152 return new LayoutSVGResourceFilterPrimitive(this); |
| 116 } | 153 } |
| 117 | 154 |
| 118 bool SVGFilterPrimitiveStandardAttributes::layoutObjectIsNeeded(const ComputedSt
yle& style) | 155 bool SVGFilterPrimitiveStandardAttributes::layoutObjectIsNeeded(const ComputedSt
yle& style) |
| 119 { | 156 { |
| 120 if (isSVGFilterElement(parentNode())) | 157 if (isSVGFilterElement(parentNode())) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 return; | 183 return; |
| 147 | 184 |
| 148 LayoutObject* layoutObject = parent->layoutObject(); | 185 LayoutObject* layoutObject = parent->layoutObject(); |
| 149 if (!layoutObject || !layoutObject->isSVGResourceFilterPrimitive()) | 186 if (!layoutObject || !layoutObject->isSVGResourceFilterPrimitive()) |
| 150 return; | 187 return; |
| 151 | 188 |
| 152 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); | 189 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); |
| 153 } | 190 } |
| 154 | 191 |
| 155 } // namespace blink | 192 } // namespace blink |
| OLD | NEW |