diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp b/chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp index 8c0a5c517a4..a53a3dcf118 100644 --- a/chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp +++ b/chromium/third_party/WebKit/Source/core/rendering/svg/ReferenceFilterBuilder.cpp @@ -29,9 +29,9 @@ #include "core/rendering/svg/ReferenceFilterBuilder.h" -#include "SVGNames.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/CSSPrimitiveValueMappings.h" +#include "core/css/StylePropertySet.h" #include "core/dom/Element.h" #include "core/fetch/DocumentResource.h" #include "core/rendering/svg/RenderSVGResourceFilter.h" @@ -80,10 +80,11 @@ static bool getSVGElementColorSpace(SVGElement* svgElement, ColorSpace& cs) if (svgStyle) { // If a layout has been performed, then we can use the fast path to get this attribute eColorInterpolation = svgStyle->colorInterpolationFilters(); + } else if (!svgElement->presentationAttributeStyle()) { + return false; } else { // Otherwise, use the slow path by using string comparison (used by external svg files) - RefPtr<CSSValue> cssValue = svgElement->getPresentationAttribute( - SVGNames::color_interpolation_filtersAttr.toString()); + RefPtrWillBeRawPtr<CSSValue> cssValue = svgElement->presentationAttributeStyle()->getPropertyCSSValue(CSSPropertyColorInterpolationFilters); if (cssValue.get() && cssValue->isPrimitiveValue()) { const CSSPrimitiveValue& primitiveValue = *((CSSPrimitiveValue*)cssValue.get()); eColorInterpolation = (EColorInterpolation)primitiveValue; @@ -110,9 +111,9 @@ static bool getSVGElementColorSpace(SVGElement* svgElement, ColorSpace& cs) PassRefPtr<FilterEffect> ReferenceFilterBuilder::build(Filter* parentFilter, RenderObject* renderer, FilterEffect* previousEffect, const ReferenceFilterOperation* filterOperation) { if (!renderer) - return 0; + return nullptr; - Document* document = &renderer->document(); + TreeScope* treeScope = &renderer->node()->treeScope(); if (DocumentResourceReference* documentResourceRef = documentResourceReference(filterOperation)) { DocumentResource* cachedSVGDocument = documentResourceRef->document(); @@ -120,25 +121,25 @@ PassRefPtr<FilterEffect> ReferenceFilterBuilder::build(Filter* parentFilter, Ren // If we have an SVG document, this is an external reference. Otherwise // we look up the referenced node in the current document. if (cachedSVGDocument) - document = cachedSVGDocument->document(); + treeScope = cachedSVGDocument->document(); } - if (!document) - return 0; + if (!treeScope) + return nullptr; - Element* filter = document->getElementById(filterOperation->fragment()); + Element* filter = treeScope->getElementById(filterOperation->fragment()); if (!filter) { // Although we did not find the referenced filter, it might exist later - // in the document - document->accessSVGExtensions()->addPendingResource(filterOperation->fragment(), toElement(renderer->node())); - return 0; + // in the document. + treeScope->document().accessSVGExtensions().addPendingResource(filterOperation->fragment(), toElement(renderer->node())); + return nullptr; } - if (!filter->isSVGElement() || !filter->hasTagName(SVGNames::filterTag)) - return 0; + if (!isSVGFilterElement(*filter)) + return nullptr; - SVGFilterElement* filterElement = toSVGFilterElement(toSVGElement(filter)); + SVGFilterElement& filterElement = toSVGFilterElement(*filter); // FIXME: Figure out what to do with SourceAlpha. Right now, we're // using the alpha of the original input layer, which is obviously @@ -148,13 +149,9 @@ PassRefPtr<FilterEffect> ReferenceFilterBuilder::build(Filter* parentFilter, Ren RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(parentFilter)); ColorSpace filterColorSpace = ColorSpaceDeviceRGB; - bool useFilterColorSpace = getSVGElementColorSpace(filterElement, filterColorSpace); - - for (Node* node = filterElement->firstChild(); node; node = node->nextSibling()) { - if (!node->isSVGElement()) - continue; + bool useFilterColorSpace = getSVGElementColorSpace(&filterElement, filterColorSpace); - SVGElement* element = toSVGElement(node); + for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement); element; element = Traversal<SVGElement>::nextSibling(*element)) { if (!element->isFilterEffect()) continue; @@ -165,11 +162,11 @@ PassRefPtr<FilterEffect> ReferenceFilterBuilder::build(Filter* parentFilter, Ren continue; effectElement->setStandardAttributes(effect.get()); - effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnitsCurrentValue(), parentFilter->sourceImageRect())); + effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->currentValue()->enumValue(), parentFilter->sourceImageRect())); ColorSpace colorSpace = filterColorSpace; if (useFilterColorSpace || getSVGElementColorSpace(effectElement, colorSpace)) effect->setOperatingColorSpace(colorSpace); - builder->add(effectElement->resultCurrentValue(), effect); + builder->add(AtomicString(effectElement->result()->currentValue()->value()), effect); } return builder->lastEffect(); } |