KeyboardController is quite a complex class with several responsibilities. We should probably split it up into smaller classes and reduce the size of the interface.
The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/3099becad3e1f35c2602ba01686e818d2f546fc8
commit 3099becad3e1f35c2602ba01686e818d2f546fc8
Author: Darren Shen <shend@chromium.org>
Date: Mon Jul 23 00:14:56 2018
[VK] Observe changes to keyboard window in KeyboardController.
There are two ways for the keyboard window bounds to change. Either
through KeyboardController or through JavaScript / the IME extension.
Notably, we always receive a JavaScript bound change when initializing
the keyboard UI.
To handle bounds changes from JavaScript, we use a LayoutManager
to intercept those changes and forward them to KeyboardController.
In production, the LayoutManager is installed by ash::Shell.
In unit tests however, we do not always have this setup because the
test may not be able to depend on ash. Unit tests that load the
keyboard will simulate the initial JavaScript bound change, but because
there's no layout manager, KeyboardController does not receive the
update and gets into a bad state.
The current workaround is to manually add a LayoutManager to the
root window in tests that need it. This is not ideal, as the correctness
of KeyboardController is silently dependent on the construction of
a LayoutManager [*].
To fix this, we observe bounds changes to the keyboard window in
KeyboardController. Then, KeyboardController will no longer need the
LayoutManager to notify bounds changes; it can observe them directly.
[*] We didn't have this problem before because we could install the
layout manager on the keyboard container, which was part of the
KeyboardController. Since we got rid of the keyboard container, we can
only install the layout manager on an ash container, which is
external to KeyboardController.
Bug: 845780
Change-Id: I053778f04ab3ccf4d13fcd79d05832f9238b21b5
Reviewed-on: https://chromium-review.googlesource.com/1133607
Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577099}
[modify] https://crrev.com/3099becad3e1f35c2602ba01686e818d2f546fc8/ui/keyboard/keyboard_controller.cc
[modify] https://crrev.com/3099becad3e1f35c2602ba01686e818d2f546fc8/ui/keyboard/keyboard_controller_unittest.cc
[modify] https://crrev.com/3099becad3e1f35c2602ba01686e818d2f546fc8/ui/keyboard/keyboard_layout_manager.cc
Comment 1 by bugdroid1@chromium.org
, May 23 2018