OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 if (LayoutSVGImage* renderSVGImage = toLayoutSVGImage(layoutObject())) { | 67 if (LayoutSVGImage* renderSVGImage = toLayoutSVGImage(layoutObject())) { |
68 if (renderSVGImage->imageResource()->hasImage()) { | 68 if (renderSVGImage->imageResource()->hasImage()) { |
69 if (Image* image = renderSVGImage->imageResource()->cachedImage()->i mage()) | 69 if (Image* image = renderSVGImage->imageResource()->cachedImage()->i mage()) |
70 return image->currentFrameHasSingleSecurityOrigin(); | 70 return image->currentFrameHasSingleSecurityOrigin(); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 bool SVGImageElement::isSupportedAttribute(const QualifiedName& attrName) | |
78 { | |
79 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | |
80 if (supportedAttributes.isEmpty()) { | |
81 SVGURIReference::addSupportedAttributes(supportedAttributes); | |
82 supportedAttributes.add(SVGNames::xAttr); | |
83 supportedAttributes.add(SVGNames::yAttr); | |
84 supportedAttributes.add(SVGNames::widthAttr); | |
85 supportedAttributes.add(SVGNames::heightAttr); | |
86 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); | |
87 } | |
88 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | |
89 } | |
90 | |
91 bool SVGImageElement::isPresentationAttribute(const QualifiedName& attrName) con st | 77 bool SVGImageElement::isPresentationAttribute(const QualifiedName& attrName) con st |
92 { | 78 { |
93 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr | 79 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr |
94 || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) | 80 || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) |
95 return true; | 81 return true; |
96 return SVGGraphicsElement::isPresentationAttribute(attrName); | 82 return SVGGraphicsElement::isPresentationAttribute(attrName); |
97 } | 83 } |
98 | 84 |
99 bool SVGImageElement::isPresentationAttributeWithSVGDOM(const QualifiedName& att rName) const | 85 bool SVGImageElement::isPresentationAttributeWithSVGDOM(const QualifiedName& att rName) const |
100 { | 86 { |
(...skipping 14 matching lines...) Expand all Loading... | |
115 else if (property == m_x) | 101 else if (property == m_x) |
116 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m _x->currentValue()); | 102 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m _x->currentValue()); |
117 else if (property == m_y) | 103 else if (property == m_y) |
118 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m _y->currentValue()); | 104 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m _y->currentValue()); |
119 else | 105 else |
120 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); | 106 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); |
121 } | 107 } |
122 | 108 |
123 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) | 109 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) |
124 { | 110 { |
125 if (!isSupportedAttribute(attrName)) { | |
126 SVGGraphicsElement::svgAttributeChanged(attrName); | |
127 return; | |
128 } | |
129 | |
130 SVGElement::InvalidationGuard invalidationGuard(this); | |
131 | |
132 bool isLengthAttribute = attrName == SVGNames::xAttr | 111 bool isLengthAttribute = attrName == SVGNames::xAttr |
133 || attrName == SVGNames::yAttr | 112 || attrName == SVGNames::yAttr |
134 || attrName == SVGNames::widthAttr | 113 || attrName == SVGNames::widthAttr |
135 || attrName == SVGNames::heightAttr; | 114 || attrName == SVGNames::heightAttr; |
136 | 115 |
137 if (isLengthAttribute) { | 116 if (isLengthAttribute) { |
138 invalidateSVGPresentationAttributeStyle(); | 117 invalidateSVGPresentationAttributeStyle(); |
139 setNeedsStyleRecalc(LocalStyleChange, | 118 setNeedsStyleRecalc(LocalStyleChange, |
140 StyleChangeReasonForTracing::fromAttribute(attrName)); | 119 StyleChangeReasonForTracing::fromAttribute(attrName)); |
141 updateRelativeLengthsInformation(); | 120 updateRelativeLengthsInformation(); |
pdr.
2015/04/10 18:39:21
Does this path need to be covered by the invalidat
Erik Dahlström (inactive)
2015/04/13 08:11:17
Hmm, yes I think it should be covered by that. I h
| |
142 } | 121 } |
143 | 122 |
123 if (isLengthAttribute || attrName == SVGNames::preserveAspectRatioAttr) { | |
124 SVGElement::InvalidationGuard invalidationGuard(this); | |
125 | |
126 LayoutObject* object = this->layoutObject(); | |
127 if (!object) | |
128 return; | |
129 | |
130 // FIXME: if isLengthAttribute then we should avoid this | |
131 // call if the viewport didn't change, however since we don't | |
132 // have the computed style yet we can't use updateImageViewport. | |
133 // See http://crbug.com/466200. | |
134 markForLayoutAndParentResourceInvalidation(object); | |
135 return; | |
136 } | |
137 | |
144 if (SVGURIReference::isKnownAttribute(attrName)) { | 138 if (SVGURIReference::isKnownAttribute(attrName)) { |
139 SVGElement::InvalidationGuard invalidationGuard(this); | |
145 if (inDocument()) | 140 if (inDocument()) |
146 imageLoader().updateFromElement(ImageLoader::UpdateIgnorePreviousErr or); | 141 imageLoader().updateFromElement(ImageLoader::UpdateIgnorePreviousErr or); |
147 else | 142 else |
148 m_needsLoaderURIUpdate = true; | 143 m_needsLoaderURIUpdate = true; |
149 return; | 144 return; |
150 } | 145 } |
151 | 146 |
152 LayoutObject* renderer = this->layoutObject(); | 147 SVGGraphicsElement::svgAttributeChanged(attrName); |
153 if (!renderer) | |
154 return; | |
155 | |
156 if (isLengthAttribute || attrName == SVGNames::preserveAspectRatioAttr) { | |
157 // FIXME: if isLengthAttribute then we should avoid this | |
158 // call if the viewport didn't change, however since we don't | |
159 // have the computed style yet we can't use updateImageViewport. | |
160 // See http://crbug.com/466200. | |
161 markForLayoutAndParentResourceInvalidation(renderer); | |
162 return; | |
163 } | |
164 | |
165 ASSERT_NOT_REACHED(); | |
166 } | 148 } |
167 | 149 |
168 bool SVGImageElement::selfHasRelativeLengths() const | 150 bool SVGImageElement::selfHasRelativeLengths() const |
169 { | 151 { |
170 return m_x->currentValue()->isRelative() | 152 return m_x->currentValue()->isRelative() |
171 || m_y->currentValue()->isRelative() | 153 || m_y->currentValue()->isRelative() |
172 || m_width->currentValue()->isRelative() | 154 || m_width->currentValue()->isRelative() |
173 || m_height->currentValue()->isRelative(); | 155 || m_height->currentValue()->isRelative(); |
174 } | 156 } |
175 | 157 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 return AtomicString(hrefString()); | 203 return AtomicString(hrefString()); |
222 } | 204 } |
223 | 205 |
224 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) | 206 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) |
225 { | 207 { |
226 imageLoader().elementDidMoveToNewDocument(); | 208 imageLoader().elementDidMoveToNewDocument(); |
227 SVGGraphicsElement::didMoveToNewDocument(oldDocument); | 209 SVGGraphicsElement::didMoveToNewDocument(oldDocument); |
228 } | 210 } |
229 | 211 |
230 } // namespace blink | 212 } // namespace blink |
OLD | NEW |