Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: ui/aura/window_property.h

Issue 2499933003: Expand aura::PropertyConverter support. (Closed)
Patch Set: Fix the other new unit test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/test/aura_test_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_AURA_WINDOW_PROPERTY_H_ 5 #ifndef UI_AURA_WINDOW_PROPERTY_H_
6 #define UI_AURA_WINDOW_PROPERTY_H_ 6 #define UI_AURA_WINDOW_PROPERTY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "ui/aura/aura_export.h" 10 #include "ui/aura/aura_export.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 static void Clear(Window* window, const WindowProperty<T>* property) { 103 static void Clear(Window* window, const WindowProperty<T>* property) {
104 window->SetProperty(property, property->default_value); \ 104 window->SetProperty(property, property->default_value); \
105 } 105 }
106 }; 106 };
107 107
108 } // namespace subtle 108 } // namespace subtle
109 109
110 } // namespace aura 110 } // namespace aura
111 111
112 // Macros to instantiate the property getter/setter template functions. 112 // Macros to instantiate the property getter/setter template functions.
113 #define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \ 113 #define DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(EXPORT, T) \
114 namespace aura { \ 114 namespace aura { \
115 template<> EXPORT void aura::Window::SetProperty( \ 115 template <> \
116 const WindowProperty<T >* property, T value) { \ 116 EXPORT void Window::SetProperty(const WindowProperty<T>* property, \
117 subtle::PropertyHelper::Set<T>(this, property, value); \ 117 T value) { \
118 } \ 118 subtle::PropertyHelper::Set<T>(this, property, value); \
119 template<> EXPORT T Window::GetProperty( \ 119 } \
120 const WindowProperty<T >* property) const { \ 120 template <> \
121 return subtle::PropertyHelper::Get<T>(this, property); \ 121 EXPORT T Window::GetProperty(const WindowProperty<T>* property) const { \
122 } \ 122 return subtle::PropertyHelper::Get<T>(this, property); \
123 template<> EXPORT void Window::ClearProperty( \ 123 } \
124 const WindowProperty<T >* property) { \ 124 template <> \
125 subtle::PropertyHelper::Clear<T>(this, property); \ 125 EXPORT void Window::ClearProperty(const WindowProperty<T>* property) { \
126 } \ 126 subtle::PropertyHelper::Clear<T>(this, property); \
127 } 127 } \
128 }
128 #define DECLARE_WINDOW_PROPERTY_TYPE(T) \ 129 #define DECLARE_WINDOW_PROPERTY_TYPE(T) \
129 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T) 130 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(, T)
130 131
131 #define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 132 #define DEFINE_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
132 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property type too large"); \ 133 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property type too large"); \
133 namespace { \ 134 namespace { \
134 const aura::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ 135 const aura::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
135 } \ 136 } \
136 const aura::WindowProperty<TYPE>* const NAME = &NAME##_Value; 137 const aura::WindowProperty<TYPE>* const NAME = &NAME##_Value;
137 138
138 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 139 #define DEFINE_LOCAL_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
139 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property type too large"); \ 140 static_assert(sizeof(TYPE) <= sizeof(int64_t), "property type too large"); \
140 namespace { \ 141 namespace { \
141 const aura::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ 142 const aura::WindowProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
142 const aura::WindowProperty<TYPE>* const NAME = &NAME##_Value; \ 143 const aura::WindowProperty<TYPE>* const NAME = &NAME##_Value; \
143 } 144 }
144 145
145 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ 146 #define DEFINE_OWNED_WINDOW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
146 namespace { \ 147 namespace { \
147 void Deallocator##NAME(int64_t p) { \ 148 void Deallocator##NAME(int64_t p) { \
148 enum { type_must_be_complete = sizeof(TYPE) }; \ 149 enum { type_must_be_complete = sizeof(TYPE) }; \
149 delete aura::WindowPropertyCaster<TYPE*>::FromInt64(p); \ 150 delete aura::WindowPropertyCaster<TYPE*>::FromInt64(p); \
150 } \ 151 } \
151 const aura::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \ 152 const aura::WindowProperty<TYPE*> NAME##_Value = {DEFAULT, #NAME, \
152 &Deallocator##NAME}; \ 153 &Deallocator##NAME}; \
153 } \ 154 } \
154 const aura::WindowProperty<TYPE*>* const NAME = &NAME##_Value; 155 const aura::WindowProperty<TYPE*>* const NAME = &NAME##_Value;
155 156
156 #endif // UI_AURA_WINDOW_PROPERTY_H_ 157 #endif // UI_AURA_WINDOW_PROPERTY_H_
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698