OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void HitTestLocation::move(const LayoutSize& offset) { | 103 void HitTestLocation::move(const LayoutSize& offset) { |
104 m_point.move(offset); | 104 m_point.move(offset); |
105 m_transformedPoint.move(offset); | 105 m_transformedPoint.move(offset); |
106 m_transformedRect.move(offset); | 106 m_transformedRect.move(offset); |
107 m_boundingBox = enclosingIntRect(m_transformedRect.boundingBox()); | 107 m_boundingBox = enclosingIntRect(m_transformedRect.boundingBox()); |
108 } | 108 } |
109 | 109 |
110 template <typename RectType> | 110 template <typename RectType> |
111 bool HitTestLocation::intersectsRect(const RectType& rect, | 111 bool HitTestLocation::intersectsRect(const RectType& rect, |
112 const RectType& boundingBox) const { | 112 const RectType& boundingBox) const { |
113 // FIXME: When the hit test is not rect based we should use rect.contains(m_po
int). | 113 // FIXME: When the hit test is not rect based we should use |
| 114 // rect.contains(m_point). |
114 // That does change some corner case tests though. | 115 // That does change some corner case tests though. |
115 | 116 |
116 // First check if rect even intersects our bounding box. | 117 // First check if rect even intersects our bounding box. |
117 if (!rect.intersects(boundingBox)) | 118 if (!rect.intersects(boundingBox)) |
118 return false; | 119 return false; |
119 | 120 |
120 // If the transformed rect is rectilinear the bounding box intersection was ac
curate. | 121 // If the transformed rect is rectilinear the bounding box intersection was |
| 122 // accurate. |
121 if (m_isRectilinear) | 123 if (m_isRectilinear) |
122 return true; | 124 return true; |
123 | 125 |
124 // If rect fully contains our bounding box, we are also sure of an intersectio
n. | 126 // If rect fully contains our bounding box, we are also sure of an |
| 127 // intersection. |
125 if (rect.contains(boundingBox)) | 128 if (rect.contains(boundingBox)) |
126 return true; | 129 return true; |
127 | 130 |
128 // Otherwise we need to do a slower quad based intersection test. | 131 // Otherwise we need to do a slower quad based intersection test. |
129 return m_transformedRect.intersectsRect(FloatRect(rect)); | 132 return m_transformedRect.intersectsRect(FloatRect(rect)); |
130 } | 133 } |
131 | 134 |
132 bool HitTestLocation::intersects(const LayoutRect& rect) const { | 135 bool HitTestLocation::intersects(const LayoutRect& rect) const { |
133 return intersectsRect(rect, LayoutRect(m_boundingBox)); | 136 return intersectsRect(rect, LayoutRect(m_boundingBox)); |
134 } | 137 } |
(...skipping 12 matching lines...) Expand all Loading... |
147 | 150 |
148 IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, | 151 IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, |
149 unsigned topPadding, | 152 unsigned topPadding, |
150 unsigned rightPadding, | 153 unsigned rightPadding, |
151 unsigned bottomPadding, | 154 unsigned bottomPadding, |
152 unsigned leftPadding) { | 155 unsigned leftPadding) { |
153 IntPoint actualPoint(flooredIntPoint(point)); | 156 IntPoint actualPoint(flooredIntPoint(point)); |
154 actualPoint -= IntSize(leftPadding, topPadding); | 157 actualPoint -= IntSize(leftPadding, topPadding); |
155 | 158 |
156 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding); | 159 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding); |
157 // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(
x, y)), adding "1". | 160 // As IntRect is left inclusive and right exclusive (seeing |
158 // FIXME: Remove this once non-rect based hit-detection stops using IntRect:in
tersects. | 161 // IntRect::contains(x, y)), adding "1". |
| 162 // FIXME: Remove this once non-rect based hit-detection stops using |
| 163 // IntRect:intersects. |
159 actualPadding += IntSize(1, 1); | 164 actualPadding += IntSize(1, 1); |
160 | 165 |
161 return IntRect(actualPoint, actualPadding); | 166 return IntRect(actualPoint, actualPadding); |
162 } | 167 } |
163 | 168 |
164 } // namespace blink | 169 } // namespace blink |
OLD | NEW |