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
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_RECT = 1,
45 CSS_WRAP_SHAPE_CIRCLE = 2,
46 CSS_WRAP_SHAPE_ELLIPSE = 3,
47 CSS_WRAP_SHAPE_POLYGON = 4,
48 CSS_WRAP_SHAPE_PATH = 5
51 virtual Type type() = 0;
52 virtual String cssText() const = 0;
55 virtual ~CSSWrapShape() { }
61 class CSSWrapShapeRect : public CSSWrapShape {
63 static PassRefPtr<CSSWrapShapeRect> create() { return adoptRef(new CSSWrapShapeRect); }
65 CSSPrimitiveValue* left() const { return m_left.get(); }
66 CSSPrimitiveValue* top() const { return m_top.get(); }
67 CSSPrimitiveValue* width() const { return m_width.get(); }
68 CSSPrimitiveValue* height() const { return m_height.get(); }
69 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
70 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
72 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
73 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
74 void setWidth(PassRefPtr<CSSPrimitiveValue> width) { m_width = width; }
75 void setHeight(PassRefPtr<CSSPrimitiveValue> height) { m_height = height; }
76 void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
77 void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
79 virtual Type type() { return CSS_WRAP_SHAPE_RECT; }
80 virtual String cssText() const;
83 CSSWrapShapeRect() { }
85 RefPtr<CSSPrimitiveValue> m_top;
86 RefPtr<CSSPrimitiveValue> m_left;
87 RefPtr<CSSPrimitiveValue> m_width;
88 RefPtr<CSSPrimitiveValue> m_height;
89 RefPtr<CSSPrimitiveValue> m_radiusX;
90 RefPtr<CSSPrimitiveValue> m_radiusY;
93 class CSSWrapShapeCircle : public CSSWrapShape {
95 static PassRefPtr<CSSWrapShapeCircle> create() { return adoptRef(new CSSWrapShapeCircle); }
97 CSSPrimitiveValue* left() const { return m_left.get(); }
98 CSSPrimitiveValue* top() const { return m_top.get(); }
99 CSSPrimitiveValue* radius() const { return m_radius.get(); }
101 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
102 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
103 void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
105 virtual Type type() { return CSS_WRAP_SHAPE_CIRCLE; }
106 virtual String cssText() const;
109 CSSWrapShapeCircle() { }
111 RefPtr<CSSPrimitiveValue> m_top;
112 RefPtr<CSSPrimitiveValue> m_left;
113 RefPtr<CSSPrimitiveValue> m_radius;
116 class CSSWrapShapeEllipse : public CSSWrapShape {
118 static PassRefPtr<CSSWrapShapeEllipse> create() { return adoptRef(new CSSWrapShapeEllipse); }
120 CSSPrimitiveValue* left() const { return m_left.get(); }
121 CSSPrimitiveValue* top() const { return m_top.get(); }
122 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
123 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
125 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
126 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
127 void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
128 void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
130 virtual Type type() { return CSS_WRAP_SHAPE_ELLIPSE; }
131 virtual String cssText() const;
134 CSSWrapShapeEllipse() { }
136 RefPtr<CSSPrimitiveValue> m_top;
137 RefPtr<CSSPrimitiveValue> m_left;
138 RefPtr<CSSPrimitiveValue> m_radiusX;
139 RefPtr<CSSPrimitiveValue> m_radiusY;
142 class CSSWrapShapePolygon : public CSSWrapShape {
144 static PassRefPtr<CSSWrapShapePolygon> create() { return adoptRef(new CSSWrapShapePolygon); }
146 void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
152 PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) { return m_values.at(i * 2); }
153 PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) { return m_values.at(i * 2 + 1); }
155 void setWindRule(WindRule w) { m_windRule = w; }
156 WindRule windRule() const { return m_windRule; }
158 virtual Type type() { return CSS_WRAP_SHAPE_POLYGON; }
159 virtual String cssText() const;
162 CSSWrapShapePolygon()
163 : m_windRule(RULE_NONZERO)
167 Vector<RefPtr<CSSPrimitiveValue> > m_values;
171 } // namespace WebCore
173 #endif // CSSWrapShapes_h