CSSFontFaceRule.cpp [plain text]
#include "config.h"
#include "CSSFontFaceRule.h"
#include "PropertySetCSSStyleDeclaration.h"
#include "StyleProperties.h"
#include "StyleRule.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
CSSFontFaceRule::CSSFontFaceRule(StyleRuleFontFace& fontFaceRule, CSSStyleSheet* parent)
: CSSRule(parent)
, m_fontFaceRule(fontFaceRule)
{
}
CSSFontFaceRule::~CSSFontFaceRule()
{
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->clearParentRule();
}
CSSStyleDeclaration& CSSFontFaceRule::style()
{
if (!m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_fontFaceRule->mutableProperties(), *this);
return *m_propertiesCSSOMWrapper;
}
String CSSFontFaceRule::cssText() const
{
String declarations = m_fontFaceRule->properties().asText();
if (declarations.isEmpty())
return "@font-face { }"_s;
return makeString("@font-face { ", declarations, " }");
}
void CSSFontFaceRule::reattach(StyleRuleBase& rule)
{
m_fontFaceRule = downcast<StyleRuleFontFace>(rule);
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
}
}