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

Side by Side Diff: chrome/browser/chromeos/ui/accessibility_focus_ring_controller.cc

Issue 2789623004: Clamp focus ring opacity to avoid debug-mode failures (Closed)
Patch Set: Use float constants explicitly Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 base::TimeDelta fade_out_time = animation_info->fade_out_time; 430 base::TimeDelta fade_out_time = animation_info->fade_out_time;
431 431
432 if (change_delta > fade_in_time + fade_out_time) { 432 if (change_delta > fade_in_time + fade_out_time) {
433 animation_info->opacity = 0.0; 433 animation_info->opacity = 0.0;
434 return; 434 return;
435 } 435 }
436 436
437 float opacity; 437 float opacity;
438 if (start_delta < fade_in_time) { 438 if (start_delta < fade_in_time) {
439 opacity = start_delta.InSecondsF() / fade_in_time.InSecondsF(); 439 opacity = start_delta.InSecondsF() / fade_in_time.InSecondsF();
440 if (opacity > 1.0)
441 opacity = 1.0;
442 } else { 440 } else {
443 opacity = 1.0 - (change_delta.InSecondsF() / 441 opacity = 1.0 - (change_delta.InSecondsF() /
444 (fade_in_time + fade_out_time).InSecondsF()); 442 (fade_in_time + fade_out_time).InSecondsF());
445 if (opacity < 0.0)
446 opacity = 0.0;
447 } 443 }
448 444
445 // Layer::SetOpacity will throw an error if we're not within 0...1.
446 opacity = std::min(std::max(opacity, 0.0f), 1.0f);
447
449 animation_info->opacity = opacity; 448 animation_info->opacity = opacity;
450 } 449 }
451 450
452 void AccessibilityFocusRingController::AnimateCursorRing( 451 void AccessibilityFocusRingController::AnimateCursorRing(
453 base::TimeTicks timestamp) { 452 base::TimeTicks timestamp) {
454 CHECK(cursor_layer_); 453 CHECK(cursor_layer_);
455 454
456 ComputeOpacity(&cursor_animation_info_, timestamp); 455 ComputeOpacity(&cursor_animation_info_, timestamp);
457 if (cursor_animation_info_.opacity == 0.0) { 456 if (cursor_animation_info_.opacity == 0.0) {
458 cursor_layer_.reset(); 457 cursor_layer_.reset();
459 return; 458 return;
460 } 459 }
461 cursor_layer_->SetOpacity(cursor_animation_info_.opacity); 460 cursor_layer_->SetOpacity(cursor_animation_info_.opacity);
462 } 461 }
463 462
464 void AccessibilityFocusRingController::AnimateCaretRing( 463 void AccessibilityFocusRingController::AnimateCaretRing(
465 base::TimeTicks timestamp) { 464 base::TimeTicks timestamp) {
466 CHECK(caret_layer_); 465 CHECK(caret_layer_);
467 466
468 ComputeOpacity(&caret_animation_info_, timestamp); 467 ComputeOpacity(&caret_animation_info_, timestamp);
469 if (caret_animation_info_.opacity == 0.0) { 468 if (caret_animation_info_.opacity == 0.0) {
470 caret_layer_.reset(); 469 caret_layer_.reset();
471 return; 470 return;
472 } 471 }
473 caret_layer_->SetOpacity(caret_animation_info_.opacity); 472 caret_layer_->SetOpacity(caret_animation_info_.opacity);
474 } 473 }
475 474
476 } // namespace chromeos 475 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698