1 /**
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2009 Apple Computer, 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 "third_party/blink/renderer/core/css/css_shadow_value.h"
21
22 #include "third_party/blink/renderer/core/css/css_identifier_value.h"
23 #include "third_party/blink/renderer/core/css/css_primitive_value.h"
24 #include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
25 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
26
27 namespace blink {
28
29 // Used for text-shadow and box-shadow
CSSShadowValue(CSSPrimitiveValue * x,CSSPrimitiveValue * y,CSSPrimitiveValue * blur,CSSPrimitiveValue * spread,CSSIdentifierValue * style,CSSValue * color)30 CSSShadowValue::CSSShadowValue(CSSPrimitiveValue* x,
31 CSSPrimitiveValue* y,
32 CSSPrimitiveValue* blur,
33 CSSPrimitiveValue* spread,
34 CSSIdentifierValue* style,
35 CSSValue* color)
36 : CSSValue(kShadowClass),
37 x(x),
38 y(y),
39 blur(blur),
40 spread(spread),
41 style(style),
42 color(color) {}
43
CustomCSSText() const44 String CSSShadowValue::CustomCSSText() const {
45 StringBuilder text;
46
47 if (color) {
48 text.Append(color->CssText());
49 text.Append(' ');
50 }
51
52 text.Append(x->CssText());
53 text.Append(' ');
54
55 text.Append(y->CssText());
56
57 if (blur) {
58 text.Append(' ');
59 text.Append(blur->CssText());
60 }
61 if (spread) {
62 text.Append(' ');
63 text.Append(spread->CssText());
64 }
65 if (style) {
66 text.Append(' ');
67 text.Append(style->CssText());
68 }
69
70 return text.ToString();
71 }
72
Equals(const CSSShadowValue & other) const73 bool CSSShadowValue::Equals(const CSSShadowValue& other) const {
74 return DataEquivalent(color, other.color) && DataEquivalent(x, other.x) &&
75 DataEquivalent(y, other.y) && DataEquivalent(blur, other.blur) &&
76 DataEquivalent(spread, other.spread) &&
77 DataEquivalent(style, other.style);
78 }
79
TraceAfterDispatch(blink::Visitor * visitor) const80 void CSSShadowValue::TraceAfterDispatch(blink::Visitor* visitor) const {
81 visitor->Trace(x);
82 visitor->Trace(y);
83 visitor->Trace(blur);
84 visitor->Trace(spread);
85 visitor->Trace(style);
86 visitor->Trace(color);
87 CSSValue::TraceAfterDispatch(visitor);
88 }
89
90 } // namespace blink
91