darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 1 | /* |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 2 | * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 | * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 4 | * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 5 | * |
| 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 |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 20 | */ |
weinig | 5b398c4 | 2006-12-29 19:28:15 +0000 | [diff] [blame] | 21 | |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 22 | #include "config.h" |
| 23 | #include "CSSFontFaceRule.h" |
| 24 | |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 25 | #include "PropertySetCSSStyleDeclaration.h" |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 26 | #include "StyleProperties.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 27 | #include "StyleRule.h" |
commit-queue@webkit.org | 1ac47ab | 2012-08-24 23:58:43 +0000 | [diff] [blame] | 28 | #include <wtf/text/StringBuilder.h> |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 29 | |
| 30 | namespace WebCore { |
| 31 | |
akling@apple.com | 39ce74c | 2014-10-03 04:38:19 +0000 | [diff] [blame] | 32 | CSSFontFaceRule::CSSFontFaceRule(StyleRuleFontFace& fontFaceRule, CSSStyleSheet* parent) |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 33 | : CSSRule(parent) |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 34 | , m_fontFaceRule(fontFaceRule) |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 35 | { |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | CSSFontFaceRule::~CSSFontFaceRule() |
| 39 | { |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 40 | if (m_propertiesCSSOMWrapper) |
| 41 | m_propertiesCSSOMWrapper->clearParentRule(); |
| 42 | } |
| 43 | |
cdumez@apple.com | a3b9381 | 2014-09-24 01:45:40 +0000 | [diff] [blame] | 44 | CSSStyleDeclaration& CSSFontFaceRule::style() |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 45 | { |
| 46 | if (!m_propertiesCSSOMWrapper) |
akling@apple.com | 208eff9 | 2013-10-17 15:17:23 +0000 | [diff] [blame] | 47 | m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_fontFaceRule->mutableProperties(), *this); |
cdumez@apple.com | a3b9381 | 2014-09-24 01:45:40 +0000 | [diff] [blame] | 48 | return *m_propertiesCSSOMWrapper; |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 49 | } |
| 50 | |
weinig | 5b398c4 | 2006-12-29 19:28:15 +0000 | [diff] [blame] | 51 | String CSSFontFaceRule::cssText() const |
| 52 | { |
commit-queue@webkit.org | 1ac47ab | 2012-08-24 23:58:43 +0000 | [diff] [blame] | 53 | StringBuilder result; |
| 54 | result.appendLiteral("@font-face { "); |
akling@apple.com | fbd786f | 2013-08-09 09:58:52 +0000 | [diff] [blame] | 55 | String descs = m_fontFaceRule->properties().asText(); |
commit-queue@webkit.org | 1ac47ab | 2012-08-24 23:58:43 +0000 | [diff] [blame] | 56 | result.append(descs); |
| 57 | if (!descs.isEmpty()) |
| 58 | result.append(' '); |
| 59 | result.append('}'); |
| 60 | return result.toString(); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 61 | } |
weinig | 5b398c4 | 2006-12-29 19:28:15 +0000 | [diff] [blame] | 62 | |
akling@apple.com | 39ce74c | 2014-10-03 04:38:19 +0000 | [diff] [blame] | 63 | void CSSFontFaceRule::reattach(StyleRuleBase& rule) |
antti@apple.com | d57c58d | 2012-05-07 09:56:49 +0000 | [diff] [blame] | 64 | { |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 65 | m_fontFaceRule = downcast<StyleRuleFontFace>(rule); |
antti@apple.com | d57c58d | 2012-05-07 09:56:49 +0000 | [diff] [blame] | 66 | if (m_propertiesCSSOMWrapper) |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 67 | m_propertiesCSSOMWrapper->reattach(m_fontFaceRule->mutableProperties()); |
antti@apple.com | d57c58d | 2012-05-07 09:56:49 +0000 | [diff] [blame] | 68 | } |
| 69 | |
weinig | 5b398c4 | 2006-12-29 19:28:15 +0000 | [diff] [blame] | 70 | } // namespace WebCore |