1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:27:34 +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:
kleines Filmröllchen 2022-03-24 15:56:09 +01:00 committed by Andreas Kling
parent ee4cec4ea9
commit 452bbcaa84

View file

@ -323,17 +323,17 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
property_name, \ property_name, \
[this] { \ [this] { \
auto size = this->getter(); \ auto size = this->getter(); \
JsonObject size_object; \ JsonArray size_array; \
size_object.set("width", size.width()); \ size_array.append(size.width()); \
size_object.set("height", size.height()); \ size_array.append(size.height()); \
return size_object; \ return size_array; \
}, \ }, \
[this](auto& value) { \ [this](auto& value) { \
if (!value.is_object()) \ if (!value.is_array()) \
return false; \ return false; \
Gfx::IntSize size; \ Gfx::IntSize size; \
size.set_width(value.as_object().get("width").to_i32()); \ size.set_width(value.as_array()[0].to_i32()); \
size.set_height(value.as_object().get("height").to_i32()); \ size.set_height(value.as_array()[1].to_i32()); \
setter(size); \ setter(size); \
return true; \ return true; \
}); });