1/* 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21#ifndef SVGFilterPrimitiveStandardAttributes_h 22#define SVGFilterPrimitiveStandardAttributes_h 23 24#include "core/rendering/svg/RenderSVGResource.h" 25#include "core/svg/SVGAnimatedLength.h" 26#include "core/svg/SVGAnimatedString.h" 27#include "core/svg/SVGElement.h" 28#include "wtf/PassRefPtr.h" 29#include "wtf/RefPtr.h" 30 31namespace blink { 32 33class Filter; 34class FilterEffect; 35class SVGFilterBuilder; 36 37class SVGFilterPrimitiveStandardAttributes : public SVGElement { 38 // No DEFINE_WRAPPERTYPEINFO() here because a) this class is never 39 // instantiated, and b) we don't generate corresponding V8T.h or V8T.cpp. 40 // The subclasses must write DEFINE_WRAPPERTYPEINFO(). 41public: 42 void setStandardAttributes(FilterEffect*) const; 43 44 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter* filter) = 0; 45 // Returns true, if the new value is different from the old one. 46 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&); 47 48 // JS API 49 SVGAnimatedLength* x() const { return m_x.get(); } 50 SVGAnimatedLength* y() const { return m_y.get(); } 51 SVGAnimatedLength* width() const { return m_width.get(); } 52 SVGAnimatedLength* height() const { return m_height.get(); } 53 SVGAnimatedString* result() const { return m_result.get(); } 54 55protected: 56 SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document&); 57 58 bool isSupportedAttribute(const QualifiedName&); 59 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 60 virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE; 61 virtual void childrenChanged(const ChildrenChange&) OVERRIDE; 62 63 inline void invalidate() 64 { 65 if (RenderObject* primitiveRenderer = renderer()) 66 RenderSVGResource::markForLayoutAndParentResourceInvalidation(primitiveRenderer); 67 } 68 69 void primitiveAttributeChanged(const QualifiedName&); 70 71private: 72 virtual bool isFilterEffect() const OVERRIDE FINAL { return true; } 73 74 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE FINAL; 75 virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE FINAL; 76 77 RefPtr<SVGAnimatedLength> m_x; 78 RefPtr<SVGAnimatedLength> m_y; 79 RefPtr<SVGAnimatedLength> m_width; 80 RefPtr<SVGAnimatedLength> m_height; 81 RefPtr<SVGAnimatedString> m_result; 82}; 83 84void invalidateFilterPrimitiveParent(SVGElement*); 85 86} // namespace blink 87 88#endif // SVGFilterPrimitiveStandardAttributes_h 89