| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) | 60 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) |
| 61 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | 61 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) |
| 62 | 62 |
| 63 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) | 63 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) |
| 64 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 64 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
| 65 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 65 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
| 66 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 66 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
| 67 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 67 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
| 68 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 68 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
| 69 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 69 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
| 70 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledTransformableElement) | 70 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
| 71 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) | |
| 72 END_REGISTER_ANIMATED_PROPERTIES | 71 END_REGISTER_ANIMATED_PROPERTIES |
| 73 | 72 |
| 74 inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* docu
ment, bool wasInsertedByParser) | 73 inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* docu
ment, bool wasInsertedByParser) |
| 75 : SVGStyledTransformableElement(tagName, document) | 74 : SVGGraphicsElement(tagName, document) |
| 76 , m_x(LengthModeWidth) | 75 , m_x(LengthModeWidth) |
| 77 , m_y(LengthModeHeight) | 76 , m_y(LengthModeHeight) |
| 78 , m_width(LengthModeWidth) | 77 , m_width(LengthModeWidth) |
| 79 , m_height(LengthModeHeight) | 78 , m_height(LengthModeHeight) |
| 80 , m_wasInsertedByParser(wasInsertedByParser) | 79 , m_wasInsertedByParser(wasInsertedByParser) |
| 81 , m_haveFiredLoadEvent(false) | 80 , m_haveFiredLoadEvent(false) |
| 82 , m_needsShadowTreeRecreation(false) | 81 , m_needsShadowTreeRecreation(false) |
| 83 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) | 82 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) |
| 84 { | 83 { |
| 85 ASSERT(hasCustomStyleCallbacks()); | 84 ASSERT(hasCustomStyleCallbacks()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 supportedAttributes.add(SVGNames::heightAttr); | 134 supportedAttributes.add(SVGNames::heightAttr); |
| 136 } | 135 } |
| 137 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 136 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 138 } | 137 } |
| 139 | 138 |
| 140 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString
& value) | 139 void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString
& value) |
| 141 { | 140 { |
| 142 SVGParsingError parseError = NoError; | 141 SVGParsingError parseError = NoError; |
| 143 | 142 |
| 144 if (!isSupportedAttribute(name)) | 143 if (!isSupportedAttribute(name)) |
| 145 SVGStyledTransformableElement::parseAttribute(name, value); | 144 SVGGraphicsElement::parseAttribute(name, value); |
| 146 else if (name == SVGNames::xAttr) | 145 else if (name == SVGNames::xAttr) |
| 147 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 146 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
| 148 else if (name == SVGNames::yAttr) | 147 else if (name == SVGNames::yAttr) |
| 149 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 148 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
| 150 else if (name == SVGNames::widthAttr) | 149 else if (name == SVGNames::widthAttr) |
| 151 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 150 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); |
| 152 else if (name == SVGNames::heightAttr) | 151 else if (name == SVGNames::heightAttr) |
| 153 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 152 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); |
| 154 else if (SVGTests::parseAttribute(name, value) | 153 else if (SVGTests::parseAttribute(name, value) |
| 155 || SVGLangSpace::parseAttribute(name, value) | 154 || SVGLangSpace::parseAttribute(name, value) |
| 156 || SVGExternalResourcesRequired::parseAttribute(name, value) | 155 || SVGExternalResourcesRequired::parseAttribute(name, value) |
| 157 || SVGURIReference::parseAttribute(name, value)) { | 156 || SVGURIReference::parseAttribute(name, value)) { |
| 158 } else | 157 } else |
| 159 ASSERT_NOT_REACHED(); | 158 ASSERT_NOT_REACHED(); |
| 160 | 159 |
| 161 reportAttributeParsingError(parseError, name, value); | 160 reportAttributeParsingError(parseError, name, value); |
| 162 } | 161 } |
| 163 | 162 |
| 164 static inline bool isWellFormedDocument(Document* document) | 163 static inline bool isWellFormedDocument(Document* document) |
| 165 { | 164 { |
| 166 if (document->isSVGDocument() || document->isXHTMLDocument()) | 165 if (document->isSVGDocument() || document->isXHTMLDocument()) |
| 167 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; | 166 return static_cast<XMLDocumentParser*>(document->parser())->wellFormed()
; |
| 168 return true; | 167 return true; |
| 169 } | 168 } |
| 170 | 169 |
| 171 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) | 170 Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* ro
otParent) |
| 172 { | 171 { |
| 173 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. | 172 // This functions exists to assure assumptions made in the code regarding SV
GElementInstance creation/destruction are satisfied. |
| 174 SVGStyledTransformableElement::insertedInto(rootParent); | 173 SVGGraphicsElement::insertedInto(rootParent); |
| 175 if (!rootParent->inDocument()) | 174 if (!rootParent->inDocument()) |
| 176 return InsertionDone; | 175 return InsertionDone; |
| 177 ASSERT(!m_targetElementInstance || !isWellFormedDocument(document())); | 176 ASSERT(!m_targetElementInstance || !isWellFormedDocument(document())); |
| 178 ASSERT(!hasPendingResources() || !isWellFormedDocument(document())); | 177 ASSERT(!hasPendingResources() || !isWellFormedDocument(document())); |
| 179 if (!m_wasInsertedByParser) | 178 if (!m_wasInsertedByParser) |
| 180 buildPendingResource(); | 179 buildPendingResource(); |
| 181 SVGExternalResourcesRequired::insertedIntoDocument(this); | 180 SVGExternalResourcesRequired::insertedIntoDocument(this); |
| 182 return InsertionDone; | 181 return InsertionDone; |
| 183 } | 182 } |
| 184 | 183 |
| 185 void SVGUseElement::removedFrom(ContainerNode* rootParent) | 184 void SVGUseElement::removedFrom(ContainerNode* rootParent) |
| 186 { | 185 { |
| 187 SVGStyledTransformableElement::removedFrom(rootParent); | 186 SVGGraphicsElement::removedFrom(rootParent); |
| 188 if (rootParent->inDocument()) | 187 if (rootParent->inDocument()) |
| 189 clearResourceReferences(); | 188 clearResourceReferences(); |
| 190 } | 189 } |
| 191 | 190 |
| 192 Document* SVGUseElement::referencedDocument() const | 191 Document* SVGUseElement::referencedDocument() const |
| 193 { | 192 { |
| 194 if (!isExternalURIReference(href(), document())) | 193 if (!isExternalURIReference(href(), document())) |
| 195 return document(); | 194 return document(); |
| 196 return externalDocument(); | 195 return externalDocument(); |
| 197 } | 196 } |
| 198 | 197 |
| 199 Document* SVGUseElement::externalDocument() const | 198 Document* SVGUseElement::externalDocument() const |
| 200 { | 199 { |
| 201 if (m_cachedDocument && m_cachedDocument->isLoaded()) { | 200 if (m_cachedDocument && m_cachedDocument->isLoaded()) { |
| 202 // Gracefully handle error condition. | 201 // Gracefully handle error condition. |
| 203 if (m_cachedDocument->errorOccurred()) | 202 if (m_cachedDocument->errorOccurred()) |
| 204 return 0; | 203 return 0; |
| 205 ASSERT(m_cachedDocument->document()); | 204 ASSERT(m_cachedDocument->document()); |
| 206 return m_cachedDocument->document(); | 205 return m_cachedDocument->document(); |
| 207 } | 206 } |
| 208 return 0; | 207 return 0; |
| 209 } | 208 } |
| 210 | 209 |
| 211 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) | 210 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) |
| 212 { | 211 { |
| 213 if (!isSupportedAttribute(attrName)) { | 212 if (!isSupportedAttribute(attrName)) { |
| 214 SVGStyledTransformableElement::svgAttributeChanged(attrName); | 213 SVGGraphicsElement::svgAttributeChanged(attrName); |
| 215 return; | 214 return; |
| 216 } | 215 } |
| 217 | 216 |
| 218 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 217 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
| 219 | 218 |
| 220 RenderObject* renderer = this->renderer(); | 219 RenderObject* renderer = this->renderer(); |
| 221 if (attrName == SVGNames::xAttr | 220 if (attrName == SVGNames::xAttr |
| 222 || attrName == SVGNames::yAttr | 221 || attrName == SVGNames::yAttr |
| 223 || attrName == SVGNames::widthAttr | 222 || attrName == SVGNames::widthAttr |
| 224 || attrName == SVGNames::heightAttr) { | 223 || attrName == SVGNames::heightAttr) { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 541 } |
| 543 | 542 |
| 544 void SVGUseElement::toClipPath(Path& path) | 543 void SVGUseElement::toClipPath(Path& path) |
| 545 { | 544 { |
| 546 ASSERT(path.isEmpty()); | 545 ASSERT(path.isEmpty()); |
| 547 | 546 |
| 548 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme
nt() : 0; | 547 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme
nt() : 0; |
| 549 if (!n) | 548 if (!n) |
| 550 return; | 549 return; |
| 551 | 550 |
| 552 if (n->isSVGElement() && toSVGElement(n)->isStyledTransformable()) { | 551 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) { |
| 553 if (!isDirectReference(n)) | 552 if (!isDirectReference(n)) |
| 554 // Spec: Indirect references are an error (14.3.5) | 553 // Spec: Indirect references are an error (14.3.5) |
| 555 document()->accessSVGExtensions()->reportError("Not allowed to use i
ndirect reference in <clip-path>"); | 554 document()->accessSVGExtensions()->reportError("Not allowed to use i
ndirect reference in <clip-path>"); |
| 556 else { | 555 else { |
| 557 toSVGStyledTransformableElement(n)->toClipPath(path); | 556 toSVGGraphicsElement(n)->toClipPath(path); |
| 558 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. | 557 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. |
| 559 SVGLengthContext lengthContext(this); | 558 SVGLengthContext lengthContext(this); |
| 560 path.translate(FloatSize(x().value(lengthContext), y().value(lengthC
ontext))); | 559 path.translate(FloatSize(x().value(lengthContext), y().value(lengthC
ontext))); |
| 561 path.transform(animatedLocalTransform()); | 560 path.transform(animatedLocalTransform()); |
| 562 } | 561 } |
| 563 } | 562 } |
| 564 } | 563 } |
| 565 | 564 |
| 566 RenderObject* SVGUseElement::rendererClipChild() const | 565 RenderObject* SVGUseElement::rendererClipChild() const |
| 567 { | 566 { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 return true; | 966 return true; |
| 968 } | 967 } |
| 969 if (instance->hasChildNodes()) | 968 if (instance->hasChildNodes()) |
| 970 instanceTreeIsLoading(instance); | 969 instanceTreeIsLoading(instance); |
| 971 } | 970 } |
| 972 return false; | 971 return false; |
| 973 } | 972 } |
| 974 | 973 |
| 975 void SVGUseElement::finishParsingChildren() | 974 void SVGUseElement::finishParsingChildren() |
| 976 { | 975 { |
| 977 SVGStyledTransformableElement::finishParsingChildren(); | 976 SVGGraphicsElement::finishParsingChildren(); |
| 978 SVGExternalResourcesRequired::finishParsingChildren(); | 977 SVGExternalResourcesRequired::finishParsingChildren(); |
| 979 if (m_wasInsertedByParser) { | 978 if (m_wasInsertedByParser) { |
| 980 buildPendingResource(); | 979 buildPendingResource(); |
| 981 m_wasInsertedByParser = false; | 980 m_wasInsertedByParser = false; |
| 982 } | 981 } |
| 983 } | 982 } |
| 984 | 983 |
| 985 void SVGUseElement::setCachedDocument(CachedResourceHandle<CachedDocument> cache
dDocument) | 984 void SVGUseElement::setCachedDocument(CachedResourceHandle<CachedDocument> cache
dDocument) |
| 986 { | 985 { |
| 987 if (m_cachedDocument == cachedDocument) | 986 if (m_cachedDocument == cachedDocument) |
| 988 return; | 987 return; |
| 989 | 988 |
| 990 if (m_cachedDocument) | 989 if (m_cachedDocument) |
| 991 m_cachedDocument->removeClient(this); | 990 m_cachedDocument->removeClient(this); |
| 992 | 991 |
| 993 m_cachedDocument = cachedDocument; | 992 m_cachedDocument = cachedDocument; |
| 994 if (m_cachedDocument) | 993 if (m_cachedDocument) |
| 995 m_cachedDocument->addClient(this); | 994 m_cachedDocument->addClient(this); |
| 996 } | 995 } |
| 997 | 996 |
| 998 } | 997 } |
| OLD | NEW |