diff options
-rw-r--r-- | ash/shelf/shelf_util.cc | 1 | ||||
-rw-r--r-- | ash/touch/touch_uma.cc | 2 | ||||
-rw-r--r-- | ash/wm/system_modal_container_layout_manager.cc | 2 | ||||
-rw-r--r-- | ash/wm/window_properties.cc | 2 | ||||
-rw-r--r-- | athena/extensions/athena_constrained_window_views_client.cc | 2 | ||||
-rw-r--r-- | athena/screen/modal_window_controller.cc | 2 | ||||
-rw-r--r-- | athena/screen/screen_manager_impl.cc | 3 | ||||
-rw-r--r-- | athena/util/fill_layout_manager.cc | 3 | ||||
-rw-r--r-- | athena/wm/window_list_provider_impl.cc | 2 | ||||
-rw-r--r-- | ui/aura/client/aura_constants.cc | 2 | ||||
-rw-r--r-- | ui/aura/client/focus_client.cc | 1 | ||||
-rw-r--r-- | ui/aura/window.h | 6 | ||||
-rw-r--r-- | ui/aura/window_property.h | 90 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 45 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc | 2 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc | 2 | ||||
-rw-r--r-- | ui/wm/core/transient_window_manager.cc | 2 | ||||
-rw-r--r-- | ui/wm/core/window_animations.cc | 2 |
18 files changed, 95 insertions, 76 deletions
diff --git a/ash/shelf/shelf_util.cc b/ash/shelf/shelf_util.cc index f5e2658..70fa02b 100644 --- a/ash/shelf/shelf_util.cc +++ b/ash/shelf/shelf_util.cc @@ -7,7 +7,6 @@ #include "ash/shelf/shelf_constants.h" #include "ui/aura/window_property.h" -DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfID); DECLARE_WINDOW_PROPERTY_TYPE(ash::ShelfItemDetails*); namespace ash { diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc index 1b9348a..9ab7ba4 100644 --- a/ash/touch/touch_uma.cc +++ b/ash/touch/touch_uma.cc @@ -46,6 +46,8 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowTouchDetails, NULL); } +DECLARE_WINDOW_PROPERTY_TYPE(WindowTouchDetails*); + namespace ash { // static diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc index 85916d8..9268458 100644 --- a/ash/wm/system_modal_container_layout_manager.cc +++ b/ash/wm/system_modal_container_layout_manager.cc @@ -30,8 +30,6 @@ #include "ui/views/widget/widget.h" #include "ui/wm/core/compound_event_filter.h" -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, bool); - namespace ash { // If this is set to true, the window will get centered. diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc index d071a5f..f7c8b56 100644 --- a/ash/wm/window_properties.cc +++ b/ash/wm/window_properties.cc @@ -8,8 +8,6 @@ #include "ui/aura/window_property.h" DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WindowState*); -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, gfx::Rect*) -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ui::WindowShowState) namespace ash { diff --git a/athena/extensions/athena_constrained_window_views_client.cc b/athena/extensions/athena_constrained_window_views_client.cc index 1645639..7a89d53 100644 --- a/athena/extensions/athena_constrained_window_views_client.cc +++ b/athena/extensions/athena_constrained_window_views_client.cc @@ -16,6 +16,8 @@ #include "ui/aura/window_observer.h" #include "ui/aura/window_property.h" +DECLARE_WINDOW_PROPERTY_TYPE(web_modal::ModalDialogHost*); + namespace athena { namespace { diff --git a/athena/screen/modal_window_controller.cc b/athena/screen/modal_window_controller.cc index 140b2c9..63d82b6 100644 --- a/athena/screen/modal_window_controller.cc +++ b/athena/screen/modal_window_controller.cc @@ -13,6 +13,8 @@ #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/wm/core/window_animations.h" +DECLARE_WINDOW_PROPERTY_TYPE(athena::ModalWindowController*); + namespace athena { namespace { diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc index 8f960eb..dee725b 100644 --- a/athena/screen/screen_manager_impl.cc +++ b/athena/screen/screen_manager_impl.cc @@ -25,8 +25,7 @@ #include "ui/wm/core/focus_controller.h" #include "ui/wm/core/window_util.h" -// This is to avoid creating type definitoin for kAlwaysOnTopKey. -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool); +DECLARE_WINDOW_PROPERTY_TYPE(athena::ScreenManager::ContainerParams*); namespace athena { namespace { diff --git a/athena/util/fill_layout_manager.cc b/athena/util/fill_layout_manager.cc index 2a3eb22..2fe7722 100644 --- a/athena/util/fill_layout_manager.cc +++ b/athena/util/fill_layout_manager.cc @@ -8,9 +8,6 @@ #include "ui/aura/window.h" #include "ui/aura/window_property.h" -// This is to avoid creating type definitoin for kAlwaysFillWindowKey. -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool); - namespace athena { namespace { diff --git a/athena/wm/window_list_provider_impl.cc b/athena/wm/window_list_provider_impl.cc index 6823a4d..eec4f8b 100644 --- a/athena/wm/window_list_provider_impl.cc +++ b/athena/wm/window_list_provider_impl.cc @@ -13,8 +13,6 @@ #include "ui/wm/core/transient_window_manager.h" #include "ui/wm/core/window_util.h" -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool); - namespace athena { namespace { diff --git a/ui/aura/client/aura_constants.cc b/ui/aura/client/aura_constants.cc index ea64f6a..7d6d89b 100644 --- a/ui/aura/client/aura_constants.cc +++ b/ui/aura/client/aura_constants.cc @@ -12,6 +12,8 @@ DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::ModalType) DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, gfx::Rect*) DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::InputMethod*) DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::WindowShowState) +DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, int) +DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, void*) namespace aura { namespace client { diff --git a/ui/aura/client/focus_client.cc b/ui/aura/client/focus_client.cc index 1f24a80..0f69c5e 100644 --- a/ui/aura/client/focus_client.cc +++ b/ui/aura/client/focus_client.cc @@ -7,7 +7,6 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_property.h" -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, aura::Window*) DECLARE_WINDOW_PROPERTY_TYPE(aura::client::FocusClient*) namespace aura { diff --git a/ui/aura/window.h b/ui/aura/window.h index 229aad6..dbd2d2b 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -52,6 +52,10 @@ class WindowTreeHost; template<typename T> struct WindowProperty; +namespace subtle { +class PropertyHelper; +} + namespace test { class WindowTestApi; } @@ -332,7 +336,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, friend class test::WindowTestApi; friend class LayoutManager; friend class WindowTargeter; - + friend class subtle::PropertyHelper; // Called by the public {Set,Get,Clear}Property functions. int64 SetPropertyInternal(const void* key, const char* name, diff --git a/ui/aura/window_property.h b/ui/aura/window_property.h index 0b1574e..0755c58 100644 --- a/ui/aura/window_property.h +++ b/ui/aura/window_property.h @@ -9,8 +9,7 @@ #include "ui/aura/aura_export.h" #include "ui/aura/window.h" -// This header should be included by code that defines WindowProperties. It -// should not be included by code that only gets and sets WindowProperties. +// This header should be included by code that defines WindowProperties. // // To define a new WindowProperty: // @@ -78,56 +77,71 @@ struct WindowProperty { Window::PropertyDeallocator deallocator; }; -template<typename T> -void Window::SetProperty(const WindowProperty<T>* property, T value) { - int64 old = SetPropertyInternal( - property, - property->name, - value == property->default_value ? NULL : property->deallocator, - WindowPropertyCaster<T>::ToInt64(value), - WindowPropertyCaster<T>::ToInt64(property->default_value)); - if (property->deallocator && - old != WindowPropertyCaster<T>::ToInt64(property->default_value)) { - (*property->deallocator)(old); - } -} +namespace subtle { -template<typename T> -T Window::GetProperty(const WindowProperty<T>* property) const { - return WindowPropertyCaster<T>::FromInt64(GetPropertyInternal( - property, WindowPropertyCaster<T>::ToInt64(property->default_value))); -} +class AURA_EXPORT PropertyHelper { + public: + template<typename T> + static void Set(Window* window, const WindowProperty<T>* property, T value) { + int64 old = window->SetPropertyInternal( + property, + property->name, + value == property->default_value ? nullptr : property->deallocator, + WindowPropertyCaster<T>::ToInt64(value), + WindowPropertyCaster<T>::ToInt64(property->default_value)); + if (property->deallocator && + old != WindowPropertyCaster<T>::ToInt64(property->default_value)) { + (*property->deallocator)(old); + } + } + template<typename T> + static T Get(const Window* window, const WindowProperty<T>* property) { + return WindowPropertyCaster<T>::FromInt64(window->GetPropertyInternal( + property, WindowPropertyCaster<T>::ToInt64(property->default_value))); + } + template<typename T> + static void Clear(Window* window, const WindowProperty<T>* property) { + window->SetProperty(property, property->default_value); \ + } +}; -template<typename T> -void Window::ClearProperty(const WindowProperty<T>* property) { - SetProperty(property, property->default_value); -} +} // namespace subtle } // namespace aura // Macros to instantiate the property getter/setter template functions. #define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \ - template EXPORT void aura::Window::SetProperty( \ - const aura::WindowProperty<T >*, T); \ - template EXPORT T aura::Window::GetProperty( \ - const aura::WindowProperty<T >*) const; \ - template EXPORT void aura::Window::ClearProperty( \ - const aura::WindowProperty<T >*); + namespace aura { \ + template<> EXPORT void aura::Window::SetProperty( \ + const WindowProperty<T >* property, T value) { \ + subtle::PropertyHelper::Set<T>(this, property, value); \ + } \ + template<> EXPORT T Window::GetProperty( \ + const WindowProperty<T >* property) const { \ + return subtle::PropertyHelper::Get<T>(this, property); \ + } \ + template<> EXPORT void Window::ClearProperty( \ + const WindowProperty<T >* property) { \ + subtle::PropertyHelper::Clear<T>(this, property); \ + } \ + } #define DECLARE_WINDOW_PROPERTY_TYPE(T) \ DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T) #define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ - COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \ - namespace { \ - const aura::WindowProperty<TYPE> NAME ## _Value = {DEFAULT, #NAME, NULL}; \ - } \ + COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \ + namespace { \ + const aura::WindowProperty<TYPE> NAME ## _Value = \ + {DEFAULT, #NAME, nullptr}; \ + } \ const aura::WindowProperty<TYPE>* const NAME = & NAME ## _Value; #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ - COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \ - namespace { \ - const aura::WindowProperty<TYPE> NAME ## _Value = {DEFAULT, #NAME, NULL}; \ - const aura::WindowProperty<TYPE>* const NAME = & NAME ## _Value; \ + COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \ + namespace { \ + const aura::WindowProperty<TYPE> NAME ## _Value = \ + {DEFAULT, #NAME, nullptr}; \ + const aura::WindowProperty<TYPE>* const NAME = & NAME ## _Value; \ } #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 9d9c754..9ae01ff 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -45,7 +45,29 @@ #include "ui/gfx/skia_util.h" DECLARE_WINDOW_PROPERTY_TYPE(const char*) -DECLARE_WINDOW_PROPERTY_TYPE(int) + +namespace { + +class TestProperty { + public: + TestProperty() {} + ~TestProperty() { + last_deleted_ = this; + } + static TestProperty* last_deleted() { return last_deleted_; } + + private: + static TestProperty* last_deleted_; + DISALLOW_COPY_AND_ASSIGN(TestProperty); +}; + +TestProperty* TestProperty::last_deleted_ = nullptr; + +DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); + +} // namespace + +DECLARE_WINDOW_PROPERTY_TYPE(TestProperty*); namespace aura { namespace test { @@ -1656,27 +1678,6 @@ TEST_F(WindowTest, Property) { EXPECT_EQ(std::string("squeamish"), w->GetProperty(kStringKey)); } -namespace { - -class TestProperty { - public: - TestProperty() {} - virtual ~TestProperty() { - last_deleted_ = this; - } - static TestProperty* last_deleted() { return last_deleted_; } - - private: - static TestProperty* last_deleted_; - DISALLOW_COPY_AND_ASSIGN(TestProperty); -}; - -TestProperty* TestProperty::last_deleted_ = NULL; - -DEFINE_OWNED_WINDOW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); - -} // namespace - TEST_F(WindowTest, OwnedProperty) { scoped_ptr<Window> w(CreateTestWindowWithId(0, root_window())); EXPECT_EQ(NULL, w->GetProperty(kOwnedKey)); diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc index 15219ca..1e8d67d 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -40,6 +40,8 @@ #include "ui/wm/core/window_animations.h" #include "ui/wm/public/scoped_tooltip_disabler.h" +DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostWin*); + namespace views { namespace { diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index 9a7851d..54d67ad 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -53,6 +53,8 @@ #include "ui/wm/core/compound_event_filter.h" #include "ui/wm/core/window_util.h" +DECLARE_WINDOW_PROPERTY_TYPE(views::DesktopWindowTreeHostX11*); + namespace views { DesktopWindowTreeHostX11* DesktopWindowTreeHostX11::g_current_capture = diff --git a/ui/wm/core/transient_window_manager.cc b/ui/wm/core/transient_window_manager.cc index 923f4a2..2ca145d 100644 --- a/ui/wm/core/transient_window_manager.cc +++ b/ui/wm/core/transient_window_manager.cc @@ -17,6 +17,8 @@ using aura::Window; +DECLARE_WINDOW_PROPERTY_TYPE(wm::TransientWindowManager*); + namespace wm { namespace { diff --git a/ui/wm/core/window_animations.cc b/ui/wm/core/window_animations.cc index 0aa3caa..94e32d6 100644 --- a/ui/wm/core/window_animations.cc +++ b/ui/wm/core/window_animations.cc @@ -38,11 +38,9 @@ #include "ui/wm/core/wm_core_switches.h" #include "ui/wm/public/animation_host.h" -DECLARE_WINDOW_PROPERTY_TYPE(int) DECLARE_WINDOW_PROPERTY_TYPE(wm::WindowVisibilityAnimationType) DECLARE_WINDOW_PROPERTY_TYPE(wm::WindowVisibilityAnimationTransition) DECLARE_WINDOW_PROPERTY_TYPE(float) -DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(WM_EXPORT, bool) namespace wm { namespace { |