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

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: update test 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
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/corewm/tooltip_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 gfx::RenderText* render_text_for_test() { return render_text_.get(); }
145
144 private: 146 private:
145 void ResetDisplayRect() { 147 void ResetDisplayRect() {
146 gfx::Insets insets = border()->GetInsets(); 148 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 } 149 }
150 150
151 std::unique_ptr<gfx::RenderText> render_text_; 151 std::unique_ptr<gfx::RenderText> render_text_;
152 int max_width_; 152 int max_width_;
153 153
154 DISALLOW_COPY_AND_ASSIGN(TooltipView); 154 DISALLOW_COPY_AND_ASSIGN(TooltipView);
155 }; 155 };
156 156
157 TooltipAura::TooltipAura() 157 TooltipAura::TooltipAura()
158 : tooltip_view_(new TooltipView), 158 : tooltip_view_(new TooltipView),
159 widget_(NULL), 159 widget_(NULL),
160 tooltip_window_(NULL) { 160 tooltip_window_(NULL) {
161 } 161 }
162 162
163 TooltipAura::~TooltipAura() { 163 TooltipAura::~TooltipAura() {
164 DestroyWidget(); 164 DestroyWidget();
165 } 165 }
166 166
167 gfx::RenderText* TooltipAura::GetRenderTextForTest() {
168 return tooltip_view_->render_text_for_test();
169 }
170
167 void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos, 171 void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
168 const gfx::Size& tooltip_size) { 172 const gfx::Size& tooltip_size) {
169 gfx::Rect tooltip_rect(mouse_pos, tooltip_size); 173 gfx::Rect tooltip_rect(mouse_pos, tooltip_size);
170 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); 174 tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
171 display::Screen* screen = display::Screen::GetScreen(); 175 display::Screen* screen = display::Screen::GetScreen();
172 gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds()); 176 gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds());
173 177
174 // If tooltip is out of bounds on the x axis, we simply shift it 178 // If tooltip is out of bounds on the x axis, we simply shift it
175 // horizontally by the offset. 179 // horizontally by the offset.
176 if (tooltip_rect.right() > display_bounds.right()) { 180 if (tooltip_rect.right() > display_bounds.right()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 245 }
242 246
243 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { 247 void TooltipAura::OnWidgetDestroying(views::Widget* widget) {
244 DCHECK_EQ(widget_, widget); 248 DCHECK_EQ(widget_, widget);
245 widget_ = NULL; 249 widget_ = NULL;
246 tooltip_window_ = NULL; 250 tooltip_window_ = NULL;
247 } 251 }
248 252
249 } // namespace corewm 253 } // namespace corewm
250 } // namespace views 254 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/corewm/tooltip_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698