CSSFontFaceRule.cpp [plain text]
#include "config.h"
#include "CSSFontFaceRule.h"
#include "PropertySetCSSStyleDeclaration.h"
#include "StylePropertySet.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.get();
}
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)
{
ASSERT(rule);
ASSERT_WITH_SECURITY_IMPLICATION(rule->isFontFaceRule());
m_fontFaceRule = static_cast<StyleRuleFontFace*>(rule);
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
}
}