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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "wtf/Allocator.h" | 30 #include "wtf/Allocator.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class HitTestLocation; | 34 class HitTestLocation; |
35 | 35 |
36 class ClipRect { | 36 class ClipRect { |
37 USING_FAST_MALLOC(ClipRect); | 37 USING_FAST_MALLOC(ClipRect); |
38 | 38 |
39 public: | 39 public: |
40 ClipRect() : m_hasRadius(false), m_isClippedByClipCss(false) {} | 40 ClipRect() : m_hasRadius(false) {} |
41 | 41 |
42 ClipRect(const LayoutRect& rect) | 42 ClipRect(const LayoutRect& rect) : m_rect(rect), m_hasRadius(false) {} |
43 : m_rect(rect), m_hasRadius(false), m_isClippedByClipCss(false) {} | |
44 | 43 |
45 const LayoutRect& rect() const { return m_rect; } | 44 const LayoutRect& rect() const { return m_rect; } |
46 | 45 |
47 bool hasRadius() const { return m_hasRadius; } | 46 bool hasRadius() const { return m_hasRadius; } |
48 void setHasRadius(bool hasRadius) { m_hasRadius = hasRadius; } | 47 void setHasRadius(bool hasRadius) { m_hasRadius = hasRadius; } |
49 | 48 |
50 bool operator==(const ClipRect& other) const { | 49 bool operator==(const ClipRect& other) const { |
51 return rect() == other.rect() && hasRadius() == other.hasRadius(); | 50 return rect() == other.rect() && hasRadius() == other.hasRadius(); |
52 } | 51 } |
53 bool operator!=(const ClipRect& other) const { | 52 bool operator!=(const ClipRect& other) const { |
54 return rect() != other.rect() || hasRadius() != other.hasRadius(); | 53 return rect() != other.rect() || hasRadius() != other.hasRadius(); |
55 } | 54 } |
56 bool operator!=(const LayoutRect& otherRect) const { | 55 bool operator!=(const LayoutRect& otherRect) const { |
57 return rect() != otherRect; | 56 return rect() != otherRect; |
58 } | 57 } |
59 | 58 |
60 void intersect(const LayoutRect& other) { m_rect.intersect(other); } | 59 void intersect(const LayoutRect& other) { m_rect.intersect(other); } |
61 void intersect(const ClipRect& other) { | 60 void intersect(const ClipRect& other) { |
62 m_rect.intersect(other.rect()); | 61 m_rect.intersect(other.rect()); |
63 if (other.hasRadius()) | 62 if (other.hasRadius()) |
64 m_hasRadius = true; | 63 m_hasRadius = true; |
65 } | 64 } |
66 void move(const LayoutSize& size) { m_rect.move(size); } | 65 void move(const LayoutSize& size) { m_rect.move(size); } |
67 void move(const IntSize& size) { m_rect.move(size); } | 66 void move(const IntSize& size) { m_rect.move(size); } |
68 void moveBy(const LayoutPoint& point) { m_rect.moveBy(point); } | 67 void moveBy(const LayoutPoint& point) { m_rect.moveBy(point); } |
69 | 68 |
70 bool isEmpty() const { return m_rect.isEmpty(); } | 69 bool isEmpty() const { return m_rect.isEmpty(); } |
71 bool intersects(const HitTestLocation&) const; | 70 bool intersects(const HitTestLocation&) const; |
72 | 71 |
73 // These have no semantic use. They are used for use-counting. | |
74 bool isClippedByClipCss() const { return m_isClippedByClipCss; } | |
75 ClipRect& setIsClippedByClipCss() { | |
76 m_isClippedByClipCss = true; | |
77 return *this; | |
78 } | |
79 | |
80 String toString() const { return m_rect.toString(); } | 72 String toString() const { return m_rect.toString(); } |
81 | 73 |
82 private: | 74 private: |
83 LayoutRect m_rect; | 75 LayoutRect m_rect; |
84 bool m_hasRadius; | 76 bool m_hasRadius; |
85 bool m_isClippedByClipCss; | |
86 }; | 77 }; |
87 | 78 |
88 inline ClipRect intersection(const ClipRect& a, const ClipRect& b) { | 79 inline ClipRect intersection(const ClipRect& a, const ClipRect& b) { |
89 ClipRect c = a; | 80 ClipRect c = a; |
90 c.intersect(b); | 81 c.intersect(b); |
91 return c; | 82 return c; |
92 } | 83 } |
93 | 84 |
94 } // namespace blink | 85 } // namespace blink |
95 | 86 |
96 #endif // ClipRect_h | 87 #endif // ClipRect_h |
OLD | NEW |