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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixups Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
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
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
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) {
fs 2015/04/10 14:25:24 I think we should either move this down to just be
Erik Dahlström (inactive) 2015/04/10 15:33:44 Done.
138 invalidateSVGPresentationAttributeStyle(); 117 invalidateSVGPresentationAttributeStyle();
139 setNeedsStyleRecalc(LocalStyleChange, 118 setNeedsStyleRecalc(LocalStyleChange,
140 StyleChangeReasonForTracing::fromAttribute(attrName)); 119 StyleChangeReasonForTracing::fromAttribute(attrName));
141 updateRelativeLengthsInformation(); 120 updateRelativeLengthsInformation();
142 } 121 }
143 122
144 if (SVGURIReference::isKnownAttribute(attrName)) { 123 if (SVGURIReference::isKnownAttribute(attrName)) {
124 SVGElement::InvalidationGuard invalidationGuard(this);
145 if (inDocument()) 125 if (inDocument())
146 imageLoader().updateFromElement(ImageLoader::UpdateIgnorePreviousErr or); 126 imageLoader().updateFromElement(ImageLoader::UpdateIgnorePreviousErr or);
147 else 127 else
148 m_needsLoaderURIUpdate = true; 128 m_needsLoaderURIUpdate = true;
149 return; 129 return;
150 } 130 }
151 131
152 LayoutObject* renderer = this->layoutObject(); 132 if (isLengthAttribute || attrName == SVGNames::preserveAspectRatioAttr) {
153 if (!renderer) 133 SVGElement::InvalidationGuard invalidationGuard(this);
154 return;
155 134
156 if (isLengthAttribute || attrName == SVGNames::preserveAspectRatioAttr) { 135 LayoutObject* object = this->layoutObject();
136 if (!object)
137 return;
138
157 // FIXME: if isLengthAttribute then we should avoid this 139 // FIXME: if isLengthAttribute then we should avoid this
158 // call if the viewport didn't change, however since we don't 140 // call if the viewport didn't change, however since we don't
159 // have the computed style yet we can't use updateImageViewport. 141 // have the computed style yet we can't use updateImageViewport.
160 // See http://crbug.com/466200. 142 // See http://crbug.com/466200.
161 markForLayoutAndParentResourceInvalidation(renderer); 143 markForLayoutAndParentResourceInvalidation(object);
162 return; 144 return;
163 } 145 }
164 146
165 ASSERT_NOT_REACHED(); 147 SVGGraphicsElement::svgAttributeChanged(attrName);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698