浏览代码

LibWeb: Grey out invisible nodes in the DOM inspector

This makes it easier to navigate large DOM trees where
some nodes have display: none
Simon Wanner 3 年之前
父节点
当前提交
69fc7009bf
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 2 0
      Userland/Libraries/LibWeb/DOM/Node.cpp
  2. 2 0
      Userland/Libraries/LibWeb/DOMTreeModel.cpp

+ 2 - 0
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -793,6 +793,8 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
         MUST(object.add("data"sv, static_cast<DOM::Comment const&>(*this).data()));
     }
 
+    MUST((object.add("visible"sv, !!layout_node())));
+
     if (has_child_nodes()) {
         auto children = MUST(object.add_array("children"));
         for_each_child([&children](DOM::Node& child) {

+ 2 - 0
Userland/Libraries/LibWeb/DOMTreeModel.cpp

@@ -126,6 +126,8 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
             return m_tree_view.palette().syntax_comment();
         if (type == "pseudo-element"sv)
             return m_tree_view.palette().syntax_type();
+        if (!node.get("visible").to_bool(true))
+            return m_tree_view.palette().syntax_comment();
         return {};
     }