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 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
6 * Copyright (C) 2012 University of Szeged | 6 * Copyright (C) 2012 University of Szeged |
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> | 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // #define DUMP_SHADOW_TREE | 52 // #define DUMP_SHADOW_TREE |
53 | 53 |
54 namespace WebCore { | 54 namespace WebCore { |
55 | 55 |
56 // Animated property definitions | 56 // Animated property definitions |
57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x) | 57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x) |
58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) | 58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) |
59 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) | 59 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) |
60 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) | 60 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) |
61 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) | 61 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) |
62 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | |
63 | 62 |
64 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) | 63 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) |
65 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 64 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
66 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 65 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
67 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 66 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
68 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 67 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
69 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 68 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
70 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | |
71 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 69 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
72 END_REGISTER_ANIMATED_PROPERTIES | 70 END_REGISTER_ANIMATED_PROPERTIES |
73 | 71 |
74 inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document& docu
ment, bool wasInsertedByParser) | 72 inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document& docu
ment, bool wasInsertedByParser) |
75 : SVGGraphicsElement(tagName, document) | 73 : SVGGraphicsElement(tagName, document) |
76 , m_x(LengthModeWidth) | 74 , m_x(LengthModeWidth) |
77 , m_y(LengthModeHeight) | 75 , m_y(LengthModeHeight) |
78 , m_width(LengthModeWidth) | 76 , m_width(LengthModeWidth) |
79 , m_height(LengthModeHeight) | 77 , m_height(LengthModeHeight) |
80 , m_wasInsertedByParser(wasInsertedByParser) | 78 , m_wasInsertedByParser(wasInsertedByParser) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 { | 117 { |
120 // FIXME: Implement me. | 118 // FIXME: Implement me. |
121 return 0; | 119 return 0; |
122 } | 120 } |
123 | 121 |
124 bool SVGUseElement::isSupportedAttribute(const QualifiedName& attrName) | 122 bool SVGUseElement::isSupportedAttribute(const QualifiedName& attrName) |
125 { | 123 { |
126 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 124 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
127 if (supportedAttributes.isEmpty()) { | 125 if (supportedAttributes.isEmpty()) { |
128 SVGLangSpace::addSupportedAttributes(supportedAttributes); | 126 SVGLangSpace::addSupportedAttributes(supportedAttributes); |
129 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | |
130 SVGURIReference::addSupportedAttributes(supportedAttributes); | 127 SVGURIReference::addSupportedAttributes(supportedAttributes); |
131 supportedAttributes.add(SVGNames::xAttr); | 128 supportedAttributes.add(SVGNames::xAttr); |
132 supportedAttributes.add(SVGNames::yAttr); | 129 supportedAttributes.add(SVGNames::yAttr); |
133 supportedAttributes.add(SVGNames::widthAttr); | 130 supportedAttributes.add(SVGNames::widthAttr); |
134 supportedAttributes.add(SVGNames::heightAttr); | 131 supportedAttributes.add(SVGNames::heightAttr); |
135 } | 132 } |
136 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 133 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
137 } | 134 } |
138 | 135 |
139 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString
& value) | 136 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString
& value) |
140 { | 137 { |
141 SVGParsingError parseError = NoError; | 138 SVGParsingError parseError = NoError; |
142 | 139 |
143 if (!isSupportedAttribute(name)) | 140 if (!isSupportedAttribute(name)) |
144 SVGGraphicsElement::parseAttribute(name, value); | 141 SVGGraphicsElement::parseAttribute(name, value); |
145 else if (name == SVGNames::xAttr) | 142 else if (name == SVGNames::xAttr) |
146 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 143 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
147 else if (name == SVGNames::yAttr) | 144 else if (name == SVGNames::yAttr) |
148 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 145 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
149 else if (name == SVGNames::widthAttr) | 146 else if (name == SVGNames::widthAttr) |
150 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 147 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); |
151 else if (name == SVGNames::heightAttr) | 148 else if (name == SVGNames::heightAttr) |
152 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 149 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); |
153 else if (SVGLangSpace::parseAttribute(name, value) | 150 else if (SVGLangSpace::parseAttribute(name, value) |
154 || SVGExternalResourcesRequired::parseAttribute(name, value) | |
155 || SVGURIReference::parseAttribute(name, value)) { | 151 || SVGURIReference::parseAttribute(name, value)) { |
156 } else | 152 } else |
157 ASSERT_NOT_REACHED(); | 153 ASSERT_NOT_REACHED(); |
158 | 154 |
159 reportAttributeParsingError(parseError, name, value); | 155 reportAttributeParsingError(parseError, name, value); |
160 } | 156 } |
161 | 157 |
162 static inline bool isWellFormedDocument(Document* document) | 158 static inline bool isWellFormedDocument(Document* document) |
163 { | 159 { |
164 if (document->isSVGDocument() || document->isXHTMLDocument()) | 160 if (document->isSVGDocument() || document->isXHTMLDocument()) |
165 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; | 161 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; |
166 return true; | 162 return true; |
167 } | 163 } |
168 | 164 |
169 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) | 165 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) |
170 { | 166 { |
171 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. | 167 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. |
172 SVGGraphicsElement::insertedInto(rootParent); | 168 SVGGraphicsElement::insertedInto(rootParent); |
173 if (!rootParent->inDocument()) | 169 if (!rootParent->inDocument()) |
174 return InsertionDone; | 170 return InsertionDone; |
175 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); | 171 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); |
176 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); | 172 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); |
177 if (!m_wasInsertedByParser) | 173 if (!m_wasInsertedByParser) { |
178 buildPendingResource(); | 174 buildPendingResource(); |
179 SVGExternalResourcesRequired::insertedIntoDocument(this); | 175 |
| 176 m_haveFiredLoadEvent = true; |
| 177 sendSVGLoadEventIfPossibleAsynchronously(); |
| 178 } |
| 179 |
180 return InsertionDone; | 180 return InsertionDone; |
181 } | 181 } |
182 | 182 |
183 void SVGUseElement::removedFrom(ContainerNode* rootParent) | 183 void SVGUseElement::removedFrom(ContainerNode* rootParent) |
184 { | 184 { |
185 SVGGraphicsElement::removedFrom(rootParent); | 185 SVGGraphicsElement::removedFrom(rootParent); |
186 if (rootParent->inDocument()) | 186 if (rootParent->inDocument()) |
187 clearResourceReferences(); | 187 clearResourceReferences(); |
188 } | 188 } |
189 | 189 |
(...skipping 29 matching lines...) Expand all Loading... |
219 if (attrName == SVGNames::xAttr | 219 if (attrName == SVGNames::xAttr |
220 || attrName == SVGNames::yAttr | 220 || attrName == SVGNames::yAttr |
221 || attrName == SVGNames::widthAttr | 221 || attrName == SVGNames::widthAttr |
222 || attrName == SVGNames::heightAttr) { | 222 || attrName == SVGNames::heightAttr) { |
223 updateRelativeLengthsInformation(); | 223 updateRelativeLengthsInformation(); |
224 if (renderer) | 224 if (renderer) |
225 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); | 225 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); |
226 return; | 226 return; |
227 } | 227 } |
228 | 228 |
229 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) | |
230 return; | |
231 | |
232 if (SVGURIReference::isKnownAttribute(attrName)) { | 229 if (SVGURIReference::isKnownAttribute(attrName)) { |
233 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do
cument()); | 230 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do
cument()); |
234 if (isExternalReference) { | 231 if (isExternalReference) { |
235 KURL url = document().completeURL(hrefCurrentValue()); | 232 KURL url = document().completeURL(hrefCurrentValue()); |
236 if (url.hasFragmentIdentifier()) { | 233 if (url.hasFragmentIdentifier()) { |
237 FetchRequest request(ResourceRequest(url.string()), localName())
; | 234 FetchRequest request(ResourceRequest(url.string()), localName())
; |
238 setDocumentResource(document().fetcher()->fetchSVGDocument(reque
st)); | 235 setDocumentResource(document().fetcher()->fetchSVGDocument(reque
st)); |
239 } | 236 } |
240 } else { | 237 } else { |
241 setDocumentResource(0); | 238 setDocumentResource(0); |
242 } | 239 } |
243 | 240 |
244 if (!m_wasInsertedByParser) | 241 if (!m_wasInsertedByParser) |
245 buildPendingResource(); | 242 buildPendingResource(); |
246 | 243 |
247 return; | 244 return; |
248 } | 245 } |
249 | 246 |
250 if (!renderer) | 247 if (!renderer) |
251 return; | 248 return; |
252 | 249 |
253 if (SVGLangSpace::isKnownAttribute(attrName) | 250 if (SVGLangSpace::isKnownAttribute(attrName)) { |
254 || SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | |
255 invalidateShadowTree(); | 251 invalidateShadowTree(); |
256 return; | 252 return; |
257 } | 253 } |
258 | 254 |
259 ASSERT_NOT_REACHED(); | 255 ASSERT_NOT_REACHED(); |
260 } | 256 } |
261 | 257 |
262 void SVGUseElement::attach(const AttachContext& context) | 258 void SVGUseElement::attach(const AttachContext& context) |
263 { | 259 { |
264 if (m_needsShadowTreeRecreation) | 260 if (m_needsShadowTreeRecreation) |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 } | 940 } |
945 | 941 |
946 void SVGUseElement::notifyFinished(Resource* resource) | 942 void SVGUseElement::notifyFinished(Resource* resource) |
947 { | 943 { |
948 if (!inDocument()) | 944 if (!inDocument()) |
949 return; | 945 return; |
950 | 946 |
951 invalidateShadowTree(); | 947 invalidateShadowTree(); |
952 if (resource->errorOccurred()) | 948 if (resource->errorOccurred()) |
953 dispatchEvent(Event::create(EventTypeNames::error)); | 949 dispatchEvent(Event::create(EventTypeNames::error)); |
954 else if (!resource->wasCanceled()) | 950 else if (!resource->wasCanceled()) { |
955 SVGExternalResourcesRequired::dispatchLoadEvent(this); | 951 if (!m_wasInsertedByParser) |
| 952 ASSERT(m_haveFiredLoadEvent); |
| 953 else if (m_haveFiredLoadEvent) |
| 954 return; |
| 955 } |
956 } | 956 } |
957 | 957 |
958 bool SVGUseElement::resourceIsStillLoading() | 958 bool SVGUseElement::resourceIsStillLoading() |
959 { | 959 { |
960 if (m_resource && m_resource->isLoading()) | 960 if (m_resource && m_resource->isLoading()) |
961 return true; | 961 return true; |
962 return false; | 962 return false; |
963 } | 963 } |
964 | 964 |
965 bool SVGUseElement::instanceTreeIsLoading(SVGElementInstance* targetElementInsta
nce) | 965 bool SVGUseElement::instanceTreeIsLoading(SVGElementInstance* targetElementInsta
nce) |
966 { | 966 { |
967 for (SVGElementInstance* instance = targetElementInstance->firstChild(); ins
tance; instance = instance->nextSibling()) { | 967 for (SVGElementInstance* instance = targetElementInstance->firstChild(); ins
tance; instance = instance->nextSibling()) { |
968 if (SVGUseElement* use = instance->correspondingUseElement()) { | 968 if (SVGUseElement* use = instance->correspondingUseElement()) { |
969 if (use->resourceIsStillLoading()) | 969 if (use->resourceIsStillLoading()) |
970 return true; | 970 return true; |
971 } | 971 } |
972 if (instance->hasChildNodes()) | 972 if (instance->hasChildNodes()) |
973 instanceTreeIsLoading(instance); | 973 instanceTreeIsLoading(instance); |
974 } | 974 } |
975 return false; | 975 return false; |
976 } | 976 } |
977 | 977 |
978 void SVGUseElement::finishParsingChildren() | 978 void SVGUseElement::finishParsingChildren() |
979 { | 979 { |
980 SVGGraphicsElement::finishParsingChildren(); | 980 SVGGraphicsElement::finishParsingChildren(); |
981 SVGExternalResourcesRequired::finishParsingChildren(); | 981 m_haveFiredLoadEvent = true; |
982 if (m_wasInsertedByParser) { | 982 if (m_wasInsertedByParser) { |
983 buildPendingResource(); | 983 buildPendingResource(); |
984 m_wasInsertedByParser = false; | 984 m_wasInsertedByParser = false; |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource) | 988 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource) |
989 { | 989 { |
990 if (m_resource == resource) | 990 if (m_resource == resource) |
991 return; | 991 return; |
992 | 992 |
993 if (m_resource) | 993 if (m_resource) |
994 m_resource->removeClient(this); | 994 m_resource->removeClient(this); |
995 | 995 |
996 m_resource = resource; | 996 m_resource = resource; |
997 if (m_resource) | 997 if (m_resource) |
998 m_resource->addClient(this); | 998 m_resource->addClient(this); |
999 } | 999 } |
1000 | 1000 |
1001 } | 1001 } |
OLD | NEW |