OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 10 matching lines...) Expand all Loading... |
21 #ifndef Rect_h | 21 #ifndef Rect_h |
22 #define Rect_h | 22 #define Rect_h |
23 | 23 |
24 #include "core/CoreExport.h" | 24 #include "core/CoreExport.h" |
25 #include "core/css/CSSPrimitiveValue.h" | 25 #include "core/css/CSSPrimitiveValue.h" |
26 #include "wtf/RefPtr.h" | 26 #include "wtf/RefPtr.h" |
27 #include "wtf/text/StringBuilder.h" | 27 #include "wtf/text/StringBuilder.h" |
28 | 28 |
29 namespace blink { | 29 namespace blink { |
30 | 30 |
31 class CORE_EXPORT RectBase : public RefCountedWillBeGarbageCollected<RectBase> { | 31 class CORE_EXPORT RectBase : public RefCounted<RectBase> { |
32 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(RectBase); | |
33 public: | 32 public: |
34 CSSPrimitiveValue* top() const { return m_top.get(); } | 33 CSSPrimitiveValue* top() const { return m_top.get(); } |
35 CSSPrimitiveValue* right() const { return m_right.get(); } | 34 CSSPrimitiveValue* right() const { return m_right.get(); } |
36 CSSPrimitiveValue* bottom() const { return m_bottom.get(); } | 35 CSSPrimitiveValue* bottom() const { return m_bottom.get(); } |
37 CSSPrimitiveValue* left() const { return m_left.get(); } | 36 CSSPrimitiveValue* left() const { return m_left.get(); } |
38 | 37 |
39 void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top) { m_top = top; } | 38 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; } |
40 void setRight(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right) { m_right = r
ight; } | 39 void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; } |
41 void setBottom(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom) { m_bottom
= bottom; } | 40 void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; } |
42 void setLeft(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) { m_left = left
; } | 41 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; } |
43 | 42 |
44 bool equals(const RectBase& other) const | 43 bool equals(const RectBase& other) const |
45 { | 44 { |
46 return compareCSSValuePtr(m_top, other.m_top) | 45 return compareCSSValuePtr(m_top, other.m_top) |
47 && compareCSSValuePtr(m_right, other.m_right) | 46 && compareCSSValuePtr(m_right, other.m_right) |
48 && compareCSSValuePtr(m_left, other.m_left) | 47 && compareCSSValuePtr(m_left, other.m_left) |
49 && compareCSSValuePtr(m_bottom, other.m_bottom); | 48 && compareCSSValuePtr(m_bottom, other.m_bottom); |
50 } | 49 } |
51 | 50 |
52 DECLARE_TRACE(); | |
53 | |
54 protected: | 51 protected: |
55 RectBase() { } | 52 RectBase() { } |
56 | 53 |
57 private: | 54 private: |
58 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 55 RefPtr<CSSPrimitiveValue> m_top; |
59 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 56 RefPtr<CSSPrimitiveValue> m_right; |
60 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 57 RefPtr<CSSPrimitiveValue> m_bottom; |
61 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 58 RefPtr<CSSPrimitiveValue> m_left; |
62 }; | 59 }; |
63 | 60 |
64 class Rect : public RectBase { | 61 class Rect : public RectBase { |
65 public: | 62 public: |
66 static PassRefPtrWillBeRawPtr<Rect> create() { return adoptRefWillBeNoop(new
Rect); } | 63 static PassRefPtr<Rect> create() { return adoptRef(new Rect); } |
67 | 64 |
68 String cssText() const | 65 String cssText() const |
69 { | 66 { |
70 return generateCSSString(top()->cssText(), right()->cssText(), bottom()-
>cssText(), left()->cssText()); | 67 return generateCSSString(top()->cssText(), right()->cssText(), bottom()-
>cssText(), left()->cssText()); |
71 } | 68 } |
72 | 69 |
73 private: | 70 private: |
74 Rect() { } | 71 Rect() { } |
75 static String generateCSSString(const String& top, const String& right, cons
t String& bottom, const String& left) | 72 static String generateCSSString(const String& top, const String& right, cons
t String& bottom, const String& left) |
76 { | 73 { |
77 return "rect(" + top + ' ' + right + ' ' + bottom + ' ' + left + ')'; | 74 return "rect(" + top + ' ' + right + ' ' + bottom + ' ' + left + ')'; |
78 } | 75 } |
79 | 76 |
80 // NOTE: If adding fields to this class please make the RectBase trace | 77 // NOTE: If adding fields to this class please make the RectBase trace |
81 // method virtual and add a trace method in this subclass tracing the new | 78 // method virtual and add a trace method in this subclass tracing the new |
82 // fields. | 79 // fields. |
83 }; | 80 }; |
84 | 81 |
85 class Quad : public RectBase { | 82 class Quad : public RectBase { |
86 public: | 83 public: |
87 static PassRefPtrWillBeRawPtr<Quad> create() { return adoptRefWillBeNoop(new
Quad); } | 84 static PassRefPtr<Quad> create() { return adoptRef(new Quad); } |
88 | 85 |
89 String cssText() const | 86 String cssText() const |
90 { | 87 { |
91 return generateCSSString(top()->cssText(), right()->cssText(), bottom()-
>cssText(), left()->cssText()); | 88 return generateCSSString(top()->cssText(), right()->cssText(), bottom()-
>cssText(), left()->cssText()); |
92 } | 89 } |
93 | 90 |
94 private: | 91 private: |
95 Quad() { } | 92 Quad() { } |
96 static String generateCSSString(const String& top, const String& right, cons
t String& bottom, const String& left) | 93 static String generateCSSString(const String& top, const String& right, cons
t String& bottom, const String& left) |
97 { | 94 { |
(...skipping 17 matching lines...) Expand all Loading... |
115 } | 112 } |
116 | 113 |
117 // NOTE: If adding fields to this class please make the RectBase trace | 114 // NOTE: If adding fields to this class please make the RectBase trace |
118 // method virtual and add a trace method in this subclass tracing the new | 115 // method virtual and add a trace method in this subclass tracing the new |
119 // fields. | 116 // fields. |
120 }; | 117 }; |
121 | 118 |
122 } // namespace blink | 119 } // namespace blink |
123 | 120 |
124 #endif // Rect_h | 121 #endif // Rect_h |
OLD | NEW |