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
30 #ifndef CSSWrapShapes_h
31 #define CSSWrapShapes_h
33 #include "CSSPrimitiveValue.h"
34 #include "PlatformString.h"
36 #include <wtf/RefPtr.h>
37 #include <wtf/Vector.h>
41 class CSSWrapShape : public RefCounted<CSSWrapShape> {
44 CSS_WRAP_SHAPE_RECTANGLE = 1,
45 CSS_WRAP_SHAPE_CIRCLE = 2,
46 CSS_WRAP_SHAPE_ELLIPSE = 3,
47 CSS_WRAP_SHAPE_POLYGON = 4
50 virtual Type type() = 0;
51 virtual String cssText() const = 0;
54 virtual ~CSSWrapShape() { }
60 class CSSWrapShapeRectangle : public CSSWrapShape {
62 static PassRefPtr<CSSWrapShapeRectangle> create() { return adoptRef(new CSSWrapShapeRectangle); }
64 CSSPrimitiveValue* left() const { return m_left.get(); }
65 CSSPrimitiveValue* top() const { return m_top.get(); }
66 CSSPrimitiveValue* width() const { return m_width.get(); }
67 CSSPrimitiveValue* height() const { return m_height.get(); }
68 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
69 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
71 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
72 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
73 void setWidth(PassRefPtr<CSSPrimitiveValue> width) { m_width = width; }
74 void setHeight(PassRefPtr<CSSPrimitiveValue> height) { m_height = height; }
75 void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
76 void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
78 virtual Type type() { return CSS_WRAP_SHAPE_RECTANGLE; }
79 virtual String cssText() const;
82 CSSWrapShapeRectangle() { }
84 RefPtr<CSSPrimitiveValue> m_top;
85 RefPtr<CSSPrimitiveValue> m_left;
86 RefPtr<CSSPrimitiveValue> m_width;
87 RefPtr<CSSPrimitiveValue> m_height;
88 RefPtr<CSSPrimitiveValue> m_radiusX;
89 RefPtr<CSSPrimitiveValue> m_radiusY;
92 class CSSWrapShapeCircle : public CSSWrapShape {
94 static PassRefPtr<CSSWrapShapeCircle> create() { return adoptRef(new CSSWrapShapeCircle); }
96 CSSPrimitiveValue* left() const { return m_left.get(); }
97 CSSPrimitiveValue* top() const { return m_top.get(); }
98 CSSPrimitiveValue* radius() const { return m_radius.get(); }
100 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
101 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
102 void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
104 virtual Type type() { return CSS_WRAP_SHAPE_CIRCLE; }
105 virtual String cssText() const;
108 CSSWrapShapeCircle() { }
110 RefPtr<CSSPrimitiveValue> m_top;
111 RefPtr<CSSPrimitiveValue> m_left;
112 RefPtr<CSSPrimitiveValue> m_radius;
115 class CSSWrapShapeEllipse : public CSSWrapShape {
117 static PassRefPtr<CSSWrapShapeEllipse> create() { return adoptRef(new CSSWrapShapeEllipse); }
119 CSSPrimitiveValue* left() const { return m_left.get(); }
120 CSSPrimitiveValue* top() const { return m_top.get(); }
121 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
122 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
124 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
125 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
126 void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
127 void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
129 virtual Type type() { return CSS_WRAP_SHAPE_ELLIPSE; }
130 virtual String cssText() const;
133 CSSWrapShapeEllipse() { }
135 RefPtr<CSSPrimitiveValue> m_top;
136 RefPtr<CSSPrimitiveValue> m_left;
137 RefPtr<CSSPrimitiveValue> m_radiusX;
138 RefPtr<CSSPrimitiveValue> m_radiusY;
141 class CSSWrapShapePolygon : public CSSWrapShape {
143 static PassRefPtr<CSSWrapShapePolygon> create() { return adoptRef(new CSSWrapShapePolygon); }
145 void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
151 PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) { return m_values.at(i * 2); }
152 PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) { return m_values.at(i * 2 + 1); }
154 void setWindRule(WindRule w) { m_windRule = w; }
155 WindRule windRule() const { return m_windRule; }
157 virtual Type type() { return CSS_WRAP_SHAPE_POLYGON; }
158 virtual String cssText() const;
161 CSSWrapShapePolygon()
162 : m_windRule(RULE_NONZERO)
166 Vector<RefPtr<CSSPrimitiveValue> > m_values;
170 } // namespace WebCore
172 #endif // CSSWrapShapes_h