6262#include < LibWeb/Loader/ResourceLoader.h>
6363#include < LibWeb/Loader/UserAgent.h>
6464#include < LibWeb/Namespace.h>
65+ #include < LibWeb/Painting/FlexboxInspectorOverlay.h>
6566#include < LibWeb/Painting/StackingContext.h>
6667#include < LibWeb/Painting/ViewportPaintable.h>
6768#include < LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
@@ -988,6 +989,21 @@ void ConnectionFromClient::highlight_dom_node(u64 page_id, Web::UniqueNodeID nod
988989 node->document ().set_highlighted_node (node, pseudo_element);
989990}
990991
992+ static Web::Painting::FlexboxInspectorOverlayOptions flexbox_inspector_overlay_options_from_json (JsonValue const & options)
993+ {
994+ Web::Painting::FlexboxInspectorOverlayOptions result;
995+
996+ if (options.is_object ()) {
997+ auto const & object = options.as_object ();
998+ if (auto color = object.get_string (" color" sv); color.has_value ()) {
999+ if (auto parsed_color = Gfx::Color::from_string (*color); parsed_color.has_value ())
1000+ result.color = *parsed_color;
1001+ }
1002+ }
1003+
1004+ return result;
1005+ }
1006+
9911007static Web::Painting::GridInspectorOverlayOptions grid_inspector_overlay_options_from_json (JsonValue const & options)
9921008{
9931009 Web::Painting::GridInspectorOverlayOptions result;
@@ -1011,6 +1027,38 @@ static Web::Painting::GridInspectorOverlayOptions grid_inspector_overlay_options
10111027 return result;
10121028}
10131029
1030+ void ConnectionFromClient::highlight_flexbox (u64 page_id, Web::UniqueNodeID node_id, JsonValue options)
1031+ {
1032+ auto page = this ->page (page_id);
1033+ if (!page.has_value ())
1034+ return ;
1035+
1036+ auto * node = Web::DOM::Node::from_unique_id (node_id);
1037+ if (!node || !node->layout_node ())
1038+ return ;
1039+
1040+ node->document ().set_flexbox_highlighted_node (node, flexbox_inspector_overlay_options_from_json (options));
1041+ }
1042+
1043+ void ConnectionFromClient::clear_flexbox_highlight (u64 page_id, Web::UniqueNodeID node_id)
1044+ {
1045+ auto page = this ->page (page_id);
1046+ if (!page.has_value ())
1047+ return ;
1048+
1049+ if (node_id != 0 ) {
1050+ auto * node = Web::DOM::Node::from_unique_id (node_id);
1051+ if (node)
1052+ node->document ().clear_flexbox_highlighted_node (node);
1053+ return ;
1054+ }
1055+
1056+ for (auto & navigable : Web::HTML::all_navigables ()) {
1057+ if (navigable->active_document ())
1058+ navigable->active_document ()->clear_flexbox_highlighted_node (nullptr );
1059+ }
1060+ }
1061+
10141062void ConnectionFromClient::highlight_grid (u64 page_id, Web::UniqueNodeID node_id, JsonValue options)
10151063{
10161064 auto page = this ->page (page_id);
0 commit comments