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

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

Issue 181783005: Have Element::ensureMutableInlineStyle() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // mapAttributeToCSSProperty(propertyNameToIdMap, x_heightAttr); 106 // mapAttributeToCSSProperty(propertyNameToIdMap, x_heightAttr);
107 } 107 }
108 108
109 return propertyNameToIdMap->get(attrName.localName().impl()); 109 return propertyNameToIdMap->get(attrName.localName().impl());
110 } 110 }
111 111
112 void SVGFontFaceElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value) 112 void SVGFontFaceElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value)
113 { 113 {
114 CSSPropertyID propId = cssPropertyIdForFontFaceAttributeName(name); 114 CSSPropertyID propId = cssPropertyIdForFontFaceAttributeName(name);
115 if (propId > 0) { 115 if (propId > 0) {
116 m_fontFaceRule->mutableProperties()->setProperty(propId, value, false); 116 m_fontFaceRule->mutableProperties().setProperty(propId, value, false);
117 rebuildFontFace(); 117 rebuildFontFace();
118 return; 118 return;
119 } 119 }
120 120
121 SVGElement::parseAttribute(name, value); 121 SVGElement::parseAttribute(name, value);
122 } 122 }
123 123
124 unsigned SVGFontFaceElement::unitsPerEm() const 124 unsigned SVGFontFaceElement::unitsPerEm() const
125 { 125 {
126 const AtomicString& value = fastGetAttribute(units_per_emAttr); 126 const AtomicString& value = fastGetAttribute(units_per_emAttr);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if (!vertOriginY.isEmpty()) 251 if (!vertOriginY.isEmpty())
252 return static_cast<int>(ceilf(vertOriginY.toFloat())); 252 return static_cast<int>(ceilf(vertOriginY.toFloat()));
253 } 253 }
254 254
255 // Match Batiks default value 255 // Match Batiks default value
256 return static_cast<int>(ceilf(unitsPerEm() * 0.2f)); 256 return static_cast<int>(ceilf(unitsPerEm() * 0.2f));
257 } 257 }
258 258
259 String SVGFontFaceElement::fontFamily() const 259 String SVGFontFaceElement::fontFamily() const
260 { 260 {
261 return m_fontFaceRule->properties()->getPropertyValue(CSSPropertyFontFamily) ; 261 return m_fontFaceRule->properties().getPropertyValue(CSSPropertyFontFamily);
262 } 262 }
263 263
264 SVGFontElement* SVGFontFaceElement::associatedFontElement() const 264 SVGFontElement* SVGFontFaceElement::associatedFontElement() const
265 { 265 {
266 ASSERT(parentNode() == m_fontElement); 266 ASSERT(parentNode() == m_fontElement);
267 ASSERT(!parentNode() || parentNode()->hasTagName(SVGNames::fontTag)); 267 ASSERT(!parentNode() || parentNode()->hasTagName(SVGNames::fontTag));
268 return m_fontElement; 268 return m_fontElement;
269 } 269 }
270 270
271 void SVGFontFaceElement::rebuildFontFace() 271 void SVGFontFaceElement::rebuildFontFace()
(...skipping 19 matching lines...) Expand all
291 list = toSVGFontFaceSrcElement(child)->srcValue(); 291 list = toSVGFontFaceSrcElement(child)->srcValue();
292 break; 292 break;
293 } 293 }
294 } 294 }
295 } 295 }
296 296
297 if (!list || !list->length()) 297 if (!list || !list->length())
298 return; 298 return;
299 299
300 // Parse in-memory CSS rules 300 // Parse in-memory CSS rules
301 m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSProper tySrc, list)); 301 m_fontFaceRule->mutableProperties().addParsedProperty(CSSProperty(CSSPropert ySrc, list));
302 302
303 if (describesParentFont) { 303 if (describesParentFont) {
304 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves. 304 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
305 RefPtrWillBeRawPtr<CSSValue> src = m_fontFaceRule->properties()->getProp ertyCSSValue(CSSPropertySrc); 305 RefPtrWillBeRawPtr<CSSValue> src = m_fontFaceRule->properties().getPrope rtyCSSValue(CSSPropertySrc);
306 CSSValueList* srcList = toCSSValueList(src.get()); 306 CSSValueList* srcList = toCSSValueList(src.get());
307 307
308 unsigned srcLength = srcList ? srcList->length() : 0; 308 unsigned srcLength = srcList ? srcList->length() : 0;
309 for (unsigned i = 0; i < srcLength; i++) { 309 for (unsigned i = 0; i < srcLength; i++) {
310 if (CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->itemW ithoutBoundsCheck(i))) 310 if (CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->itemW ithoutBoundsCheck(i)))
311 item->setSVGFontFaceElement(this); 311 item->setSVGFontFaceElement(this);
312 } 312 }
313 } 313 }
314 314
315 document().styleResolverChanged(RecalcStyleDeferred); 315 document().styleResolverChanged(RecalcStyleDeferred);
(...skipping 13 matching lines...) Expand all
329 } 329 }
330 330
331 void SVGFontFaceElement::removedFrom(ContainerNode* rootParent) 331 void SVGFontFaceElement::removedFrom(ContainerNode* rootParent)
332 { 332 {
333 SVGElement::removedFrom(rootParent); 333 SVGElement::removedFrom(rootParent);
334 334
335 if (rootParent->inDocument()) { 335 if (rootParent->inDocument()) {
336 m_fontElement = 0; 336 m_fontElement = 0;
337 document().accessSVGExtensions().unregisterSVGFontFaceElement(this); 337 document().accessSVGExtensions().unregisterSVGFontFaceElement(this);
338 document().styleEngine()->fontSelector()->fontFaceCache()->remove(m_font FaceRule.get()); 338 document().styleEngine()->fontSelector()->fontFaceCache()->remove(m_font FaceRule.get());
339 m_fontFaceRule->mutableProperties()->clear(); 339 m_fontFaceRule->mutableProperties().clear();
340 340
341 document().styleResolverChanged(RecalcStyleDeferred); 341 document().styleResolverChanged(RecalcStyleDeferred);
342 } else 342 } else
343 ASSERT(!m_fontElement); 343 ASSERT(!m_fontElement);
344 } 344 }
345 345
346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta) 346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta)
347 { 347 {
348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta); 348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta);
349 rebuildFontFace(); 349 rebuildFontFace();
350 } 350 }
351 351
352 } // namespace WebCore 352 } // namespace WebCore
353 353
354 #endif // ENABLE(SVG_FONTS) 354 #endif // ENABLE(SVG_FONTS)
OLDNEW
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698