Views which cannot process events cannot be tooltip targets

The check for CanProcessEventsWithinSubtree() needs
to be made on |this| before the loop (along with
HitTestRect()) instead of inside the loop on the
children. Otherwise it would be possible to return
a view for which CanProcessEventsWithinSubtree()
returns false.

BUG=382873, 378530
TEST=Added coverage in ViewTest.CanProcessEventsWithinSubtree

Review URL: https://codereview.chromium.org/327843002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276873 0039d316-1c4b-4281-b951-d872f2087c98
parent 45c6f687
......@@ -913,7 +913,7 @@ bool View::CanProcessEventsWithinSubtree() const {
}
View* View::GetTooltipHandlerForPoint(const gfx::Point& point) {
if (!HitTestPoint(point))
if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree())
return NULL;
// Walk the child Views recursively looking for the View that most
......@@ -923,9 +923,6 @@ View* View::GetTooltipHandlerForPoint(const gfx::Point& point) {
if (!child->visible())
continue;
if (!child->CanProcessEventsWithinSubtree())
continue;
gfx::Point point_in_child_coords(point);
ConvertPointToTarget(this, child, &point_in_child_coords);
View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords);
......
......@@ -1311,6 +1311,16 @@ TEST_F(ViewTest, CanProcessEventsWithinSubtree) {
result_view = NULL;
result_view = root_view->GetTooltipHandlerForPoint(point_in_v);
EXPECT_EQ(v, result_view);
// When |v_grandchild| returns false when CanProcessEventsWithinSubtree()
// is called, then NULL should be returned as a target if we call
// GetTooltipHandlerForPoint() with |v_grandchild| as the root of the
// views tree. Note that the location must be in the coordinate space
// of the root view (|v_grandchild| in this case), so use (1, 1).
result_view = v_grandchild;
result_view = v_grandchild->GetTooltipHandlerForPoint(gfx::Point(1, 1));
EXPECT_EQ(NULL, result_view);
result_view = NULL;
// When |v_child| returns false when CanProcessEventsWithinSubtree()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment