Commit 5166102a authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Chromium LUCI CQ

virtual keyboard: clean up dead code.

Looks like kEmbeddedWindowEnsureNotInRect was introduced for mus and has
been cleaned up partially. Clean up the remaining part.

Bug: None
Change-Id: I390338677625c8b12aa8d0016a8d32e40acb456b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600326
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841731}
parent 3fa8fea5
...@@ -49,9 +49,6 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowLayerDrawn, false) ...@@ -49,9 +49,6 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowLayerDrawn, false)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kConstrainedWindowKey, false) DEFINE_UI_CLASS_PROPERTY_KEY(bool, kConstrainedWindowKey, false)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCreatedByUserGesture, false) DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCreatedByUserGesture, false)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kDrawAttentionKey, false) DEFINE_UI_CLASS_PROPERTY_KEY(bool, kDrawAttentionKey, false)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect,
kEmbeddedWindowEnsureNotInRect,
nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(FocusClient*, kFocusClientKey, nullptr) DEFINE_UI_CLASS_PROPERTY_KEY(FocusClient*, kFocusClientKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(Window*, kHostWindowKey, nullptr) DEFINE_UI_CLASS_PROPERTY_KEY(Window*, kHostWindowKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(Window*, kChildModalParentKey, nullptr) DEFINE_UI_CLASS_PROPERTY_KEY(Window*, kChildModalParentKey, nullptr)
......
...@@ -18,7 +18,7 @@ namespace ws { ...@@ -18,7 +18,7 @@ namespace ws {
namespace mojom { namespace mojom {
enum class WindowType; enum class WindowType;
} }
} } // namespace ws
namespace aura { namespace aura {
namespace client { namespace client {
...@@ -84,12 +84,6 @@ AURA_EXPORT extern const WindowProperty<bool>* const kCreatedByUserGesture; ...@@ -84,12 +84,6 @@ AURA_EXPORT extern const WindowProperty<bool>* const kCreatedByUserGesture;
// attention. // attention.
AURA_EXPORT extern const WindowProperty<bool>* const kDrawAttentionKey; AURA_EXPORT extern const WindowProperty<bool>* const kDrawAttentionKey;
// A property key to store a bounds in screen coordinates that an embedded
// window wants to be moved out of. This is only used in MUS to move the
// embedding top-level window at the other side.
AURA_EXPORT extern const WindowProperty<gfx::Rect*>* const
kEmbeddedWindowEnsureNotInRect;
// A property key to store the focus client on the window. // A property key to store the focus client on the window.
AURA_EXPORT extern const WindowProperty<FocusClient*>* const kFocusClientKey; AURA_EXPORT extern const WindowProperty<FocusClient*>* const kFocusClientKey;
......
...@@ -59,9 +59,6 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect, ...@@ -59,9 +59,6 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect,
nullptr) nullptr)
void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) { void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) {
window->GetRootWindow()->ClearProperty(
aura::client::kEmbeddedWindowEnsureNotInRect);
// Get restore bounds of the window // Get restore bounds of the window
gfx::Rect* vk_restore_bounds = gfx::Rect* vk_restore_bounds =
window->GetProperty(kVirtualKeyboardRestoreBoundsKey); window->GetProperty(kVirtualKeyboardRestoreBoundsKey);
...@@ -97,37 +94,4 @@ void EnsureWindowNotInRect(aura::Window* window, ...@@ -97,37 +94,4 @@ void EnsureWindowNotInRect(aura::Window* window,
MoveWindowToEnsureCaretNotInRect(window, rect_in_screen); MoveWindowToEnsureCaretNotInRect(window, rect_in_screen);
} }
EnsureWindowNotInRectHelper::EnsureWindowNotInRectHelper(
aura::Window* embedding_root)
: embedding_root_(embedding_root) {
embedding_root_->AddObserver(this);
}
EnsureWindowNotInRectHelper::~EnsureWindowNotInRectHelper() {
if (embedding_root_)
embedding_root_->RemoveObserver(this);
}
void EnsureWindowNotInRectHelper::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
DCHECK_EQ(embedding_root_, window);
if (key != aura::client::kEmbeddedWindowEnsureNotInRect)
return;
aura::Window* top_level = embedding_root_->GetToplevelWindow();
gfx::Rect* rect_in_screen = embedding_root_->GetProperty(
aura::client::kEmbeddedWindowEnsureNotInRect);
if (rect_in_screen)
EnsureWindowNotInRect(top_level, *rect_in_screen);
else
RestoreWindowBoundsOnClientFocusLost(top_level);
}
void EnsureWindowNotInRectHelper::OnWindowDestroyed(aura::Window* window) {
DCHECK_EQ(embedding_root_, window);
embedding_root_ = nullptr;
}
} // namespace wm } // namespace wm
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define UI_WM_CORE_IME_UTIL_CHROMEOS_H_ #define UI_WM_CORE_IME_UTIL_CHROMEOS_H_
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/wm/core/wm_core_export.h" #include "ui/wm/core/wm_core_export.h"
namespace gfx { namespace gfx {
...@@ -20,11 +19,7 @@ namespace wm { ...@@ -20,11 +19,7 @@ namespace wm {
WM_CORE_EXPORT extern const aura::WindowProperty<gfx::Rect*>* const WM_CORE_EXPORT extern const aura::WindowProperty<gfx::Rect*>* const
kVirtualKeyboardRestoreBoundsKey; kVirtualKeyboardRestoreBoundsKey;
// Moves |window| to ensure it does not intersect with |rect_in_screen| if it // Moves |window| to ensure it does not intersect with |rect_in_screen|.
// does not belong to an embedded window tree. Otherwise, sets |rect_in_screen|
// in kEmbeddedWindowEnsureNotInRect window property on the root window of the
// embedded tree so that the embedding side could forward the call to the
// relevant top level window. See also EnsureWindowNotInRectHelper.
WM_CORE_EXPORT void EnsureWindowNotInRect(aura::Window* window, WM_CORE_EXPORT void EnsureWindowNotInRect(aura::Window* window,
const gfx::Rect& rect_in_screen); const gfx::Rect& rect_in_screen);
...@@ -32,25 +27,6 @@ WM_CORE_EXPORT void EnsureWindowNotInRect(aura::Window* window, ...@@ -32,25 +27,6 @@ WM_CORE_EXPORT void EnsureWindowNotInRect(aura::Window* window,
WM_CORE_EXPORT void RestoreWindowBoundsOnClientFocusLost( WM_CORE_EXPORT void RestoreWindowBoundsOnClientFocusLost(
aura::Window* top_level_window); aura::Window* top_level_window);
// Helper to call EnsureWindowNotInRect/RestoreWindowBoundsOnClientFocusLost
// on the top-level window of an embedding root when its
// kEmbeddedWindowEnsureNotInRect window property changes.
class WM_CORE_EXPORT EnsureWindowNotInRectHelper : public aura::WindowObserver {
public:
explicit EnsureWindowNotInRectHelper(aura::Window* embedding_root);
~EnsureWindowNotInRectHelper() override;
private:
// aura::WindowObsever:
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) override;
void OnWindowDestroyed(aura::Window* window) override;
aura::Window* embedding_root_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(EnsureWindowNotInRectHelper);
};
} // namespace wm } // namespace wm
#endif // UI_WM_CORE_IME_UTIL_CHROMEOS_H_ #endif // UI_WM_CORE_IME_UTIL_CHROMEOS_H_
...@@ -128,23 +128,4 @@ TEST_F(ImeUtilChromeosTest, MoveUpThenRestore) { ...@@ -128,23 +128,4 @@ TEST_F(ImeUtilChromeosTest, MoveUpThenRestore) {
EXPECT_EQ(original_bounds, window->GetBoundsInScreen()); EXPECT_EQ(original_bounds, window->GetBoundsInScreen());
} }
// Tests that setting/clearing kEmbeddedWindowEnsureNotInRect window property
// triggers the relevant top level to be moved/restored.
TEST_F(ImeUtilChromeosTest, EnsureWindowNotInRectHelper) {
const gfx::Rect original_bounds(10, 10, 100, 100);
aura::Window* top_level = aura::test::CreateTestWindow(
SK_ColorWHITE, 1, original_bounds, root_window());
aura::Window* embedding_root = aura::test::CreateTestWindowWithBounds(
gfx::Rect(original_bounds.size()), top_level);
EnsureWindowNotInRectHelper helper(embedding_root);
gfx::Rect occluded_rect(50, 50, 200, 200);
embedding_root->SetProperty(aura::client::kEmbeddedWindowEnsureNotInRect,
new gfx::Rect(occluded_rect));
EXPECT_EQ(gfx::Rect(10, 0, 100, 100), top_level->bounds());
embedding_root->ClearProperty(aura::client::kEmbeddedWindowEnsureNotInRect);
EXPECT_EQ(original_bounds, top_level->bounds());
}
} // namespace wm } // namespace wm
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