| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" | 14 #include "chrome/browser/chromeos/ui/focus_ring_layer.h" |
| 15 #include "ui/gfx/screen.h" | 15 #include "ui/display/screen.h" |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // The number of pixels the focus ring is outset from the object it outlines, | 21 // The number of pixels the focus ring is outset from the object it outlines, |
| 22 // which also determines the border radius of the rounded corners. | 22 // which also determines the border radius of the rounded corners. |
| 23 // TODO(dmazzoni): take display resolution into account. | 23 // TODO(dmazzoni): take display resolution into account. |
| 24 const int kAccessibilityFocusRingMargin = 7; | 24 const int kAccessibilityFocusRingMargin = 7; |
| 25 | 25 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (compositor_ && compositor_->HasAnimationObserver(this)) { | 99 if (compositor_ && compositor_->HasAnimationObserver(this)) { |
| 100 focus_change_time_ = base::TimeTicks::Now(); | 100 focus_change_time_ = base::TimeTicks::Now(); |
| 101 } else { | 101 } else { |
| 102 // If we can't animate, set the location of the first ring. | 102 // If we can't animate, set the location of the first ring. |
| 103 layers_[0]->Set(rings_[0]); | 103 layers_[0]->Set(rings_[0]); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 ui::Compositor* AccessibilityFocusRingController::CompositorForBounds( | 107 ui::Compositor* AccessibilityFocusRingController::CompositorForBounds( |
| 108 const gfx::Rect& bounds) { | 108 const gfx::Rect& bounds) { |
| 109 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(bounds); | 109 display::Display display = |
| 110 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 110 aura::Window* root_window = ash::Shell::GetInstance() | 111 aura::Window* root_window = ash::Shell::GetInstance() |
| 111 ->window_tree_host_manager() | 112 ->window_tree_host_manager() |
| 112 ->GetRootWindowForDisplayId(display.id()); | 113 ->GetRootWindowForDisplayId(display.id()); |
| 113 return root_window->layer()->GetCompositor(); | 114 return root_window->layer()->GetCompositor(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void AccessibilityFocusRingController::RemoveAnimationObservers() { | 117 void AccessibilityFocusRingController::RemoveAnimationObservers() { |
| 117 if (compositor_ && compositor_->HasAnimationObserver(this)) | 118 if (compositor_ && compositor_->HasAnimationObserver(this)) |
| 118 compositor_->RemoveAnimationObserver(this); | 119 compositor_->RemoveAnimationObserver(this); |
| 119 if (cursor_compositor_ && cursor_compositor_->HasAnimationObserver(this)) | 120 if (cursor_compositor_ && cursor_compositor_->HasAnimationObserver(this)) |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (compositor == compositor_ || compositor == cursor_compositor_) | 445 if (compositor == compositor_ || compositor == cursor_compositor_) |
| 445 compositor->RemoveAnimationObserver(this); | 446 compositor->RemoveAnimationObserver(this); |
| 446 | 447 |
| 447 if (compositor == compositor_) | 448 if (compositor == compositor_) |
| 448 compositor_ = nullptr; | 449 compositor_ = nullptr; |
| 449 if (compositor == cursor_compositor_) | 450 if (compositor == cursor_compositor_) |
| 450 cursor_compositor_ = nullptr; | 451 cursor_compositor_ = nullptr; |
| 451 } | 452 } |
| 452 | 453 |
| 453 } // namespace chromeos | 454 } // namespace chromeos |
| OLD | NEW |