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

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

Issue 133493002: Improve a search logic to find a SVGFontFaceSrcElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return m_fontElement; 266 return m_fontElement;
267 } 267 }
268 268
269 void SVGFontFaceElement::rebuildFontFace() 269 void SVGFontFaceElement::rebuildFontFace()
270 { 270 {
271 if (!inDocument()) { 271 if (!inDocument()) {
272 ASSERT(!m_fontElement); 272 ASSERT(!m_fontElement);
273 return; 273 return;
274 } 274 }
275 275
276 // we currently ignore all but the first src element, alternatively we could concat them
277 SVGFontFaceSrcElement* srcElement = 0;
278
279 for (Node* child = firstChild(); child && !srcElement; child = child->nextSi bling()) {
280 if (child->hasTagName(font_face_srcTag))
281 srcElement = static_cast<SVGFontFaceSrcElement*>(child);
282 }
283
284 bool describesParentFont = parentNode()->hasTagName(SVGNames::fontTag); 276 bool describesParentFont = parentNode()->hasTagName(SVGNames::fontTag);
285 RefPtr<CSSValueList> list; 277 RefPtr<CSSValueList> list;
286 278
287 if (describesParentFont) { 279 if (describesParentFont) {
288 m_fontElement = toSVGFontElement(parentNode()); 280 m_fontElement = toSVGFontElement(parentNode());
289 281
290 list = CSSValueList::createCommaSeparated(); 282 list = CSSValueList::createCommaSeparated();
291 list->append(CSSFontFaceSrcValue::createLocal(fontFamily())); 283 list->append(CSSFontFaceSrcValue::createLocal(fontFamily()));
292 } else { 284 } else {
293 m_fontElement = 0; 285 m_fontElement = 0;
294 if (srcElement) 286 // we currently ignore all but the last src element, alternatively we co uld concat them
295 list = srcElement->srcValue(); 287 for (Node* child = lastChild(); child && !list; child = child->previousS ibling()) {
288 if (child->hasTagName(font_face_srcTag)) {
289 list = static_cast<SVGFontFaceSrcElement*>(child)->srcValue();
290 break;
291 }
292 }
296 } 293 }
297 294
298 if (!list || !list->length()) 295 if (!list || !list->length())
299 return; 296 return;
300 297
301 // Parse in-memory CSS rules 298 // Parse in-memory CSS rules
302 m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSProper tySrc, list)); 299 m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSProper tySrc, list));
303 300
304 if (describesParentFont) { 301 if (describesParentFont) {
305 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves. 302 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 342
346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta) 343 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta)
347 { 344 {
348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta); 345 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta);
349 rebuildFontFace(); 346 rebuildFontFace();
350 } 347 }
351 348
352 } // namespace WebCore 349 } // namespace WebCore
353 350
354 #endif // ENABLE(SVG_FONTS) 351 #endif // ENABLE(SVG_FONTS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698