OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef ClipRects_h | 26 #ifndef ClipRects_h |
27 #define ClipRects_h | 27 #define ClipRects_h |
28 | 28 |
29 #include "core/rendering/ClipRect.h" | 29 #include "core/rendering/ClipRect.h" |
| 30 #include "wtf/RefCounted.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 class ClipRects { | 34 class ClipRects : public RefCounted<ClipRects> { |
34 WTF_MAKE_FAST_ALLOCATED; | 35 WTF_MAKE_FAST_ALLOCATED; |
35 public: | 36 public: |
36 static PassRefPtr<ClipRects> create() | 37 static PassRefPtr<ClipRects> create() |
37 { | 38 { |
38 return adoptRef(new ClipRects); | 39 return adoptRef(new ClipRects); |
39 } | 40 } |
40 | 41 |
41 static PassRefPtr<ClipRects> create(const ClipRects& other) | 42 static PassRefPtr<ClipRects> create(const ClipRects& other) |
42 { | 43 { |
43 return adoptRef(new ClipRects(other)); | 44 return adoptRef(new ClipRects(other)); |
44 } | 45 } |
45 | 46 |
46 ClipRects() | 47 ClipRects() |
47 : m_refCnt(1) | 48 : m_fixed(0) |
48 , m_fixed(0) | |
49 { | 49 { |
50 } | 50 } |
51 | 51 |
52 void reset(const LayoutRect& r) | 52 void reset(const LayoutRect& r) |
53 { | 53 { |
54 m_overflowClipRect = r; | 54 m_overflowClipRect = r; |
55 m_fixedClipRect = r; | 55 m_fixedClipRect = r; |
56 m_posClipRect = r; | 56 m_posClipRect = r; |
57 m_fixed = 0; | 57 m_fixed = 0; |
58 } | 58 } |
59 | 59 |
60 const ClipRect& overflowClipRect() const { return m_overflowClipRect; } | 60 const ClipRect& overflowClipRect() const { return m_overflowClipRect; } |
61 void setOverflowClipRect(const ClipRect& r) { m_overflowClipRect = r; } | 61 void setOverflowClipRect(const ClipRect& r) { m_overflowClipRect = r; } |
62 | 62 |
63 const ClipRect& fixedClipRect() const { return m_fixedClipRect; } | 63 const ClipRect& fixedClipRect() const { return m_fixedClipRect; } |
64 void setFixedClipRect(const ClipRect&r) { m_fixedClipRect = r; } | 64 void setFixedClipRect(const ClipRect&r) { m_fixedClipRect = r; } |
65 | 65 |
66 const ClipRect& posClipRect() const { return m_posClipRect; } | 66 const ClipRect& posClipRect() const { return m_posClipRect; } |
67 void setPosClipRect(const ClipRect& r) { m_posClipRect = r; } | 67 void setPosClipRect(const ClipRect& r) { m_posClipRect = r; } |
68 | 68 |
69 bool fixed() const { return static_cast<bool>(m_fixed); } | 69 bool fixed() const { return static_cast<bool>(m_fixed); } |
70 void setFixed(bool fixed) { m_fixed = fixed ? 1 : 0; } | 70 void setFixed(bool fixed) { m_fixed = fixed ? 1 : 0; } |
71 | 71 |
72 void ref() { m_refCnt++; } | |
73 void deref() | |
74 { | |
75 if (!--m_refCnt) | |
76 delete this; | |
77 } | |
78 | |
79 bool operator==(const ClipRects& other) const | 72 bool operator==(const ClipRects& other) const |
80 { | 73 { |
81 return m_overflowClipRect == other.overflowClipRect() | 74 return m_overflowClipRect == other.overflowClipRect() |
82 && m_fixedClipRect == other.fixedClipRect() | 75 && m_fixedClipRect == other.fixedClipRect() |
83 && m_posClipRect == other.posClipRect() | 76 && m_posClipRect == other.posClipRect() |
84 && fixed() == other.fixed(); | 77 && fixed() == other.fixed(); |
85 } | 78 } |
86 | 79 |
87 ClipRects& operator=(const ClipRects& other) | 80 ClipRects& operator=(const ClipRects& other) |
88 { | 81 { |
89 m_overflowClipRect = other.overflowClipRect(); | 82 m_overflowClipRect = other.overflowClipRect(); |
90 m_fixedClipRect = other.fixedClipRect(); | 83 m_fixedClipRect = other.fixedClipRect(); |
91 m_posClipRect = other.posClipRect(); | 84 m_posClipRect = other.posClipRect(); |
92 m_fixed = other.fixed(); | 85 m_fixed = other.fixed(); |
93 return *this; | 86 return *this; |
94 } | 87 } |
95 | 88 |
96 private: | 89 private: |
97 ClipRects(const LayoutRect& r) | 90 ClipRects(const LayoutRect& r) |
98 : m_overflowClipRect(r) | 91 : m_overflowClipRect(r) |
99 , m_fixedClipRect(r) | 92 , m_fixedClipRect(r) |
100 , m_posClipRect(r) | 93 , m_posClipRect(r) |
101 , m_refCnt(1) | |
102 , m_fixed(0) | 94 , m_fixed(0) |
103 { | 95 { |
104 } | 96 } |
105 | 97 |
106 ClipRects(const ClipRects& other) | 98 ClipRects(const ClipRects& other) |
107 : m_overflowClipRect(other.overflowClipRect()) | 99 : m_overflowClipRect(other.overflowClipRect()) |
108 , m_fixedClipRect(other.fixedClipRect()) | 100 , m_fixedClipRect(other.fixedClipRect()) |
109 , m_posClipRect(other.posClipRect()) | 101 , m_posClipRect(other.posClipRect()) |
110 , m_refCnt(1) | |
111 , m_fixed(other.fixed()) | 102 , m_fixed(other.fixed()) |
112 { | 103 { |
113 } | 104 } |
114 | 105 |
115 ClipRect m_overflowClipRect; | 106 ClipRect m_overflowClipRect; |
116 ClipRect m_fixedClipRect; | 107 ClipRect m_fixedClipRect; |
117 ClipRect m_posClipRect; | 108 ClipRect m_posClipRect; |
118 unsigned m_refCnt : 31; | 109 unsigned m_fixed; |
119 unsigned m_fixed : 1; | |
120 }; | 110 }; |
121 | 111 |
122 } // namespace blink | 112 } // namespace blink |
123 | 113 |
124 #endif // ClipRects_h | 114 #endif // ClipRects_h |
OLD | NEW |