mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
script: Tell devtools whether a node is displayed or not (#38575)
Doing so makes the devtools inspector display the nodes in gray, as it is the case in firefox. The relevant node parameter already exists but is hardcoded. Before: <img width="1108" height="408" alt="image" src="https://github.com/user-attachments/assets/4a442fc9-92db-4a97-9e70-3b02f994a9d1" /> After: <img width="1169" height="404" alt="image" src="https://github.com/user-attachments/assets/ec1674a4-c025-4ceb-93c8-0cc3f695ddc7" /> Testing: We don't have tests for the devtools inspector. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
c4044e17bb
commit
4d7a0d3863
5 changed files with 16 additions and 15 deletions
|
@ -92,13 +92,8 @@ impl Actor for InspectorActor {
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| registry.new_name("walker"));
|
.unwrap_or_else(|| registry.new_name("walker"));
|
||||||
|
|
||||||
let root = root_info.encode(
|
let root =
|
||||||
registry,
|
root_info.encode(registry, self.script_chan.clone(), pipeline, name.clone());
|
||||||
false,
|
|
||||||
self.script_chan.clone(),
|
|
||||||
pipeline,
|
|
||||||
name.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if self.walker.borrow().is_none() {
|
if self.walker.borrow().is_none() {
|
||||||
let walker = WalkerActor {
|
let walker = WalkerActor {
|
||||||
|
|
|
@ -59,6 +59,9 @@ pub struct NodeActorMsg {
|
||||||
is_anonymous: bool,
|
is_anonymous: bool,
|
||||||
is_before_pseudo_element: bool,
|
is_before_pseudo_element: bool,
|
||||||
is_direct_shadow_host_child: Option<bool>,
|
is_direct_shadow_host_child: Option<bool>,
|
||||||
|
/// Whether or not this node is displayed.
|
||||||
|
///
|
||||||
|
/// Setting this value to `false` will cause the devtools to render the node name in gray.
|
||||||
is_displayed: bool,
|
is_displayed: bool,
|
||||||
#[serde(rename = "isInHTMLDocument")]
|
#[serde(rename = "isInHTMLDocument")]
|
||||||
is_in_html_document: Option<bool>,
|
is_in_html_document: Option<bool>,
|
||||||
|
@ -158,7 +161,6 @@ impl Actor for NodeActor {
|
||||||
.ok_or(ActorError::Internal)?;
|
.ok_or(ActorError::Internal)?;
|
||||||
let node = doc_elem_info.encode(
|
let node = doc_elem_info.encode(
|
||||||
registry,
|
registry,
|
||||||
true,
|
|
||||||
self.script_chan.clone(),
|
self.script_chan.clone(),
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
self.walker.clone(),
|
self.walker.clone(),
|
||||||
|
@ -181,7 +183,6 @@ pub trait NodeInfoToProtocol {
|
||||||
fn encode(
|
fn encode(
|
||||||
self,
|
self,
|
||||||
actors: &ActorRegistry,
|
actors: &ActorRegistry,
|
||||||
display: bool,
|
|
||||||
script_chan: IpcSender<DevtoolScriptControlMsg>,
|
script_chan: IpcSender<DevtoolScriptControlMsg>,
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
walker: String,
|
walker: String,
|
||||||
|
@ -192,7 +193,6 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||||
fn encode(
|
fn encode(
|
||||||
self,
|
self,
|
||||||
actors: &ActorRegistry,
|
actors: &ActorRegistry,
|
||||||
display: bool,
|
|
||||||
script_chan: IpcSender<DevtoolScriptControlMsg>,
|
script_chan: IpcSender<DevtoolScriptControlMsg>,
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
walker: String,
|
walker: String,
|
||||||
|
@ -239,7 +239,7 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||||
let mut children = rx.recv().ok()??;
|
let mut children = rx.recv().ok()??;
|
||||||
|
|
||||||
let child = children.pop()?;
|
let child = children.pop()?;
|
||||||
let msg = child.encode(actors, true, script_chan.clone(), pipeline, walker);
|
let msg = child.encode(actors, script_chan.clone(), pipeline, walker);
|
||||||
|
|
||||||
// If the node child is not a text node, do not represent it inline.
|
// If the node child is not a text node, do not represent it inline.
|
||||||
if msg.node_type != TEXT_NODE {
|
if msg.node_type != TEXT_NODE {
|
||||||
|
@ -267,7 +267,7 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||||
is_anonymous: false,
|
is_anonymous: false,
|
||||||
is_before_pseudo_element: false,
|
is_before_pseudo_element: false,
|
||||||
is_direct_shadow_host_child: None,
|
is_direct_shadow_host_child: None,
|
||||||
is_displayed: display,
|
is_displayed: self.is_displayed,
|
||||||
is_in_html_document: Some(true),
|
is_in_html_document: Some(true),
|
||||||
is_marker_pseudo_element: false,
|
is_marker_pseudo_element: false,
|
||||||
is_native_anonymous: false,
|
is_native_anonymous: false,
|
||||||
|
|
|
@ -156,7 +156,6 @@ impl Actor for WalkerActor {
|
||||||
.map(|child| {
|
.map(|child| {
|
||||||
child.encode(
|
child.encode(
|
||||||
registry,
|
registry,
|
||||||
true,
|
|
||||||
self.script_chan.clone(),
|
self.script_chan.clone(),
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
self.name(),
|
self.name(),
|
||||||
|
@ -182,7 +181,6 @@ impl Actor for WalkerActor {
|
||||||
.ok_or(ActorError::Internal)?;
|
.ok_or(ActorError::Internal)?;
|
||||||
let node = doc_elem_info.encode(
|
let node = doc_elem_info.encode(
|
||||||
registry,
|
registry,
|
||||||
true,
|
|
||||||
self.script_chan.clone(),
|
self.script_chan.clone(),
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
self.name(),
|
self.name(),
|
||||||
|
@ -319,7 +317,7 @@ pub fn find_child(
|
||||||
let children = rx.recv().unwrap().ok_or(vec![])?;
|
let children = rx.recv().unwrap().ok_or(vec![])?;
|
||||||
|
|
||||||
for child in children {
|
for child in children {
|
||||||
let msg = child.encode(registry, true, script_chan.clone(), pipeline, name.into());
|
let msg = child.encode(registry, script_chan.clone(), pipeline, name.into());
|
||||||
if compare_fn(&msg) {
|
if compare_fn(&msg) {
|
||||||
hierarchy.push(msg);
|
hierarchy.push(msg);
|
||||||
return Ok(hierarchy);
|
return Ok(hierarchy);
|
||||||
|
|
|
@ -1320,6 +1320,10 @@ impl Node {
|
||||||
is_shadow_host,
|
is_shadow_host,
|
||||||
shadow_root_mode,
|
shadow_root_mode,
|
||||||
display,
|
display,
|
||||||
|
// It is not entirely clear when this should be set to false.
|
||||||
|
// Firefox considers nodes with "display: contents" to be displayed.
|
||||||
|
// The doctype node is displayed despite being `display: none`.
|
||||||
|
is_displayed: !self.is_display_none() || self.is::<DocumentType>(),
|
||||||
doctype_name: self
|
doctype_name: self
|
||||||
.downcast::<DocumentType>()
|
.downcast::<DocumentType>()
|
||||||
.map(DocumentType::name)
|
.map(DocumentType::name)
|
||||||
|
|
|
@ -149,6 +149,10 @@ pub struct NodeInfo {
|
||||||
pub shadow_root_mode: Option<ShadowRootMode>,
|
pub shadow_root_mode: Option<ShadowRootMode>,
|
||||||
pub is_shadow_host: bool,
|
pub is_shadow_host: bool,
|
||||||
pub display: Option<String>,
|
pub display: Option<String>,
|
||||||
|
/// Whether this node is currently displayed.
|
||||||
|
///
|
||||||
|
/// For example, the node might have `display: none`.
|
||||||
|
pub is_displayed: bool,
|
||||||
|
|
||||||
/// The `DOCTYPE` name if this is a `DocumentType` node, `None` otherwise
|
/// The `DOCTYPE` name if this is a `DocumentType` node, `None` otherwise
|
||||||
pub doctype_name: Option<String>,
|
pub doctype_name: Option<String>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue