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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: invalidation guard tweaks 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, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 start = start.next(); 193 start = start.next();
194 194
195 // Find selection end 195 // Find selection end
196 VisiblePosition end(start); 196 VisiblePosition end(start);
197 for (unsigned i = 0; i < nchars; ++i) 197 for (unsigned i = 0; i < nchars; ++i)
198 end = end.next(); 198 end = end.next();
199 199
200 document().frame()->selection().setSelection(VisibleSelection(start, end)); 200 document().frame()->selection().setSelection(VisibleSelection(start, end));
201 } 201 }
202 202
203 bool SVGTextContentElement::isSupportedAttribute(const QualifiedName& attrName)
204 {
205 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
206 if (supportedAttributes.isEmpty()) {
207 supportedAttributes.add(SVGNames::lengthAdjustAttr);
208 supportedAttributes.add(SVGNames::textLengthAttr);
209 supportedAttributes.add(XMLNames::spaceAttr);
210 }
211 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
212 }
213
214 bool SVGTextContentElement::isPresentationAttribute(const QualifiedName& name) c onst 203 bool SVGTextContentElement::isPresentationAttribute(const QualifiedName& name) c onst
215 { 204 {
216 if (name.matches(XMLNames::spaceAttr)) 205 if (name.matches(XMLNames::spaceAttr))
217 return true; 206 return true;
218 return SVGGraphicsElement::isPresentationAttribute(name); 207 return SVGGraphicsElement::isPresentationAttribute(name);
219 } 208 }
220 209
221 void SVGTextContentElement::collectStyleForPresentationAttribute(const Qualified Name& name, const AtomicString& value, MutableStylePropertySet* style) 210 void SVGTextContentElement::collectStyleForPresentationAttribute(const Qualified Name& name, const AtomicString& value, MutableStylePropertySet* style)
222 { 211 {
223 if (!isSupportedAttribute(name)) 212 if (name.matches(XMLNames::spaceAttr)) {
224 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
225 else if (name.matches(XMLNames::spaceAttr)) {
226 DEFINE_STATIC_LOCAL(const AtomicString, preserveString, ("preserve", Ato micString::ConstructFromLiteral)); 213 DEFINE_STATIC_LOCAL(const AtomicString, preserveString, ("preserve", Ato micString::ConstructFromLiteral));
227 214
228 if (value == preserveString) { 215 if (value == preserveString) {
229 UseCounter::count(document(), UseCounter::WhiteSpacePreFromXMLSpace) ; 216 UseCounter::count(document(), UseCounter::WhiteSpacePreFromXMLSpace) ;
230 addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace , CSSValuePre); 217 addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace , CSSValuePre);
231 } else { 218 } else {
232 UseCounter::count(document(), UseCounter::WhiteSpaceNowrapFromXMLSpa ce); 219 UseCounter::count(document(), UseCounter::WhiteSpaceNowrapFromXMLSpa ce);
233 addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace , CSSValueNowrap); 220 addPropertyToPresentationAttributeStyle(style, CSSPropertyWhiteSpace , CSSValueNowrap);
234 } 221 }
222 } else {
223 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
235 } 224 }
236 } 225 }
237 226
238 void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName) 227 void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName)
239 { 228 {
240 if (!isSupportedAttribute(attrName)) { 229 if (attrName == SVGNames::textLengthAttr)
241 SVGGraphicsElement::svgAttributeChanged(attrName); 230 m_textLengthIsSpecifiedByUser = true;
231
232 if (attrName == SVGNames::textLengthAttr
233 || attrName == SVGNames::lengthAdjustAttr
234 || attrName == XMLNames::spaceAttr) {
235 SVGElement::InvalidationGuard invalidationGuard(this);
236
237 if (LayoutObject* renderer = this->layoutObject())
238 markForLayoutAndParentResourceInvalidation(renderer);
239
242 return; 240 return;
243 } 241 }
244 242
245 if (attrName == SVGNames::textLengthAttr) 243 SVGGraphicsElement::svgAttributeChanged(attrName);
246 m_textLengthIsSpecifiedByUser = true;
247
248 SVGElement::InvalidationGuard invalidationGuard(this);
249
250 if (LayoutObject* renderer = this->layoutObject())
251 markForLayoutAndParentResourceInvalidation(renderer);
252 } 244 }
253 245
254 bool SVGTextContentElement::selfHasRelativeLengths() const 246 bool SVGTextContentElement::selfHasRelativeLengths() const
255 { 247 {
256 // Any element of the <text> subtree is advertized as using relative lengths . 248 // Any element of the <text> subtree is advertized as using relative lengths .
257 // On any window size change, we have to relayout the text subtree, as the 249 // On any window size change, we have to relayout the text subtree, as the
258 // effective 'on-screen' font size may change. 250 // effective 'on-screen' font size may change.
259 return true; 251 return true;
260 } 252 }
261 253
262 SVGTextContentElement* SVGTextContentElement::elementFromRenderer(LayoutObject* renderer) 254 SVGTextContentElement* SVGTextContentElement::elementFromRenderer(LayoutObject* renderer)
263 { 255 {
264 if (!renderer) 256 if (!renderer)
265 return 0; 257 return 0;
266 258
267 if (!renderer->isSVGText() && !renderer->isSVGInline()) 259 if (!renderer->isSVGText() && !renderer->isSVGInline())
268 return 0; 260 return 0;
269 261
270 SVGElement* element = toSVGElement(renderer->node()); 262 SVGElement* element = toSVGElement(renderer->node());
271 ASSERT(element); 263 ASSERT(element);
272 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0; 264 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0;
273 } 265 }
274 266
275 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698