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
{
StringBuilder result;
result.appendLiteral("@font-face { ");
String descs = m_fontFaceRule->properties().asText();
result.append(descs);
if (!descs.isEmpty())
result.append(' ');
result.append('}');
return result.toString();
}
void CSSFontFaceRule::reattach(StyleRuleBase& rule)
{
m_fontFaceRule = downcast<StyleRuleFontFace>(rule);
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
}
}