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) { ...@@ -973,7 +973,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) {
display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
// Notify keyboard bounds changing. // Notify keyboard bounds changing.
controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); controller->NotifyContentsBoundsChanging(keyboard_container->bounds());
if (!keyboard::IsKeyboardOverscrollEnabled()) { if (!keyboard::IsKeyboardOverscrollEnabled()) {
gfx::Rect after = gfx::Rect after =
......
...@@ -83,7 +83,7 @@ TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) { ...@@ -83,7 +83,7 @@ TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) {
root_window->bounds(), kKeyboardHeight); root_window->bounds(), kKeyboardHeight);
contents_window->SetBounds(keyboard_bounds); contents_window->SetBounds(keyboard_bounds);
contents_window->Show(); contents_window->Show();
keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds); keyboard_controller->NotifyContentsBoundsChanging(keyboard_bounds);
// Verify that test manager was notified of bounds change. // Verify that test manager was notified of bounds change.
ASSERT_TRUE(manager->keyboard_bounds_changed()); ASSERT_TRUE(manager->keyboard_bounds_changed());
} }
......
...@@ -204,7 +204,7 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardAppWindowTest, ...@@ -204,7 +204,7 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardAppWindowTest,
controller->ui()->GetContentsWindow()->SetBounds(test_bounds); controller->ui()->GetContentsWindow()->SetBounds(test_bounds);
gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds(); gfx::Rect keyboard_bounds = controller->GetContainerWindow()->bounds();
// Starts overscroll. // Starts overscroll.
controller->NotifyKeyboardBoundsChanging(keyboard_bounds); controller->NotifyContentsBoundsChanging(keyboard_bounds);
// Non ime window should have smaller visible view port due to overlap with // Non ime window should have smaller visible view port due to overlap with
// virtual keyboard. // virtual keyboard.
......
...@@ -331,7 +331,7 @@ aura::Window* KeyboardController::GetContainerWindowWithoutCreationForTest() { ...@@ -331,7 +331,7 @@ aura::Window* KeyboardController::GetContainerWindowWithoutCreationForTest() {
return container_.get(); return container_.get();
} }
void KeyboardController::NotifyKeyboardBoundsChanging( void KeyboardController::NotifyContentsBoundsChanging(
const gfx::Rect& new_bounds) { const gfx::Rect& new_bounds) {
current_keyboard_bounds_ = new_bounds; current_keyboard_bounds_ = new_bounds;
if (ui_->HasContentsWindow() && ui_->GetContentsWindow()->IsVisible()) { if (ui_->HasContentsWindow() && ui_->GetContentsWindow()->IsVisible()) {
...@@ -346,7 +346,7 @@ void KeyboardController::NotifyKeyboardBoundsChanging( ...@@ -346,7 +346,7 @@ void KeyboardController::NotifyKeyboardBoundsChanging(
} }
} }
void KeyboardController::NotifyKeyboardLoadingComplete() { void KeyboardController::NotifyContentsLoadingComplete() {
if (state_ != KeyboardControllerState::LOADING_EXTENSION) if (state_ != KeyboardControllerState::LOADING_EXTENSION)
return; return;
...@@ -371,7 +371,7 @@ void KeyboardController::HideKeyboard(HideReason reason) { ...@@ -371,7 +371,7 @@ void KeyboardController::HideKeyboard(HideReason reason) {
keyboard::KEYBOARD_CONTROL_HIDE_AUTO : keyboard::KEYBOARD_CONTROL_HIDE_AUTO :
keyboard::KEYBOARD_CONTROL_HIDE_USER); keyboard::KEYBOARD_CONTROL_HIDE_USER);
NotifyKeyboardBoundsChanging(gfx::Rect()); NotifyContentsBoundsChanging(gfx::Rect());
set_keyboard_locked(false); set_keyboard_locked(false);
...@@ -423,7 +423,7 @@ void KeyboardController::SetKeyboardMode(KeyboardMode mode) { ...@@ -423,7 +423,7 @@ void KeyboardController::SetKeyboardMode(KeyboardMode mode) {
// When keyboard is floating, no overscroll or resize is necessary. Sets // When keyboard is floating, no overscroll or resize is necessary. Sets
// keyboard bounds to zero so overscroll or resize is disabled. // keyboard bounds to zero so overscroll or resize is disabled.
if (keyboard_mode_ == FLOATING) { if (keyboard_mode_ == FLOATING) {
NotifyKeyboardBoundsChanging(gfx::Rect()); NotifyContentsBoundsChanging(gfx::Rect());
} else if (keyboard_mode_ == FULL_WIDTH) { } else if (keyboard_mode_ == FULL_WIDTH) {
AdjustKeyboardBounds(); AdjustKeyboardBounds();
// No animation added, so call ShowAnimationFinished immediately. // No animation added, so call ShowAnimationFinished immediately.
...@@ -691,7 +691,7 @@ void KeyboardController::ShowAnimationFinished() { ...@@ -691,7 +691,7 @@ void KeyboardController::ShowAnimationFinished() {
// Notify observers after animation finished to prevent reveal desktop // Notify observers after animation finished to prevent reveal desktop
// background during animation. // background during animation.
NotifyKeyboardBoundsChanging(container_->bounds()); NotifyContentsBoundsChanging(container_->bounds());
ui_->EnsureCaretInWorkArea(); ui_->EnsureCaretInWorkArea();
ChangeState(KeyboardControllerState::SHOWN); ChangeState(KeyboardControllerState::SHOWN);
} }
......
...@@ -105,8 +105,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -105,8 +105,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// when the focus of input field quickly change. // when the focus of input field quickly change.
void HideKeyboard(HideReason reason); void HideKeyboard(HideReason reason);
// Notifies the keyboard observer for keyboard bounds changed. // Notifies the observer for contents bounds changed.
void NotifyKeyboardBoundsChanging(const gfx::Rect& new_bounds); void NotifyContentsBoundsChanging(const gfx::Rect& new_bounds);
// Management of the observer list. // Management of the observer list.
void AddObserver(KeyboardControllerObserver* observer); void AddObserver(KeyboardControllerObserver* observer);
...@@ -163,7 +163,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -163,7 +163,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// For access to Observer methods for simulation. // For access to Observer methods for simulation.
friend class KeyboardControllerTest; friend class KeyboardControllerTest;
// For access to NotifyKeyboardLoadingComplete. // For access to NotifyContentsLoadingComplete.
friend class KeyboardLayoutManager; friend class KeyboardLayoutManager;
// aura::WindowObserver overrides // aura::WindowObserver overrides
...@@ -184,7 +184,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -184,7 +184,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
void OnShowImeIfNeeded() override; void OnShowImeIfNeeded() override;
// Notifies that the extension has completed loading // Notifies that the extension has completed loading
void NotifyKeyboardLoadingComplete(); void NotifyContentsLoadingComplete();
// Show virtual keyboard immediately with animation. // Show virtual keyboard immediately with animation.
void ShowKeyboardInternal(int64_t display_id); void ShowKeyboardInternal(int64_t display_id);
...@@ -225,6 +225,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -225,6 +225,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
base::ObserverList<KeyboardControllerObserver> observer_list_; base::ObserverList<KeyboardControllerObserver> observer_list_;
// The currently used keyboard position. // 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_; gfx::Rect current_keyboard_bounds_;
KeyboardControllerState state_; KeyboardControllerState state_;
......
...@@ -14,35 +14,32 @@ namespace keyboard { ...@@ -14,35 +14,32 @@ namespace keyboard {
// Overridden from aura::LayoutManager // Overridden from aura::LayoutManager
void KeyboardLayoutManager::OnWindowResized() { void KeyboardLayoutManager::OnWindowResized() {
if (keyboard_) { if (contents_window_) {
// 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.
gfx::Rect container_bounds = controller_->GetContainerWindow()->bounds(); gfx::Rect container_bounds = controller_->GetContainerWindow()->bounds();
// Always align container window and keyboard window. // Always align container window and keyboard window.
if (controller_->keyboard_mode() == FULL_WIDTH) { if (controller_->keyboard_mode() == FULL_WIDTH) {
SetChildBounds(keyboard_, gfx::Rect(container_bounds.size())); SetChildBounds(contents_window_, gfx::Rect(container_bounds.size()));
} else { } else {
SetChildBoundsDirect(keyboard_, gfx::Rect(container_bounds.size())); SetChildBoundsDirect(contents_window_,
gfx::Rect(container_bounds.size()));
} }
} }
} }
void KeyboardLayoutManager::OnWindowAddedToLayout(aura::Window* child) { void KeyboardLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
DCHECK(!keyboard_); DCHECK(!contents_window_);
keyboard_ = child; contents_window_ = child;
if (controller_->keyboard_mode() == FULL_WIDTH) { if (controller_->keyboard_mode() == FULL_WIDTH) {
controller_->GetContainerWindow()->SetBounds(gfx::Rect()); controller_->GetContainerWindow()->SetBounds(gfx::Rect());
} else if (controller_->keyboard_mode() == FLOATING) { } else if (controller_->keyboard_mode() == FLOATING) {
controller_->GetContainerWindow()->SetBounds(child->bounds()); 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, void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) { const gfx::Rect& requested_bounds) {
DCHECK(child == keyboard_); DCHECK(child == contents_window_);
TRACE_EVENT0("vk", "KeyboardLayoutSetChildBounds"); TRACE_EVENT0("vk", "KeyboardLayoutSetChildBounds");
...@@ -64,10 +61,9 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, ...@@ -64,10 +61,9 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
// Keyboard bounds should only be reset when it actually changes. Otherwise // Keyboard bounds should only be reset when it actually changes. Otherwise
// it interrupts the initial animation of showing the keyboard. Described in // it interrupts the initial animation of showing the keyboard. Described in
// crbug.com/356753. // crbug.com/356753.
gfx::Rect old_bounds = keyboard_->GetTargetBounds(); gfx::Rect old_bounds = contents_window_->GetTargetBounds();
aura::Window::ConvertRectToTarget(keyboard_, aura::Window::ConvertRectToTarget(
keyboard_->GetRootWindow(), contents_window_, contents_window_->GetRootWindow(), &old_bounds);
&old_bounds);
if (new_bounds == old_bounds) if (new_bounds == old_bounds)
return; return;
...@@ -78,7 +74,7 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, ...@@ -78,7 +74,7 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
animator->StopAnimating(); animator->StopAnimating();
controller_->GetContainerWindow()->SetBounds(new_bounds); 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 container_had_size = old_bounds.height() != 0;
const bool child_has_size = child->bounds().height() != 0; const bool child_has_size = child->bounds().height() != 0;
...@@ -103,16 +99,16 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, ...@@ -103,16 +99,16 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
!controller_->keyboard_visible()) { !controller_->keyboard_visible()) {
// When the child is layed out, the controller is not shown, but showing // 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. // is not desired, this is indicative that the pre-load has completed.
controller_->NotifyKeyboardLoadingComplete(); controller_->NotifyContentsLoadingComplete();
} }
if (controller_->keyboard_mode() == FULL_WIDTH) { if (controller_->keyboard_mode() == FULL_WIDTH) {
// We need to send out this notification only if keyboard is visible since // 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()) if (controller_->keyboard_visible())
controller_->NotifyKeyboardBoundsChanging(new_bounds); controller_->NotifyContentsBoundsChanging(new_bounds);
} else if (controller_->keyboard_mode() == FLOATING) { } else if (controller_->keyboard_mode() == FLOATING) {
controller_->NotifyKeyboardBoundsChanging(gfx::Rect()); controller_->NotifyContentsBoundsChanging(gfx::Rect());
} }
} }
} }
......
...@@ -19,8 +19,7 @@ class KeyboardController; ...@@ -19,8 +19,7 @@ class KeyboardController;
class KeyboardLayoutManager : public aura::LayoutManager { class KeyboardLayoutManager : public aura::LayoutManager {
public: public:
explicit KeyboardLayoutManager(KeyboardController* controller) explicit KeyboardLayoutManager(KeyboardController* controller)
: controller_(controller), keyboard_(NULL) { : controller_(controller), contents_window_(NULL) {}
}
// Overridden from aura::LayoutManager // Overridden from aura::LayoutManager
void OnWindowResized() override; void OnWindowResized() override;
...@@ -34,7 +33,7 @@ class KeyboardLayoutManager : public aura::LayoutManager { ...@@ -34,7 +33,7 @@ class KeyboardLayoutManager : public aura::LayoutManager {
private: private:
KeyboardController* controller_; KeyboardController* controller_;
aura::Window* keyboard_; aura::Window* contents_window_;
DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager); 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