[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / views / widget / tooltip_manager.cc
blobf1a85fe2df44b8ac981e98a10f99a66249b750ea
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/widget/tooltip_manager.h"
7 #include "ui/gfx/rect.h"
8 #include "ui/gfx/screen.h"
9 #include "ui/gfx/text_elider.h"
11 namespace views {
13 const size_t kMaxTooltipLength = 1024;
15 // static
16 const char TooltipManager::kGroupingPropertyKey[] = "GroupingPropertyKey";
18 // static
19 int TooltipManager::GetMaxWidth(int x, int y, gfx::NativeView context) {
20 return GetMaxWidth(gfx::Screen::GetScreenFor(context)->GetDisplayNearestPoint(
21 gfx::Point(x, y)));
24 // static
25 int TooltipManager::GetMaxWidth(const gfx::Display& display) {
26 return (display.bounds().width() + 1) / 2;
29 // static
30 void TooltipManager::TrimTooltipText(base::string16* text) {
31 // Clamp the tooltip length to kMaxTooltipLength so that we don't
32 // accidentally DOS the user with a mega tooltip.
33 *text = gfx::TruncateString(*text, kMaxTooltipLength);
36 } // namespace views