OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/fetch/FetchRequest.h" | 28 #include "core/fetch/FetchRequest.h" |
29 #include "core/fetch/ResourceFetcher.h" | 29 #include "core/fetch/ResourceFetcher.h" |
30 #include "core/rendering/svg/RenderSVGResource.h" | 30 #include "core/rendering/svg/RenderSVGResource.h" |
31 #include "core/svg/SVGElementInstance.h" | 31 #include "core/svg/SVGElementInstance.h" |
32 #include "core/svg/SVGPreserveAspectRatio.h" | 32 #include "core/svg/SVGPreserveAspectRatio.h" |
33 #include "platform/graphics/Image.h" | 33 #include "platform/graphics/Image.h" |
34 | 34 |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
37 // Animated property definitions | 37 // Animated property definitions |
38 DEFINE_ANIMATED_STRING(SVGFEImageElement, XLinkNames::hrefAttr, Href, href) | |
39 | 38 |
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEImageElement) | 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEImageElement) |
41 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | |
42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
43 END_REGISTER_ANIMATED_PROPERTIES | 41 END_REGISTER_ANIMATED_PROPERTIES |
44 | 42 |
45 inline SVGFEImageElement::SVGFEImageElement(Document& document) | 43 inline SVGFEImageElement::SVGFEImageElement(Document& document) |
46 : SVGFilterPrimitiveStandardAttributes(SVGNames::feImageTag, document) | 44 : SVGFilterPrimitiveStandardAttributes(SVGNames::feImageTag, document) |
47 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 45 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 46 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) |
48 { | 47 { |
49 ScriptWrappable::init(this); | 48 ScriptWrappable::init(this); |
50 addToPropertyMap(m_preserveAspectRatio); | 49 addToPropertyMap(m_preserveAspectRatio); |
| 50 addToPropertyMap(m_href); |
51 registerAnimatedPropertiesForSVGFEImageElement(); | 51 registerAnimatedPropertiesForSVGFEImageElement(); |
52 } | 52 } |
53 | 53 |
54 PassRefPtr<SVGFEImageElement> SVGFEImageElement::create(Document& document) | 54 PassRefPtr<SVGFEImageElement> SVGFEImageElement::create(Document& document) |
55 { | 55 { |
56 return adoptRef(new SVGFEImageElement(document)); | 56 return adoptRef(new SVGFEImageElement(document)); |
57 } | 57 } |
58 | 58 |
59 SVGFEImageElement::~SVGFEImageElement() | 59 SVGFEImageElement::~SVGFEImageElement() |
60 { | 60 { |
(...skipping 13 matching lines...) Expand all Loading... |
74 if (m_cachedImage) { | 74 if (m_cachedImage) { |
75 m_cachedImage->removeClient(this); | 75 m_cachedImage->removeClient(this); |
76 m_cachedImage = 0; | 76 m_cachedImage = 0; |
77 } | 77 } |
78 | 78 |
79 document().accessSVGExtensions()->removeAllTargetReferencesForElement(this); | 79 document().accessSVGExtensions()->removeAllTargetReferencesForElement(this); |
80 } | 80 } |
81 | 81 |
82 void SVGFEImageElement::fetchImageResource() | 82 void SVGFEImageElement::fetchImageResource() |
83 { | 83 { |
84 FetchRequest request(ResourceRequest(ownerDocument()->completeURL(hrefCurren
tValue())), localName()); | 84 FetchRequest request(ResourceRequest(ownerDocument()->completeURL(m_href->cu
rrentValue()->value())), localName()); |
85 m_cachedImage = document().fetcher()->fetchImage(request); | 85 m_cachedImage = document().fetcher()->fetchImage(request); |
86 | 86 |
87 if (m_cachedImage) | 87 if (m_cachedImage) |
88 m_cachedImage->addClient(this); | 88 m_cachedImage->addClient(this); |
89 } | 89 } |
90 | 90 |
91 void SVGFEImageElement::buildPendingResource() | 91 void SVGFEImageElement::buildPendingResource() |
92 { | 92 { |
93 clearResourceReferences(); | 93 clearResourceReferences(); |
94 if (!inDocument()) | 94 if (!inDocument()) |
95 return; | 95 return; |
96 | 96 |
97 AtomicString id; | 97 AtomicString id; |
98 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal
ue(), document(), &id); | 98 Element* target = SVGURIReference::targetElementFromIRIString(m_href->curren
tValue()->value(), document(), &id); |
99 if (!target) { | 99 if (!target) { |
100 if (id.isEmpty()) | 100 if (id.isEmpty()) |
101 fetchImageResource(); | 101 fetchImageResource(); |
102 else { | 102 else { |
103 document().accessSVGExtensions()->addPendingResource(id, this); | 103 document().accessSVGExtensions()->addPendingResource(id, this); |
104 ASSERT(hasPendingResources()); | 104 ASSERT(hasPendingResources()); |
105 } | 105 } |
106 } else if (target->isSVGElement()) { | 106 } else if (target->isSVGElement()) { |
107 // Register us with the target in the dependencies map. Any change of hr
efElement | 107 // Register us with the target in the dependencies map. Any change of hr
efElement |
108 // that leads to relayout/repainting now informs us, so we can react to
it. | 108 // that leads to relayout/repainting now informs us, so we can react to
it. |
(...skipping 17 matching lines...) Expand all Loading... |
126 { | 126 { |
127 if (!isSupportedAttribute(name)) { | 127 if (!isSupportedAttribute(name)) { |
128 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 128 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 SVGParsingError parseError = NoError; | 132 SVGParsingError parseError = NoError; |
133 | 133 |
134 if (name == SVGNames::preserveAspectRatioAttr) { | 134 if (name == SVGNames::preserveAspectRatioAttr) { |
135 m_preserveAspectRatio->setBaseValueAsString(value, parseError); | 135 m_preserveAspectRatio->setBaseValueAsString(value, parseError); |
136 } else if (SVGURIReference::parseAttribute(name, value)) { | 136 } else if (name.matches(XLinkNames::hrefAttr)) { |
| 137 m_href->setBaseValueAsString(value, parseError); |
137 } else { | 138 } else { |
138 ASSERT_NOT_REACHED(); | 139 ASSERT_NOT_REACHED(); |
139 } | 140 } |
140 | 141 |
141 reportAttributeParsingError(parseError, name, value); | 142 reportAttributeParsingError(parseError, name, value); |
142 } | 143 } |
143 | 144 |
144 void SVGFEImageElement::svgAttributeChanged(const QualifiedName& attrName) | 145 void SVGFEImageElement::svgAttributeChanged(const QualifiedName& attrName) |
145 { | 146 { |
146 if (!isSupportedAttribute(attrName)) { | 147 if (!isSupportedAttribute(attrName)) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return; | 190 return; |
190 | 191 |
191 if (RenderObject* renderer = this->renderer()) | 192 if (RenderObject* renderer = this->renderer()) |
192 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 193 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
193 } | 194 } |
194 | 195 |
195 PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*, Filter* fil
ter) | 196 PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*, Filter* fil
ter) |
196 { | 197 { |
197 if (m_cachedImage) | 198 if (m_cachedImage) |
198 return FEImage::createWithImage(filter, m_cachedImage->imageForRenderer(
renderer()), m_preserveAspectRatio->currentValue()); | 199 return FEImage::createWithImage(filter, m_cachedImage->imageForRenderer(
renderer()), m_preserveAspectRatio->currentValue()); |
199 return FEImage::createWithIRIReference(filter, document(), hrefCurrentValue(
), m_preserveAspectRatio->currentValue()); | 200 return FEImage::createWithIRIReference(filter, document(), m_href->currentVa
lue()->value(), m_preserveAspectRatio->currentValue()); |
200 } | 201 } |
201 | 202 |
202 } | 203 } |
OLD | NEW |