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

Unified Diff: ui/views/corewm/tooltip_controller.cc

Issue 2615993002: Remove unnecessary spin in ToolTipController (Closed)
Patch Set: Fix unit tests Created 3 years, 11 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
Index: ui/views/corewm/tooltip_controller.cc
diff --git a/ui/views/corewm/tooltip_controller.cc b/ui/views/corewm/tooltip_controller.cc
index cd1792ffa29d03692804fa4162d8a450adcb171c..c2d8462b61a81ab1ccf662cdf4485a141c67f35c 100644
--- a/ui/views/corewm/tooltip_controller.cc
+++ b/ui/views/corewm/tooltip_controller.cc
@@ -30,7 +30,6 @@ namespace views {
namespace corewm {
namespace {
-const int kTooltipTimeoutMs = 500;
const int kDefaultTooltipShownTimeoutMs = 10000;
#if defined(OS_WIN)
// Drawing a long word in tooltip is very slow on Windows. crbug.com/513693
@@ -129,11 +128,7 @@ TooltipController::TooltipController(std::unique_ptr<Tooltip> tooltip)
tooltip_id_(NULL),
tooltip_window_at_mouse_press_(NULL),
tooltip_(std::move(tooltip)),
- tooltips_enabled_(true) {
- tooltip_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
- this, &TooltipController::TooltipTimerFired);
-}
+ tooltips_enabled_(true) {}
TooltipController::~TooltipController() {
if (tooltip_window_)
@@ -160,17 +155,6 @@ void TooltipController::UpdateTooltip(aura::Window* target) {
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()) {
- if (tooltip_window_ != target || (tooltip_window_ &&
- tooltip_text_ != aura::client::GetTooltipText(tooltip_window_))) {
- tooltip_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
- this, &TooltipController::TooltipTimerFired);
- }
- }
}
void TooltipController::SetTooltipShownTimeout(aura::Window* target,
@@ -211,10 +195,10 @@ void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
target = GetTooltipTarget(*event, &curr_mouse_loc_);
}
SetTooltipWindow(target);
- if (tooltip_timer_.IsRunning())
- tooltip_timer_.Reset();
- if (tooltip_->IsVisible())
+ if (tooltip_->IsVisible() || tooltip_window_ != target ||
+ (tooltip_window_ &&
+ tooltip_text_ != aura::client::GetTooltipText(tooltip_window_)))
brucedawson 2017/01/06 20:45:23 I don't understand why this logic has changed. Can
chengx 2017/01/06 20:58:19 Previously, mouse event handlers update tooltip on
UpdateIfRequired();
break;
}
@@ -232,10 +216,6 @@ void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
// Hide the tooltip for click, release, drag, wheel events.
if (tooltip_->IsVisible())
tooltip_->Hide();
-
- // Don't reshow the tooltip during scroll.
- if (tooltip_timer_.IsRunning())
- tooltip_timer_.Reset();
break;
default:
break;
@@ -266,17 +246,8 @@ void TooltipController::OnWindowDestroyed(aura::Window* window) {
////////////////////////////////////////////////////////////////////////////////
// TooltipController private:
-void TooltipController::TooltipTimerFired() {
- UpdateIfRequired();
-}
-
void TooltipController::TooltipShownTimerFired() {
tooltip_->Hide();
-
- // Since the user presumably no longer needs the tooltip, we also stop the
- // tooltip timer so that tooltip does not pop back up. We will restart this
- // timer if the tooltip changes (see UpdateTooltip()).
- tooltip_timer_.Stop();
}
void TooltipController::UpdateIfRequired() {

Powered by Google App Engine
This is Rietveld 408576698