1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:37:35 +00:00

LibGUI: Move GML parsing and formatting to new AST

This commit introduces a couple of connected changes that are hard to
untangle, unfortunately:
- Parse GML into the AST instead of JSON
- Change the load_from_json API on Widget to load_from_gml_ast
- Remove this same API from Core::Object as it isn't used outside of
  LibGUI and was a workaround for the object registration detection;
  by verifying the objects we're getting and casting we can remove this
  constraint.
- Format GML by calling the formating APIs on the AST itself; remove
  GMLFormatter.cpp as it's not needed anymore.

After this change, GML formatting already respects comments :^)
This commit is contained in:
kleines Filmröllchen 2022-02-04 17:19:22 +01:00 committed by Andreas Kling
parent 1806b297b6
commit 41ef4f11dc
10 changed files with 127 additions and 236 deletions

View file

@ -8,12 +8,14 @@
#include <AK/EnumBits.h>
#include <AK/JsonObject.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <LibCore/Object.h>
#include <LibGUI/Event.h>
#include <LibGUI/FocusPolicy.h>
#include <LibGUI/Forward.h>
#include <LibGUI/GML/AST.h>
#include <LibGUI/Margins.h>
#include <LibGfx/Color.h>
#include <LibGfx/Forward.h>
@ -299,6 +301,9 @@ public:
bool has_pending_drop() const;
// In order for others to be able to call this, it needs to be public.
virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(const String&));
protected:
Widget();
@ -354,8 +359,6 @@ private:
void focus_previous_widget(FocusSource, bool siblings_only);
void focus_next_widget(FocusSource, bool siblings_only);
virtual bool load_from_json(const JsonObject&, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) override;
// HACK: These are used as property getters for the fixed_* size property aliases.
int dummy_fixed_width() { return 0; }
int dummy_fixed_height() { return 0; }