Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/corewm/tooltip_controller.h" | 5 #include "ui/views/corewm/tooltip_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 kDelayForTooltipUpdateInMs), | 320 kDelayForTooltipUpdateInMs), |
| 321 this, &TooltipController::ShowTooltip); | 321 this, &TooltipController::ShowTooltip); |
| 322 } | 322 } |
| 323 } else { | 323 } else { |
| 324 ShowTooltip(); // Allow tooltip to show up without delay for unit tests. | 324 ShowTooltip(); // Allow tooltip to show up without delay for unit tests. |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 void TooltipController::ShowTooltip() { | 329 void TooltipController::ShowTooltip() { |
| 330 if (!tooltip_window_) | 330 if (!tooltip_window_ || tooltip_text_whitespace_trimmed_.empty()) |
|
sky
2017/01/25 23:43:21
Also, how do we end up here with an empty tooltip?
chengx
2017/01/26 01:16:24
Because this function is called from UpdateIfRequi
| |
| 331 return; | 331 return; |
| 332 gfx::Point widget_loc = | 332 gfx::Point widget_loc = |
| 333 curr_mouse_loc_ + tooltip_window_->GetBoundsInScreen().OffsetFromOrigin(); | 333 curr_mouse_loc_ + tooltip_window_->GetBoundsInScreen().OffsetFromOrigin(); |
| 334 tooltip_->SetText(tooltip_window_, tooltip_text_whitespace_trimmed_, | 334 tooltip_->SetText(tooltip_window_, tooltip_text_whitespace_trimmed_, |
| 335 widget_loc); | 335 widget_loc); |
| 336 tooltip_->Show(); | 336 tooltip_->Show(); |
| 337 int timeout = GetTooltipShownTimeout(); | 337 int timeout = GetTooltipShownTimeout(); |
| 338 if (timeout > 0) { | 338 if (timeout > 0) { |
| 339 tooltip_shown_timer_.Start(FROM_HERE, | 339 tooltip_shown_timer_.Start(FROM_HERE, |
| 340 base::TimeDelta::FromMilliseconds(timeout), this, | 340 base::TimeDelta::FromMilliseconds(timeout), this, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 return; | 379 return; |
| 380 if (tooltip_window_) | 380 if (tooltip_window_) |
| 381 tooltip_window_->RemoveObserver(this); | 381 tooltip_window_->RemoveObserver(this); |
| 382 tooltip_window_ = target; | 382 tooltip_window_ = target; |
| 383 if (tooltip_window_) | 383 if (tooltip_window_) |
| 384 tooltip_window_->AddObserver(this); | 384 tooltip_window_->AddObserver(this); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace corewm | 387 } // namespace corewm |
| 388 } // namespace views | 388 } // namespace views |
| OLD | NEW |