示例#1
0
SVGFontElement* FontResource::getSVGFontById(const String& fontName) const
{
    RefPtr<HTMLCollection> collection = m_externalSVGDocument->getElementsByTagNameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName());
    if (!collection)
        return 0;

    unsigned collectionLength = collection->length();
    if (!collectionLength)
        return 0;

#ifndef NDEBUG
    for (unsigned i = 0; i < collectionLength; ++i) {
        ASSERT(collection->item(i));
        ASSERT(isSVGFontElement(collection->item(i)));
    }
#endif

    if (fontName.isEmpty())
        return toSVGFontElement(collection->item(0));

    for (unsigned i = 0; i < collectionLength; ++i) {
        SVGFontElement* element = toSVGFontElement(collection->item(i));
        if (element->getIdAttribute() == fontName)
            return element;
    }

    return 0;
}
示例#2
0
SVGFontElement* CachedFont::getSVGFontById(const String& fontName) const
{
    RefPtr<NodeList> list = m_externalSVGDocument->getElementsByTagNameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName());
    if (!list)
        return 0;

    unsigned listLength = list->length();
    if (!listLength)
        return 0;

#ifndef NDEBUG
    for (unsigned i = 0; i < listLength; ++i) {
        ASSERT(list->item(i));
        ASSERT(isSVGFontElement(list->item(i)));
    }
#endif

    if (fontName.isEmpty())
        return toSVGFontElement(list->item(0));

    for (unsigned i = 0; i < listLength; ++i) {
        SVGFontElement* element = toSVGFontElement(list->item(i));
        if (element->getIdAttribute() == fontName)
            return element;
    }

    return 0;
}
示例#3
0
void SVGHKernElement::removedFrom(ContainerNode& rootParent)
{
    ContainerNode* fontNode = parentNode();
    if (fontNode && isSVGFontElement(fontNode))
        toSVGFontElement(fontNode)->invalidateGlyphCache();

    SVGElement::removedFrom(rootParent);
}
示例#4
0
Node::InsertionNotificationRequest SVGHKernElement::insertedInto(ContainerNode& rootParent)
{
    ContainerNode* fontNode = parentNode();
    if (fontNode && isSVGFontElement(fontNode))
        toSVGFontElement(fontNode)->invalidateGlyphCache();

    return SVGElement::insertedInto(rootParent);
}
示例#5
0
void SVGVKernElement::removedFrom(ContainerNode* rootParent)
{
    ContainerNode* fontNode = parentNode();
    if (fontNode && fontNode->hasTagName(SVGNames::fontTag))
        toSVGFontElement(fontNode)->invalidateGlyphCache();

    SVGElement::removedFrom(rootParent);
}
示例#6
0
Node::InsertionNotificationRequest SVGVKernElement::insertedInto(ContainerNode* rootParent)
{
    if (rootParent->inDocument()) {
        ContainerNode* fontNode = parentNode();
        if (isSVGFontElement(fontNode))
            toSVGFontElement(*fontNode).invalidateGlyphCache();
    }

    return SVGElement::insertedInto(rootParent);
}
示例#7
0
Node::InsertionNotificationRequest SVGVKernElement::insertedInto(ContainerNode* rootParent)
{
    if (rootParent->inDocument()) {
        ContainerNode* fontNode = parentNode();
        if (fontNode && fontNode->hasTagName(SVGNames::fontTag))
            toSVGFontElement(fontNode)->invalidateGlyphCache();
    }

    return SVGElement::insertedInto(rootParent);
}
示例#8
0
void SVGFontFaceElement::rebuildFontFace()
{
    if (!inDocument()) {
        ASSERT(!m_fontElement);
        return;
    }

    bool describesParentFont = isSVGFontElement(*parentNode());
    RefPtrWillBeRawPtr<CSSValueList> list = nullptr;

    if (describesParentFont) {
        m_fontElement = toSVGFontElement(parentNode());

        list = CSSValueList::createCommaSeparated();
        list->append(CSSFontFaceSrcValue::createLocal(fontFamily()));
    } else {
        m_fontElement = nullptr;
        // we currently ignore all but the last src element, alternatively we could concat them
        if (SVGFontFaceSrcElement* element = Traversal<SVGFontFaceSrcElement>::lastChild(*this))
            list = element->srcValue();
    }

    if (!list || !list->length())
        return;

    // Parse in-memory CSS rules
    m_fontFaceRule->mutableProperties().addParsedProperty(CSSProperty(CSSPropertySrc, list));

    if (describesParentFont) {
        // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
        RefPtrWillBeRawPtr<CSSValue> src = m_fontFaceRule->properties().getPropertyCSSValue(CSSPropertySrc);
        CSSValueList* srcList = toCSSValueList(src.get());

        unsigned srcLength = srcList ? srcList->length() : 0;
        for (unsigned i = 0; i < srcLength; i++) {
            if (CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)))
                item->setSVGFontFaceElement(this);
        }
    }

    document().styleResolverChanged();
}
示例#9
0
void SVGGlyphElement::invalidateGlyphCache()
{
    ContainerNode* fontNode = parentNode();
    if (fontNode && isSVGFontElement(fontNode))
        toSVGFontElement(fontNode)->invalidateGlyphCache();
}