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

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;
286 // we currently ignore all but the first src element, alternatively we c ould concat them
Stephen Chennney 2014/01/10 12:22:34 The comment was wrong before and it's still wrong
gyuyoung-inactive 2014/01/10 15:46:23 Fixed. Thanks.
fs 2014/01/10 17:43:00 Friendly note: The comment was actually correct -
287 SVGFontFaceSrcElement* srcElement = 0;
288
289 for (Node* child = lastChild(); child && !srcElement; child = child->pre viousSibling()) {
290 if (child->hasTagName(font_face_srcTag)) {
291 srcElement = static_cast<SVGFontFaceSrcElement*>(child);
292 break;
293 }
294 }
295
294 if (srcElement) 296 if (srcElement)
295 list = srcElement->srcValue(); 297 list = srcElement->srcValue();
Stephen Chennney 2014/01/10 12:22:34 This can be moved up inside the if. You don't need
gyuyoung-inactive 2014/01/10 15:46:23 Yes, right. Moved it into inside the if.
296 } 298 }
297 299
298 if (!list || !list->length()) 300 if (!list || !list->length())
299 return; 301 return;
300 302
301 // Parse in-memory CSS rules 303 // Parse in-memory CSS rules
302 m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSProper tySrc, list)); 304 m_fontFaceRule->mutableProperties()->addParsedProperty(CSSProperty(CSSProper tySrc, list));
303 305
304 if (describesParentFont) { 306 if (describesParentFont) {
305 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves. 307 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 347
346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta) 348 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang e, Node* afterChange, int childCountDelta)
347 { 349 {
348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta); 350 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta);
349 rebuildFontFace(); 351 rebuildFontFace();
350 } 352 }
351 353
352 } // namespace WebCore 354 } // namespace WebCore
353 355
354 #endif // ENABLE(SVG_FONTS) 356 #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