Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: Source/core/layout/HitTestLocation.cpp

Issue 952273006: Make the constructor of a LayoutRect from an IntRect explicit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/HitTestLocation.h ('k') | Source/core/layout/Layer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 void HitTestLocation::move(const LayoutSize& offset) 112 void HitTestLocation::move(const LayoutSize& offset)
113 { 113 {
114 m_point.move(offset); 114 m_point.move(offset);
115 m_transformedPoint.move(offset); 115 m_transformedPoint.move(offset);
116 m_transformedRect.move(offset); 116 m_transformedRect.move(offset);
117 m_boundingBox = enclosingIntRect(m_transformedRect.boundingBox()); 117 m_boundingBox = enclosingIntRect(m_transformedRect.boundingBox());
118 } 118 }
119 119
120 template<typename RectType> 120 template<typename RectType>
121 bool HitTestLocation::intersectsRect(const RectType& rect) const 121 bool HitTestLocation::intersectsRect(const RectType& rect, const RectType& bound ingBox) const
122 { 122 {
123 // FIXME: When the hit test is not rect based we should use rect.contains(m_ point). 123 // FIXME: When the hit test is not rect based we should use rect.contains(m_ point).
124 // That does change some corner case tests though. 124 // That does change some corner case tests though.
125 125
126 // First check if rect even intersects our bounding box. 126 // First check if rect even intersects our bounding box.
127 if (!rect.intersects(m_boundingBox)) 127 if (!rect.intersects(boundingBox))
128 return false; 128 return false;
129 129
130 // If the transformed rect is rectilinear the bounding box intersection was accurate. 130 // If the transformed rect is rectilinear the bounding box intersection was accurate.
131 if (m_isRectilinear) 131 if (m_isRectilinear)
132 return true; 132 return true;
133 133
134 // If rect fully contains our bounding box, we are also sure of an intersect ion. 134 // If rect fully contains our bounding box, we are also sure of an intersect ion.
135 if (rect.contains(m_boundingBox)) 135 if (rect.contains(boundingBox))
136 return true; 136 return true;
137 137
138 // Otherwise we need to do a slower quad based intersection test. 138 // Otherwise we need to do a slower quad based intersection test.
139 return m_transformedRect.intersectsRect(rect); 139 return m_transformedRect.intersectsRect(rect);
140 } 140 }
141 141
142 bool HitTestLocation::intersects(const LayoutRect& rect) const 142 bool HitTestLocation::intersects(const LayoutRect& rect) const
143 { 143 {
144 return intersectsRect(rect); 144 return intersectsRect(rect, LayoutRect(m_boundingBox));
145 } 145 }
146 146
147 bool HitTestLocation::intersects(const FloatRect& rect) const 147 bool HitTestLocation::intersects(const FloatRect& rect) const
148 { 148 {
149 return intersectsRect(rect); 149 return intersectsRect(rect, FloatRect(m_boundingBox));
150 } 150 }
151 151
152 bool HitTestLocation::intersects(const FloatRoundedRect& rect) const 152 bool HitTestLocation::intersects(const FloatRoundedRect& rect) const
153 { 153 {
154 return rect.intersectsQuad(m_transformedRect); 154 return rect.intersectsQuad(m_transformedRect);
155 } 155 }
156 156
157 bool HitTestLocation::containsPoint(const FloatPoint& point) const 157 bool HitTestLocation::containsPoint(const FloatPoint& point) const
158 { 158 {
159 return m_transformedRect.containsPoint(point); 159 return m_transformedRect.containsPoint(point);
160 } 160 }
161 161
162 IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, unsigned topPadd ing, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) 162 IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, unsigned topPadd ing, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
163 { 163 {
164 IntPoint actualPoint(flooredIntPoint(point)); 164 IntPoint actualPoint(flooredIntPoint(point));
165 actualPoint -= IntSize(leftPadding, topPadding); 165 actualPoint -= IntSize(leftPadding, topPadding);
166 166
167 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding ); 167 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding );
168 // As IntRect is left inclusive and right exclusive (seeing IntRect::contain s(x, y)), adding "1". 168 // As IntRect is left inclusive and right exclusive (seeing IntRect::contain s(x, y)), adding "1".
169 // FIXME: Remove this once non-rect based hit-detection stops using IntRect: intersects. 169 // FIXME: Remove this once non-rect based hit-detection stops using IntRect: intersects.
170 actualPadding += IntSize(1, 1); 170 actualPadding += IntSize(1, 1);
171 171
172 return IntRect(actualPoint, actualPadding); 172 return IntRect(actualPoint, actualPadding);
173 } 173 }
174 174
175 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestLocation.h ('k') | Source/core/layout/Layer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698