blob: 0dda1b2c5a3b4bec9005f44eb32a4adf779c02bf [file] [log] [blame]
darin@apple.com894e8132008-06-17 19:16:22 +00001/*
eseidel13a64222006-05-16 05:33:34 +00002 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
akling@apple.comc713db32012-11-22 03:45:40 +00004 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
eseidel13a64222006-05-16 05:33:34 +00005 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
ddkilzerc8eccec2007-09-26 02:29:57 +000018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
eseidel13a64222006-05-16 05:33:34 +000020 */
weinig5b398c42006-12-29 19:28:15 +000021
eseidel13a64222006-05-16 05:33:34 +000022#include "config.h"
23#include "CSSFontFaceRule.h"
24
akling@apple.comc713db32012-11-22 03:45:40 +000025#include "PropertySetCSSStyleDeclaration.h"
antti@apple.come5428c52013-11-28 20:53:22 +000026#include "StyleProperties.h"
antti@apple.comd09a7922012-04-02 19:50:34 +000027#include "StyleRule.h"
commit-queue@webkit.org1ac47ab2012-08-24 23:58:43 +000028#include <wtf/text/StringBuilder.h>
eseidel13a64222006-05-16 05:33:34 +000029
30namespace WebCore {
31
akling@apple.com39ce74c2014-10-03 04:38:19 +000032CSSFontFaceRule::CSSFontFaceRule(StyleRuleFontFace& fontFaceRule, CSSStyleSheet* parent)
akling@apple.comc713db32012-11-22 03:45:40 +000033 : CSSRule(parent)
antti@apple.comd09a7922012-04-02 19:50:34 +000034 , m_fontFaceRule(fontFaceRule)
eseidel13a64222006-05-16 05:33:34 +000035{
eseidel13a64222006-05-16 05:33:34 +000036}
37
38CSSFontFaceRule::~CSSFontFaceRule()
39{
antti@apple.com745b7902012-03-31 18:02:35 +000040 if (m_propertiesCSSOMWrapper)
41 m_propertiesCSSOMWrapper->clearParentRule();
42}
43
cdumez@apple.coma3b93812014-09-24 01:45:40 +000044CSSStyleDeclaration& CSSFontFaceRule::style()
antti@apple.com745b7902012-03-31 18:02:35 +000045{
46 if (!m_propertiesCSSOMWrapper)
akling@apple.com208eff92013-10-17 15:17:23 +000047 m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_fontFaceRule->mutableProperties(), *this);
cdumez@apple.coma3b93812014-09-24 01:45:40 +000048 return *m_propertiesCSSOMWrapper;
eseidel13a64222006-05-16 05:33:34 +000049}
50
weinig5b398c42006-12-29 19:28:15 +000051String CSSFontFaceRule::cssText() const
52{
commit-queue@webkit.org1ac47ab2012-08-24 23:58:43 +000053 StringBuilder result;
54 result.appendLiteral("@font-face { ");
akling@apple.comfbd786f2013-08-09 09:58:52 +000055 String descs = m_fontFaceRule->properties().asText();
commit-queue@webkit.org1ac47ab2012-08-24 23:58:43 +000056 result.append(descs);
57 if (!descs.isEmpty())
58 result.append(' ');
59 result.append('}');
60 return result.toString();
eseidel13a64222006-05-16 05:33:34 +000061}
weinig5b398c42006-12-29 19:28:15 +000062
akling@apple.com39ce74c2014-10-03 04:38:19 +000063void CSSFontFaceRule::reattach(StyleRuleBase& rule)
antti@apple.comd57c58d2012-05-07 09:56:49 +000064{
cdumez@apple.com7687ecf2014-12-12 20:28:17 +000065 m_fontFaceRule = downcast<StyleRuleFontFace>(rule);
antti@apple.comd57c58d2012-05-07 09:56:49 +000066 if (m_propertiesCSSOMWrapper)
kling@webkit.org5e60b732012-05-29 12:25:07 +000067 m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties());
antti@apple.comd57c58d2012-05-07 09:56:49 +000068}
69
weinig5b398c42006-12-29 19:28:15 +000070} // namespace WebCore