Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: Source/core/svg/SVGUseElement.cpp

Issue 62083002: Remove support for the externalResourcesRequired attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebaseline test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | Source/core/svg/SVGUseElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // #define DUMP_SHADOW_TREE 50 // #define DUMP_SHADOW_TREE
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 // Animated property definitions 54 // Animated property definitions
55 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x) 55 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x)
56 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) 56 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y)
57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) 57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width)
58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) 58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height)
59 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) 59 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href)
60 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
61 60
62 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) 61 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement)
63 REGISTER_LOCAL_ANIMATED_PROPERTY(x) 62 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
64 REGISTER_LOCAL_ANIMATED_PROPERTY(y) 63 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
65 REGISTER_LOCAL_ANIMATED_PROPERTY(width) 64 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
66 REGISTER_LOCAL_ANIMATED_PROPERTY(height) 65 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
67 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 66 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
68 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
69 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 67 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
70 END_REGISTER_ANIMATED_PROPERTIES 68 END_REGISTER_ANIMATED_PROPERTIES
71 69
72 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser ) 70 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser )
73 : SVGGraphicsElement(SVGNames::useTag, document) 71 : SVGGraphicsElement(SVGNames::useTag, document)
74 , m_x(LengthModeWidth) 72 , m_x(LengthModeWidth)
75 , m_y(LengthModeHeight) 73 , m_y(LengthModeHeight)
76 , m_width(LengthModeWidth) 74 , m_width(LengthModeWidth)
77 , m_height(LengthModeHeight) 75 , m_height(LengthModeHeight)
78 , m_wasInsertedByParser(wasInsertedByParser) 76 , m_wasInsertedByParser(wasInsertedByParser)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 SVGElementInstance* SVGUseElement::animatedInstanceRoot() const 113 SVGElementInstance* SVGUseElement::animatedInstanceRoot() const
116 { 114 {
117 // FIXME: Implement me. 115 // FIXME: Implement me.
118 return 0; 116 return 0;
119 } 117 }
120 118
121 bool SVGUseElement::isSupportedAttribute(const QualifiedName& attrName) 119 bool SVGUseElement::isSupportedAttribute(const QualifiedName& attrName)
122 { 120 {
123 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 121 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
124 if (supportedAttributes.isEmpty()) { 122 if (supportedAttributes.isEmpty()) {
125 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
126 SVGURIReference::addSupportedAttributes(supportedAttributes); 123 SVGURIReference::addSupportedAttributes(supportedAttributes);
127 supportedAttributes.add(SVGNames::xAttr); 124 supportedAttributes.add(SVGNames::xAttr);
128 supportedAttributes.add(SVGNames::yAttr); 125 supportedAttributes.add(SVGNames::yAttr);
129 supportedAttributes.add(SVGNames::widthAttr); 126 supportedAttributes.add(SVGNames::widthAttr);
130 supportedAttributes.add(SVGNames::heightAttr); 127 supportedAttributes.add(SVGNames::heightAttr);
131 } 128 }
132 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 129 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
133 } 130 }
134 131
135 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString & value) 132 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString & value)
136 { 133 {
137 SVGParsingError parseError = NoError; 134 SVGParsingError parseError = NoError;
138 135
139 if (!isSupportedAttribute(name)) 136 if (!isSupportedAttribute(name))
140 SVGGraphicsElement::parseAttribute(name, value); 137 SVGGraphicsElement::parseAttribute(name, value);
141 else if (name == SVGNames::xAttr) 138 else if (name == SVGNames::xAttr)
142 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 139 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
143 else if (name == SVGNames::yAttr) 140 else if (name == SVGNames::yAttr)
144 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 141 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ;
145 else if (name == SVGNames::widthAttr) 142 else if (name == SVGNames::widthAttr)
146 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 143 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths));
147 else if (name == SVGNames::heightAttr) 144 else if (name == SVGNames::heightAttr)
148 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 145 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths));
149 else if (SVGExternalResourcesRequired::parseAttribute(name, value) 146 else if (SVGURIReference::parseAttribute(name, value)) {
150 || SVGURIReference::parseAttribute(name, value)) {
151 } else 147 } else
152 ASSERT_NOT_REACHED(); 148 ASSERT_NOT_REACHED();
153 149
154 reportAttributeParsingError(parseError, name, value); 150 reportAttributeParsingError(parseError, name, value);
155 } 151 }
156 152
157 #if !ASSERT_DISABLED 153 #if !ASSERT_DISABLED
158 static inline bool isWellFormedDocument(Document* document) 154 static inline bool isWellFormedDocument(Document* document)
159 { 155 {
160 if (document->isSVGDocument() || document->isXHTMLDocument()) 156 if (document->isSVGDocument() || document->isXHTMLDocument())
161 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ; 157 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed() ;
162 return true; 158 return true;
163 } 159 }
164 #endif 160 #endif
165 161
166 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent) 162 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro otParent)
167 { 163 {
168 // This functions exists to assure assumptions made in the code regarding SV GElementInstance creation/destruction are satisfied. 164 // This functions exists to assure assumptions made in the code regarding SV GElementInstance creation/destruction are satisfied.
169 SVGGraphicsElement::insertedInto(rootParent); 165 SVGGraphicsElement::insertedInto(rootParent);
170 if (!rootParent->inDocument()) 166 if (!rootParent->inDocument())
171 return InsertionDone; 167 return InsertionDone;
172 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); 168 ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document()));
173 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); 169 ASSERT(!hasPendingResources() || !isWellFormedDocument(&document()));
174 if (!m_wasInsertedByParser) 170 if (!m_wasInsertedByParser) {
175 buildPendingResource(); 171 buildPendingResource();
176 SVGExternalResourcesRequired::insertedIntoDocument(this); 172
173 m_haveFiredLoadEvent = true;
174 sendSVGLoadEventIfPossibleAsynchronously();
175 }
176
177 return InsertionDone; 177 return InsertionDone;
178 } 178 }
179 179
180 void SVGUseElement::removedFrom(ContainerNode* rootParent) 180 void SVGUseElement::removedFrom(ContainerNode* rootParent)
181 { 181 {
182 SVGGraphicsElement::removedFrom(rootParent); 182 SVGGraphicsElement::removedFrom(rootParent);
183 if (rootParent->inDocument()) 183 if (rootParent->inDocument())
184 clearResourceReferences(); 184 clearResourceReferences();
185 } 185 }
186 186
(...skipping 29 matching lines...) Expand all
216 if (attrName == SVGNames::xAttr 216 if (attrName == SVGNames::xAttr
217 || attrName == SVGNames::yAttr 217 || attrName == SVGNames::yAttr
218 || attrName == SVGNames::widthAttr 218 || attrName == SVGNames::widthAttr
219 || attrName == SVGNames::heightAttr) { 219 || attrName == SVGNames::heightAttr) {
220 updateRelativeLengthsInformation(); 220 updateRelativeLengthsInformation();
221 if (renderer) 221 if (renderer)
222 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er); 222 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er);
223 return; 223 return;
224 } 224 }
225 225
226 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName))
227 return;
228
229 if (SVGURIReference::isKnownAttribute(attrName)) { 226 if (SVGURIReference::isKnownAttribute(attrName)) {
230 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do cument()); 227 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do cument());
231 if (isExternalReference) { 228 if (isExternalReference) {
232 KURL url = document().completeURL(hrefCurrentValue()); 229 KURL url = document().completeURL(hrefCurrentValue());
233 if (url.hasFragmentIdentifier()) { 230 if (url.hasFragmentIdentifier()) {
234 FetchRequest request(ResourceRequest(url.string()), localName()) ; 231 FetchRequest request(ResourceRequest(url.string()), localName()) ;
235 setDocumentResource(document().fetcher()->fetchSVGDocument(reque st)); 232 setDocumentResource(document().fetcher()->fetchSVGDocument(reque st));
236 } 233 }
237 } else { 234 } else {
238 setDocumentResource(0); 235 setDocumentResource(0);
239 } 236 }
240 237
241 if (!m_wasInsertedByParser) 238 if (!m_wasInsertedByParser)
242 buildPendingResource(); 239 buildPendingResource();
243 240
244 return; 241 return;
245 } 242 }
246 243
247 if (!renderer) 244 if (!renderer)
248 return; 245 return;
249 246
250 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) {
251 invalidateShadowTree();
252 return;
253 }
254
255 ASSERT_NOT_REACHED(); 247 ASSERT_NOT_REACHED();
256 } 248 }
257 249
258 void SVGUseElement::attach(const AttachContext& context) 250 void SVGUseElement::attach(const AttachContext& context)
259 { 251 {
260 if (m_needsShadowTreeRecreation) 252 if (m_needsShadowTreeRecreation)
261 buildPendingResource(); 253 buildPendingResource();
262 SVGGraphicsElement::attach(context); 254 SVGGraphicsElement::attach(context);
263 } 255 }
264 256
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } 934 }
943 935
944 void SVGUseElement::notifyFinished(Resource* resource) 936 void SVGUseElement::notifyFinished(Resource* resource)
945 { 937 {
946 if (!inDocument()) 938 if (!inDocument())
947 return; 939 return;
948 940
949 invalidateShadowTree(); 941 invalidateShadowTree();
950 if (resource->errorOccurred()) 942 if (resource->errorOccurred())
951 dispatchEvent(Event::create(EventTypeNames::error)); 943 dispatchEvent(Event::create(EventTypeNames::error));
952 else if (!resource->wasCanceled()) 944 else if (!resource->wasCanceled()) {
953 SVGExternalResourcesRequired::dispatchLoadEvent(this); 945 if (!m_wasInsertedByParser)
946 ASSERT(m_haveFiredLoadEvent);
947 else if (m_haveFiredLoadEvent)
948 return;
949 }
954 } 950 }
955 951
956 bool SVGUseElement::resourceIsStillLoading() 952 bool SVGUseElement::resourceIsStillLoading()
957 { 953 {
958 if (m_resource && m_resource->isLoading()) 954 if (m_resource && m_resource->isLoading())
959 return true; 955 return true;
960 return false; 956 return false;
961 } 957 }
962 958
963 bool SVGUseElement::instanceTreeIsLoading(SVGElementInstance* targetElementInsta nce) 959 bool SVGUseElement::instanceTreeIsLoading(SVGElementInstance* targetElementInsta nce)
964 { 960 {
965 for (SVGElementInstance* instance = targetElementInstance->firstChild(); ins tance; instance = instance->nextSibling()) { 961 for (SVGElementInstance* instance = targetElementInstance->firstChild(); ins tance; instance = instance->nextSibling()) {
966 if (SVGUseElement* use = instance->correspondingUseElement()) { 962 if (SVGUseElement* use = instance->correspondingUseElement()) {
967 if (use->resourceIsStillLoading()) 963 if (use->resourceIsStillLoading())
968 return true; 964 return true;
969 } 965 }
970 if (instance->hasChildNodes()) 966 if (instance->hasChildNodes())
971 instanceTreeIsLoading(instance); 967 instanceTreeIsLoading(instance);
972 } 968 }
973 return false; 969 return false;
974 } 970 }
975 971
976 void SVGUseElement::finishParsingChildren() 972 void SVGUseElement::finishParsingChildren()
977 { 973 {
978 SVGGraphicsElement::finishParsingChildren(); 974 SVGGraphicsElement::finishParsingChildren();
979 SVGExternalResourcesRequired::finishParsingChildren(); 975 m_haveFiredLoadEvent = true;
980 if (m_wasInsertedByParser) { 976 if (m_wasInsertedByParser) {
981 buildPendingResource(); 977 buildPendingResource();
982 m_wasInsertedByParser = false; 978 m_wasInsertedByParser = false;
983 } 979 }
984 } 980 }
985 981
986 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource) 982 void SVGUseElement::setDocumentResource(ResourcePtr<DocumentResource> resource)
987 { 983 {
988 if (m_resource == resource) 984 if (m_resource == resource)
989 return; 985 return;
990 986
991 if (m_resource) 987 if (m_resource)
992 m_resource->removeClient(this); 988 m_resource->removeClient(this);
993 989
994 m_resource = resource; 990 m_resource = resource;
995 if (m_resource) 991 if (m_resource)
996 m_resource->addClient(this); 992 m_resource->addClient(this);
997 } 993 }
998 994
999 } 995 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | Source/core/svg/SVGUseElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698