1/**
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2009 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 "CSSShadowValue.h"
22
23#include "CSSPrimitiveValue.h"
24#include <wtf/text/StringBuilder.h>
25
26namespace WebCore {
27
28// Used for text-shadow and box-shadow
29CSSShadowValue::CSSShadowValue(RefPtr<CSSPrimitiveValue>&& x, RefPtr<CSSPrimitiveValue>&& y, RefPtr<CSSPrimitiveValue>&& blur, RefPtr<CSSPrimitiveValue>&& spread, RefPtr<CSSPrimitiveValue>&& style, RefPtr<CSSPrimitiveValue>&& color)
30 : CSSValue(ShadowClass)
31 , x(WTFMove(x))
32 , y(WTFMove(y))
33 , blur(WTFMove(blur))
34 , spread(WTFMove(spread))
35 , style(WTFMove(style))
36 , color(WTFMove(color))
37{
38}
39
40String CSSShadowValue::customCSSText() const
41{
42 StringBuilder text;
43
44 if (color)
45 text.append(color->cssText());
46 if (x) {
47 if (!text.isEmpty())
48 text.append(' ');
49 text.append(x->cssText());
50 }
51 if (y) {
52 if (!text.isEmpty())
53 text.append(' ');
54 text.append(y->cssText());
55 }
56 if (blur) {
57 if (!text.isEmpty())
58 text.append(' ');
59 text.append(blur->cssText());
60 }
61 if (spread) {
62 if (!text.isEmpty())
63 text.append(' ');
64 text.append(spread->cssText());
65 }
66 if (style) {
67 if (!text.isEmpty())
68 text.append(' ');
69 text.append(style->cssText());
70 }
71
72 return text.toString();
73}
74
75bool CSSShadowValue::equals(const CSSShadowValue& other) const
76{
77 return compareCSSValuePtr(color, other.color)
78 && compareCSSValuePtr(x, other.x)
79 && compareCSSValuePtr(y, other.y)
80 && compareCSSValuePtr(blur, other.blur)
81 && compareCSSValuePtr(spread, other.spread)
82 && compareCSSValuePtr(style, other.style);
83}
84
85}
86