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