summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 03:20:04 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 03:20:04 +0000
commit9d08115e9ac028545d8648290366adb49fda20f3 (patch)
treefd742b2e9dfa830e91fe4271c8296691506c7c6f
parentd5a7f68f7b9569ff9cd2e40ccf39779bd1809298 (diff)
downloadchromium_src-9d08115e9ac028545d8648290366adb49fda20f3.zip
chromium_src-9d08115e9ac028545d8648290366adb49fda20f3.tar.gz
chromium_src-9d08115e9ac028545d8648290366adb49fda20f3.tar.bz2
Makes tooltip reshow in the following circumstances
. Move mouse to v1, wait for tooltip to show. . Click on v1. . Move mouse to v2, then back to v1. I'm using v1/v2 to mean views, but it really means regions of the same window with different tooltips. BUG=306131 TEST=covered by test. R=varunjain@chromium.org Review URL: https://codereview.chromium.org/110253004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241459 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/corewm/tooltip_controller.cc12
-rw-r--r--ui/views/corewm/tooltip_controller_unittest.cc38
2 files changed, 50 insertions, 0 deletions
diff --git a/ui/views/corewm/tooltip_controller.cc b/ui/views/corewm/tooltip_controller.cc
index b411688..23bea64 100644
--- a/ui/views/corewm/tooltip_controller.cc
+++ b/ui/views/corewm/tooltip_controller.cc
@@ -133,6 +133,18 @@ void TooltipController::UpdateTooltip(aura::Window* target) {
if (tooltip_window_ == target && tooltip_->IsVisible())
UpdateIfRequired();
+ // Reset |tooltip_window_at_mouse_press_| if the moving within the same window
+ // but over a region that has different tooltip text. By resetting
+ // |tooltip_window_at_mouse_press_| we ensure the next time the timer fires
+ // we'll requery for the tooltip text.
+ // This handles the case of clicking on a view, moving within the same window
+ // but over a different view, than back to the original.
+ if (tooltip_window_at_mouse_press_ &&
+ target == tooltip_window_at_mouse_press_ &&
+ aura::client::GetTooltipText(target) != tooltip_text_at_mouse_press_) {
+ tooltip_window_at_mouse_press_ = NULL;
+ }
+
// If we had stopped the tooltip timer for some reason, we must restart it if
// there is a change in the tooltip.
if (!tooltip_timer_.IsRunning()) {
diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc
index 6ebf4b9..53f84e3 100644
--- a/ui/views/corewm/tooltip_controller_unittest.cc
+++ b/ui/views/corewm/tooltip_controller_unittest.cc
@@ -344,6 +344,44 @@ TEST_F(TooltipControllerTest, HideOnExit) {
EXPECT_FALSE(helper_->IsTooltipVisible());
}
+TEST_F(TooltipControllerTest, ReshowOnClickAfterEnterExit) {
+ // Owned by |view_|.
+ TooltipTestView* v1 = new TooltipTestView;
+ TooltipTestView* v2 = new TooltipTestView;
+ view_->AddChildView(v1);
+ view_->AddChildView(v2);
+ gfx::Rect view_bounds(view_->GetLocalBounds());
+ view_bounds.set_height(view_bounds.height() / 2);
+ v1->SetBoundsRect(view_bounds);
+ view_bounds.set_y(view_bounds.height());
+ v2->SetBoundsRect(view_bounds);
+ const base::string16 v1_tt(ASCIIToUTF16("v1"));
+ const base::string16 v2_tt(ASCIIToUTF16("v2"));
+ v1->set_tooltip_text(v1_tt);
+ v2->set_tooltip_text(v2_tt);
+
+ gfx::Point v1_point(1, 1);
+ View::ConvertPointToWidget(v1, &v1_point);
+ generator_->MoveMouseRelativeTo(GetWindow(), v1_point);
+
+ // Fire tooltip timer so tooltip becomes visible.
+ helper_->FireTooltipTimer();
+ EXPECT_TRUE(helper_->IsTooltipVisible());
+ EXPECT_EQ(v1_tt, helper_->GetTooltipText());
+
+ // Press the mouse, move to v2 and back to v1.
+ generator_->ClickLeftButton();
+
+ gfx::Point v2_point(1, 1);
+ View::ConvertPointToWidget(v2, &v2_point);
+ generator_->MoveMouseRelativeTo(GetWindow(), v2_point);
+ generator_->MoveMouseRelativeTo(GetWindow(), v1_point);
+
+ helper_->FireTooltipTimer();
+ EXPECT_TRUE(helper_->IsTooltipVisible());
+ EXPECT_EQ(v1_tt, helper_->GetTooltipText());
+}
+
namespace {
// Returns the index of |window| in its parent's children.