| Index: cc/math_util.cc
|
| diff --git a/cc/math_util.cc b/cc/math_util.cc
|
| index f5c0cb4eae3f447f214018ba766bfa102ca7ea9d..47bddd3a4b1ecbe0c4c4ead4cda787c75544f4a1 100644
|
| --- a/cc/math_util.cc
|
| +++ b/cc/math_util.cc
|
| @@ -386,6 +386,26 @@ gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des
|
| return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * destination.y());
|
| }
|
|
|
| +bool MathUtil::pointHitsRect(const gfx::PointF& screenSpacePoint,
|
| + const gfx::Transform& localSpaceToScreenSpaceTransform,
|
| + gfx::RectF localSpaceRect)
|
| +{
|
| + // If the transform is not invertible, then assume that this point doesn't hit this rect.
|
| + gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitialization);
|
| + if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenSpace))
|
| + return false;
|
| +
|
| + // Transform the hit test point from screen space to the local space of the given rect.
|
| + bool clipped = false;
|
| + gfx::PointF hitTestPointInLocalSpace = projectPoint(inverseLocalSpaceToScreenSpace, screenSpacePoint, clipped);
|
| +
|
| + // If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect.
|
| + if (clipped)
|
| + return false;
|
| +
|
| + return localSpaceRect.Contains(hitTestPointInLocalSpace);
|
| +}
|
| +
|
| scoped_ptr<base::Value> MathUtil::asValue(gfx::Size s) {
|
| scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
|
| res->SetDouble("width", s.width());
|
|
|