OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 5 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" | 10 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 void AccessibilityFocusRingController::OnAnimationStep( | 290 void AccessibilityFocusRingController::OnAnimationStep( |
291 base::TimeTicks timestamp) { | 291 base::TimeTicks timestamp) { |
292 if (rings_.empty()) | 292 if (rings_.empty()) |
293 return; | 293 return; |
294 | 294 |
295 CHECK(compositor_); | 295 CHECK(compositor_); |
296 CHECK(!rings_.empty()); | 296 CHECK(!rings_.empty()); |
297 CHECK(!layers_.empty()); | 297 CHECK(!layers_.empty()); |
298 CHECK(layers_[0]); | 298 CHECK(layers_[0]); |
299 | 299 |
| 300 // It's quite possible for the first 1 or 2 animation frames to be |
| 301 // for a timestamp that's earlier than the time we received the |
| 302 // focus change, so we just treat those as a delta of zero. |
| 303 if (timestamp < focus_change_time_) |
| 304 timestamp = focus_change_time_; |
| 305 |
300 base::TimeDelta delta = timestamp - focus_change_time_; | 306 base::TimeDelta delta = timestamp - focus_change_time_; |
301 base::TimeDelta transition_time = | 307 base::TimeDelta transition_time = |
302 base::TimeDelta::FromMilliseconds(kTransitionTimeMilliseconds); | 308 base::TimeDelta::FromMilliseconds(kTransitionTimeMilliseconds); |
303 if (delta >= transition_time) { | 309 if (delta >= transition_time) { |
304 layers_[0]->Set(rings_[0]); | 310 layers_[0]->Set(rings_[0]); |
305 compositor_->RemoveAnimationObserver(this); | 311 compositor_->RemoveAnimationObserver(this); |
306 compositor_ = NULL; | 312 compositor_ = NULL; |
307 return; | 313 return; |
308 } | 314 } |
309 | 315 |
310 double fraction = delta.InSecondsF() / transition_time.InSecondsF(); | 316 double fraction = delta.InSecondsF() / transition_time.InSecondsF(); |
311 | 317 |
312 // Ease-in effect. | 318 // Ease-in effect. |
313 fraction = pow(fraction, 0.3); | 319 fraction = pow(fraction, 0.3); |
314 | 320 |
315 layers_[0]->Set(AccessibilityFocusRing::Interpolate( | 321 layers_[0]->Set(AccessibilityFocusRing::Interpolate( |
316 previous_rings_[0], rings_[0], fraction)); | 322 previous_rings_[0], rings_[0], fraction)); |
317 } | 323 } |
318 | 324 |
319 } // namespace chromeos | 325 } // namespace chromeos |
OLD | NEW |