Commit 8e37fbee authored by sky's avatar sky Committed by Commit bot

Removes aura::Window::set_user_data()

It overlaps with properties, and properties add type safety.

BUG=none
TEST=none
R=ben@chromium.org

Review-Url: https://codereview.chromium.org/2610203002
Cr-Commit-Position: refs/heads/master@{#441474}
parent 9a7c0efc
...@@ -59,7 +59,6 @@ Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port) ...@@ -59,7 +59,6 @@ Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port)
visible_(false), visible_(false),
id_(kInitialId), id_(kInitialId),
transparent_(false), transparent_(false),
user_data_(nullptr),
ignore_events_(false), ignore_events_(false),
// Don't notify newly added observers during notification. This causes // Don't notify newly added observers during notification. This causes
// problems for code that adds an observer as part of an observer // problems for code that adds an observer as part of an observer
......
...@@ -135,10 +135,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate, ...@@ -135,10 +135,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void set_host(WindowTreeHost* host) { host_ = host; } void set_host(WindowTreeHost* host) { host_ = host; }
bool IsRootWindow() const { return !!host_; } bool IsRootWindow() const { return !!host_; }
// The Window does not own this object.
void set_user_data(void* user_data) { user_data_ = user_data; }
void* user_data() const { return user_data_; }
// Changes the visibility of the window. // Changes the visibility of the window.
void Show(); void Show();
void Hide(); void Hide();
...@@ -507,8 +503,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate, ...@@ -507,8 +503,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
std::unique_ptr<LayoutManager> layout_manager_; std::unique_ptr<LayoutManager> layout_manager_;
std::unique_ptr<ui::EventTargeter> targeter_; std::unique_ptr<ui::EventTargeter> targeter_;
void* user_data_;
// Makes the window pass all events through to any windows behind it. // Makes the window pass all events through to any windows behind it.
bool ignore_events_; bool ignore_events_;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
...@@ -69,10 +70,16 @@ ...@@ -69,10 +70,16 @@
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
#endif #endif
DECLARE_WINDOW_PROPERTY_TYPE(views::internal::NativeWidgetPrivate*)
namespace views { namespace views {
namespace { namespace {
DEFINE_WINDOW_PROPERTY_KEY(internal::NativeWidgetPrivate*,
kNativeWidgetPrivateKey,
nullptr);
void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) {
window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
} }
...@@ -110,7 +117,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate, ...@@ -110,7 +117,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
void NativeWidgetAura::RegisterNativeWidgetForWindow( void NativeWidgetAura::RegisterNativeWidgetForWindow(
internal::NativeWidgetPrivate* native_widget, internal::NativeWidgetPrivate* native_widget,
aura::Window* window) { aura::Window* window) {
window->set_user_data(native_widget); window->SetProperty(kNativeWidgetPrivateKey, native_widget);
} }
// static // static
...@@ -1103,15 +1110,13 @@ NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( ...@@ -1103,15 +1110,13 @@ NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
// static // static
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
gfx::NativeView native_view) { gfx::NativeView native_view) {
// Cast must match type supplied to RegisterNativeWidgetForWindow(). return native_view->GetProperty(kNativeWidgetPrivateKey);
return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data());
} }
// static // static
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) { gfx::NativeWindow native_window) {
// Cast must match type supplied to RegisterNativeWidgetForWindow(). return native_window->GetProperty(kNativeWidgetPrivateKey);
return reinterpret_cast<NativeWidgetPrivate*>(native_window->user_data());
} }
// static // static
......
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