2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 #include "core/svg/SVGVKernElement.h"
26 #include "core/svg/SVGFontElement.h"
27 #include "core/svg/SVGParserUtilities.h"
31 inline SVGVKernElement::SVGVKernElement(const QualifiedName& tagName, Document& document)
32 : SVGElement(tagName, document)
34 ASSERT(hasTagName(SVGNames::vkernTag));
35 ScriptWrappable::init(this);
38 PassRefPtr<SVGVKernElement> SVGVKernElement::create(const QualifiedName& tagName, Document& document)
40 return adoptRef(new SVGVKernElement(tagName, document));
43 Node::InsertionNotificationRequest SVGVKernElement::insertedInto(ContainerNode* rootParent)
45 if (rootParent->inDocument()) {
46 ContainerNode* fontNode = parentNode();
47 if (fontNode && fontNode->hasTagName(SVGNames::fontTag))
48 toSVGFontElement(fontNode)->invalidateGlyphCache();
51 return SVGElement::insertedInto(rootParent);
54 void SVGVKernElement::removedFrom(ContainerNode* rootParent)
56 ContainerNode* fontNode = parentNode();
57 if (fontNode && fontNode->hasTagName(SVGNames::fontTag))
58 toSVGFontElement(fontNode)->invalidateGlyphCache();
60 SVGElement::removedFrom(rootParent);
63 void SVGVKernElement::buildVerticalKerningPair(KerningPairVector& kerningPairs)
65 String u1 = fastGetAttribute(SVGNames::u1Attr);
66 String g1 = fastGetAttribute(SVGNames::g1Attr);
67 String u2 = fastGetAttribute(SVGNames::u2Attr);
68 String g2 = fastGetAttribute(SVGNames::g2Attr);
69 if ((u1.isEmpty() && g1.isEmpty()) || (u2.isEmpty() && g2.isEmpty()))
72 SVGKerningPair kerningPair;
73 if (parseGlyphName(g1, kerningPair.glyphName1)
74 && parseGlyphName(g2, kerningPair.glyphName2)
75 && parseKerningUnicodeString(u1, kerningPair.unicodeRange1, kerningPair.unicodeName1)
76 && parseKerningUnicodeString(u2, kerningPair.unicodeRange2, kerningPair.unicodeName2)) {
77 kerningPair.kerning = fastGetAttribute(SVGNames::kAttr).string().toFloat();
78 kerningPairs.append(kerningPair);
84 #endif // ENABLE(SVG_FONTS)