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

Unified Diff: Source/core/svg/SVGFontElement.cpp

Issue 192133002: Use isSVG*Element() helpers more in SVG code (Part 1) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGFontData.cpp ('k') | Source/core/svg/SVGFontFaceElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGFontElement.cpp
diff --git a/Source/core/svg/SVGFontElement.cpp b/Source/core/svg/SVGFontElement.cpp
index 862526d5cdd35b67e8cf528895af9dbdeabbfee7..17fbfefb8bcbf85015f1a2f5e5ff4613587bc5f1 100644
--- a/Source/core/svg/SVGFontElement.cpp
+++ b/Source/core/svg/SVGFontElement.cpp
@@ -24,6 +24,7 @@
#if ENABLE(SVG_FONTS)
#include "core/svg/SVGFontElement.h"
+#include "core/dom/ElementTraversal.h"
#include "core/frame/UseCounter.h"
#include "core/svg/SVGGlyphElement.h"
#include "core/svg/SVGHKernElement.h"
@@ -60,12 +61,7 @@ void SVGFontElement::invalidateGlyphCache()
SVGMissingGlyphElement* SVGFontElement::firstMissingGlyphElement() const
{
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (child->hasTagName(SVGNames::missing_glyphTag))
- return toSVGMissingGlyphElement(child);
- }
-
- return 0;
+ return Traversal<SVGMissingGlyphElement>::firstChild(*this);
}
void SVGFontElement::registerLigaturesInGlyphCache(Vector<String>& ligatures)
@@ -169,25 +165,25 @@ void SVGFontElement::ensureGlyphCache()
SVGMissingGlyphElement* firstMissingGlyphElement = 0;
Vector<String> ligatures;
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (child->hasTagName(SVGNames::glyphTag)) {
- SVGGlyphElement* glyph = toSVGGlyphElement(child);
- AtomicString unicode = glyph->fastGetAttribute(SVGNames::unicodeAttr);
- AtomicString glyphId = glyph->getIdAttribute();
+ for (SVGElement* element = Traversal<SVGElement>::firstChild(*this); element; element = Traversal<SVGElement>::nextSibling(*element)) {
+ if (isSVGGlyphElement(*element)) {
+ SVGGlyphElement& glyph = toSVGGlyphElement(*element);
+ AtomicString unicode = glyph.fastGetAttribute(SVGNames::unicodeAttr);
+ AtomicString glyphId = glyph.getIdAttribute();
if (glyphId.isEmpty() && unicode.isEmpty())
continue;
- m_glyphMap.addGlyph(glyphId, unicode, glyph->buildGlyphIdentifier());
+ m_glyphMap.addGlyph(glyphId, unicode, glyph.buildGlyphIdentifier());
// Register ligatures, if needed, don't mix up with surrogate pairs though!
if (unicode.length() > 1 && !U16_IS_SURROGATE(unicode[0]))
ligatures.append(unicode.string());
- } else if (child->hasTagName(SVGNames::hkernTag)) {
- toSVGHKernElement(child)->buildHorizontalKerningPair(horizontalKerningPairs);
- } else if (child->hasTagName(SVGNames::vkernTag)) {
- toSVGVKernElement(child)->buildVerticalKerningPair(verticalKerningPairs);
- } else if (child->hasTagName(SVGNames::missing_glyphTag) && !firstMissingGlyphElement) {
- firstMissingGlyphElement = toSVGMissingGlyphElement(child);
+ } else if (isSVGHKernElement(*element)) {
+ toSVGHKernElement(*element).buildHorizontalKerningPair(horizontalKerningPairs);
+ } else if (isSVGVKernElement(*element)) {
+ toSVGVKernElement(*element).buildVerticalKerningPair(verticalKerningPairs);
+ } else if (isSVGMissingGlyphElement(*element) && !firstMissingGlyphElement) {
+ firstMissingGlyphElement = toSVGMissingGlyphElement(element);
}
}
« no previous file with comments | « Source/core/svg/SVGFontData.cpp ('k') | Source/core/svg/SVGFontFaceElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698