mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb: Show element namespace URI in DOM tree dumps
This is helpful when debugging SVG-in-HTML content.
This commit is contained in:
parent
ddcb87fb40
commit
61df035612
Notes:
github-actions[bot]
2025-07-09 12:38:01 +00:00
Author: https://github.com/awesomekling
Commit: 61df035612
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5369
Reviewed-by: https://github.com/gmta ✅
1 changed files with 14 additions and 1 deletions
|
@ -95,7 +95,20 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node)
|
|||
for (int i = 0; i < indent; ++i)
|
||||
builder.append(" "sv);
|
||||
if (is<DOM::Element>(node)) {
|
||||
builder.appendff("<{}", as<DOM::Element>(node).local_name());
|
||||
auto short_namespace = [&] -> FlyString {
|
||||
auto const& namespace_uri = as<DOM::Element>(node).namespace_uri();
|
||||
if (!namespace_uri.has_value())
|
||||
return "n/a"_fly_string;
|
||||
if (namespace_uri == "http://www.w3.org/1999/xhtml"sv)
|
||||
return "html"_fly_string;
|
||||
if (namespace_uri == "http://www.w3.org/2000/svg"sv)
|
||||
return "svg"_fly_string;
|
||||
if (namespace_uri == "http://www.w3.org/1998/Math/MathML"sv)
|
||||
return "mathml"_fly_string;
|
||||
return *namespace_uri;
|
||||
}();
|
||||
|
||||
builder.appendff("<{}:{}", short_namespace, as<DOM::Element>(node).local_name());
|
||||
as<DOM::Element>(node).for_each_attribute([&](auto& name, auto& value) {
|
||||
builder.appendff(" {}={}", name, value);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue