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

Browser+LibWeb: Add an Element size preview widget to inspector

This Adds an element size preview widget to the inspector widget
in a new tab. This functions similar to chrome and firefox and
shows the margin, border, padding, and content size of the selected
element in the inspector.

The colors for the size preview widget are taken from the chrome
browser.
This commit is contained in:
Vrins 2022-02-27 01:38:12 +01:00 committed by Andreas Kling
parent 3b22fd9a9f
commit 39a5076f40
14 changed files with 234 additions and 18 deletions

View file

@ -8,8 +8,10 @@
#pragma once
#include "ElementSizePreviewWidget.h"
#include <LibGUI/Widget.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/BoxModelMetrics.h>
namespace Browser {
@ -21,7 +23,7 @@ public:
void set_web_view(NonnullRefPtr<Web::OutOfProcessWebView> web_view) { m_web_view = web_view; }
void set_dom_json(String);
void clear_dom_json();
void set_dom_node_properties_json(i32 node_id, String specified_values_json, String computed_values_json, String custom_properties_json);
void set_dom_node_properties_json(i32 node_id, String specified_values_json, String computed_values_json, String custom_properties_json, String node_box_sizing_json);
void set_inspected_node(i32 node_id);
void select_default_node();
@ -31,6 +33,7 @@ private:
void set_inspected_node(GUI::ModelIndex);
void load_style_json(String specified_values_json, String computed_values_json, String custom_properties_json);
void update_node_box_model(Optional<String> node_box_sizing_json);
void clear_style_json();
RefPtr<Web::OutOfProcessWebView> m_web_view;
@ -39,6 +42,9 @@ private:
RefPtr<GUI::TableView> m_style_table_view;
RefPtr<GUI::TableView> m_computed_style_table_view;
RefPtr<GUI::TableView> m_custom_properties_table_view;
RefPtr<ElementSizePreviewWidget> m_element_size_view;
Web::Layout::BoxModelMetrics m_node_box_sizing;
// Multi-process mode
Optional<i32> m_pending_inspect_node_id;