mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
LibWeb: Colorize tag names in layout tree dumps + show element IDs
Showing element IDs in layout tree dumps makes it much easier to compare against the DOM.
This commit is contained in:
parent
e45c8b842c
commit
a01fd7ecc5
1 changed files with 15 additions and 2 deletions
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/Utf8View.h>
|
#include <AK/Utf8View.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleSheet.h>
|
#include <LibWeb/CSS/StyleSheet.h>
|
||||||
|
@ -90,13 +91,25 @@ void dump_tree(const LayoutNode& layout_node)
|
||||||
else
|
else
|
||||||
tag_name = "???";
|
tag_name = "???";
|
||||||
|
|
||||||
|
String identifier = "";
|
||||||
|
if (layout_node.node() && is<Element>(*layout_node.node())) {
|
||||||
|
auto id = to<Element>(*layout_node.node()).attribute("id");
|
||||||
|
if (!id.is_empty()) {
|
||||||
|
StringBuilder builder;
|
||||||
|
builder.append('#');
|
||||||
|
builder.append(id);
|
||||||
|
identifier = builder.to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!layout_node.is_box()) {
|
if (!layout_node.is_box()) {
|
||||||
dbgprintf("%s {%s}\n", layout_node.class_name(), tag_name.characters());
|
dbgprintf("%s {\033[33m%s\033[0m%s}\n", layout_node.class_name(), tag_name.characters(), identifier.characters());
|
||||||
} else {
|
} else {
|
||||||
auto& layout_box = to<LayoutBox>(layout_node);
|
auto& layout_box = to<LayoutBox>(layout_node);
|
||||||
dbgprintf("%s {%s} at (%g,%g) size %gx%g",
|
dbgprintf("%s {\033[34m%s\033[0m%s} at (%g,%g) size %gx%g",
|
||||||
layout_box.class_name(),
|
layout_box.class_name(),
|
||||||
tag_name.characters(),
|
tag_name.characters(),
|
||||||
|
identifier.characters(),
|
||||||
layout_box.x(),
|
layout_box.x(),
|
||||||
layout_box.y(),
|
layout_box.y(),
|
||||||
layout_box.width(),
|
layout_box.width(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue