Show correctly computed element display type in devtools (#35870)

Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
This commit is contained in:
Stephen Muss 2025-03-10 23:32:30 +11:00 committed by GitHub
parent 6cfa94f3bc
commit 79e25a3e77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -244,7 +244,7 @@ impl NodeInfoToProtocol for NodeInfo {
causes_overflow: false,
container_type: None,
display_name: self.node_name.clone().to_lowercase(),
display_type: Some("block".into()),
display_type: self.display,
inline_text_child,
is_after_pseudo_element: false,
is_anonymous: false,

View file

@ -52,6 +52,7 @@ use crate::document_loader::DocumentLoader;
use crate::dom::attr::Attr;
use crate::dom::bindings::cell::{DomRefCell, Ref, RefMut};
use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
@ -1207,6 +1208,12 @@ impl Node {
self.ChildNodes().Length() as usize
};
let window = self.owner_window();
let display = self
.downcast::<Element>()
.map(|elem| window.GetComputedStyle(elem, None))
.map(|style| style.Display().into());
NodeInfo {
unique_id: self.unique_id(),
host,
@ -1222,6 +1229,7 @@ impl Node {
attrs: self.downcast().map(Element::summarize).unwrap_or(vec![]),
is_shadow_host,
shadow_root_mode,
display,
}
}

View file

@ -139,6 +139,7 @@ pub struct NodeInfo {
pub is_top_level_document: bool,
pub shadow_root_mode: Option<ShadowRootMode>,
pub is_shadow_host: bool,
pub display: Option<String>,
}
pub struct StartedTimelineMarker {