summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 06:50:00 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 06:50:00 +0000
commit9b2a18d8d24244eb1834ce54ac1e82a6dbfc13bc (patch)
treee441d7fe3198db3bb2a535ebe4783b510b6bfc35 /chrome
parent9a64ea76098e9e2c1f932b5430b6f08bb75871b1 (diff)
downloadchromium_src-9b2a18d8d24244eb1834ce54ac1e82a6dbfc13bc.zip
chromium_src-9b2a18d8d24244eb1834ce54ac1e82a6dbfc13bc.tar.gz
chromium_src-9b2a18d8d24244eb1834ce54ac1e82a6dbfc13bc.tar.bz2
Fix long tooltips flashing like crazy under Windows.
Tooltips longer than 1024 chars get truncated. However, to determine if the tooltip changed, the un-truncated new text was compared to the truncated old text. Thus, for long tooltips, the tooltip text was considered to be constantly changing, causing the tooltip to be destroyed and re-created constantly. Patch by Simon Radford R=beng,darin BUG=4754 TEST=Go to (for example) http://people.mozilla.org/~rdoherty/tooltips.html and check that the long tooltips do not flash on Windows (I used Vista). Review URL: http://codereview.chromium.org/265003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index 8225487..d180419 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -626,14 +626,14 @@ void RenderWidgetHostViewWin::Destroy() {
}
void RenderWidgetHostViewWin::SetTooltipText(const std::wstring& tooltip_text) {
- if (tooltip_text != tooltip_text_) {
- tooltip_text_ = tooltip_text;
-
- // Clamp the tooltip length to kMaxTooltipLength so that we don't
- // accidentally DOS the user with a mega tooltip (since Windows doesn't seem
- // to do this itself).
- if (tooltip_text_.length() > kMaxTooltipLength)
- tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength);
+ // Clamp the tooltip length to kMaxTooltipLength so that we don't
+ // accidentally DOS the user with a mega tooltip (since Windows doesn't seem
+ // to do this itself).
+ const std::wstring& new_tooltip_text =
+ l10n_util::TruncateString(tooltip_text, kMaxTooltipLength);
+
+ if (new_tooltip_text != tooltip_text_) {
+ tooltip_text_ = new_tooltip_text;
// Need to check if the tooltip is already showing so that we don't
// immediately show the tooltip with no delay when we move the mouse from