Commit 60b9c2ff authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[VK] Draw shadows for docked keyboard.

In a previous patch, we removed shadows for both docked and floating
keyboard so that IME can draw them. Unfortunately, this means that
KeyboardController no longer knows which area of the keyboard is the
shadow and which is the actual UI, which breaks things like overscrolling.

A fix would be to make IME indicate what the actual occluded bounds are
through setOccludedBounds. Unfortunately, setOccludedBounds has several
problems (e.g. what happens when occluded bounds and visual bounds go
out of sync, e.g. when the screen is rotating). This requires some
additional thought.

So in the meantime, we just draw shadows only for docked mode. This will
at least unblock the new UI while we find a permanent solution.

Bug: 867775
Change-Id: Iebd8f5edfeac5643fe837b672bf65dab5bfcdb4d
Reviewed-on: https://chromium-review.googlesource.com/1152328
Commit-Queue: Darren Shen <shend@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578979}
parent 40f4afbe
......@@ -490,13 +490,6 @@ void ChromeKeyboardUI::AddBoundsChangedObserver(aura::Window* window) {
}
void ChromeKeyboardUI::SetShadowAroundKeyboard() {
// In the new keyboard UI, the shadows are drawn by the extension.
// TODO(https://crbug.com/856195): Remove this method when we switch
// completely to the new UI. The default extension may need to draw its own
// shadows too.
if (keyboard::IsVirtualKeyboardMdUiEnabled())
return;
aura::Window* contents_window = keyboard_contents_->GetNativeView();
if (!shadow_) {
shadow_ = std::make_unique<ui::Shadow>();
......@@ -506,6 +499,15 @@ void ChromeKeyboardUI::SetShadowAroundKeyboard() {
}
shadow_->SetContentBounds(gfx::Rect(contents_window->bounds().size()));
// In floating mode, make the shadow layer invisible because the shadows are
// drawn manually by the IME extension.
// TODO(https://crbug.com/856195): Remove this when we figure out how ChromeOS
// can draw custom shaped shadows, or how overscrolling can account for
// shadows drawn by IME.
shadow_->layer()->SetVisible(
keyboard_controller()->GetActiveContainerType() ==
keyboard::ContainerType::FULL_WIDTH);
}
void ChromeKeyboardUI::SetupWebContents(content::WebContents* contents) {
......
......@@ -38,18 +38,3 @@ class TestChromeKeyboardUI : public ChromeKeyboardUI {
} // namespace
using ChromeKeyboardUITest = ChromeRenderViewHostTestHarness;
// A test for crbug.com/734534
TEST_F(ChromeKeyboardUITest, DoesNotCrashWhenParentDoesNotExist) {
std::unique_ptr<content::WebContents> contents = CreateTestWebContents();
TestChromeKeyboardUI keyboard_ui(std::move(contents));
EXPECT_FALSE(keyboard_ui.HasKeyboardWindow());
aura::Window* view = keyboard_ui.GetKeyboardWindow();
EXPECT_TRUE(keyboard_ui.HasKeyboardWindow());
EXPECT_FALSE(view->parent());
// Change window size to trigger OnWindowBoundsChanged.
view->SetBounds(gfx::Rect(0, 0, 1200, 800));
}
......@@ -147,6 +147,27 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardWebContentTest,
EXPECT_EQ(gfx::Point(50, 50), contents_window->bounds().origin());
}
// A test for crbug.com/734534
IN_PROC_BROWSER_TEST_F(VirtualKeyboardWebContentTest,
DoesNotCrashWhenParentDoesNotExist) {
auto* controller = keyboard::KeyboardController::Get();
controller->LoadKeyboardWindowInBackground();
keyboard::KeyboardUI* keyboard_ui = controller->ui();
ASSERT_TRUE(keyboard_ui);
aura::Window* view = keyboard_ui->GetKeyboardWindow();
EXPECT_TRUE(keyboard_ui->HasKeyboardWindow());
// Remove the keyboard window parent.
EXPECT_TRUE(view->parent());
controller->DeactivateKeyboard();
EXPECT_FALSE(view->parent());
// Change window size to trigger OnWindowBoundsChanged.
view->SetBounds(gfx::Rect(0, 0, 1200, 800));
}
class VirtualKeyboardAppWindowTest : public extensions::PlatformAppBrowserTest {
public:
VirtualKeyboardAppWindowTest() {}
......
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