Commit 907eabfa authored by yukishiino's avatar yukishiino Committed by Commit bot

text input focus: Supports Window::GetFocusedTextInputClient.

This CL is split off from http://crrev.com/785463002 and
Window::GetFocusedTextInputClient is necessary in that CL.

BUG=290701

Review URL: https://codereview.chromium.org/860983004

Cr-Commit-Position: refs/heads/master@{#313448}
parent 4a8dee9a
...@@ -33,6 +33,7 @@ class CursorWindowDelegate : public aura::WindowDelegate { ...@@ -33,6 +33,7 @@ class CursorWindowDelegate : public aura::WindowDelegate {
gfx::Size GetMaximumSize() const override { return size_; } gfx::Size GetMaximumSize() const override { return size_; }
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override { return nullptr; }
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -88,6 +88,7 @@ class DragDropTrackerDelegate : public aura::WindowDelegate { ...@@ -88,6 +88,7 @@ class DragDropTrackerDelegate : public aura::WindowDelegate {
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override { return nullptr; }
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -221,6 +221,7 @@ class EmptyWindowDelegate : public aura::WindowDelegate { ...@@ -221,6 +221,7 @@ class EmptyWindowDelegate : public aura::WindowDelegate {
gfx::Size GetMaximumSize() const override { return gfx::Size(); } gfx::Size GetMaximumSize() const override { return gfx::Size(); }
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override { return nullptr; }
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -1704,6 +1704,10 @@ void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, ...@@ -1704,6 +1704,10 @@ void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
GetInputMethod()->OnCaretBoundsChanged(this); GetInputMethod()->OnCaretBoundsChanged(this);
} }
ui::TextInputClient* RenderWidgetHostViewAura::GetFocusedTextInputClient() {
return GetTextInputClient();
}
gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) {
if (mouse_locked_) if (mouse_locked_)
return ui::kCursorNone; return ui::kCursorNone;
......
...@@ -276,6 +276,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -276,6 +276,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override; const gfx::Rect& new_bounds) override;
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
......
...@@ -43,6 +43,10 @@ void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, ...@@ -43,6 +43,10 @@ void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
size_mismatch_ = window_size_ != image_.AsImageSkia().size(); size_mismatch_ = window_size_ != image_.AsImageSkia().size();
} }
ui::TextInputClient* ImageWindowDelegate::GetFocusedTextInputClient() {
return nullptr;
}
gfx::NativeCursor ImageWindowDelegate::GetCursor(const gfx::Point& point) { gfx::NativeCursor ImageWindowDelegate::GetCursor(const gfx::Point& point) {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -29,6 +29,7 @@ class CONTENT_EXPORT ImageWindowDelegate : public aura::WindowDelegate { ...@@ -29,6 +29,7 @@ class CONTENT_EXPORT ImageWindowDelegate : public aura::WindowDelegate {
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override; const gfx::Rect& new_bounds) override;
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
......
...@@ -1435,6 +1435,10 @@ void WebContentsViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, ...@@ -1435,6 +1435,10 @@ void WebContentsViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
} }
} }
ui::TextInputClient* WebContentsViewAura::GetFocusedTextInputClient() {
return nullptr;
}
gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) { gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -159,6 +159,7 @@ class WebContentsViewAura ...@@ -159,6 +159,7 @@ class WebContentsViewAura
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override; const gfx::Rect& new_bounds) override;
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
......
...@@ -45,6 +45,7 @@ class DemoWindowDelegate : public aura::WindowDelegate { ...@@ -45,6 +45,7 @@ class DemoWindowDelegate : public aura::WindowDelegate {
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override { return nullptr; }
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
...@@ -81,7 +82,7 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient { ...@@ -81,7 +82,7 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient {
} }
~DemoWindowTreeClient() override { ~DemoWindowTreeClient() override {
aura::client::SetWindowTreeClient(window_, NULL); aura::client::SetWindowTreeClient(window_, nullptr);
} }
// Overridden from aura::client::WindowTreeClient: // Overridden from aura::client::WindowTreeClient:
......
...@@ -50,6 +50,10 @@ void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, ...@@ -50,6 +50,10 @@ void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) { const gfx::Rect& new_bounds) {
} }
ui::TextInputClient* TestWindowDelegate::GetFocusedTextInputClient() {
return &text_input_client_;
}
gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) { gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
#include "ui/base/ime/dummy_text_input_client.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -46,6 +47,7 @@ class TestWindowDelegate : public WindowDelegate { ...@@ -46,6 +47,7 @@ class TestWindowDelegate : public WindowDelegate {
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override; const gfx::Rect& new_bounds) override;
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
...@@ -66,6 +68,7 @@ class TestWindowDelegate : public WindowDelegate { ...@@ -66,6 +68,7 @@ class TestWindowDelegate : public WindowDelegate {
bool delete_on_destroyed_; bool delete_on_destroyed_;
gfx::Size minimum_size_; gfx::Size minimum_size_;
gfx::Size maximum_size_; gfx::Size maximum_size_;
ui::DummyTextInputClient text_input_client_;
bool can_focus_; bool can_focus_;
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
......
...@@ -647,6 +647,10 @@ void Window::ConvertRectToTarget(const Window* source, ...@@ -647,6 +647,10 @@ void Window::ConvertRectToTarget(const Window* source,
rect->set_origin(origin); rect->set_origin(origin);
} }
ui::TextInputClient* Window::GetFocusedTextInputClient() {
return delegate_ ? delegate_->GetFocusedTextInputClient() : nullptr;
}
void Window::MoveCursorTo(const gfx::Point& point_in_window) { void Window::MoveCursorTo(const gfx::Point& point_in_window) {
Window* root_window = GetRootWindow(); Window* root_window = GetRootWindow();
DCHECK(root_window); DCHECK(root_window);
......
...@@ -38,6 +38,7 @@ class Vector2d; ...@@ -38,6 +38,7 @@ class Vector2d;
namespace ui { namespace ui {
class EventHandler; class EventHandler;
class Layer; class Layer;
class TextInputClient;
class Texture; class Texture;
} }
...@@ -218,6 +219,10 @@ class AURA_EXPORT Window : public ui::LayerDelegate, ...@@ -218,6 +219,10 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
const Window* target, const Window* target,
gfx::Rect* rect); gfx::Rect* rect);
// Returns the focused text input client within this window.
// This function does not look at child windows.
ui::TextInputClient* GetFocusedTextInputClient();
// Moves the cursor to the specified location relative to the window. // Moves the cursor to the specified location relative to the window.
void MoveCursorTo(const gfx::Point& point_in_window); void MoveCursorTo(const gfx::Point& point_in_window);
......
...@@ -25,6 +25,7 @@ class GestureEvent; ...@@ -25,6 +25,7 @@ class GestureEvent;
class KeyEvent; class KeyEvent;
class Layer; class Layer;
class MouseEvent; class MouseEvent;
class TextInputClient;
class Texture; class Texture;
class TouchEvent; class TouchEvent;
} }
...@@ -44,6 +45,10 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler { ...@@ -44,6 +45,10 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler {
virtual void OnBoundsChanged(const gfx::Rect& old_bounds, virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) = 0; const gfx::Rect& new_bounds) = 0;
// Returns the focused text input client within this window.
// This function does not look at child windows.
virtual ui::TextInputClient* GetFocusedTextInputClient() = 0;
// Returns the native cursor for the specified point, in window coordinates, // Returns the native cursor for the specified point, in window coordinates,
// or NULL for the default cursor. // or NULL for the default cursor.
virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0; virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0;
......
...@@ -93,6 +93,9 @@ class KeyboardWindowDelegate : public aura::WindowDelegate { ...@@ -93,6 +93,9 @@ class KeyboardWindowDelegate : public aura::WindowDelegate {
const gfx::Rect& new_bounds) override { const gfx::Rect& new_bounds) override {
bounds_ = new_bounds; bounds_ = new_bounds;
} }
ui::TextInputClient* GetFocusedTextInputClient() override {
return nullptr;
}
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -30,6 +30,7 @@ class NativeViewHostAura::ClippingWindowDelegate : public aura::WindowDelegate { ...@@ -30,6 +30,7 @@ class NativeViewHostAura::ClippingWindowDelegate : public aura::WindowDelegate {
gfx::Size GetMaximumSize() const override { return gfx::Size(); } gfx::Size GetMaximumSize() const override { return gfx::Size(); }
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override { return nullptr; }
gfx::NativeCursor GetCursor(const gfx::Point& point) override { gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor; return gfx::kNullCursor;
} }
......
...@@ -982,6 +982,10 @@ gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const { ...@@ -982,6 +982,10 @@ gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const {
return native_widget_delegate_->GetMaximumSize(); return native_widget_delegate_->GetMaximumSize();
} }
ui::TextInputClient* DesktopNativeWidgetAura::GetFocusedTextInputClient() {
return GetWidget()->GetFocusedTextInputClient();
}
gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) {
return cursor_; return cursor_;
} }
......
...@@ -187,6 +187,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -187,6 +187,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override {} const gfx::Rect& new_bounds) override {}
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
......
...@@ -771,6 +771,10 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, ...@@ -771,6 +771,10 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds,
delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
} }
ui::TextInputClient* NativeWidgetAura::GetFocusedTextInputClient() {
return GetWidget()->GetFocusedTextInputClient();
}
gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) {
return cursor_; return cursor_;
} }
......
...@@ -146,6 +146,7 @@ class VIEWS_EXPORT NativeWidgetAura ...@@ -146,6 +146,7 @@ class VIEWS_EXPORT NativeWidgetAura
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnBoundsChanged(const gfx::Rect& old_bounds, void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override; const gfx::Rect& new_bounds) override;
ui::TextInputClient* GetFocusedTextInputClient() override;
gfx::NativeCursor GetCursor(const gfx::Point& point) override; gfx::NativeCursor GetCursor(const gfx::Point& point) override;
int GetNonClientComponent(const gfx::Point& point) const override; int GetNonClientComponent(const gfx::Point& point) const override;
bool ShouldDescendIntoChildForEventHandling( bool ShouldDescendIntoChildForEventHandling(
......
...@@ -439,9 +439,9 @@ void Widget::NotifyNativeViewHierarchyChanged() { ...@@ -439,9 +439,9 @@ void Widget::NotifyNativeViewHierarchyChanged() {
} }
void Widget::NotifyWillRemoveView(View* view) { void Widget::NotifyWillRemoveView(View* view) {
FOR_EACH_OBSERVER(WidgetRemovalsObserver, FOR_EACH_OBSERVER(WidgetRemovalsObserver,
removals_observers_, removals_observers_,
OnWillRemoveView(this, view)); OnWillRemoveView(this, view));
} }
// Converted methods (see header) ---------------------------------------------- // Converted methods (see header) ----------------------------------------------
...@@ -758,6 +758,12 @@ const FocusManager* Widget::GetFocusManager() const { ...@@ -758,6 +758,12 @@ const FocusManager* Widget::GetFocusManager() const {
return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
} }
ui::TextInputClient* Widget::GetFocusedTextInputClient() {
FocusManager* focus_manager = GetFocusManager();
View* view = focus_manager ? focus_manager->GetFocusedView() : nullptr;
return view ? view->GetTextInputClient() : nullptr;
}
InputMethod* Widget::GetInputMethod() { InputMethod* Widget::GetInputMethod() {
return const_cast<InputMethod*>( return const_cast<InputMethod*>(
const_cast<const Widget*>(this)->GetInputMethod()); const_cast<const Widget*>(this)->GetInputMethod());
......
...@@ -567,6 +567,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, ...@@ -567,6 +567,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
FocusManager* GetFocusManager(); FocusManager* GetFocusManager();
const FocusManager* GetFocusManager() const; const FocusManager* GetFocusManager() const;
// Returns the focused text input client within this widget.
ui::TextInputClient* GetFocusedTextInputClient();
// Returns the InputMethod for this widget. // Returns the InputMethod for this widget.
// Note that all widgets in a widget hierarchy share the same input method. // Note that all widgets in a widget hierarchy share the same input method.
InputMethod* GetInputMethod(); InputMethod* GetInputMethod();
......
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