Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis (at) 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 #if ENABLE(SVG) && ENABLE(FILTERS)
     25 #include "RenderSVGResourceFilter.h"
     26 #include "RenderSVGResourceFilterPrimitive.h"
     27 #include "SVGAnimatedLength.h"
     28 #include "SVGAnimatedString.h"
     29 #include "SVGStyledElement.h"
     30 
     31 #include <wtf/PassRefPtr.h>
     32 #include <wtf/RefPtr.h>
     33 
     34 namespace WebCore {
     35 
     36 class Filter;
     37 class FilterEffect;
     38 class SVGFilterBuilder;
     39 
     40 class SVGFilterPrimitiveStandardAttributes : public SVGStyledElement {
     41 public:
     42     void setStandardAttributes(bool, 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 protected:
     49     SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document*);
     50 
     51     virtual void parseMappedAttribute(Attribute*);
     52     virtual void svgAttributeChanged(const QualifiedName&);
     53     virtual void synchronizeProperty(const QualifiedName&);
     54     void fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap&);
     55     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     56 
     57     inline void invalidate()
     58     {
     59         if (RenderObject* primitiveRenderer = renderer())
     60             RenderSVGResource::markForLayoutAndParentResourceInvalidation(primitiveRenderer);
     61     }
     62 
     63     inline void primitiveAttributeChanged(const QualifiedName& attribute)
     64     {
     65         if (RenderObject* primitiveRenderer = renderer())
     66             static_cast<RenderSVGResourceFilterPrimitive*>(primitiveRenderer)->primitiveAttributeChanged(attribute);
     67     }
     68 
     69 private:
     70     virtual bool isFilterEffect() const { return true; }
     71 
     72     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     73     virtual bool rendererIsNeeded(RenderStyle*);
     74 
     75     // Animated property declarations
     76     DECLARE_ANIMATED_LENGTH(X, x)
     77     DECLARE_ANIMATED_LENGTH(Y, y)
     78     DECLARE_ANIMATED_LENGTH(Width, width)
     79     DECLARE_ANIMATED_LENGTH(Height, height)
     80     DECLARE_ANIMATED_STRING(Result, result)
     81 };
     82 
     83 } // namespace WebCore
     84 
     85 #endif // ENABLE(SVG)
     86 #endif
     87