diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-03-04 16:29:05 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-10 17:30:09 +0100 |
commit | 0326ad34dfdd618c8b7b5fbb9f309d1bd8d615fe (patch) | |
tree | 238d3f453953646d20be574b332c8f467a7eae64 /Userland/Applications/Browser/InspectorWidget.cpp | |
parent | 2c970b9516cc2a89a119ea60761f947df71ffb46 (diff) | |
download | serenity-0326ad34dfdd618c8b7b5fbb9f309d1bd8d615fe.zip |
Browser+LibWeb+WebContent: Show style for pseudo-elements :^)
This expands the InspectorWidget::Selection to include an optional
PseudoElement, which is then passed over IPC to request style
information for it.
As noted, this has some pretty big limitations because pseudo-elements
don't have DOM nodes:
- Declared style has to be recalculated when it's requested.
- We don't display the computed style.
- We don't display custom properties.
Diffstat (limited to 'Userland/Applications/Browser/InspectorWidget.cpp')
-rw-r--r-- | Userland/Applications/Browser/InspectorWidget.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp index c369807df7..488f35c8ef 100644 --- a/Userland/Applications/Browser/InspectorWidget.cpp +++ b/Userland/Applications/Browser/InspectorWidget.cpp @@ -46,12 +46,19 @@ void InspectorWidget::set_selection(GUI::ModelIndex const index) auto* json = static_cast<JsonObject const*>(index.internal_data()); VERIFY(json); - Selection selection { json->get("id").to_i32() }; + Selection selection {}; + if (json->has_u32("pseudo-element")) { + selection.dom_node_id = json->get("parent-id").to_i32(); + selection.pseudo_element = static_cast<Web::CSS::Selector::PseudoElement>(json->get("pseudo-element").to_u32()); + } else { + selection.dom_node_id = json->get("id").to_i32(); + } + if (selection == m_selection) return; m_selection = move(selection); - auto maybe_inspected_node_properties = m_web_view->inspect_dom_node(m_inspected_node_id); + auto maybe_inspected_node_properties = m_web_view->inspect_dom_node(m_selection.dom_node_id, m_selection.pseudo_element); if (maybe_inspected_node_properties.has_value()) { auto inspected_node_properties = maybe_inspected_node_properties.value(); load_style_json(inspected_node_properties.specified_values_json, inspected_node_properties.computed_values_json, inspected_node_properties.custom_properties_json); |