| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 24 */ | |
| 25 | |
| 26 #ifndef ClipRect_h | |
| 27 #define ClipRect_h | |
| 28 | |
| 29 #include "platform/geometry/LayoutRect.h" | |
| 30 #include "wtf/Allocator.h" | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 class HitTestLocation; | |
| 35 | |
| 36 class ClipRect { | |
| 37 USING_FAST_MALLOC(ClipRect); | |
| 38 | |
| 39 public: | |
| 40 ClipRect() : m_hasRadius(false), m_isClippedByClipCss(false) {} | |
| 41 | |
| 42 ClipRect(const LayoutRect& rect) | |
| 43 : m_rect(rect), m_hasRadius(false), m_isClippedByClipCss(false) {} | |
| 44 | |
| 45 const LayoutRect& rect() const { return m_rect; } | |
| 46 | |
| 47 bool hasRadius() const { return m_hasRadius; } | |
| 48 void setHasRadius(bool hasRadius) { m_hasRadius = hasRadius; } | |
| 49 | |
| 50 bool operator==(const ClipRect& other) const { | |
| 51 return rect() == other.rect() && hasRadius() == other.hasRadius(); | |
| 52 } | |
| 53 bool operator!=(const ClipRect& other) const { | |
| 54 return rect() != other.rect() || hasRadius() != other.hasRadius(); | |
| 55 } | |
| 56 bool operator!=(const LayoutRect& otherRect) const { | |
| 57 return rect() != otherRect; | |
| 58 } | |
| 59 | |
| 60 void intersect(const LayoutRect& other) { m_rect.intersect(other); } | |
| 61 void intersect(const ClipRect& other) { | |
| 62 m_rect.intersect(other.rect()); | |
| 63 if (other.hasRadius()) | |
| 64 m_hasRadius = true; | |
| 65 } | |
| 66 void move(const LayoutSize& size) { m_rect.move(size); } | |
| 67 void move(const IntSize& size) { m_rect.move(size); } | |
| 68 void moveBy(const LayoutPoint& point) { m_rect.moveBy(point); } | |
| 69 | |
| 70 bool isEmpty() const { return m_rect.isEmpty(); } | |
| 71 bool intersects(const HitTestLocation&) const; | |
| 72 | |
| 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(); } | |
| 81 | |
| 82 private: | |
| 83 LayoutRect m_rect; | |
| 84 bool m_hasRadius; | |
| 85 bool m_isClippedByClipCss; | |
| 86 }; | |
| 87 | |
| 88 inline ClipRect intersection(const ClipRect& a, const ClipRect& b) { | |
| 89 ClipRect c = a; | |
| 90 c.intersect(b); | |
| 91 return c; | |
| 92 } | |
| 93 | |
| 94 } // namespace blink | |
| 95 | |
| 96 #endif // ClipRect_h | |
| OLD | NEW |