| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/accelerators/accelerator_controller.h" | 10 #include "ash/common/accelerators/accelerator_controller.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // caret bounds in screen coordinates. | 805 // caret bounds in screen coordinates. |
| 806 const gfx::Rect caret_bounds = client->GetCaretBounds(); | 806 const gfx::Rect caret_bounds = client->GetCaretBounds(); |
| 807 // Note: OnCaretBoundsChanged could be fired OnTextInputTypeChanged during | 807 // Note: OnCaretBoundsChanged could be fired OnTextInputTypeChanged during |
| 808 // which the caret position is not set a meaning position, and we do not | 808 // which the caret position is not set a meaning position, and we do not |
| 809 // need to adjust the view port position based on the bogus caret position. | 809 // need to adjust the view port position based on the bogus caret position. |
| 810 // This is only a transition period, the caret position will be fixed upon | 810 // This is only a transition period, the caret position will be fixed upon |
| 811 // focusing right after. | 811 // focusing right after. |
| 812 if (caret_bounds.width() == 0 && caret_bounds.height() == 0) | 812 if (caret_bounds.width() == 0 && caret_bounds.height() == 0) |
| 813 return; | 813 return; |
| 814 | 814 |
| 815 caret_point_ = caret_bounds.CenterPoint(); | 815 gfx::Point new_caret_point = caret_bounds.CenterPoint(); |
| 816 // |caret_point_| in |root_window_| coordinates. | 816 // |caret_point_| in |root_window_| coordinates. |
| 817 ::wm::ConvertPointFromScreen(root_window_, &caret_point_); | 817 ::wm::ConvertPointFromScreen(root_window_, &new_caret_point); |
| 818 |
| 819 // When the caret point was not actually changed, nothing should happen. |
| 820 // OnCaretBoundsChanged could be fired on every event that may change the |
| 821 // caret bounds, in particular a window creation/movement, that may not result |
| 822 // in an actual movement. |
| 823 if (new_caret_point == caret_point_) |
| 824 return; |
| 825 caret_point_ = new_caret_point; |
| 818 | 826 |
| 819 // If the feature for centering the text input focus is disabled, the | 827 // If the feature for centering the text input focus is disabled, the |
| 820 // magnifier window will be moved to follow the focus with a panning margin. | 828 // magnifier window will be moved to follow the focus with a panning margin. |
| 821 if (!KeepFocusCentered()) { | 829 if (!KeepFocusCentered()) { |
| 822 // Visible window_rect in |root_window_| coordinates. | 830 // Visible window_rect in |root_window_| coordinates. |
| 823 const gfx::Rect visible_window_rect = GetViewportRect(); | 831 const gfx::Rect visible_window_rect = GetViewportRect(); |
| 824 const int panning_margin = kCaretPanningMargin / scale_; | 832 const int panning_margin = kCaretPanningMargin / scale_; |
| 825 MoveMagnifierWindowFollowPoint(caret_point_, panning_margin, panning_margin, | 833 MoveMagnifierWindowFollowPoint(caret_point_, panning_margin, panning_margin, |
| 826 visible_window_rect.width() / 2, | 834 visible_window_rect.width() / 2, |
| 827 visible_window_rect.height() / 2); | 835 visible_window_rect.height() / 2); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 849 | 857 |
| 850 //////////////////////////////////////////////////////////////////////////////// | 858 //////////////////////////////////////////////////////////////////////////////// |
| 851 // MagnificationController: | 859 // MagnificationController: |
| 852 | 860 |
| 853 // static | 861 // static |
| 854 MagnificationController* MagnificationController::CreateInstance() { | 862 MagnificationController* MagnificationController::CreateInstance() { |
| 855 return new MagnificationControllerImpl(); | 863 return new MagnificationControllerImpl(); |
| 856 } | 864 } |
| 857 | 865 |
| 858 } // namespace ash | 866 } // namespace ash |
| OLD | NEW |