blob: faac929972875d4e81806ea5b0524eb47ad3c766 [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
zimmermann@webkit.org711245f2010-08-03 19:39:01 +00002 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
darin@apple.comd8721272015-01-26 03:22:09 +00004 * Copyright (C) 2015 Apple Inc. All rights reserved.
zimmermann@webkit.org711245f2010-08-03 19:39:01 +00005 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
darinb9481ed2006-03-20 02:57:59 +000021
eseidel8eddecf2007-01-16 00:49:43 +000022#ifndef SVGUseElement_h
23#define SVGUseElement_h
zimmermann58e4e142006-12-17 12:16:31 +000024
andersca@apple.com0920f1b2013-04-05 00:08:09 +000025#include "CachedResourceHandle.h"
26#include "CachedSVGDocumentClient.h"
zimmermann@webkit.orge50a8b12010-12-03 09:44:21 +000027#include "SVGAnimatedBoolean.h"
zimmermann@webkit.org001d2522010-10-21 10:25:25 +000028#include "SVGAnimatedLength.h"
darinb9481ed2006-03-20 02:57:59 +000029#include "SVGExternalResourcesRequired.h"
ch.dumez@sisa.samsung.coma47b6182013-06-28 15:58:03 +000030#include "SVGGraphicsElement.h"
rwlbuis7ccc98a2006-10-13 12:56:42 +000031#include "SVGURIReference.h"
darinb9481ed2006-03-20 02:57:59 +000032
zimmermann@webkit.org52b39ec2008-02-03 23:18:53 +000033namespace WebCore {
34
reni@webkit.orgff4b9f22012-03-14 08:52:35 +000035class CachedSVGDocument;
darin@apple.comd8721272015-01-26 03:22:09 +000036class SVGGElement;
zimmermann995e15b2007-01-19 14:03:41 +000037
darin@apple.com43c27462015-02-12 03:53:48 +000038class SVGUseElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired, public SVGURIReference, private CachedSVGDocumentClient {
zimmermann@webkit.orgabd88452008-10-09 03:34:43 +000039
zimmermann@webkit.orga2857422011-07-09 11:26:10 +000040 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGUseElement)
41 DECLARE_ANIMATED_LENGTH(X, x)
42 DECLARE_ANIMATED_LENGTH(Y, y)
43 DECLARE_ANIMATED_LENGTH(Width, width)
44 DECLARE_ANIMATED_LENGTH(Height, height)
zandobersek@gmail.com7d97f1c2015-06-12 13:44:43 +000045 DECLARE_ANIMATED_STRING_OVERRIDE(Href, href)
46 DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired)
zimmermann@webkit.orga2857422011-07-09 11:26:10 +000047 END_DECLARE_ANIMATED_PROPERTIES
zimmermann@webkit.orgab0da702010-12-01 12:17:12 +000048
darin@apple.com43c27462015-02-12 03:53:48 +000049public:
50 static Ref<SVGUseElement> create(const QualifiedName&, Document&);
51 virtual ~SVGUseElement();
52
53 void invalidateShadowTree();
54
55 RenderElement* rendererClipChild() const;
56
57private:
58 SVGUseElement(const QualifiedName&, Document&);
59
darin@apple.com11ff47c2016-03-04 16:47:55 +000060 bool isValid() const override;
61 InsertionNotificationRequest insertedInto(ContainerNode&) override;
62 void removedFrom(ContainerNode&) override;
63 void buildPendingResource() override;
64 void parseAttribute(const QualifiedName&, const AtomicString&) override;
65 void svgAttributeChanged(const QualifiedName&) override;
antti@apple.come7468a42016-04-01 09:54:12 +000066 bool willRecalcStyle(Style::Change) override;
antti@apple.comde6dae7b2016-04-24 13:54:59 +000067 RenderPtr<RenderElement> createElementRenderer(std::unique_ptr<RenderStyle>, const RenderTreePosition&) override;
darin@apple.com11ff47c2016-03-04 16:47:55 +000068 void toClipPath(Path&) override;
69 bool haveLoadedRequiredResources() override;
70 void finishParsingChildren() override;
71 bool selfHasRelativeLengths() const override;
72 void setHaveFiredLoadEvent(bool) override;
73 bool haveFiredLoadEvent() const override;
74 Timer* svgLoadEventTimer() override;
75 void notifyFinished(CachedResource*) override;
reni@webkit.orgff4b9f22012-03-14 08:52:35 +000076
darin@apple.com43c27462015-02-12 03:53:48 +000077 Document* externalDocument() const;
78 void updateExternalDocument();
zimmermann@webkit.org684359d2012-03-14 16:59:16 +000079
darin@apple.com43c27462015-02-12 03:53:48 +000080 SVGElement* findTarget(String* targetID = nullptr) const;
81
82 void cloneTarget(ContainerNode&, SVGElement& target) const;
83 SVGElement* targetClone() const;
84
85 void updateShadowTree();
86 void expandUseElementsInShadowTree() const;
87 void expandSymbolElementsInShadowTree() const;
88 void transferEventListenersToShadowTree() const;
89 void transferSizeAttributesToTargetClone(SVGElement&) const;
90
91 void clearShadowTree();
92 void invalidateDependentShadowTrees();
93
94 bool m_haveFiredLoadEvent { false };
95 bool m_shadowTreeNeedsUpdate { true };
96 CachedResourceHandle<CachedSVGDocument> m_externalDocument;
jer.noble@apple.com50862fe2014-11-06 23:06:03 +000097 Timer m_svgLoadEventTimer;
zimmermann@webkit.orgab0da702010-12-01 12:17:12 +000098};
weinigab5f09e2006-07-29 23:15:25 +000099
zimmermann@webkit.orga975c402010-01-21 23:22:56 +0000100}
darinb9481ed2006-03-20 02:57:59 +0000101
zimmermann@webkit.orga975c402010-01-21 23:22:56 +0000102#endif