| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // Dump SVGElementInstance object tree - useful to debug instanceRoot problems | 46 // Dump SVGElementInstance object tree - useful to debug instanceRoot problems |
| 47 // #define DUMP_INSTANCE_TREE | 47 // #define DUMP_INSTANCE_TREE |
| 48 | 48 |
| 49 // Dump the deep-expanded shadow tree (where the renderers are built from) | 49 // Dump the deep-expanded shadow tree (where the renderers are built from) |
| 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) | |
| 56 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) | |
| 57 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) | |
| 58 DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) | |
| 59 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) | 55 DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) |
| 60 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | 56 DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) |
| 61 | 57 |
| 62 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) | 58 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) |
| 63 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | |
| 64 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | |
| 65 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | |
| 66 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | |
| 67 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 59 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
| 68 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 60 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
| 69 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 61 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
| 70 END_REGISTER_ANIMATED_PROPERTIES | 62 END_REGISTER_ANIMATED_PROPERTIES |
| 71 | 63 |
| 72 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser
) | 64 inline SVGUseElement::SVGUseElement(Document& document, bool wasInsertedByParser
) |
| 73 : SVGGraphicsElement(SVGNames::useTag, document) | 65 : SVGGraphicsElement(SVGNames::useTag, document) |
| 74 , m_x(LengthModeWidth) | 66 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 75 , m_y(LengthModeHeight) | 67 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 76 , m_width(LengthModeWidth) | 68 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 77 , m_height(LengthModeHeight) | 69 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
| 78 , m_wasInsertedByParser(wasInsertedByParser) | 70 , m_wasInsertedByParser(wasInsertedByParser) |
| 79 , m_haveFiredLoadEvent(false) | 71 , m_haveFiredLoadEvent(false) |
| 80 , m_needsShadowTreeRecreation(false) | 72 , m_needsShadowTreeRecreation(false) |
| 81 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) | 73 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) |
| 82 { | 74 { |
| 83 ASSERT(hasCustomStyleCallbacks()); | 75 ASSERT(hasCustomStyleCallbacks()); |
| 84 ScriptWrappable::init(this); | 76 ScriptWrappable::init(this); |
| 77 |
| 78 addToPropertyMap(m_x); |
| 79 addToPropertyMap(m_y); |
| 80 addToPropertyMap(m_width); |
| 81 addToPropertyMap(m_height); |
| 85 registerAnimatedPropertiesForSVGUseElement(); | 82 registerAnimatedPropertiesForSVGUseElement(); |
| 86 } | 83 } |
| 87 | 84 |
| 88 PassRefPtr<SVGUseElement> SVGUseElement::create(Document& document, bool wasInse
rtedByParser) | 85 PassRefPtr<SVGUseElement> SVGUseElement::create(Document& document, bool wasInse
rtedByParser) |
| 89 { | 86 { |
| 90 // Always build a #shadow-root for SVGUseElement. | 87 // Always build a #shadow-root for SVGUseElement. |
| 91 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(document, wasInserted
ByParser)); | 88 RefPtr<SVGUseElement> use = adoptRef(new SVGUseElement(document, wasInserted
ByParser)); |
| 92 use->ensureUserAgentShadowRoot(); | 89 use->ensureUserAgentShadowRoot(); |
| 93 return use.release(); | 90 return use.release(); |
| 94 } | 91 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 143 else if (name == SVGNames::yAttr) | 140 else if (name == SVGNames::yAttr) |
| 144 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 141 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 145 else if (name == SVGNames::widthAttr) | 142 else if (name == SVGNames::widthAttr) |
| 146 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 143 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 147 else if (name == SVGNames::heightAttr) | 144 else if (name == SVGNames::heightAttr) |
| 148 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 145 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
| 149 else if (SVGExternalResourcesRequired::parseAttribute(name, value) | 146 else if (SVGExternalResourcesRequired::parseAttribute(name, value) |
| 150 || SVGURIReference::parseAttribute(name, value)) { | 147 || SVGURIReference::parseAttribute(name, value)) { |
| 151 } else | 148 } else |
| 152 ASSERT_NOT_REACHED(); | 149 ASSERT_NOT_REACHED(); |
| 153 | 150 |
| 154 reportAttributeParsingError(parseError, name, value); | 151 reportAttributeParsingError(parseError, name, value); |
| 155 } | 152 } |
| 156 | 153 |
| 157 #if !ASSERT_DISABLED | 154 #if !ASSERT_DISABLED |
| 158 static inline bool isWellFormedDocument(Document* document) | 155 static inline bool isWellFormedDocument(Document* document) |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 return; | 544 return; |
| 548 | 545 |
| 549 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) { | 546 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) { |
| 550 if (!isDirectReference(n)) { | 547 if (!isDirectReference(n)) { |
| 551 // Spec: Indirect references are an error (14.3.5) | 548 // Spec: Indirect references are an error (14.3.5) |
| 552 document().accessSVGExtensions()->reportError("Not allowed to use in
direct reference in <clip-path>"); | 549 document().accessSVGExtensions()->reportError("Not allowed to use in
direct reference in <clip-path>"); |
| 553 } else { | 550 } else { |
| 554 toSVGGraphicsElement(n)->toClipPath(path); | 551 toSVGGraphicsElement(n)->toClipPath(path); |
| 555 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. | 552 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf
ul. |
| 556 SVGLengthContext lengthContext(this); | 553 SVGLengthContext lengthContext(this); |
| 557 path.translate(FloatSize(xCurrentValue().value(lengthContext), yCurr
entValue().value(lengthContext))); | 554 path.translate(FloatSize(m_x->currentValue()->value(lengthContext),
m_y->currentValue()->value(lengthContext))); |
| 558 path.transform(animatedLocalTransform()); | 555 path.transform(animatedLocalTransform()); |
| 559 } | 556 } |
| 560 } | 557 } |
| 561 } | 558 } |
| 562 | 559 |
| 563 RenderObject* SVGUseElement::rendererClipChild() const | 560 RenderObject* SVGUseElement::rendererClipChild() const |
| 564 { | 561 { |
| 565 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme
nt() : 0; | 562 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme
nt() : 0; |
| 566 if (!n) | 563 if (!n) |
| 567 return 0; | 564 return 0; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 915 |
| 919 to->removeAttribute(SVGNames::xAttr); | 916 to->removeAttribute(SVGNames::xAttr); |
| 920 to->removeAttribute(SVGNames::yAttr); | 917 to->removeAttribute(SVGNames::yAttr); |
| 921 to->removeAttribute(SVGNames::widthAttr); | 918 to->removeAttribute(SVGNames::widthAttr); |
| 922 to->removeAttribute(SVGNames::heightAttr); | 919 to->removeAttribute(SVGNames::heightAttr); |
| 923 to->removeAttribute(XLinkNames::hrefAttr); | 920 to->removeAttribute(XLinkNames::hrefAttr); |
| 924 } | 921 } |
| 925 | 922 |
| 926 bool SVGUseElement::selfHasRelativeLengths() const | 923 bool SVGUseElement::selfHasRelativeLengths() const |
| 927 { | 924 { |
| 928 if (xCurrentValue().isRelative() | 925 if (m_x->currentValue()->isRelative() |
| 929 || yCurrentValue().isRelative() | 926 || m_y->currentValue()->isRelative() |
| 930 || widthCurrentValue().isRelative() | 927 || m_width->currentValue()->isRelative() |
| 931 || heightCurrentValue().isRelative()) | 928 || m_height->currentValue()->isRelative()) |
| 932 return true; | 929 return true; |
| 933 | 930 |
| 934 if (!m_targetElementInstance) | 931 if (!m_targetElementInstance) |
| 935 return false; | 932 return false; |
| 936 | 933 |
| 937 SVGElement* element = m_targetElementInstance->correspondingElement(); | 934 SVGElement* element = m_targetElementInstance->correspondingElement(); |
| 938 if (!element) | 935 if (!element) |
| 939 return false; | 936 return false; |
| 940 | 937 |
| 941 return element->hasRelativeLengths(); | 938 return element->hasRelativeLengths(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 987 |
| 991 if (m_resource) | 988 if (m_resource) |
| 992 m_resource->removeClient(this); | 989 m_resource->removeClient(this); |
| 993 | 990 |
| 994 m_resource = resource; | 991 m_resource = resource; |
| 995 if (m_resource) | 992 if (m_resource) |
| 996 m_resource->addClient(this); | 993 m_resource->addClient(this); |
| 997 } | 994 } |
| 998 | 995 |
| 999 } | 996 } |
| OLD | NEW |