Commit c94fe768 authored by oka@chromium.org's avatar oka@chromium.org Committed by Commit Bot

Rename keyboard to contents if it indicates the contents window.

Bug: 739069
Change-Id: I358d67e6842d5fd4dc4d51098736647107f9e113
Reviewed-on: https://chromium-review.googlesource.com/570118
Commit-Queue: Keigo Oka <oka@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487407}
parent 5325997f
......@@ -973,7 +973,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) {
display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
// Notify keyboard bounds changing.
controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds());
controller->NotifyContentsBoundsChanging(keyboard_container->bounds());
if (!keyboard::IsKeyboardOverscrollEnabled()) {
gfx::Rect after =
......
......@@ -83,7 +83,7 @@ TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) {
root_window->bounds(), kKeyboardHeight);
contents_window->SetBounds(keyboard_bounds);
contents_window->Show();
keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds);
keyboard_controller->NotifyContentsBoundsChanging(keyboard_bounds);
// Verify that test manager was notified of bounds change.
ASSERT_TRUE(manager->keyboard_bounds_changed());
}
......
......@@ -204,7 +204,7 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardAppWindowTest,
controller->ui()->GetContentsWindow()->SetBounds(test_bounds);
gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds();
// Starts overscroll.
controller->NotifyKeyboardBoundsChanging(keyboard_bounds);
controller->NotifyContentsBoundsChanging(keyboard_bounds);
// Non ime window should have smaller visible view port due to overlap with
// virtual keyboard.
......
......@@ -331,7 +331,7 @@ aura::Window* KeyboardController::GetContainerWindowWithoutCreationForTest() {
return container_.get();
}
void KeyboardController::NotifyKeyboardBoundsChanging(
void KeyboardController::NotifyContentsBoundsChanging(
const gfx::Rect& new_bounds) {
current_keyboard_bounds_ = new_bounds;
if (ui_->HasContentsWindow() && ui_->GetContentsWindow()->IsVisible()) {
......@@ -346,7 +346,7 @@ void KeyboardController::NotifyKeyboardBoundsChanging(
}
}
void KeyboardController::NotifyKeyboardLoadingComplete() {
void KeyboardController::NotifyContentsLoadingComplete() {
if (state_ != KeyboardControllerState::LOADING_EXTENSION)
return;
......@@ -371,7 +371,7 @@ void KeyboardController::HideKeyboard(HideReason reason) {
keyboard::KEYBOARD_CONTROL_HIDE_AUTO :
keyboard::KEYBOARD_CONTROL_HIDE_USER);
NotifyKeyboardBoundsChanging(gfx::Rect());
NotifyContentsBoundsChanging(gfx::Rect());
set_keyboard_locked(false);
......@@ -423,7 +423,7 @@ void KeyboardController::SetKeyboardMode(KeyboardMode mode) {
// When keyboard is floating, no overscroll or resize is necessary. Sets
// keyboard bounds to zero so overscroll or resize is disabled.
if (keyboard_mode_ == FLOATING) {
NotifyKeyboardBoundsChanging(gfx::Rect());
NotifyContentsBoundsChanging(gfx::Rect());
} else if (keyboard_mode_ == FULL_WIDTH) {
AdjustKeyboardBounds();
// No animation added, so call ShowAnimationFinished immediately.
......@@ -691,7 +691,7 @@ void KeyboardController::ShowAnimationFinished() {
// Notify observers after animation finished to prevent reveal desktop
// background during animation.
NotifyKeyboardBoundsChanging(container_->bounds());
NotifyContentsBoundsChanging(container_->bounds());
ui_->EnsureCaretInWorkArea();
ChangeState(KeyboardControllerState::SHOWN);
}
......
......@@ -105,8 +105,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// when the focus of input field quickly change.
void HideKeyboard(HideReason reason);
// Notifies the keyboard observer for keyboard bounds changed.
void NotifyKeyboardBoundsChanging(const gfx::Rect& new_bounds);
// Notifies the observer for contents bounds changed.
void NotifyContentsBoundsChanging(const gfx::Rect& new_bounds);
// Management of the observer list.
void AddObserver(KeyboardControllerObserver* observer);
......@@ -163,7 +163,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// For access to Observer methods for simulation.
friend class KeyboardControllerTest;
// For access to NotifyKeyboardLoadingComplete.
// For access to NotifyContentsLoadingComplete.
friend class KeyboardLayoutManager;
// aura::WindowObserver overrides
......@@ -184,7 +184,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
void OnShowImeIfNeeded() override;
// Notifies that the extension has completed loading
void NotifyKeyboardLoadingComplete();
void NotifyContentsLoadingComplete();
// Show virtual keyboard immediately with animation.
void ShowKeyboardInternal(int64_t display_id);
......@@ -225,6 +225,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
base::ObserverList<KeyboardControllerObserver> observer_list_;
// The currently used keyboard position.
// If the contents window is visible, this should be the same size as the
// contents window. If not, this should be empty.
gfx::Rect current_keyboard_bounds_;
KeyboardControllerState state_;
......
......@@ -14,35 +14,32 @@ namespace keyboard {
// Overridden from aura::LayoutManager
void KeyboardLayoutManager::OnWindowResized() {
if (keyboard_) {
// Container window is the top level window of the virtual keyboard window.
// To support window.moveTo for the virtual keyboard window, as it actually
// moves the top level window, the container window should be set to the
// desired bounds before changing the bounds of the virtual keyboard window.
if (contents_window_) {
gfx::Rect container_bounds = controller_->GetContainerWindow()->bounds();
// Always align container window and keyboard window.
if (controller_->keyboard_mode() == FULL_WIDTH) {
SetChildBounds(keyboard_, gfx::Rect(container_bounds.size()));
SetChildBounds(contents_window_, gfx::Rect(container_bounds.size()));
} else {
SetChildBoundsDirect(keyboard_, gfx::Rect(container_bounds.size()));
SetChildBoundsDirect(contents_window_,
gfx::Rect(container_bounds.size()));
}
}
}
void KeyboardLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
DCHECK(!keyboard_);
keyboard_ = child;
DCHECK(!contents_window_);
contents_window_ = child;
if (controller_->keyboard_mode() == FULL_WIDTH) {
controller_->GetContainerWindow()->SetBounds(gfx::Rect());
} else if (controller_->keyboard_mode() == FLOATING) {
controller_->GetContainerWindow()->SetBounds(child->bounds());
SetChildBoundsDirect(keyboard_, gfx::Rect(child->bounds().size()));
SetChildBoundsDirect(contents_window_, gfx::Rect(child->bounds().size()));
}
}
void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) {
DCHECK(child == keyboard_);
DCHECK(child == contents_window_);
TRACE_EVENT0("vk", "KeyboardLayoutSetChildBounds");
......@@ -64,10 +61,9 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
// Keyboard bounds should only be reset when it actually changes. Otherwise
// it interrupts the initial animation of showing the keyboard. Described in
// crbug.com/356753.
gfx::Rect old_bounds = keyboard_->GetTargetBounds();
aura::Window::ConvertRectToTarget(keyboard_,
keyboard_->GetRootWindow(),
&old_bounds);
gfx::Rect old_bounds = contents_window_->GetTargetBounds();
aura::Window::ConvertRectToTarget(
contents_window_, contents_window_->GetRootWindow(), &old_bounds);
if (new_bounds == old_bounds)
return;
......@@ -78,7 +74,7 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
animator->StopAnimating();
controller_->GetContainerWindow()->SetBounds(new_bounds);
SetChildBoundsDirect(keyboard_, gfx::Rect(new_bounds.size()));
SetChildBoundsDirect(contents_window_, gfx::Rect(new_bounds.size()));
const bool container_had_size = old_bounds.height() != 0;
const bool child_has_size = child->bounds().height() != 0;
......@@ -103,16 +99,16 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
!controller_->keyboard_visible()) {
// When the child is layed out, the controller is not shown, but showing
// is not desired, this is indicative that the pre-load has completed.
controller_->NotifyKeyboardLoadingComplete();
controller_->NotifyContentsLoadingComplete();
}
if (controller_->keyboard_mode() == FULL_WIDTH) {
// We need to send out this notification only if keyboard is visible since
// keyboard window is resized even if keyboard is hidden.
// the contents window is resized even if keyboard is hidden.
if (controller_->keyboard_visible())
controller_->NotifyKeyboardBoundsChanging(new_bounds);
controller_->NotifyContentsBoundsChanging(new_bounds);
} else if (controller_->keyboard_mode() == FLOATING) {
controller_->NotifyKeyboardBoundsChanging(gfx::Rect());
controller_->NotifyContentsBoundsChanging(gfx::Rect());
}
}
}
......
......@@ -19,8 +19,7 @@ class KeyboardController;
class KeyboardLayoutManager : public aura::LayoutManager {
public:
explicit KeyboardLayoutManager(KeyboardController* controller)
: controller_(controller), keyboard_(NULL) {
}
: controller_(controller), contents_window_(NULL) {}
// Overridden from aura::LayoutManager
void OnWindowResized() override;
......@@ -34,7 +33,7 @@ class KeyboardLayoutManager : public aura::LayoutManager {
private:
KeyboardController* controller_;
aura::Window* keyboard_;
aura::Window* contents_window_;
DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment