2 * Copyright 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 "CSSWrapShapes.h"
34 #include <wtf/text/StringBuilder.h>
40 String CSSWrapShapeRect::cssText() const
42 DEFINE_STATIC_LOCAL(const String, rectParen, ("rect("));
43 DEFINE_STATIC_LOCAL(const String, comma, (", "));
46 result.reserveCapacity(32);
47 result.append(rectParen);
49 result.append(m_left->cssText());
52 result.append(m_top->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 CSSWrapShapeCircle::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_left->cssText());
87 result.append(m_top->cssText());
90 result.append(m_radius->cssText());
93 return result.toString();
96 String CSSWrapShapeEllipse::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_left->cssText());
106 result.append(comma);
108 result.append(m_top->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 CSSWrapShapePolygon::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, (", "));
126 StringBuilder result;
127 result.reserveCapacity(32);
128 if (m_windRule == RULE_EVENODD)
129 result.append(polygonParenEvenOdd);
131 result.append(polygonParenNonZero);
133 ASSERT(!(m_values.size() % 2));
135 for (unsigned i = 0; i < m_values.size(); i += 2) {
138 result.append(m_values.at(i)->cssText());
139 result.append(comma);
140 result.append(m_values.at(i + 1)->cssText());
145 return result.toString();
148 } // namespace WebCore