Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / svg / SVGUseElement.h
blob778ced47d08f68290e7a9d69a06759a78c78f187
1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
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.
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.
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.
21 #ifndef SVGUseElement_h
22 #define SVGUseElement_h
24 #include "core/events/EventSender.h"
25 #include "core/fetch/DocumentResource.h"
26 #include "core/svg/SVGAnimatedLength.h"
27 #include "core/svg/SVGGeometryElement.h"
28 #include "core/svg/SVGGraphicsElement.h"
29 #include "core/svg/SVGURIReference.h"
30 #include "platform/heap/Handle.h"
32 namespace blink {
34 typedef EventSender<SVGUseElement> SVGUseEventSender;
36 class SVGUseElement final : public SVGGraphicsElement,
37 public SVGURIReference,
38 public DocumentResourceClient {
39 DEFINE_WRAPPERTYPEINFO();
40 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SVGUseElement);
41 public:
42 static PassRefPtrWillBeRawPtr<SVGUseElement> create(Document&);
43 ~SVGUseElement() override;
45 void invalidateShadowTree();
47 // Return the element that should be used for clipping,
48 // or null if a valid clip element is not directly referenced.
49 SVGGraphicsElement* targetGraphicsElementForClipping() const;
51 SVGAnimatedLength* x() const { return m_x.get(); }
52 SVGAnimatedLength* y() const { return m_y.get(); }
53 SVGAnimatedLength* width() const { return m_width.get(); }
54 SVGAnimatedLength* height() const { return m_height.get(); }
56 void buildPendingResource() override;
58 void dispatchPendingEvent(SVGUseEventSender*);
59 void toClipPath(Path&) const;
61 DECLARE_VIRTUAL_TRACE();
63 private:
64 explicit SVGUseElement(Document&);
66 FloatRect getBBox() override;
68 bool isPresentationAttribute(const QualifiedName&) const override;
69 void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) override;
70 bool isPresentationAttributeWithSVGDOM(const QualifiedName&) const override;
72 bool isStructurallyExternal() const override { return !hrefString().isNull() && isExternalURIReference(hrefString(), document()); }
74 InsertionNotificationRequest insertedInto(ContainerNode*) override;
75 void removedFrom(ContainerNode*) override;
77 void svgAttributeChanged(const QualifiedName&) override;
79 LayoutObject* createLayoutObject(const ComputedStyle&) override;
81 void scheduleShadowTreeRecreation();
82 void cancelShadowTreeRecreation();
83 bool haveLoadedRequiredResources() override { return !isStructurallyExternal() || m_haveFiredLoadEvent; }
85 bool selfHasRelativeLengths() const override;
87 // Instance tree handling
88 void buildShadowAndInstanceTree(SVGElement* target);
89 void clearInstanceRoot();
90 bool buildShadowTree(SVGElement* target, SVGElement* targetInstance, bool foundUse);
91 void clearShadowTree();
92 bool hasCycleUseReferencing(SVGUseElement*, ContainerNode* targetInstance, SVGElement*& newTarget);
93 bool expandUseElementsInShadowTree(SVGElement*);
94 void expandSymbolElementsInShadowTree(SVGElement*);
96 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const;
98 void invalidateDependentShadowTrees();
100 bool resourceIsStillLoading();
101 Document* externalDocument() const;
102 bool instanceTreeIsLoading(SVGElement*);
103 void notifyFinished(Resource*) override;
104 TreeScope* referencedScope() const;
105 void setDocumentResource(ResourcePtr<DocumentResource>);
107 RefPtrWillBeMember<SVGAnimatedLength> m_x;
108 RefPtrWillBeMember<SVGAnimatedLength> m_y;
109 RefPtrWillBeMember<SVGAnimatedLength> m_width;
110 RefPtrWillBeMember<SVGAnimatedLength> m_height;
112 bool m_haveFiredLoadEvent;
113 bool m_needsShadowTreeRecreation;
114 RefPtrWillBeMember<SVGElement> m_targetElementInstance;
115 ResourcePtr<DocumentResource> m_resource;
118 } // namespace blink
120 #endif // SVGUseElement_h