diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp b/src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp index 7f6c6d2..096f0c2 100644 --- a/src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp +++ b/src/3rdparty/webkit/WebCore/svg/SVGFontFaceUriElement.cpp @@ -1,5 +1,6 @@ /* Copyright (C) 2007 Eric Seidel <eric@webkit.org> + Copyright (C) 2009 Apple Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -23,6 +24,10 @@ #include "SVGFontFaceUriElement.h" #include "CSSFontFaceSrcValue.h" +#include "CachedFont.h" +#include "DocLoader.h" +#include "Document.h" +#include "MappedAttribute.h" #include "SVGFontFaceElement.h" #include "SVGNames.h" #include "XLinkNames.h" @@ -36,6 +41,12 @@ SVGFontFaceUriElement::SVGFontFaceUriElement(const QualifiedName& tagName, Docum { } +SVGFontFaceUriElement::~SVGFontFaceUriElement() +{ + if (m_cachedFont) + m_cachedFont->removeClient(this); +} + PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const { RefPtr<CSSFontFaceSrcValue> src = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr)); @@ -44,6 +55,15 @@ PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const return src.release(); } +void SVGFontFaceUriElement::parseMappedAttribute(MappedAttribute* attr) +{ + const QualifiedName& attrName = attr->name(); + if (attrName == XLinkNames::hrefAttr) + loadFont(); + else + SVGElement::parseMappedAttribute(attr); +} + void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); @@ -56,6 +76,28 @@ void SVGFontFaceUriElement::childrenChanged(bool changedByParser, Node* beforeCh static_cast<SVGFontFaceElement*>(grandParent)->rebuildFontFace(); } +void SVGFontFaceUriElement::insertedIntoDocument() +{ + loadFont(); + SVGElement::insertedIntoDocument(); +} + +void SVGFontFaceUriElement::loadFont() +{ + if (m_cachedFont) + m_cachedFont->removeClient(this); + + String href = getAttribute(XLinkNames::hrefAttr); + if (!href.isNull()) { + DocLoader* docLoader = document()->docLoader(); + m_cachedFont = docLoader->requestFont(href); + m_cachedFont->setSVGFont(true); + m_cachedFont->addClient(this); + m_cachedFont->beginLoadIfNeeded(docLoader); + } else + m_cachedFont = 0; +} + } #endif // ENABLE(SVG_FONTS) |