| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 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> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef SVGUseElement_h | 21 #ifndef SVGUseElement_h |
| 22 #define SVGUseElement_h | 22 #define SVGUseElement_h |
| 23 | 23 |
| 24 #include "SVGNames.h" | 24 #include "SVGNames.h" |
| 25 #include "core/fetch/DocumentResource.h" | 25 #include "core/fetch/DocumentResource.h" |
| 26 #include "core/svg/SVGAnimatedBoolean.h" | 26 #include "core/svg/SVGAnimatedBoolean.h" |
| 27 #include "core/svg/SVGAnimatedLength.h" | 27 #include "core/svg/SVGAnimatedLength.h" |
| 28 #include "core/svg/SVGExternalResourcesRequired.h" | |
| 29 #include "core/svg/SVGGraphicsElement.h" | 28 #include "core/svg/SVGGraphicsElement.h" |
| 30 #include "core/svg/SVGURIReference.h" | 29 #include "core/svg/SVGURIReference.h" |
| 31 | 30 |
| 32 namespace WebCore { | 31 namespace WebCore { |
| 33 | 32 |
| 34 class DocumentResource; | 33 class DocumentResource; |
| 35 class SVGElementInstance; | 34 class SVGElementInstance; |
| 36 | 35 |
| 37 class SVGUseElement FINAL : public SVGGraphicsElement, | 36 class SVGUseElement FINAL : public SVGGraphicsElement, |
| 38 public SVGExternalResourcesRequired, | |
| 39 public SVGURIReference, | 37 public SVGURIReference, |
| 40 public DocumentResourceClient { | 38 public DocumentResourceClient { |
| 41 public: | 39 public: |
| 42 static PassRefPtr<SVGUseElement> create(Document&, bool wasInsertedByParser)
; | 40 static PassRefPtr<SVGUseElement> create(Document&, bool wasInsertedByParser)
; |
| 43 virtual ~SVGUseElement(); | 41 virtual ~SVGUseElement(); |
| 44 | 42 |
| 45 SVGElementInstance* instanceRoot(); | 43 SVGElementInstance* instanceRoot(); |
| 46 SVGElementInstance* animatedInstanceRoot() const; | 44 SVGElementInstance* animatedInstanceRoot() const; |
| 47 SVGElementInstance* instanceForShadowTreeElement(Node*) const; | 45 SVGElementInstance* instanceForShadowTreeElement(Node*) const; |
| 48 void invalidateShadowTree(); | 46 void invalidateShadowTree(); |
| 49 void invalidateDependentShadowTrees(); | 47 void invalidateDependentShadowTrees(); |
| 50 | 48 |
| 51 RenderObject* rendererClipChild() const; | 49 RenderObject* rendererClipChild() const; |
| 52 | 50 |
| 53 private: | 51 private: |
| 54 SVGUseElement(Document&, bool wasInsertedByParser); | 52 SVGUseElement(Document&, bool wasInsertedByParser); |
| 55 | 53 |
| 56 virtual bool isValid() const { return SVGTests::isValid(); } | 54 virtual bool isValid() const { return SVGTests::isValid(); } |
| 55 virtual bool isStructurallyExternal() const { return isExternalURIReference(
hrefCurrentValue(), document()); } |
| 57 virtual bool supportsFocus() const OVERRIDE { return hasFocusEventListeners(
); } | 56 virtual bool supportsFocus() const OVERRIDE { return hasFocusEventListeners(
); } |
| 58 | 57 |
| 59 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 58 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; |
| 60 virtual void removedFrom(ContainerNode*) OVERRIDE; | 59 virtual void removedFrom(ContainerNode*) OVERRIDE; |
| 61 virtual void buildPendingResource(); | 60 virtual void buildPendingResource(); |
| 62 | 61 |
| 63 bool isSupportedAttribute(const QualifiedName&); | 62 bool isSupportedAttribute(const QualifiedName&); |
| 64 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 63 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; |
| 65 virtual void svgAttributeChanged(const QualifiedName&); | 64 virtual void svgAttributeChanged(const QualifiedName&); |
| 66 | 65 |
| 67 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; | 66 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; |
| 68 virtual void willRecalcStyle(StyleRecalcChange) OVERRIDE; | 67 virtual void willRecalcStyle(StyleRecalcChange) OVERRIDE; |
| 69 | 68 |
| 70 virtual RenderObject* createRenderer(RenderStyle*); | 69 virtual RenderObject* createRenderer(RenderStyle*); |
| 71 virtual void toClipPath(Path&); | 70 virtual void toClipPath(Path&); |
| 72 | 71 |
| 73 void clearResourceReferences(); | 72 void clearResourceReferences(); |
| 74 void buildShadowAndInstanceTree(SVGElement* target); | 73 void buildShadowAndInstanceTree(SVGElement* target); |
| 75 void detachInstance(); | 74 void detachInstance(); |
| 76 | 75 |
| 77 virtual bool haveLoadedRequiredResources() { return SVGExternalResourcesRequ
ired::haveLoadedRequiredResources(); } | 76 virtual bool haveLoadedRequiredResources() { return m_haveFiredLoadEvent; } |
| 78 | 77 |
| 79 virtual void finishParsingChildren(); | 78 virtual void finishParsingChildren(); |
| 80 virtual bool selfHasRelativeLengths() const; | 79 virtual bool selfHasRelativeLengths() const; |
| 81 | 80 |
| 82 // Instance tree handling | 81 // Instance tree handling |
| 83 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstanc
e, bool& foundCycle, bool foundUse); | 82 void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstanc
e, bool& foundCycle, bool foundUse); |
| 84 bool hasCycleUseReferencing(SVGUseElement*, SVGElementInstance* targetInstan
ce, SVGElement*& newTarget); | 83 bool hasCycleUseReferencing(SVGUseElement*, SVGElementInstance* targetInstan
ce, SVGElement*& newTarget); |
| 85 | 84 |
| 86 // Shadow tree handling | 85 // Shadow tree handling |
| 87 void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance)
; | 86 void buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance)
; |
| 88 | 87 |
| 89 void expandUseElementsInShadowTree(Node* element); | 88 void expandUseElementsInShadowTree(Node* element); |
| 90 void expandSymbolElementsInShadowTree(Node* element); | 89 void expandSymbolElementsInShadowTree(Node* element); |
| 91 | 90 |
| 92 // "Tree connector" | 91 // "Tree connector" |
| 93 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstan
ce* targetInstance); | 92 void associateInstancesWithShadowTreeElements(Node* target, SVGElementInstan
ce* targetInstance); |
| 94 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementIn
stance* instance) const; | 93 SVGElementInstance* instanceForShadowTreeElement(Node* element, SVGElementIn
stance* instance) const; |
| 95 | 94 |
| 96 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to
) const; | 95 void transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to
) const; |
| 97 void transferEventListenersToShadowTree(SVGElementInstance* target); | 96 void transferEventListenersToShadowTree(SVGElementInstance* target); |
| 98 | 97 |
| 99 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGUseElement) | 98 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGUseElement) |
| 100 DECLARE_ANIMATED_LENGTH(X, x) | 99 DECLARE_ANIMATED_LENGTH(X, x) |
| 101 DECLARE_ANIMATED_LENGTH(Y, y) | 100 DECLARE_ANIMATED_LENGTH(Y, y) |
| 102 DECLARE_ANIMATED_LENGTH(Width, width) | 101 DECLARE_ANIMATED_LENGTH(Width, width) |
| 103 DECLARE_ANIMATED_LENGTH(Height, height) | 102 DECLARE_ANIMATED_LENGTH(Height, height) |
| 104 DECLARE_ANIMATED_STRING(Href, href) | 103 DECLARE_ANIMATED_STRING(Href, href) |
| 105 DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesReq
uired) | |
| 106 END_DECLARE_ANIMATED_PROPERTIES | 104 END_DECLARE_ANIMATED_PROPERTIES |
| 107 | 105 |
| 108 bool resourceIsStillLoading(); | 106 bool resourceIsStillLoading(); |
| 109 Document* externalDocument() const; | 107 Document* externalDocument() const; |
| 110 bool instanceTreeIsLoading(SVGElementInstance*); | 108 bool instanceTreeIsLoading(SVGElementInstance*); |
| 111 virtual void notifyFinished(Resource*); | 109 virtual void notifyFinished(Resource*); |
| 112 Document* referencedDocument() const; | 110 Document* referencedDocument() const; |
| 113 void setDocumentResource(ResourcePtr<DocumentResource>); | 111 void setDocumentResource(ResourcePtr<DocumentResource>); |
| 114 | 112 |
| 115 // SVGExternalResourcesRequired | |
| 116 virtual void setHaveFiredLoadEvent(bool haveFiredLoadEvent) { m_haveFiredLoa
dEvent = haveFiredLoadEvent; } | |
| 117 virtual bool isParserInserted() const { return m_wasInsertedByParser; } | |
| 118 virtual bool haveFiredLoadEvent() const { return m_haveFiredLoadEvent; } | |
| 119 virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadE
ventTimer; } | 113 virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadE
ventTimer; } |
| 120 | 114 |
| 121 bool m_wasInsertedByParser; | 115 bool m_wasInsertedByParser; |
| 122 bool m_haveFiredLoadEvent; | 116 bool m_haveFiredLoadEvent; |
| 123 bool m_needsShadowTreeRecreation; | 117 bool m_needsShadowTreeRecreation; |
| 124 RefPtr<SVGElementInstance> m_targetElementInstance; | 118 RefPtr<SVGElementInstance> m_targetElementInstance; |
| 125 ResourcePtr<DocumentResource> m_resource; | 119 ResourcePtr<DocumentResource> m_resource; |
| 126 Timer<SVGElement> m_svgLoadEventTimer; | 120 Timer<SVGElement> m_svgLoadEventTimer; |
| 127 }; | 121 }; |
| 128 | 122 |
| 129 DEFINE_NODE_TYPE_CASTS(SVGUseElement, hasTagName(SVGNames::useTag)); | 123 DEFINE_NODE_TYPE_CASTS(SVGUseElement, hasTagName(SVGNames::useTag)); |
| 130 | 124 |
| 131 } | 125 } |
| 132 | 126 |
| 133 #endif | 127 #endif |
| OLD | NEW |