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

Side by Side Diff: ash/magnifier/magnification_controller.cc

Issue 11316014: Full Screen Magnifier: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 | « no previous file | ui/compositor/dip_util.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/magnifier/magnification_controller.h" 5 #include "ash/magnifier/magnification_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
11 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_property.h" 13 #include "ui/aura/window_property.h"
14 #include "ui/base/events/event.h" 14 #include "ui/base/events/event.h"
15 #include "ui/base/events/event_handler.h" 15 #include "ui/base/events/event_handler.h"
16 #include "ui/compositor/dip_util.h" 16 #include "ui/compositor/dip_util.h"
17 #include "ui/compositor/layer.h" 17 #include "ui/compositor/layer.h"
18 #include "ui/compositor/layer_animation_observer.h" 18 #include "ui/compositor/layer_animation_observer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 19 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/point_conversions.h"
21 #include "ui/gfx/point_f.h"
22 #include "ui/gfx/rect_conversions.h"
20 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
21 #include "ui/views/corewm/compound_event_filter.h" 24 #include "ui/views/corewm/compound_event_filter.h"
22 25
23 namespace { 26 namespace {
24 27
25 const float kMaxMagnifiedScale = 4.0f; 28 const float kMaxMagnifiedScale = 4.0f;
26 const float kMaxMagnifiedScaleThreshold = 4.0f; 29 const float kMaxMagnifiedScaleThreshold = 4.0f;
27 const float kMinMagnifiedScaleThreshold = 1.1f; 30 const float kMinMagnifiedScaleThreshold = 1.1f;
28 const float kNonMagnifiedScale = 1.0f; 31 const float kNonMagnifiedScale = 1.0f;
29 32
(...skipping 14 matching lines...) Expand all
44 public: 47 public:
45 MagnificationControllerImpl(); 48 MagnificationControllerImpl();
46 virtual ~MagnificationControllerImpl(); 49 virtual ~MagnificationControllerImpl();
47 50
48 // MagnificationController overrides: 51 // MagnificationController overrides:
49 virtual void SetEnabled(bool enabled) OVERRIDE; 52 virtual void SetEnabled(bool enabled) OVERRIDE;
50 virtual void SetScale(float scale, bool animate) OVERRIDE; 53 virtual void SetScale(float scale, bool animate) OVERRIDE;
51 virtual float GetScale() const OVERRIDE { return scale_; } 54 virtual float GetScale() const OVERRIDE { return scale_; }
52 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; 55 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE;
53 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE; 56 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE;
54 virtual gfx::Point GetWindowPosition() const OVERRIDE { return origin_; } 57 virtual gfx::Point GetWindowPosition() const OVERRIDE {
58 return gfx::ToFlooredPoint(origin_);
59 }
55 virtual void EnsureRectIsVisible(const gfx::Rect& rect, 60 virtual void EnsureRectIsVisible(const gfx::Rect& rect,
56 bool animate) OVERRIDE; 61 bool animate) OVERRIDE;
57 virtual void EnsurePointIsVisible(const gfx::Point& point, 62 virtual void EnsurePointIsVisible(const gfx::Point& point,
58 bool animate) OVERRIDE; 63 bool animate) OVERRIDE;
59 64
60 private: 65 private:
61 // ui::ImplicitAnimationObserver overrides: 66 // ui::ImplicitAnimationObserver overrides:
62 virtual void OnImplicitAnimationsCompleted() OVERRIDE; 67 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
63 68
64 // Redraws the magnification window with the given origin position and the 69 // Redraws the magnification window with the given origin position and the
65 // given scale. Returns true if the window is changed; otherwise, false. 70 // given scale. Returns true if the window is changed; otherwise, false.
66 // These methods should be called internally just after the scale and/or 71 // These methods should be called internally just after the scale and/or
67 // the position are changed to redraw the window. 72 // the position are changed to redraw the window.
68 bool Redraw(const gfx::Point& position, float scale, bool animate); 73 bool Redraw(const gfx::PointF& position, float scale, bool animate);
69 bool RedrawDIP(const gfx::Point& position, float scale, bool animate); 74 bool RedrawDIP(const gfx::PointF& position, float scale, bool animate);
70 75
71 // Redraw with the given zoom scale keeping the mouse cursor location. In 76 // Redraw with the given zoom scale keeping the mouse cursor location. In
72 // other words, zoom (or unzoom) centering around the cursor. 77 // other words, zoom (or unzoom) centering around the cursor.
73 void RedrawKeepingMousePosition(float scale, bool animate); 78 void RedrawKeepingMousePosition(float scale, bool animate);
74 79
75 // Ensures that the given point, rect or last mouse location is inside 80 // Ensures that the given point, rect or last mouse location is inside
76 // magnification window. If not, the controller moves the window to contain 81 // magnification window. If not, the controller moves the window to contain
77 // the given point/rect. 82 // the given point/rect.
78 void EnsureRectIsVisibleWithScale(const gfx::Rect& target_rect, 83 void EnsureRectIsVisibleWithScale(const gfx::Rect& target_rect,
79 float scale, 84 float scale,
80 bool animate); 85 bool animate);
81 void EnsureRectIsVisibleDIP(const gfx::Rect& target_rect_in_dip, 86 void EnsureRectIsVisibleDIP(const gfx::Rect& target_rect_in_dip,
82 float scale, 87 float scale,
83 bool animate); 88 bool animate);
84 void EnsurePointIsVisibleWithScale(const gfx::Point& point, 89 void EnsurePointIsVisibleWithScale(const gfx::Point& point,
85 float scale, 90 float scale,
86 bool animate); 91 bool animate);
87 void OnMouseMove(const gfx::Point& location); 92 void OnMouseMove(const gfx::Point& location);
88 93
94 // Move the mouse cursot to the given point. Actual move will be done when
95 // the animation is completed. This should be called after animation is
96 // started.
97 void MoveCursorToAfterAnimation(const gfx::Point& location);
98
89 // Switch Magnified RootWindow to |new_root_window|. This does following: 99 // Switch Magnified RootWindow to |new_root_window|. This does following:
90 // - Unzoom the current root_window. 100 // - Unzoom the current root_window.
91 // - Zoom the given new root_window |new_root_window|. 101 // - Zoom the given new root_window |new_root_window|.
92 // - Switch the target window from current window to |new_root_window|. 102 // - Switch the target window from current window to |new_root_window|.
93 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); 103 void SwitchTargetRootWindow(aura::RootWindow* new_root_window);
94 104
95 // Returns if the magnification scale is 1.0 or not (larger then 1.0). 105 // Returns if the magnification scale is 1.0 or not (larger then 1.0).
96 bool IsMagnified() const; 106 bool IsMagnified() const;
97 107
98 // Returns the default scale which depends on the login status. 108 // Returns the default scale which depends on the login status.
99 float GetDefaultZoomScale() const { 109 float GetDefaultZoomScale() const {
100 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ? 110 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ?
101 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() : 111 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() :
102 user::LOGGED_IN_NONE; 112 user::LOGGED_IN_NONE;
103 113
104 // On login screen, don't magnify the screen by default. 114 // On login screen, don't magnify the screen by default.
105 if (login == user::LOGGED_IN_NONE) 115 if (login == user::LOGGED_IN_NONE)
106 return kNonMagnifiedScale; 116 return kNonMagnifiedScale;
107 117
108 return kInitialMagnifiedScale; 118 return kInitialMagnifiedScale;
109 } 119 }
110 120
111 // Returns the rect of the magnification window. 121 // Returns the rect of the magnification window.
112 gfx::Rect GetWindowRectDIP(float scale) const; 122 gfx::RectF GetWindowRectDIP(float scale) const;
113 // Returns the size of the root window. 123 // Returns the size of the root window.
114 gfx::Size GetHostSizeDIP() const; 124 gfx::Size GetHostSizeDIP() const;
115 125
116 // Correct the givin scale value if nessesary. 126 // Correct the givin scale value if nessesary.
117 void ValidateScale(float* scale); 127 void ValidateScale(float* scale);
118 128
119 // ui::EventHandler overrides: 129 // ui::EventHandler overrides:
120 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; 130 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
121 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; 131 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
122 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; 132 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
123 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; 133 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
124 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 134 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
125 135
126 aura::RootWindow* root_window_; 136 aura::RootWindow* root_window_;
127 137
128 // True if the magnified window is in motion of zooming or un-zooming effect. 138 // True if the magnified window is in motion of zooming or un-zooming effect.
129 // Otherwise, false. 139 // Otherwise, false.
130 bool is_on_zooming_; 140 bool is_on_zooming_;
131 141
132 bool is_enabled_; 142 bool is_enabled_;
133 143
144 // True if the cursor needs to move the given position after the animation
145 // will be finished. When using this, set |position_after_animation_| as well.
146 bool move_cursor_after_animation_;
147 // Stores the position of cursor to be moved after animation.
148 gfx::Point position_after_animation_;
149
134 // Current scale, origin (left-top) position of the magnification window. 150 // Current scale, origin (left-top) position of the magnification window.
135 float scale_; 151 float scale_;
136 gfx::Point origin_; 152 gfx::PointF origin_;
137 153
138 DISALLOW_COPY_AND_ASSIGN(MagnificationControllerImpl); 154 DISALLOW_COPY_AND_ASSIGN(MagnificationControllerImpl);
139 }; 155 };
140 156
141 //////////////////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////////////////
142 // MagnificationControllerImpl: 158 // MagnificationControllerImpl:
143 159
144 MagnificationControllerImpl::MagnificationControllerImpl() 160 MagnificationControllerImpl::MagnificationControllerImpl()
145 : root_window_(ash::Shell::GetPrimaryRootWindow()), 161 : root_window_(ash::Shell::GetPrimaryRootWindow()),
146 is_on_zooming_(false), 162 is_on_zooming_(false),
147 is_enabled_(false), 163 is_enabled_(false),
164 move_cursor_after_animation_(false),
148 scale_(std::numeric_limits<double>::min()) { 165 scale_(std::numeric_limits<double>::min()) {
149 Shell::GetInstance()->AddPreTargetHandler(this); 166 Shell::GetInstance()->AddPreTargetHandler(this);
150 } 167 }
151 168
152 MagnificationControllerImpl::~MagnificationControllerImpl() { 169 MagnificationControllerImpl::~MagnificationControllerImpl() {
153 Shell::GetInstance()->RemovePreTargetHandler(this); 170 Shell::GetInstance()->RemovePreTargetHandler(this);
154 } 171 }
155 172
156 void MagnificationControllerImpl::RedrawKeepingMousePosition( 173 void MagnificationControllerImpl::RedrawKeepingMousePosition(
157 float scale, bool animate) { 174 float scale, bool animate) {
158 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot(); 175 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot();
159 const gfx::Point origin = 176
160 gfx::Point(mouse_in_root.x() * (1.0f - 1.0f / scale), 177 // mouse_in_root is invalid value when the cursor is hidden.
161 mouse_in_root.y() * (1.0f - 1.0f / scale)); 178 if (!root_window_->bounds().Contains(mouse_in_root))
162 Redraw(origin, scale, animate); 179 return;
180
181 const gfx::PointF origin =
182 gfx::PointF(mouse_in_root.x() -
183 (scale_ / scale) * (mouse_in_root.x() - origin_.x()),
184 mouse_in_root.y() -
185 (scale_ / scale) * (mouse_in_root.y() - origin_.y()));
186 bool changed = Redraw(origin, scale, animate);
187 if (changed && origin_ != origin)
188 MoveCursorToAfterAnimation(mouse_in_root);
163 } 189 }
164 190
165 bool MagnificationControllerImpl::Redraw(const gfx::Point& position, 191 bool MagnificationControllerImpl::Redraw(const gfx::PointF& position,
166 float scale, 192 float scale,
167 bool animate) { 193 bool animate) {
168 const gfx::Point position_in_dip = 194 const gfx::PointF position_in_dip =
169 ui::ConvertPointToDIP(root_window_->layer(), position); 195 ui::ConvertPointToDIP(root_window_->layer(), position);
170 return RedrawDIP(position_in_dip, scale, animate); 196 return RedrawDIP(position_in_dip, scale, animate);
171 } 197 }
172 198
173 bool MagnificationControllerImpl::RedrawDIP(const gfx::Point& position_in_dip, 199 bool MagnificationControllerImpl::RedrawDIP(const gfx::PointF& position_in_dip,
174 float scale, 200 float scale,
175 bool animate) { 201 bool animate) {
176 int x = position_in_dip.x(); 202 float x = position_in_dip.x();
177 int y = position_in_dip.y(); 203 float y = position_in_dip.y();
178 204
179 ValidateScale(&scale); 205 ValidateScale(&scale);
180 206
181 if (x < 0) 207 if (x < 0)
182 x = 0; 208 x = 0;
183 if (y < 0) 209 if (y < 0)
184 y = 0; 210 y = 0;
185 211
186 const gfx::Size host_size_in_dip = GetHostSizeDIP(); 212 const gfx::Size host_size_in_dip = GetHostSizeDIP();
187 const gfx::Size window_size_in_dip = GetWindowRectDIP(scale).size(); 213 const gfx::SizeF window_size_in_dip = GetWindowRectDIP(scale).size();
188 int max_x = host_size_in_dip.width() - window_size_in_dip.width(); 214 float max_x = host_size_in_dip.width() - window_size_in_dip.width();
189 int max_y = host_size_in_dip.height() - window_size_in_dip.height(); 215 float max_y = host_size_in_dip.height() - window_size_in_dip.height();
190 if (x > max_x) 216 if (x > max_x)
191 x = max_x; 217 x = max_x;
192 if (y > max_y) 218 if (y > max_y)
193 y = max_y; 219 y = max_y;
194 220
195 // Does nothing if both the origin and the scale are not changed. 221 // Does nothing if both the origin and the scale are not changed.
196 if (origin_.x() == x && 222 if (origin_.x() == x &&
197 origin_.y() == y && 223 origin_.y() == y &&
198 scale == scale_) { 224 scale == scale_) {
199 return false; 225 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 ui::ConvertRectToDIP(root_window_->layer(), target_rect); 258 ui::ConvertRectToDIP(root_window_->layer(), target_rect);
233 EnsureRectIsVisibleDIP(target_rect_in_dip, scale, animate); 259 EnsureRectIsVisibleDIP(target_rect_in_dip, scale, animate);
234 } 260 }
235 261
236 void MagnificationControllerImpl::EnsureRectIsVisibleDIP( 262 void MagnificationControllerImpl::EnsureRectIsVisibleDIP(
237 const gfx::Rect& target_rect, 263 const gfx::Rect& target_rect,
238 float scale, 264 float scale,
239 bool animate) { 265 bool animate) {
240 ValidateScale(&scale); 266 ValidateScale(&scale);
241 267
242 const gfx::Rect window_rect = GetWindowRectDIP(scale); 268 const gfx::Rect window_rect = gfx::ToEnclosingRect(GetWindowRectDIP(scale));
243 if (scale == scale_ && window_rect.Contains(target_rect)) 269 if (scale == scale_ && window_rect.Contains(target_rect))
244 return; 270 return;
245 271
246 // TODO(yoshiki): Un-zoom and change the scale if the magnification window 272 // TODO(yoshiki): Un-zoom and change the scale if the magnification window
247 // can't contain the whole given rect. 273 // can't contain the whole given rect.
248 274
249 gfx::Rect rect = window_rect; 275 gfx::Rect rect = window_rect;
250 if (target_rect.width() > rect.width()) 276 if (target_rect.width() > rect.width())
251 rect.set_x(target_rect.CenterPoint().x() - rect.x() / 2); 277 rect.set_x(target_rect.CenterPoint().x() - rect.x() / 2);
252 else if (target_rect.right() < rect.x()) 278 else if (target_rect.right() < rect.x())
(...skipping 20 matching lines...) Expand all
273 animate); 299 animate);
274 } 300 }
275 301
276 void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) { 302 void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) {
277 gfx::Point mouse(location); 303 gfx::Point mouse(location);
278 304
279 int x = origin_.x(); 305 int x = origin_.x();
280 int y = origin_.y(); 306 int y = origin_.y();
281 bool start_zoom = false; 307 bool start_zoom = false;
282 308
283 const gfx::Rect window_rect = GetWindowRectDIP(scale_); 309 const gfx::Rect window_rect = gfx::ToEnclosingRect(GetWindowRectDIP(scale_));
284 const int left = window_rect.x(); 310 const int left = window_rect.x();
285 const int right = window_rect.right(); 311 const int right = window_rect.right();
286 const int width_margin = static_cast<int>(0.1f * window_rect.width()); 312 const int width_margin = static_cast<int>(0.1f * window_rect.width());
287 const int width_offset = static_cast<int>(0.5f * window_rect.width()); 313 const int width_offset = static_cast<int>(0.5f * window_rect.width());
288 314
289 if (mouse.x() < left + width_margin) { 315 if (mouse.x() < left + width_margin) {
290 x -= width_offset; 316 x -= width_offset;
291 start_zoom = true; 317 start_zoom = true;
292 } else if (right - width_margin < mouse.x()) { 318 } else if (right - width_margin < mouse.x()) {
293 x += width_offset; 319 x += width_offset;
(...skipping 16 matching lines...) Expand all
310 336
311 if (start_zoom && !is_on_zooming_) { 337 if (start_zoom && !is_on_zooming_) {
312 bool ret = RedrawDIP(gfx::Point(x, y), scale_, true); 338 bool ret = RedrawDIP(gfx::Point(x, y), scale_, true);
313 339
314 if (ret) { 340 if (ret) {
315 is_on_zooming_ = true; 341 is_on_zooming_ = true;
316 342
317 int x_diff = origin_.x() - window_rect.x(); 343 int x_diff = origin_.x() - window_rect.x();
318 int y_diff = origin_.y() - window_rect.y(); 344 int y_diff = origin_.y() - window_rect.y();
319 // If the magnified region is moved, hides the mouse cursor and moves it. 345 // If the magnified region is moved, hides the mouse cursor and moves it.
320 if (x_diff != 0 || y_diff != 0) { 346 if (x_diff != 0 || y_diff != 0)
321 aura::client::CursorClient* cursor_client = 347 MoveCursorToAfterAnimation(mouse);
322 aura::client::GetCursorClient(root_window_);
323 if (cursor_client)
324 cursor_client->ShowCursor(false);
325 mouse.set_x(mouse.x() - (origin_.x() - window_rect.x()));
326 mouse.set_y(mouse.y() - (origin_.y() - window_rect.y()));
327 root_window_->MoveCursorTo(mouse);
328 }
329 } 348 }
330 } 349 }
331 } 350 }
332 351
352 void MagnificationControllerImpl::MoveCursorToAfterAnimation(
353 const gfx::Point& location) {
354 aura::client::CursorClient* cursor_client =
355 aura::client::GetCursorClient(root_window_);
356 if (cursor_client)
357 cursor_client->ShowCursor(false);
358 move_cursor_after_animation_ = true;
359 position_after_animation_ = location;
360 }
361
333 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const { 362 gfx::Size MagnificationControllerImpl::GetHostSizeDIP() const {
334 return ui::ConvertSizeToDIP(root_window_->layer(), 363 return ui::ConvertSizeToDIP(root_window_->layer(),
335 root_window_->GetHostSize()); 364 root_window_->GetHostSize());
336 } 365 }
337 366
338 gfx::Rect MagnificationControllerImpl::GetWindowRectDIP(float scale) const { 367 gfx::RectF MagnificationControllerImpl::GetWindowRectDIP(float scale) const {
339 const gfx::Size size_in_dip = 368 const gfx::Size size_in_dip =
340 ui::ConvertSizeToDIP(root_window_->layer(), 369 ui::ConvertSizeToDIP(root_window_->layer(),
341 root_window_->GetHostSize()); 370 root_window_->GetHostSize());
342 const int width = size_in_dip.width() / scale; 371 const float width = size_in_dip.width() / scale;
343 const int height = size_in_dip.height() / scale; 372 const float height = size_in_dip.height() / scale;
344 373
345 return gfx::Rect(origin_.x(), origin_.y(), width, height); 374 return gfx::RectF(origin_.x(), origin_.y(), width, height);
346 } 375 }
347 376
348 bool MagnificationControllerImpl::IsMagnified() const { 377 bool MagnificationControllerImpl::IsMagnified() const {
349 return scale_ >= kMinMagnifiedScaleThreshold; 378 return scale_ >= kMinMagnifiedScaleThreshold;
350 } 379 }
351 380
352 void MagnificationControllerImpl::ValidateScale(float* scale) { 381 void MagnificationControllerImpl::ValidateScale(float* scale) {
353 // Adjust the scale to just |kNonMagnifiedScale| if scale is smaller than 382 // Adjust the scale to just |kNonMagnifiedScale| if scale is smaller than
354 // |kMinMagnifiedScaleThreshold|; 383 // |kMinMagnifiedScaleThreshold|;
355 if (*scale < kMinMagnifiedScaleThreshold) 384 if (*scale < kMinMagnifiedScaleThreshold)
356 *scale = kNonMagnifiedScale; 385 *scale = kNonMagnifiedScale;
357 386
358 // Adjust the scale to just |kMinMagnifiedScale| if scale is bigger than 387 // Adjust the scale to just |kMinMagnifiedScale| if scale is bigger than
359 // |kMinMagnifiedScaleThreshold|; 388 // |kMinMagnifiedScaleThreshold|;
360 if (*scale > kMaxMagnifiedScaleThreshold) 389 if (*scale > kMaxMagnifiedScaleThreshold)
361 *scale = kMaxMagnifiedScale; 390 *scale = kMaxMagnifiedScale;
362 391
363 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); 392 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale);
364 } 393 }
365 394
366 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { 395 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() {
367 aura::client::CursorClient* cursor_client = 396 aura::client::CursorClient* cursor_client =
368 aura::client::GetCursorClient(root_window_); 397 aura::client::GetCursorClient(root_window_);
398 if (move_cursor_after_animation_) {
399 root_window_->MoveCursorTo(position_after_animation_);
400 move_cursor_after_animation_ = false;
401 }
402 gfx::Point mouse_in_root = root_window_->GetLastMouseLocationInRoot();
369 if (cursor_client) 403 if (cursor_client)
370 cursor_client->ShowCursor(true); 404 cursor_client->ShowCursor(true);
371 is_on_zooming_ = false; 405 is_on_zooming_ = false;
372 } 406 }
373 407
374 void MagnificationControllerImpl::SwitchTargetRootWindow( 408 void MagnificationControllerImpl::SwitchTargetRootWindow(
375 aura::RootWindow* new_root_window) { 409 aura::RootWindow* new_root_window) {
376 if (new_root_window == root_window_) 410 if (new_root_window == root_window_)
377 return; 411 return;
378 412
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 //////////////////////////////////////////////////////////////////////////////// 535 ////////////////////////////////////////////////////////////////////////////////
502 // MagnificationController: 536 // MagnificationController:
503 537
504 // static 538 // static
505 MagnificationController* MagnificationController::CreateInstance() { 539 MagnificationController* MagnificationController::CreateInstance() {
506 return new MagnificationControllerImpl(); 540 return new MagnificationControllerImpl();
507 } 541 }
508 542
509 } // namespace internal 543 } // namespace internal
510 } // namespace ash 544 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/dip_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698