commit | 490a005bad0ad30e394f5567459c271c9afea663 | [log] [tgz] |
---|---|---|
author | Dana Fried <dfried@chromium.org> | Wed Jun 19 01:05:02 2019 |
committer | Commit Bot <commit-bot@chromium.org> | Wed Jun 19 01:05:02 2019 |
tree | 82ef7889f4ea6b6bf6b3f6a81edd53250304023f | |
parent | b4569facf70084936c10d08e5b8d3152c70a518c [diff] |
Allow setting class properties by value for assignable types. Most of our Views class properties are of type ClassProperty<T*> where T is a value type, but we're forced to use pointers because T can be of any type and must therefore be allocated on the heap. This leads to a lot of code like: my_view->SetProperty(kMarginsKey, new Insets(kMyViewDefaultInsets)); ... *my_view->GetProperty(kMarginsKey) = new_insets; (The latter pattern is to prevent a second heap allocation - but only works if the initial allocation happens; otherwise it crashes.) This CL shortcuts this behavior so that it behaves in the way we actually want to use the system 90% of the time: // Allocates a copy of kMyViewDefaultInsets for the property. my_view->SetProperty(kMarginsKey, kMyViewDefaultInsets); // Updates the value of the existing property. my_view->SetProperty(kMarginsKey, new_insets); // De-allocates the existing property value. my_view->ClearProperty(kMarginsKey); In order to use this new functionality: - The property must be an owned property of pointer type. - The property type behind the pointer must be copy- or move-assignable. Change-Id: Idec1d5b9c104814f234270214b615774fa5a7084 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1657288 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Dana Fried <dfried@chromium.org> Cr-Commit-Position: refs/heads/master@{#670329}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .