From cfc7115867f123d8905ff80612954b100e03ed72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Thu, 1 May 2025 08:37:23 +0200 Subject: [PATCH] Send info about the `DocumentType` node to the devtools inspector (#36787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the DOCTYPE tag show up correctly in the inspector. Before: ![image](https://github.com/user-attachments/assets/fd101337-95ce-45ee-8ac5-ae701109eb94) After: ![image](https://github.com/user-attachments/assets/4e80f4c0-6ae4-4c53-88ca-614803caa032) Testing: We don't have devtools tests Signed-off-by: Simon Wülker --- components/devtools/actors/inspector/node.rs | 15 +++++++++++++++ components/script/dom/node.rs | 15 +++++++++++++++ components/shared/devtools/lib.rs | 9 +++++++++ 3 files changed, 39 insertions(+) diff --git a/components/devtools/actors/inspector/node.rs b/components/devtools/actors/inspector/node.rs index 10ff9801844..a731f15b2d8 100644 --- a/components/devtools/actors/inspector/node.rs +++ b/components/devtools/actors/inspector/node.rs @@ -78,6 +78,18 @@ pub struct NodeActorMsg { shadow_root_mode: Option, traits: HashMap, attrs: Vec, + + /// The `DOCTYPE` name if this is a `DocumentType` node, `None` otherwise + #[serde(skip_serializing_if = "Option::is_none")] + name: Option, + + /// The `DOCTYPE` public identifier if this is a `DocumentType` node, `None` otherwise + #[serde(skip_serializing_if = "Option::is_none")] + public_id: Option, + + /// The `DOCTYPE` system identifier if this is a `DocumentType` node, `None` otherwise + #[serde(skip_serializing_if = "Option::is_none")] + system_id: Option, } pub struct NodeActor { @@ -276,6 +288,9 @@ impl NodeInfoToProtocol for NodeInfo { value: attr.value, }) .collect(), + name: self.doctype_name, + public_id: self.doctype_public_identifier, + system_id: self.doctype_system_identifier, } } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 1117eff6d3c..2caec47de25 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1283,6 +1283,21 @@ impl Node { is_shadow_host, shadow_root_mode, display, + doctype_name: self + .downcast::() + .map(DocumentType::name) + .cloned() + .map(String::from), + doctype_public_identifier: self + .downcast::() + .map(DocumentType::public_id) + .cloned() + .map(String::from), + doctype_system_identifier: self + .downcast::() + .map(DocumentType::system_id) + .cloned() + .map(String::from), } } diff --git a/components/shared/devtools/lib.rs b/components/shared/devtools/lib.rs index 0cf99d22658..c07f4529073 100644 --- a/components/shared/devtools/lib.rs +++ b/components/shared/devtools/lib.rs @@ -144,6 +144,15 @@ pub struct NodeInfo { pub shadow_root_mode: Option, pub is_shadow_host: bool, pub display: Option, + + /// The `DOCTYPE` name if this is a `DocumentType` node, `None` otherwise + pub doctype_name: Option, + + /// The `DOCTYPE` public identifier if this is a `DocumentType` node , `None` otherwise + pub doctype_public_identifier: Option, + + /// The `DOCTYPE` system identifier if this is a `DocumentType` node, `None` otherwise + pub doctype_system_identifier: Option, } pub struct StartedTimelineMarker {