Commit a9018a06 authored by tapted@chromium.org's avatar tapted@chromium.org

MacViews: Replace NativeWidget::GetEventHandler() with RepostNativeEvent(..)

This removes an aura dependency in webview/web_dialog_view.cc and is a
step towards getting the views_examples target compiling on Mac.

NativeWidget::GetEventHandler isn't used elsewhere.

Pre-Aura Win would use ::DefWindowProc() in
WebDialogView::HandleKeyboardEvent(), so NativeWidget feels like the
right place for this.

BUG=366007
TEST=Just refactoring

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273793 0039d316-1c4b-4281-b951-d872f2087c98
parent 1017a321
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/native_widget_aura.h" #include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/root_view.h" #include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_delegate.h"
...@@ -280,14 +280,8 @@ void WebDialogView::HandleKeyboardEvent(content::WebContents* source, ...@@ -280,14 +280,8 @@ void WebDialogView::HandleKeyboardEvent(content::WebContents* source,
const NativeWebKeyboardEvent& event) { const NativeWebKeyboardEvent& event) {
if (!event.os_event) if (!event.os_event)
return; return;
ui::KeyEvent aura_event(event.os_event->native_event(), false);
ui::EventHandler* event_handler =
GetWidget()->native_widget()->GetEventHandler();
DCHECK(event_handler);
if (event_handler)
event_handler->OnKeyEvent(&aura_event);
GetWidget()->native_widget_private()->RepostNativeEvent(event.os_event);
} }
void WebDialogView::CloseContents(WebContents* source) { void WebDialogView::CloseContents(WebContents* source) {
......
...@@ -932,6 +932,10 @@ void DesktopNativeWidgetAura::OnRootViewLayout() const { ...@@ -932,6 +932,10 @@ void DesktopNativeWidgetAura::OnRootViewLayout() const {
desktop_window_tree_host_->OnRootViewLayout(); desktop_window_tree_host_->OnRootViewLayout();
} }
void DesktopNativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) {
OnEvent(native_event);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, aura::WindowDelegate implementation: // DesktopNativeWidgetAura, aura::WindowDelegate implementation:
...@@ -1178,11 +1182,7 @@ void DesktopNativeWidgetAura::OnHostMoved(const aura::WindowTreeHost* host, ...@@ -1178,11 +1182,7 @@ void DesktopNativeWidgetAura::OnHostMoved(const aura::WindowTreeHost* host,
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, NativeWidget implementation: // DesktopNativeWidgetAura, private:
ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() {
return this;
}
void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { void DesktopNativeWidgetAura::InstallInputMethodEventFilter() {
DCHECK(!input_method_event_filter_.get()); DCHECK(!input_method_event_filter_.get());
......
...@@ -89,9 +89,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -89,9 +89,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
return host_.get(); return host_.get();
} }
// Overridden from NativeWidget:
virtual ui::EventHandler* GetEventHandler() OVERRIDE;
// Ensures that the correct window is activated/deactivated based on whether // Ensures that the correct window is activated/deactivated based on whether
// we are being activated/deactivated. // we are being activated/deactivated.
void HandleActivationChanged(bool active); void HandleActivationChanged(bool active);
...@@ -181,6 +178,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -181,6 +178,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE; virtual void OnRootViewLayout() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
// Overridden from aura::WindowDelegate: // Overridden from aura::WindowDelegate:
virtual gfx::Size GetMinimumSize() const OVERRIDE; virtual gfx::Size GetMinimumSize() const OVERRIDE;
......
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace ui {
class EventHandler;
}
namespace views { namespace views {
namespace internal { namespace internal {
class NativeWidgetPrivate; class NativeWidgetPrivate;
...@@ -30,9 +26,6 @@ class VIEWS_EXPORT NativeWidget { ...@@ -30,9 +26,6 @@ class VIEWS_EXPORT NativeWidget {
public: public:
virtual ~NativeWidget() {} virtual ~NativeWidget() {}
// Retrieves the event handler
virtual ui::EventHandler* GetEventHandler() = 0;
private: private:
friend class Widget; friend class Widget;
......
...@@ -691,6 +691,10 @@ ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const { ...@@ -691,6 +691,10 @@ ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const {
void NativeWidgetAura::OnRootViewLayout() const { void NativeWidgetAura::OnRootViewLayout() const {
} }
void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) {
OnEvent(native_event);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, views::InputMethodDelegate implementation: // NativeWidgetAura, views::InputMethodDelegate implementation:
...@@ -948,13 +952,6 @@ int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { ...@@ -948,13 +952,6 @@ int NativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
last_drop_operation_); last_drop_operation_);
} }
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, NativeWidget implementation:
ui::EventHandler* NativeWidgetAura::GetEventHandler() {
return this;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, protected: // NativeWidgetAura, protected:
......
...@@ -132,6 +132,7 @@ class VIEWS_EXPORT NativeWidgetAura ...@@ -132,6 +132,7 @@ class VIEWS_EXPORT NativeWidgetAura
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE; virtual void OnRootViewLayout() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
// Overridden from views::InputMethodDelegate: // Overridden from views::InputMethodDelegate:
virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
...@@ -179,9 +180,6 @@ class VIEWS_EXPORT NativeWidgetAura ...@@ -179,9 +180,6 @@ class VIEWS_EXPORT NativeWidgetAura
virtual void OnDragExited() OVERRIDE; virtual void OnDragExited() OVERRIDE;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
// Overridden from NativeWidget:
virtual ui::EventHandler* GetEventHandler() OVERRIDE;
protected: protected:
virtual ~NativeWidgetAura(); virtual ~NativeWidgetAura();
......
...@@ -101,9 +101,7 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { ...@@ -101,9 +101,7 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE; virtual void OnRootViewLayout() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
// NativeWidget:
virtual ui::EventHandler* GetEventHandler() OVERRIDE;
private: private:
internal::NativeWidgetDelegate* delegate_; internal::NativeWidgetDelegate* delegate_;
......
...@@ -355,11 +355,8 @@ void NativeWidgetMac::OnRootViewLayout() const { ...@@ -355,11 +355,8 @@ void NativeWidgetMac::OnRootViewLayout() const {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
//////////////////////////////////////////////////////////////////////////////// void NativeWidgetMac::RepostNativeEvent(gfx::NativeEvent native_event) {
// NativeWidgetMac, NativeWidget implementation: NOTIMPLEMENTED();
ui::EventHandler* NativeWidgetMac::GetEventHandler() {
return NULL;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -228,9 +228,11 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { ...@@ -228,9 +228,11 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
virtual ui::NativeTheme* GetNativeTheme() const = 0; virtual ui::NativeTheme* GetNativeTheme() const = 0;
virtual void OnRootViewLayout() const = 0; virtual void OnRootViewLayout() const = 0;
// Repost an unhandled event to the native widget for default OS processing.
virtual void RepostNativeEvent(gfx::NativeEvent native_event) = 0;
// Overridden from NativeWidget: // Overridden from NativeWidget:
virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE;
virtual ui::EventHandler* GetEventHandler() = 0;
}; };
} // namespace internal } // namespace internal
......
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