File indexing completed on 2024-04-28 15:24:41

0001 /*
0002     Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef SVGStyledElement_h
0024 #define SVGStyledElement_h
0025 
0026 #if ENABLE(SVG)
0027 #include "AffineTransform.h"
0028 #include "Path.h"
0029 #include "SVGElement.h"
0030 #include "SVGLength.h"
0031 #include "SVGResource.h"
0032 #include "SVGStylable.h"
0033 
0034 //khtml compat
0035 #include "RenderStyle.h"
0036 
0037 namespace WebCore
0038 {
0039 
0040 class SVGStyledElement : public SVGElement,
0041     public SVGStylable
0042 {
0043 public:
0044     SVGStyledElement(const QualifiedName &, Document *);
0045     virtual ~SVGStyledElement();
0046 
0047     bool isStyled() const override
0048     {
0049         return true;
0050     }
0051     virtual bool supportsMarkers() const
0052     {
0053         return false;
0054     }
0055 
0056     PassRefPtr<DOM::CSSValueImpl> getPresentationAttribute(const DOMString &name) override;
0057     DOM::CSSStyleDeclarationImpl *style() override
0058     {
0059         return StyledElement::style();
0060     }
0061 
0062     bool isKnownAttribute(const QualifiedName &);
0063 
0064     bool rendererIsNeeded(RenderStyle *) override;
0065     virtual SVGResource *canvasResource()
0066     {
0067         return nullptr;
0068     }
0069 
0070     /*virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;*/
0071     void parseMappedAttribute(MappedAttribute *) override;
0072 
0073     void svgAttributeChanged(const QualifiedName &) override;
0074 
0075     using DOM::NodeImpl::childrenChanged;
0076     virtual void childrenChanged(bool changedByParser = false, Node *beforeChange = nullptr, Node *afterChange = nullptr, int childCountDelta = 0);
0077 
0078     // Centralized place to force a manual style resolution. Hacky but needed for now.
0079     RenderStyle *resolveStyle(RenderStyle *parentStyle);
0080 
0081     void invalidateResourcesInAncestorChain() const;
0082     void detach() override;
0083 
0084     void setInstanceUpdatesBlocked(bool);
0085 
0086 protected:
0087     virtual bool hasRelativeValues() const
0088     {
0089         return true;
0090     }
0091 
0092     static int cssPropertyIdForSVGAttributeName(const QualifiedName &);
0093 
0094 private:
0095     ANIMATED_PROPERTY_DECLARATIONS(SVGStyledElement, String, String, ClassName, className)
0096 
0097     void updateElementInstance(SVGDocumentExtensions *) const;
0098 };
0099 
0100 } // namespace WebCore
0101 
0102 #endif // ENABLE(SVG)
0103 #endif // SVGStyledElement