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

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

Issue 916423002: Tooltip Cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win build fix Created 5 years, 10 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
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/corewm/tooltip_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/tooltip_aura.cc
diff --git a/ui/views/corewm/tooltip_aura.cc b/ui/views/corewm/tooltip_aura.cc
index ef69bbcce068d5d7f9ed418b4b9c9edf6dda30e1..3e98cf16440855cd1adea7d6262603c79957c8a8 100644
--- a/ui/views/corewm/tooltip_aura.cc
+++ b/ui/views/corewm/tooltip_aura.cc
@@ -47,9 +47,8 @@ views::Widget* CreateTooltipWidget(aura::Window* tooltip_window) {
namespace views {
namespace corewm {
-TooltipAura::TooltipAura(gfx::ScreenType screen_type)
- : screen_type_(screen_type),
- widget_(NULL),
+TooltipAura::TooltipAura()
+ : widget_(NULL),
tooltip_window_(NULL) {
label_.set_owned_by_client();
label_.SetMultiLine(true);
@@ -142,19 +141,11 @@ void TooltipAura::TrimTooltipToFit(const gfx::FontList& font_list,
*text = result;
}
-int TooltipAura::GetMaxWidth(const gfx::Point& location) const {
- // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
- // out a way to merge.
- gfx::Screen* screen = gfx::Screen::GetScreenByType(screen_type_);
- gfx::Rect display_bounds(screen->GetDisplayNearestPoint(location).bounds());
- return (display_bounds.width() + 1) / 2;
-}
-
void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
const gfx::Size& tooltip_size) {
gfx::Rect tooltip_rect(mouse_pos, tooltip_size);
tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
- gfx::Screen* screen = gfx::Screen::GetScreenByType(screen_type_);
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(tooltip_window_);
gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds());
// If tooltip is out of bounds on the x axis, we simply shift it
@@ -181,6 +172,13 @@ void TooltipAura::DestroyWidget() {
}
}
+int TooltipAura::GetMaxWidth(const gfx::Point& location,
+ aura::Window* context) const {
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(context);
+ gfx::Rect display_bounds(screen->GetDisplayNearestPoint(location).bounds());
+ return std::min(kTooltipMaxWidthPixels, (display_bounds.width() + 1) / 2);
+}
+
void TooltipAura::SetText(aura::Window* window,
const base::string16& tooltip_text,
const gfx::Point& location) {
@@ -188,8 +186,8 @@ void TooltipAura::SetText(aura::Window* window,
int max_width = 0;
int line_count = 0;
base::string16 trimmed_text(tooltip_text);
- TrimTooltipToFit(label_.font_list(), GetMaxWidth(location), &trimmed_text,
- &max_width, &line_count);
+ TrimTooltipToFit(label_.font_list(), GetMaxWidth(location, window),
+ &trimmed_text, &max_width, &line_count);
label_.SetText(trimmed_text);
if (!widget_) {
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/corewm/tooltip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698