diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-27 06:07:04 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-27 06:07:04 +0000 |
commit | 62c9f106125075e5c14a16f4ca050a105579dec9 (patch) | |
tree | cdfe9f43f43e7de2e2edbcb6cbee0a70bd55ef15 /ui | |
parent | 51c3b307889ae0ebebb73409bd02b110db7ef99a (diff) | |
download | chromium_src-62c9f106125075e5c14a16f4ca050a105579dec9.zip chromium_src-62c9f106125075e5c14a16f4ca050a105579dec9.tar.gz chromium_src-62c9f106125075e5c14a16f4ca050a105579dec9.tar.bz2 |
Revert of Move GetCursor() method from WindowDelegate to its own delegate interface CursorDelegate. (https://codereview.chromium.org/211733003/)
Reason for revert:
http://crbug.com/357015
Original issue's description:
> Move GetCursor() method from WindowDelegate to its own delegate interface CursorDelegate.
>
> R=sky@chromium.org
> http://crbug.com/308845
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259631
TBR=sky@chromium.org
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/213383007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/demo/demo_main.cc | 3 | ||||
-rw-r--r-- | ui/aura/test/test_window_delegate.cc | 4 | ||||
-rw-r--r-- | ui/aura/test/test_window_delegate.h | 1 | ||||
-rw-r--r-- | ui/aura/window.cc | 4 | ||||
-rw-r--r-- | ui/aura/window.h | 3 | ||||
-rw-r--r-- | ui/aura/window_delegate.h | 4 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller.cc | 3 | ||||
-rw-r--r-- | ui/views/controls/native/native_view_host_aura.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 13 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura.h | 8 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 12 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 8 | ||||
-rw-r--r-- | ui/wm/core/compound_event_filter.cc | 5 | ||||
-rw-r--r-- | ui/wm/public/cursor_delegate.cc | 24 | ||||
-rw-r--r-- | ui/wm/public/cursor_delegate.h | 35 | ||||
-rw-r--r-- | ui/wm/wm.gyp | 2 |
16 files changed, 37 insertions, 100 deletions
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index a7a21cc..548aede 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -49,6 +49,9 @@ class DemoWindowDelegate : public aura::WindowDelegate { virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE {} + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { + return gfx::kNullCursor; + } virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { return HTCAPTION; } diff --git a/ui/aura/test/test_window_delegate.cc b/ui/aura/test/test_window_delegate.cc index 127c545..7f0ca1b 100644 --- a/ui/aura/test/test_window_delegate.cc +++ b/ui/aura/test/test_window_delegate.cc @@ -50,6 +50,10 @@ void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { } +gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) { + return gfx::kNullCursor; +} + int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const { return window_component_; } diff --git a/ui/aura/test/test_window_delegate.h b/ui/aura/test/test_window_delegate.h index e100116..6f36e44 100644 --- a/ui/aura/test/test_window_delegate.h +++ b/ui/aura/test/test_window_delegate.h @@ -46,6 +46,7 @@ class TestWindowDelegate : public WindowDelegate { virtual gfx::Size GetMaximumSize() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE; + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual bool ShouldDescendIntoChildForEventHandling( Window* child, diff --git a/ui/aura/window.cc b/ui/aura/window.cc index f3b8d5a..86c9046 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -622,6 +622,10 @@ void Window::MoveCursorTo(const gfx::Point& point_in_window) { root_window->GetHost()->MoveCursorTo(point_in_root); } +gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const { + return delegate_ ? delegate_->GetCursor(point) : gfx::kNullCursor; +} + void Window::SetEventFilter(ui::EventHandler* event_filter) { if (event_filter_) RemovePreTargetHandler(event_filter_.get()); diff --git a/ui/aura/window.h b/ui/aura/window.h index b74e605..2324533 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -217,6 +217,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate, // Moves the cursor to the specified location relative to the window. virtual void MoveCursorTo(const gfx::Point& point_in_window); + // Returns the cursor for the specified point, in window coordinates. + gfx::NativeCursor GetCursor(const gfx::Point& point) const; + // Sets an 'event filter' for the window. An 'event filter' for a Window is // a pre-target event handler, where the window owns the handler. A window // can have only one such event filter. Setting a new filter removes and diff --git a/ui/aura/window_delegate.h b/ui/aura/window_delegate.h index ce0a457..90e978a 100644 --- a/ui/aura/window_delegate.h +++ b/ui/aura/window_delegate.h @@ -44,6 +44,10 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler { virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) = 0; + // Returns the native cursor for the specified point, in window coordinates, + // or NULL for the default cursor. + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0; + // Returns the non-client component (see hit_test.h) containing |point|, in // window coordinates. virtual int GetNonClientComponent(const gfx::Point& point) const = 0; diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc index 72f16ce..1de832c 100644 --- a/ui/keyboard/keyboard_controller.cc +++ b/ui/keyboard/keyboard_controller.cc @@ -84,6 +84,9 @@ class KeyboardWindowDelegate : public aura::WindowDelegate { const gfx::Rect& new_bounds) OVERRIDE { bounds_ = new_bounds; } + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { + return gfx::kNullCursor; + } virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { return HTNOWHERE; } diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc index edd65a6..49bf733 100644 --- a/ui/views/controls/native/native_view_host_aura.cc +++ b/ui/views/controls/native/native_view_host_aura.cc @@ -11,7 +11,6 @@ #include "ui/views/controls/native/native_view_host.h" #include "ui/views/view_constants_aura.h" #include "ui/views/widget/widget.h" -#include "ui/wm/public/cursor_delegate.h" namespace views { @@ -103,11 +102,8 @@ gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() { } gfx::NativeCursor NativeViewHostAura::GetCursor(int x, int y) { - if (host_->native_view()) { - wm::CursorDelegate* delegate = wm::GetCursorDelegate(host_->native_view()); - if (delegate) - return delegate->GetCursorForPoint(gfx::Point(x, y)); - } + if (host_->native_view()) + return host_->native_view()->GetCursor(gfx::Point(x, y)); return gfx::kNullCursor; } diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index ed46dc0..8341bce 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -259,7 +259,6 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura( widget_type_(Widget::InitParams::TYPE_WINDOW) { aura::client::SetFocusChangeObserver(content_window_, this); aura::client::SetActivationChangeObserver(content_window_, this); - wm::SetCursorDelegate(content_window_, this); } DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { @@ -930,6 +929,10 @@ gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const { return native_widget_delegate_->GetMaximumSize(); } +gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { + return cursor_; +} + int DesktopNativeWidgetAura::GetNonClientComponent( const gfx::Point& point) const { return native_widget_delegate_->GetNonClientComponent(point); @@ -1157,14 +1160,6 @@ void DesktopNativeWidgetAura::OnHostMoved(const aura::WindowTreeHost* host, } //////////////////////////////////////////////////////////////////////////////// -// DesktopNativeWidgetAura, wm::CursorDelegate implementation: - -gfx::NativeCursor DesktopNativeWidgetAura::GetCursorForPoint( - const gfx::Point& point) { - return cursor_; -} - -//////////////////////////////////////////////////////////////////////////////// // DesktopNativeWidgetAura, NativeWidget implementation: ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index 687b0b3..c2966d9 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -15,7 +15,6 @@ #include "ui/wm/core/compound_event_filter.h" #include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_delegate.h" -#include "ui/wm/public/cursor_delegate.h" #include "ui/wm/public/drag_drop_delegate.h" namespace aura { @@ -61,8 +60,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura public aura::client::FocusChangeObserver, public views::internal::InputMethodDelegate, public aura::client::DragDropDelegate, - public aura::WindowTreeHostObserver, - public wm::CursorDelegate { + public aura::WindowTreeHostObserver { public: explicit DesktopNativeWidgetAura(internal::NativeWidgetDelegate* delegate); virtual ~DesktopNativeWidgetAura(); @@ -188,6 +186,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura virtual gfx::Size GetMaximumSize() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE {} + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual bool ShouldDescendIntoChildForEventHandling( aura::Window* child, @@ -235,9 +234,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura virtual void OnHostMoved(const aura::WindowTreeHost* host, const gfx::Point& new_origin) OVERRIDE; - // Overridden from wm::CursorDelegate: - virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) OVERRIDE; - private: friend class FocusManagerEventHandler; friend class RootWindowDestructionObserver; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 4b35744..75e78a4 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -80,7 +80,6 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) saved_window_state_(ui::SHOW_STATE_DEFAULT) { aura::client::SetFocusChangeObserver(window_, this); aura::client::SetActivationChangeObserver(window_, this); - wm::SetCursorDelegate(window_, this); } // static @@ -726,6 +725,10 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); } +gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { + return cursor_; +} + int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { return delegate_->GetNonClientComponent(point); } @@ -941,13 +944,6 @@ int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { } //////////////////////////////////////////////////////////////////////////////// -// NativeWidgetAura, wm::CursorDelegate implementation: - -gfx::NativeCursor NativeWidgetAura::GetCursorForPoint(const gfx::Point& point) { - return cursor_; -} - -//////////////////////////////////////////////////////////////////////////////// // NativeWidgetAura, NativeWidget implementation: ui::EventHandler* NativeWidgetAura::GetEventHandler() { diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 387eb31..6ca1e71 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -16,7 +16,6 @@ #include "ui/views/widget/native_widget_private.h" #include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_delegate.h" -#include "ui/wm/public/cursor_delegate.h" #include "ui/wm/public/drag_drop_delegate.h" namespace aura { @@ -39,8 +38,7 @@ class VIEWS_EXPORT NativeWidgetAura public aura::client::ActivationDelegate, public aura::client::ActivationChangeObserver, public aura::client::FocusChangeObserver, - public aura::client::DragDropDelegate, - public wm::CursorDelegate { + public aura::client::DragDropDelegate { public: explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate); @@ -146,6 +144,7 @@ class VIEWS_EXPORT NativeWidgetAura virtual gfx::Size GetMaximumSize() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE; + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual bool ShouldDescendIntoChildForEventHandling( aura::Window* child, @@ -184,9 +183,6 @@ class VIEWS_EXPORT NativeWidgetAura virtual void OnDragExited() OVERRIDE; virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; - // Overridden from wm::CursorDelegate: - virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) OVERRIDE; - // Overridden from NativeWidget: virtual ui::EventHandler* GetEventHandler() OVERRIDE; diff --git a/ui/wm/core/compound_event_filter.cc b/ui/wm/core/compound_event_filter.cc index 6efafea..edb7146 100644 --- a/ui/wm/core/compound_event_filter.cc +++ b/ui/wm/core/compound_event_filter.cc @@ -15,7 +15,6 @@ #include "ui/base/hit_test.h" #include "ui/events/event.h" #include "ui/wm/public/activation_client.h" -#include "ui/wm/public/cursor_delegate.h" #include "ui/wm/public/drag_drop_client.h" #if defined(OS_CHROMEOS) && defined(USE_X11) @@ -159,9 +158,7 @@ void CompoundEventFilter::UpdateCursor(aura::Window* target, aura::client::CursorClient* cursor_client = aura::client::GetCursorClient(root_window); if (cursor_client) { - CursorDelegate* delegate = GetCursorDelegate(target); - gfx::NativeCursor cursor = delegate ? - delegate->GetCursorForPoint(event->location()) : gfx::kNullCursor; + gfx::NativeCursor cursor = target->GetCursor(event->location()); if ((event->flags() & ui::EF_IS_NON_CLIENT)) { if (target->delegate()) { int window_component = diff --git a/ui/wm/public/cursor_delegate.cc b/ui/wm/public/cursor_delegate.cc deleted file mode 100644 index bea259d..0000000 --- a/ui/wm/public/cursor_delegate.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/wm/public/cursor_delegate.h" - -#include "ui/aura/window.h" -#include "ui/aura/window_property.h" - -DECLARE_WINDOW_PROPERTY_TYPE(wm::CursorDelegate*); - -namespace wm { - -DEFINE_LOCAL_WINDOW_PROPERTY_KEY(CursorDelegate*, kCursorDelegateKey, NULL); - -void SetCursorDelegate(aura::Window* window, CursorDelegate* delegate) { - window->SetProperty(kCursorDelegateKey, delegate); -} - -CursorDelegate* GetCursorDelegate(aura::Window* window) { - return window ? window->GetProperty(kCursorDelegateKey) : NULL; -} - -} // namespace wm diff --git a/ui/wm/public/cursor_delegate.h b/ui/wm/public/cursor_delegate.h deleted file mode 100644 index 1acf4d7..0000000 --- a/ui/wm/public/cursor_delegate.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_WM_PUBLIC_CURSOR_DELEGATE_H_ -#define UI_WM_PUBLIC_CURSOR_DELEGATE_H_ - -#include "ui/gfx/native_widget_types.h" -#include "ui/wm/core/wm_core_export.h" - -namespace aura { -class Window; -} - -namespace gfx { -class Point; -} - -namespace wm { - -class WM_CORE_EXPORT CursorDelegate { - public: - virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) = 0; - - protected: - virtual ~CursorDelegate() {} -}; - -WM_CORE_EXPORT void SetCursorDelegate(aura::Window* window, - CursorDelegate* delegate); -WM_CORE_EXPORT CursorDelegate* GetCursorDelegate(aura::Window* window); - -} // namespace wm - -#endif // UI_WM_PUBLIC_CURSOR_DELEGATE_H_ diff --git a/ui/wm/wm.gyp b/ui/wm/wm.gyp index cccadc0..a1960ec 100644 --- a/ui/wm/wm.gyp +++ b/ui/wm/wm.gyp @@ -85,8 +85,6 @@ 'core/wm_core_switches.h', 'core/wm_state.cc', 'core/wm_state.h', - 'public/cursor_delegate.cc', - 'public/cursor_delegate.h', ], }, { |