1 | /** |
2 | * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 | * Copyright (C) 2004, 2005, 2006 Apple Inc. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | #include "config.h" |
21 | #include "CSSFontValue.h" |
22 | |
23 | #include "CSSValueList.h" |
24 | #include <wtf/text/StringBuilder.h> |
25 | |
26 | namespace WebCore { |
27 | |
28 | String CSSFontValue::customCSSText() const |
29 | { |
30 | // font variant weight size / line-height family |
31 | |
32 | StringBuilder result; |
33 | |
34 | if (style) |
35 | result.append(style->cssText()); |
36 | if (variant) { |
37 | if (!result.isEmpty()) |
38 | result.append(' '); |
39 | result.append(variant->cssText()); |
40 | } |
41 | if (weight) { |
42 | if (!result.isEmpty()) |
43 | result.append(' '); |
44 | result.append(weight->cssText()); |
45 | } |
46 | if (stretch) { |
47 | if (!result.isEmpty()) |
48 | result.append(' '); |
49 | result.append(stretch->cssText()); |
50 | } |
51 | if (size) { |
52 | if (!result.isEmpty()) |
53 | result.append(' '); |
54 | result.append(size->cssText()); |
55 | } |
56 | if (lineHeight) { |
57 | if (!size) |
58 | result.append(' '); |
59 | result.append('/'); |
60 | result.append(lineHeight->cssText()); |
61 | } |
62 | if (family) { |
63 | if (!result.isEmpty()) |
64 | result.append(' '); |
65 | result.append(family->cssText()); |
66 | } |
67 | |
68 | return result.toString(); |
69 | } |
70 | |
71 | bool CSSFontValue::equals(const CSSFontValue& other) const |
72 | { |
73 | return compareCSSValuePtr(style, other.style) |
74 | && compareCSSValuePtr(variant, other.variant) |
75 | && compareCSSValuePtr(weight, other.weight) |
76 | && compareCSSValuePtr(stretch, other.stretch) |
77 | && compareCSSValuePtr(size, other.size) |
78 | && compareCSSValuePtr(lineHeight, other.lineHeight) |
79 | && compareCSSValuePtr(family, other.family); |
80 | } |
81 | |
82 | } |
83 | |