[Cherry-pick] Refactor WrapShape to Shape/BasicShape
[framework/web/webkit-efl.git] / Source / WebCore / css / Rect.h
1 /*
2  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
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
21 #ifndef Rect_h
22 #define Rect_h
23
24 #include "CSSPrimitiveValue.h"
25 #include <wtf/RefPtr.h>
26
27 namespace WebCore {
28
29 class RectBase {
30 public:
31     CSSPrimitiveValue* top() const { return m_top.get(); }
32     CSSPrimitiveValue* right() const { return m_right.get(); }
33     CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
34     CSSPrimitiveValue* left() const { return m_left.get(); }
35
36     void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
37     void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
38     void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
39     void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
40
41 protected:
42     RectBase() { }
43     RectBase(const RectBase& cloneFrom)
44         : m_top(cloneFrom.m_top ? cloneFrom.m_top->cloneForCSSOM() : 0)
45         , m_right(cloneFrom.m_right ? cloneFrom.m_right->cloneForCSSOM() : 0)
46         , m_bottom(cloneFrom.m_bottom ? cloneFrom.m_bottom->cloneForCSSOM() : 0)
47         , m_left(cloneFrom.m_left ? cloneFrom.m_left->cloneForCSSOM() : 0)
48     {
49     }
50
51     ~RectBase() { }
52
53 private:
54     RefPtr<CSSPrimitiveValue> m_top;
55     RefPtr<CSSPrimitiveValue> m_right;
56     RefPtr<CSSPrimitiveValue> m_bottom;
57     RefPtr<CSSPrimitiveValue> m_left;
58 };
59
60 class Rect : public RectBase, public RefCounted<Rect> {
61 public:
62     static PassRefPtr<Rect> create() { return adoptRef(new Rect); }
63     
64     PassRefPtr<Rect> cloneForCSSOM() const { return adoptRef(new Rect(*this)); }
65
66 private:
67     Rect() { }
68     Rect(const Rect& cloneFrom) : RectBase(cloneFrom), RefCounted<Rect>() { }
69 };
70
71 class Quad : public RectBase, public RefCounted<Quad> {
72 public:
73     static PassRefPtr<Quad> create() { return adoptRef(new Quad); }
74     
75     PassRefPtr<Quad> cloneForCSSOM() const { return adoptRef(new Quad(*this)); }
76
77 private:
78     Quad() { }
79     Quad(const Quad& cloneFrom) : RectBase(cloneFrom), RefCounted<Quad>() { }
80 };
81
82 } // namespace WebCore
83
84 #endif // Rect_h