mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibCore: Turn size properties from an object into a size 2 array
Previously, size properties were a JSON object of the form { "width": x, "height": y }. Now they are a JSON array [x, y]. Reasons for this change: - Much more concise. - More intuitive, as existing multi-dimensional properties (like margins) already use this array format.
This commit is contained in:
parent
ee4cec4ea9
commit
452bbcaa84
Notes:
sideshowbarker
2024-07-17 14:34:25 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/452bbcaa84 Pull-request: https://github.com/SerenityOS/serenity/pull/13125
1 changed files with 18 additions and 18 deletions
|
@ -318,24 +318,24 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
|
|||
return true; \
|
||||
});
|
||||
|
||||
#define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \
|
||||
register_property( \
|
||||
property_name, \
|
||||
[this] { \
|
||||
auto size = this->getter(); \
|
||||
JsonObject size_object; \
|
||||
size_object.set("width", size.width()); \
|
||||
size_object.set("height", size.height()); \
|
||||
return size_object; \
|
||||
}, \
|
||||
[this](auto& value) { \
|
||||
if (!value.is_object()) \
|
||||
return false; \
|
||||
Gfx::IntSize size; \
|
||||
size.set_width(value.as_object().get("width").to_i32()); \
|
||||
size.set_height(value.as_object().get("height").to_i32()); \
|
||||
setter(size); \
|
||||
return true; \
|
||||
#define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \
|
||||
register_property( \
|
||||
property_name, \
|
||||
[this] { \
|
||||
auto size = this->getter(); \
|
||||
JsonArray size_array; \
|
||||
size_array.append(size.width()); \
|
||||
size_array.append(size.height()); \
|
||||
return size_array; \
|
||||
}, \
|
||||
[this](auto& value) { \
|
||||
if (!value.is_array()) \
|
||||
return false; \
|
||||
Gfx::IntSize size; \
|
||||
size.set_width(value.as_array()[0].to_i32()); \
|
||||
size.set_height(value.as_array()[1].to_i32()); \
|
||||
setter(size); \
|
||||
return true; \
|
||||
});
|
||||
|
||||
#define REGISTER_ENUM_PROPERTY(property_name, getter, setter, EnumType, ...) \
|
||||
|
|
Loading…
Reference in a new issue