KHtml

SVGUseElement.h
1 /*
2  Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <[email protected]>
3  2004, 2005, 2006, 2007 Rob Buis <[email protected]>
4 
5  This file is part of the KDE project
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef SVGUseElement_h
24 #define SVGUseElement_h
25 
26 #if ENABLE(SVG)
27 #include "SVGExternalResourcesRequired.h"
28 #include "SVGLangSpace.h"
29 #include "SVGStyledTransformableElement.h"
30 #include "SVGTests.h"
31 #include "SVGURIReference.h"
32 
33 namespace WebCore
34 {
35 
36 class SVGElementInstance;
37 class SVGLength;
38 
39 class SVGUseElement : public SVGStyledTransformableElement,
40  public SVGTests,
41  public SVGLangSpace,
42  public SVGExternalResourcesRequired,
43  public SVGURIReference
44 {
45 public:
46  SVGUseElement(const QualifiedName &, Document *);
47  virtual ~SVGUseElement();
48 
49  SVGElementInstance *instanceRoot() const;
50  SVGElementInstance *animatedInstanceRoot() const;
51 
52  bool isValid() const override
53  {
54  return SVGTests::isValid();
55  }
56 
57  void insertedIntoDocument() override;
58  void removedFromDocument() override;
59  void buildPendingResource() override;
60 
61  void parseMappedAttribute(MappedAttribute *) override;
62  using DOM::NodeImpl::childrenChanged;
63  void childrenChanged(bool changedByParser = false, Node *beforeChange = nullptr, Node *afterChange = nullptr, int childCountDelta = 0) override;
64 
65  void svgAttributeChanged(const QualifiedName &) override;
66  void recalcStyle(StyleChange = NoChange) override;
67 
68  RenderObject *createRenderer(RenderArena *, RenderStyle *) override;
69  void attach() override;
70  void detach() override;
71 
72  Path toClipPath() const override;
73 
74  static void removeDisallowedElementsFromSubtree(Node *element);
75 
76  // KHTML ElementImpl pure virtual method
77  quint32 id() const override
78  {
79  return SVGNames::useTag.id();
80  }
81 protected:
82  const SVGElement *contextElement() const override
83  {
84  return this;
85  }
86 
87 private:
88  ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
89  ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href)
90 
91  ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, X, x)
92  ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Y, y)
93  ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Width, width)
94  ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGLength, SVGLength, Height, height)
95 
96 private:
97  friend class SVGElement;
98  SVGElementInstance *instanceForShadowTreeElement(Node *element) const;
99 
100 private:
101  // Instance tree handling
102  void buildInstanceTree(SVGElement *target, SVGElementInstance *targetInstance, bool &foundCycle);
103  void handleDeepUseReferencing(SVGElement *use, SVGElementInstance *targetInstance, bool &foundCycle);
104 
105  // Shadow tree handling
106  PassRefPtr<SVGSVGElement> buildShadowTreeForSymbolTag(SVGElement *target, SVGElementInstance *targetInstance);
107  void alterShadowTreeForSVGTag(SVGElement *target);
108 
109  void buildShadowTree(SVGElement *target, SVGElementInstance *targetInstance);
110 
111 #if ENABLE(SVG) && ENABLE(SVG_USE)
112  void expandUseElementsInShadowTree(Node *element);
113  void expandSymbolElementsInShadowTree(Node *element);
114 #endif
115 
116  void attachShadowTree();
117 
118  // "Tree connector"
119  void associateInstancesWithShadowTreeElements(Node *target, SVGElementInstance *targetInstance);
120 
121  SVGElementInstance *instanceForShadowTreeElement(Node *element, SVGElementInstance *instance) const;
122  void transferUseAttributesToReplacedElement(SVGElement *from, SVGElement *to) const;
123 
124  RefPtr<SVGElement> m_shadowTreeRootElement;
125  RefPtr<SVGElementInstance> m_targetElementInstance;
126 };
127 
128 } // namespace WebCore
129 
130 #endif // ENABLE(SVG)
131 #endif
bool isValid(QStringView ifopt)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.