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 WebCore {
32
33class Filter;
34class FilterEffect;
35class RenderSVGResourceFilterPrimitive;
36class SVGFilterBuilder;
37
38class SVGFilterPrimitiveStandardAttributes : public SVGElement {
39public:
40    void setStandardAttributes(FilterEffect*) const;
41
42    virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter* filter) = 0;
43    // Returns true, if the new value is different from the old one.
44    virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);
45
46protected:
47    SVGFilterPrimitiveStandardAttributes(const QualifiedName&, Document&);
48
49    bool isSupportedAttribute(const QualifiedName&);
50    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
51    virtual void svgAttributeChanged(const QualifiedName&);
52    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
53
54    inline void invalidate()
55    {
56        if (RenderObject* primitiveRenderer = renderer())
57            RenderSVGResource::markForLayoutAndParentResourceInvalidation(primitiveRenderer);
58    }
59
60    void primitiveAttributeChanged(const QualifiedName&);
61
62private:
63    virtual bool isFilterEffect() const { return true; }
64
65    virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
66    virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
67    virtual bool childShouldCreateRenderer(const Node& child) const OVERRIDE { return false; }
68
69    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes)
70        DECLARE_ANIMATED_LENGTH(X, x)
71        DECLARE_ANIMATED_LENGTH(Y, y)
72        DECLARE_ANIMATED_LENGTH(Width, width)
73        DECLARE_ANIMATED_LENGTH(Height, height)
74        DECLARE_ANIMATED_STRING(Result, result)
75    END_DECLARE_ANIMATED_PROPERTIES
76};
77
78void invalidateFilterPrimitiveParent(SVGElement*);
79
80} // namespace WebCore
81
82#endif
83