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(PassRefPtr<CSSPrimitiveValue> x,
30    PassRefPtr<CSSPrimitiveValue> y,
31    PassRefPtr<CSSPrimitiveValue> blur,
32    PassRefPtr<CSSPrimitiveValue> spread,
33    PassRefPtr<CSSPrimitiveValue> style,
34    PassRefPtr<CSSPrimitiveValue> color)
35    : CSSValue(ShadowClass)
36    , x(x)
37    , y(y)
38    , blur(blur)
39    , spread(spread)
40    , style(style)
41    , color(color)
42{
43}
44
45String CSSShadowValue::customCSSText() const
46{
47    StringBuilder text;
48
49    if (color)
50        text.append(color->cssText());
51    if (x) {
52        if (!text.isEmpty())
53            text.append(' ');
54        text.append(x->cssText());
55    }
56    if (y) {
57        if (!text.isEmpty())
58            text.append(' ');
59        text.append(y->cssText());
60    }
61    if (blur) {
62        if (!text.isEmpty())
63            text.append(' ');
64        text.append(blur->cssText());
65    }
66    if (spread) {
67        if (!text.isEmpty())
68            text.append(' ');
69        text.append(spread->cssText());
70    }
71    if (style) {
72        if (!text.isEmpty())
73            text.append(' ');
74        text.append(style->cssText());
75    }
76
77    return text.toString();
78}
79
80bool CSSShadowValue::equals(const CSSShadowValue& other) const
81{
82    return compareCSSValuePtr(color, other.color)
83        && compareCSSValuePtr(x, other.x)
84        && compareCSSValuePtr(y, other.y)
85        && compareCSSValuePtr(blur, other.blur)
86        && compareCSSValuePtr(spread, other.spread)
87        && compareCSSValuePtr(style, other.style);
88}
89
90}
91