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

Side by Side Diff: ui/views/corewm/tooltip_aura.cc

Issue 2556083002: Don't subtract border from max size for display rect. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_aura.h" 5 #include "ui/views/corewm/tooltip_aura.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // opaque. 134 // opaque.
135 render_text_->set_subpixel_rendering_suppressed( 135 render_text_->set_subpixel_rendering_suppressed(
136 SkColorGetA(background_color) != 0xFF); 136 SkColorGetA(background_color) != 0xFF);
137 } 137 }
138 138
139 void SetMaxWidth(int width) { 139 void SetMaxWidth(int width) {
140 max_width_ = width; 140 max_width_ = width;
141 ResetDisplayRect(); 141 ResetDisplayRect();
142 } 142 }
143 143
144 size_t GetLineSizeForTest() const {
145 return render_text_->line_size_for_test();
146 }
147
144 private: 148 private:
145 void ResetDisplayRect() { 149 void ResetDisplayRect() {
146 gfx::Insets insets = border()->GetInsets(); 150 render_text_->SetDisplayRect(gfx::Rect(0, 0, max_width_, 100000));
147 int max_text_width = max_width_ - insets.width();
148 render_text_->SetDisplayRect(gfx::Rect(0, 0, max_text_width, 100000));
149 } 151 }
150 152
151 std::unique_ptr<gfx::RenderText> render_text_; 153 std::unique_ptr<gfx::RenderText> render_text_;
152 int max_width_; 154 int max_width_;
153 155
154 DISALLOW_COPY_AND_ASSIGN(TooltipView); 156 DISALLOW_COPY_AND_ASSIGN(TooltipView);
155 }; 157 };
156 158
157 TooltipAura::TooltipAura() 159 TooltipAura::TooltipAura()
158 : tooltip_view_(new TooltipView), 160 : tooltip_view_(new TooltipView),
159 widget_(NULL), 161 widget_(NULL),
160 tooltip_window_(NULL) { 162 tooltip_window_(NULL) {
161 } 163 }
162 164
163 TooltipAura::~TooltipAura() { 165 TooltipAura::~TooltipAura() {
164 DestroyWidget(); 166 DestroyWidget();
165 } 167 }
166 168
169 size_t TooltipAura::GetLineSizeForTest() const {
170 return tooltip_view_->GetLineSizeForTest();
171 }
172
167 void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos, 173 void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
168 const gfx::Size& tooltip_size) { 174 const gfx::Size& tooltip_size) {
169 gfx::Rect tooltip_rect(mouse_pos, tooltip_size); 175 gfx::Rect tooltip_rect(mouse_pos, tooltip_size);
170 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); 176 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
171 display::Screen* screen = display::Screen::GetScreen(); 177 display::Screen* screen = display::Screen::GetScreen();
172 gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds()); 178 gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds());
173 179
174 // If tooltip is out of bounds on the x axis, we simply shift it 180 // If tooltip is out of bounds on the x axis, we simply shift it
175 // horizontally by the offset. 181 // horizontally by the offset.
176 if (tooltip_rect.right() > display_bounds.right()) { 182 if (tooltip_rect.right() > display_bounds.right()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 247 }
242 248
243 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { 249 void TooltipAura::OnWidgetDestroying(views::Widget* widget) {
244 DCHECK_EQ(widget_, widget); 250 DCHECK_EQ(widget_, widget);
245 widget_ = NULL; 251 widget_ = NULL;
246 tooltip_window_ = NULL; 252 tooltip_window_ = NULL;
247 } 253 }
248 254
249 } // namespace corewm 255 } // namespace corewm
250 } // namespace views 256 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698