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; }
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; }
void SVGHKernElement::removedFrom(ContainerNode& rootParent) { ContainerNode* fontNode = parentNode(); if (fontNode && isSVGFontElement(fontNode)) toSVGFontElement(fontNode)->invalidateGlyphCache(); SVGElement::removedFrom(rootParent); }
Node::InsertionNotificationRequest SVGHKernElement::insertedInto(ContainerNode& rootParent) { ContainerNode* fontNode = parentNode(); if (fontNode && isSVGFontElement(fontNode)) toSVGFontElement(fontNode)->invalidateGlyphCache(); return SVGElement::insertedInto(rootParent); }
Node::InsertionNotificationRequest SVGVKernElement::insertedInto(ContainerNode* rootParent) { if (rootParent->inDocument()) { ContainerNode* fontNode = parentNode(); if (isSVGFontElement(fontNode)) toSVGFontElement(*fontNode).invalidateGlyphCache(); } return SVGElement::insertedInto(rootParent); }
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(); }
void SVGGlyphElement::invalidateGlyphCache() { ContainerNode* fontNode = parentNode(); if (fontNode && isSVGFontElement(fontNode)) toSVGFontElement(fontNode)->invalidateGlyphCache(); }
SVGFontElement* SVGFontFaceElement::associatedFontElement() const { ASSERT(parentNode() == m_fontElement); ASSERT(!parentNode() || isSVGFontElement(*parentNode())); return m_fontElement; }