mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Hide servo internal shadow roots from the inspector by default (#35958)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
4a9967725f
commit
e627ac5cfd
5 changed files with 27 additions and 4 deletions
|
@ -146,6 +146,8 @@ pub struct Preferences {
|
||||||
/// Whether or not subpixel antialiasing is enabled for text rendering.
|
/// Whether or not subpixel antialiasing is enabled for text rendering.
|
||||||
pub gfx_subpixel_text_antialiasing_enabled: bool,
|
pub gfx_subpixel_text_antialiasing_enabled: bool,
|
||||||
pub gfx_texture_swizzling_enabled: bool,
|
pub gfx_texture_swizzling_enabled: bool,
|
||||||
|
/// Whether or not the DOM inspector should show shadow roots of user-agent shadow trees
|
||||||
|
pub inspector_show_servo_internal_shadow_roots: bool,
|
||||||
pub js_asmjs_enabled: bool,
|
pub js_asmjs_enabled: bool,
|
||||||
pub js_asyncstack: bool,
|
pub js_asyncstack: bool,
|
||||||
pub js_baseline_interpreter_enabled: bool,
|
pub js_baseline_interpreter_enabled: bool,
|
||||||
|
@ -312,6 +314,7 @@ impl Preferences {
|
||||||
gfx_text_antialiasing_enabled: true,
|
gfx_text_antialiasing_enabled: true,
|
||||||
gfx_subpixel_text_antialiasing_enabled: true,
|
gfx_subpixel_text_antialiasing_enabled: true,
|
||||||
gfx_texture_swizzling_enabled: true,
|
gfx_texture_swizzling_enabled: true,
|
||||||
|
inspector_show_servo_internal_shadow_roots: false,
|
||||||
js_asmjs_enabled: true,
|
js_asmjs_enabled: true,
|
||||||
js_asyncstack: false,
|
js_asyncstack: false,
|
||||||
js_baseline_interpreter_enabled: true,
|
js_baseline_interpreter_enabled: true,
|
||||||
|
|
|
@ -14,6 +14,7 @@ use devtools_traits::{
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::ToString;
|
use js::rust::ToString;
|
||||||
|
use servo_config::pref;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::document_collection::DocumentCollection;
|
use crate::document_collection::DocumentCollection;
|
||||||
|
@ -162,8 +163,12 @@ pub(crate) fn handle_get_children(
|
||||||
|
|
||||||
let mut children = vec![];
|
let mut children = vec![];
|
||||||
if let Some(shadow_root) = parent.downcast::<Element>().and_then(Element::shadow_root) {
|
if let Some(shadow_root) = parent.downcast::<Element>().and_then(Element::shadow_root) {
|
||||||
|
if !shadow_root.is_user_agent_widget() ||
|
||||||
|
pref!(inspector_show_servo_internal_shadow_roots)
|
||||||
|
{
|
||||||
children.push(shadow_root.upcast::<Node>().summarize());
|
children.push(shadow_root.upcast::<Node>().summarize());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let children_iter = parent.children().enumerate().filter_map(|(i, child)| {
|
let children_iter = parent.children().enumerate().filter_map(|(i, child)| {
|
||||||
// Filter whitespace only text nodes that are not inline level
|
// Filter whitespace only text nodes that are not inline level
|
||||||
// https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_html/index.html#whitespace-only-text-nodes
|
// https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_html/index.html#whitespace-only-text-nodes
|
||||||
|
|
|
@ -542,6 +542,7 @@ impl Element {
|
||||||
mode,
|
mode,
|
||||||
slot_assignment_mode,
|
slot_assignment_mode,
|
||||||
clonable,
|
clonable,
|
||||||
|
is_ua_widget,
|
||||||
can_gc,
|
can_gc,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ use selectors::matching::{
|
||||||
};
|
};
|
||||||
use selectors::parser::SelectorList;
|
use selectors::parser::SelectorList;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
use servo_config::pref;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use style::context::QuirksMode;
|
use style::context::QuirksMode;
|
||||||
|
@ -1209,9 +1210,12 @@ impl Node {
|
||||||
let host = maybe_shadow_root
|
let host = maybe_shadow_root
|
||||||
.map(ShadowRoot::Host)
|
.map(ShadowRoot::Host)
|
||||||
.map(|host| host.upcast::<Node>().unique_id());
|
.map(|host| host.upcast::<Node>().unique_id());
|
||||||
let is_shadow_host = self
|
let is_shadow_host = self.downcast::<Element>().is_some_and(|potential_host| {
|
||||||
.downcast::<Element>()
|
let Some(root) = potential_host.shadow_root() else {
|
||||||
.is_some_and(Element::is_shadow_host);
|
return false;
|
||||||
|
};
|
||||||
|
!root.is_user_agent_widget() || pref!(inspector_show_servo_internal_shadow_roots)
|
||||||
|
});
|
||||||
|
|
||||||
let num_children = if is_shadow_host {
|
let num_children = if is_shadow_host {
|
||||||
// Shadow roots count as children
|
// Shadow roots count as children
|
||||||
|
|
|
@ -77,6 +77,8 @@ pub(crate) struct ShadowRoot {
|
||||||
available_to_element_internals: Cell<bool>,
|
available_to_element_internals: Cell<bool>,
|
||||||
|
|
||||||
slots: DomRefCell<HashMap<DOMString, Vec<Dom<HTMLSlotElement>>>>,
|
slots: DomRefCell<HashMap<DOMString, Vec<Dom<HTMLSlotElement>>>>,
|
||||||
|
|
||||||
|
is_user_agent_widget: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShadowRoot {
|
impl ShadowRoot {
|
||||||
|
@ -87,6 +89,7 @@ impl ShadowRoot {
|
||||||
mode: ShadowRootMode,
|
mode: ShadowRootMode,
|
||||||
slot_assignment_mode: SlotAssignmentMode,
|
slot_assignment_mode: SlotAssignmentMode,
|
||||||
clonable: bool,
|
clonable: bool,
|
||||||
|
is_user_agent_widget: IsUserAgentWidget,
|
||||||
) -> ShadowRoot {
|
) -> ShadowRoot {
|
||||||
let document_fragment = DocumentFragment::new_inherited(document);
|
let document_fragment = DocumentFragment::new_inherited(document);
|
||||||
let node = document_fragment.upcast::<Node>();
|
let node = document_fragment.upcast::<Node>();
|
||||||
|
@ -109,6 +112,7 @@ impl ShadowRoot {
|
||||||
clonable,
|
clonable,
|
||||||
available_to_element_internals: Cell::new(false),
|
available_to_element_internals: Cell::new(false),
|
||||||
slots: Default::default(),
|
slots: Default::default(),
|
||||||
|
is_user_agent_widget: is_user_agent_widget == IsUserAgentWidget::Yes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +122,7 @@ impl ShadowRoot {
|
||||||
mode: ShadowRootMode,
|
mode: ShadowRootMode,
|
||||||
slot_assignment_mode: SlotAssignmentMode,
|
slot_assignment_mode: SlotAssignmentMode,
|
||||||
clonable: bool,
|
clonable: bool,
|
||||||
|
is_user_agent_widget: IsUserAgentWidget,
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ShadowRoot> {
|
) -> DomRoot<ShadowRoot> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
|
@ -127,6 +132,7 @@ impl ShadowRoot {
|
||||||
mode,
|
mode,
|
||||||
slot_assignment_mode,
|
slot_assignment_mode,
|
||||||
clonable,
|
clonable,
|
||||||
|
is_user_agent_widget,
|
||||||
)),
|
)),
|
||||||
document.window(),
|
document.window(),
|
||||||
can_gc,
|
can_gc,
|
||||||
|
@ -266,6 +272,10 @@ impl ShadowRoot {
|
||||||
pub(crate) fn is_available_to_element_internals(&self) -> bool {
|
pub(crate) fn is_available_to_element_internals(&self) -> bool {
|
||||||
self.available_to_element_internals.get()
|
self.available_to_element_internals.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_user_agent_widget(&self) -> bool {
|
||||||
|
self.is_user_agent_widget
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShadowRootMethods<crate::DomTypeHolder> for ShadowRoot {
|
impl ShadowRootMethods<crate::DomTypeHolder> for ShadowRoot {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue