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

Unified Diff: ui/aura/window.h

Issue 2632543003: Refactor and push window properties up to class properties. (Closed)
Patch Set: Created 3 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/window.h
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 80770c17b4d567b0980b2b9652e028ca05095cff..54558256bbd01c3a5c539cbfd52da61e0f450446 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -19,6 +19,7 @@
#include "base/strings/string16.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window_observer.h"
+#include "ui/base/class_property.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h"
@@ -53,7 +54,7 @@ class WindowTreeHost;
// Defined in window_property.h (which we do not include)
template<typename T>
-struct WindowProperty;
+using WindowProperty = ui::ClassProperty<T>;
namespace subtle {
class PropertyHelper;
@@ -69,7 +70,8 @@ class WindowTestApi;
class AURA_EXPORT Window : public ui::LayerDelegate,
public ui::LayerOwner,
public ui::EventTarget,
- public ui::GestureConsumer {
+ public ui::GestureConsumer,
+ public ui::PropertyHandler {
public:
// Initial value of id() for newly created windows.
static constexpr int kInitialId = -1;
@@ -295,21 +297,21 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Sets the |value| of the given window |property|. Setting to the default
// value (e.g., NULL) removes the property. The caller is responsible for the
// lifetime of any object set as a property on the Window.
- template<typename T>
- void SetProperty(const WindowProperty<T>* property, T value);
+ //template<typename T>
+ //void SetProperty(const WindowProperty<T>* property, T value);
sky 2017/01/13 20:28:20 Is there a reason you are commenting this out and
kylix_rd 2017/01/13 21:44:59 I'll do a cleanup pass once the substance of these
kylix_rd 2017/01/24 15:14:53 Done.
// Returns the value of the given window |property|. Returns the
// property-specific default value if the property was not previously set.
- template<typename T>
- T GetProperty(const WindowProperty<T>* property) const;
+ //template<typename T>
+ //T GetProperty(const WindowProperty<T>* property) const;
// Sets the |property| to its default value. Useful for avoiding a cast when
// setting to NULL.
- template<typename T>
- void ClearProperty(const WindowProperty<T>* property);
+ //template<typename T>
+ //void ClearProperty(const WindowProperty<T>* property);
// Returns the value of all properties with a non-default value.
- std::set<const void*> GetAllPropertKeys() const;
+ //std::set<const void*> GetAllPropertKeys() const;
// NativeWidget::[GS]etNativeWindowProperty use strings as keys, and this is
// difficult to change while retaining compatibility with other platforms.
@@ -318,7 +320,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void* GetNativeWindowProperty(const char* key) const;
// Type of a function to delete a property that this window owns.
- typedef void (*PropertyDeallocator)(int64_t value);
+ //typedef void (*PropertyDeallocator)(int64_t value);
// Overridden from ui::LayerDelegate:
void OnDeviceScaleFactorChanged(float device_scale_factor) override;
@@ -337,18 +339,24 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// use from the destructor.
void RemoveOrDestroyChildren();
+ // Overrides from ui::PropertyHandler
+ std::unique_ptr<ui::PropertyData> BeforePropertyChange(const void* key)
+ override;
+ void AfterPropertyChange(const void* key,
+ int64_t old_value,
+ std::unique_ptr<ui::PropertyData> data) override;
private:
friend class LayoutManager;
friend class PropertyConverter;
friend class WindowPort;
friend class WindowTargeter;
- friend class subtle::PropertyHelper;
+ //friend class subtle::PropertyHelper;
friend class test::WindowTestApi;
// Called by the public {Set,Get,Clear}Property functions.
int64_t SetPropertyInternal(const void* key,
const char* name,
- PropertyDeallocator deallocator,
+ ui::PropertyDeallocator deallocator,
int64_t value,
int64_t default_value);
int64_t GetPropertyInternal(const void* key, int64_t default_value) const;
@@ -514,13 +522,13 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
// Value struct to keep the name and deallocator for this property.
// Key cannot be used for this purpose because it can be char* or
// WindowProperty<>.
- struct Value {
- const char* name;
- int64_t value;
- PropertyDeallocator deallocator;
- };
+ //struct Value {
+ // const char* name;
+ // int64_t value;
+ // PropertyDeallocator deallocator;
+ //};
- std::map<const void*, Value> prop_map_;
+ //std::map<const void*, Value> prop_map_;
DISALLOW_COPY_AND_ASSIGN(Window);
};
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/window.cc » ('j') | ui/base/class_property.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698