2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include "CSSBasicShapes.h"
34 #include <wtf/text/StringBuilder.h>
40 String CSSBasicShapeRectangle::cssText() const
42 DEFINE_STATIC_LOCAL(const String, rectangleParen, ("rectangle("));
43 DEFINE_STATIC_LOCAL(const String, comma, (", "));
46 result.reserveCapacity(32);
47 result.append(rectangleParen);
49 result.append(m_x->cssText());
52 result.append(m_y->cssText());
55 result.append(m_width->cssText());
58 result.append(m_height->cssText());
60 if (m_radiusX.get()) {
62 result.append(m_radiusX->cssText());
64 if (m_radiusY.get()) {
66 result.append(m_radiusY->cssText());
72 return result.toString();
75 String CSSBasicShapeCircle::cssText() const
77 DEFINE_STATIC_LOCAL(const String, circleParen, ("circle("));
78 DEFINE_STATIC_LOCAL(const String, comma, (", "));
81 result.reserveCapacity(32);
82 result.append(circleParen);
84 result.append(m_centerX->cssText());
87 result.append(m_centerY->cssText());
90 result.append(m_radius->cssText());
93 return result.toString();
96 String CSSBasicShapeEllipse::cssText() const
98 DEFINE_STATIC_LOCAL(const String, ellipseParen, ("ellipse("));
99 DEFINE_STATIC_LOCAL(const String, comma, (", "));
101 StringBuilder result;
102 result.reserveCapacity(32);
103 result.append(ellipseParen);
105 result.append(m_centerX->cssText());
106 result.append(comma);
108 result.append(m_centerY->cssText());
109 result.append(comma);
111 result.append(m_radiusX->cssText());
112 result.append(comma);
114 result.append(m_radiusY->cssText());
117 return result.toString();
120 String CSSBasicShapePolygon::cssText() const
122 DEFINE_STATIC_LOCAL(const String, polygonParenEvenOdd, ("polygon(evenodd, "));
123 DEFINE_STATIC_LOCAL(const String, polygonParenNonZero, ("polygon(nonzero, "));
124 DEFINE_STATIC_LOCAL(const String, comma, (", "));
125 DEFINE_STATIC_LOCAL(const String, space, (" "));
127 StringBuilder result;
128 result.reserveCapacity(32);
129 if (m_windRule == RULE_EVENODD)
130 result.append(polygonParenEvenOdd);
132 result.append(polygonParenNonZero);
134 ASSERT(!(m_values.size() % 2));
136 for (unsigned i = 0; i < m_values.size(); i += 2) {
138 result.append(comma);
139 result.append(m_values.at(i)->cssText());
140 result.append(space);
141 result.append(m_values.at(i + 1)->cssText());
146 return result.toString();
149 } // namespace WebCore