This source file includes following definitions.
- isSVGFontFaceSrc
- isSupportedFormat
- customCSSText
- hasFailedOrCanceledSubresources
- fetch
- equals
#include "config.h"
#include "core/css/CSSFontFaceSrcValue.h"
#include "FetchInitiatorTypeNames.h"
#include "core/css/StyleSheetContents.h"
#include "core/dom/Document.h"
#include "core/dom/Node.h"
#include "core/fetch/FetchRequest.h"
#include "core/fetch/FontResource.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/svg/SVGFontFaceElement.h"
#include "platform/fonts/FontCustomPlatformData.h"
#include "wtf/text/StringBuilder.h"
namespace WebCore {
#if ENABLE(SVG_FONTS)
bool CSSFontFaceSrcValue::isSVGFontFaceSrc() const
{
return equalIgnoringCase(m_format, "svg");
}
#endif
bool CSSFontFaceSrcValue::isSupportedFormat() const
{
if (m_format.isEmpty()) {
if (!m_resource.startsWith("data:", false) && m_resource.endsWith(".eot", false))
return false;
return true;
}
return FontCustomPlatformData::supportsFormat(m_format)
#if ENABLE(SVG_FONTS)
|| isSVGFontFaceSrc()
#endif
;
}
String CSSFontFaceSrcValue::customCSSText() const
{
StringBuilder result;
if (isLocal())
result.appendLiteral("local(");
else
result.appendLiteral("url(");
result.append(m_resource);
result.append(')');
if (!m_format.isEmpty()) {
result.appendLiteral(" format(");
result.append(m_format);
result.append(')');
}
return result.toString();
}
bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const
{
if (!m_fetched)
return false;
return m_fetched->loadFailedOrCanceled();
}
FontResource* CSSFontFaceSrcValue::fetch(Document* document)
{
if (!m_fetched) {
FetchRequest request(ResourceRequest(document->completeURL(m_resource)), FetchInitiatorTypeNames::css);
m_fetched = document->fetcher()->fetchFont(request);
}
return m_fetched.get();
}
bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const
{
return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resource == other.m_resource;
}
}