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

Unified Diff: ui/views/view.cc

Issue 10827198: Change View::HitTest to View::HitTestRect (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed errors reported by trybots Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 80bd221359589cc850369a3bb9de561f8537f722..ab1ec177c0dc023d6bef600aeba6c92fd7eac7d2 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -22,6 +22,7 @@
#include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/path.h"
#include "ui/gfx/point3.h"
+#include "ui/gfx/skia_util.h"
#include "ui/gfx/transform.h"
#include "ui/views/background.h"
#include "ui/views/context_menu_controller.h"
@@ -757,7 +758,7 @@ View* View::GetEventHandlerForPoint(const gfx::Point& point) {
gfx::Point point_in_child_coords(point);
View::ConvertPointToView(this, child, &point_in_child_coords);
- if (child->HitTest(point_in_child_coords))
+ if (child->HitTestPoint(point_in_child_coords))
return child->GetEventHandlerForPoint(point_in_child_coords);
}
return this;
@@ -772,8 +773,12 @@ gfx::NativeCursor View::GetCursor(const MouseEvent& event) {
#endif
}
-bool View::HitTest(const gfx::Point& l) const {
- if (GetLocalBounds().Contains(l)) {
+bool View::HitTestPoint(const gfx::Point& point) const {
+ return HitTestRect(gfx::Rect(point, gfx::Size(1, 1)));
+}
+
+bool View::HitTestRect(const gfx::Rect& rect) const {
+ if (GetLocalBounds().Intersects(rect)) {
if (HasHitTestMask()) {
gfx::Path mask;
GetHitTestMask(&mask);
@@ -783,10 +788,11 @@ bool View::HitTest(const gfx::Point& l) const {
clip_region.setRect(0, 0, width(), height());
SkRegion mask_region;
return mask_region.setPath(mask, clip_region) &&
- mask_region.contains(l.x(), l.y());
+ mask_region.intersects(RectToSkIRect(rect));
#elif defined(OS_WIN)
base::win::ScopedRegion rgn(mask.CreateNativeRegion());
- return !!PtInRegion(rgn, l.x(), l.y());
+ const RECT r(rect.ToRECT());
+ return RectInRegion(rgn, &r) != 0;
#endif
}
// No mask, but inside our bounds.
@@ -1896,8 +1902,9 @@ void View::DestroyLayer() {
bool View::ProcessMousePressed(const MouseEvent& event, DragInfo* drag_info) {
int drag_operations =
- (enabled_ && event.IsOnlyLeftMouseButton() && HitTest(event.location())) ?
- GetDragOperations(event.location()) : 0;
+ (enabled_ && event.IsOnlyLeftMouseButton() &&
+ HitTestPoint(event.location())) ?
+ GetDragOperations(event.location()) : 0;
ContextMenuController* context_menu_controller = event.IsRightMouseButton() ?
context_menu_controller_ : 0;
@@ -1942,7 +1949,7 @@ void View::ProcessMouseReleased(const MouseEvent& event) {
// from mouse released.
gfx::Point location(event.location());
OnMouseReleased(event);
- if (HitTest(location)) {
+ if (HitTestPoint(location)) {
ConvertPointToScreen(this, &location);
ShowContextMenu(location, true);
}
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698