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

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

Issue 213833018: Aura tooltips do not move on mouse move in case of many neighboring views with the same label (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Write unit test for the case when a tooltip moves from one view to another with the same tooltip bu… Created 6 years, 8 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 500466fdf4d646c69ccba8f31c98ef85a8f9496c..e947ded0f678a9d280386458e00ce0826e26d3f2 100644
--- a/ui/views/corewm/tooltip_controller.cc
+++ b/ui/views/corewm/tooltip_controller.cc
@@ -128,10 +128,11 @@ TooltipController::~TooltipController() {
tooltip_window_->RemoveObserver(this);
}
-void TooltipController::UpdateTooltip(aura::Window* target) {
+void TooltipController::UpdateTooltip(aura::Window* target,
+ bool force) {
// If tooltip is visible, we may want to hide it. If it is not, we are ok.
if (tooltip_window_ == target && tooltip_->IsVisible())
- UpdateIfRequired();
+ UpdateIfRequired(force);
// Reset |tooltip_window_at_mouse_press_| if the moving within the same window
// but over a region that has different tooltip text. By resetting
@@ -166,7 +167,7 @@ void TooltipController::SetTooltipsEnabled(bool enable) {
if (tooltips_enabled_ == enable)
return;
tooltips_enabled_ = enable;
- UpdateTooltip(tooltip_window_);
+ UpdateTooltip(tooltip_window_, false);
}
void TooltipController::OnKeyEvent(ui::KeyEvent* event) {
@@ -192,7 +193,7 @@ void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
tooltip_timer_.Reset();
if (tooltip_->IsVisible())
- UpdateIfRequired();
+ UpdateIfRequired(false);
break;
}
case ui::ET_MOUSE_PRESSED:
@@ -239,9 +240,7 @@ void TooltipController::OnWindowDestroyed(aura::Window* window) {
////////////////////////////////////////////////////////////////////////////////
// TooltipController private:
-void TooltipController::TooltipTimerFired() {
- UpdateIfRequired();
-}
+void TooltipController::TooltipTimerFired() { UpdateIfRequired(false); }
void TooltipController::TooltipShownTimerFired() {
tooltip_->Hide();
@@ -252,7 +251,7 @@ void TooltipController::TooltipShownTimerFired() {
tooltip_timer_.Stop();
}
-void TooltipController::UpdateIfRequired() {
+void TooltipController::UpdateIfRequired(bool force) {
if (!tooltips_enabled_ ||
aura::Env::GetInstance()->IsMouseButtonDown() ||
IsDragDropInProgress() || !IsCursorVisible()) {
@@ -280,7 +279,7 @@ void TooltipController::UpdateIfRequired() {
// want to update the tooltip because the timer has fired.
// If we come here from UpdateTooltip(), we have already checked for tooltip
// visibility and this check below will have no effect.
- if (tooltip_text_ != tooltip_text || !tooltip_->IsVisible()) {
+ if (tooltip_text_ != tooltip_text || !tooltip_->IsVisible() || force) {
tooltip_shown_timer_.Stop();
tooltip_text_ = tooltip_text;
base::string16 trimmed_text(tooltip_text_);

Powered by Google App Engine
This is Rietveld 408576698