mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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.
|
||||
pub gfx_subpixel_text_antialiasing_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_asyncstack: bool,
|
||||
pub js_baseline_interpreter_enabled: bool,
|
||||
|
@ -312,6 +314,7 @@ impl Preferences {
|
|||
gfx_text_antialiasing_enabled: true,
|
||||
gfx_subpixel_text_antialiasing_enabled: true,
|
||||
gfx_texture_swizzling_enabled: true,
|
||||
inspector_show_servo_internal_shadow_roots: false,
|
||||
js_asmjs_enabled: true,
|
||||
js_asyncstack: false,
|
||||
js_baseline_interpreter_enabled: true,
|
||||
|
|
|
@ -14,6 +14,7 @@ use devtools_traits::{
|
|||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::ToString;
|
||||
use servo_config::pref;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::document_collection::DocumentCollection;
|
||||
|
@ -162,7 +163,11 @@ pub(crate) fn handle_get_children(
|
|||
|
||||
let mut children = vec![];
|
||||
if let Some(shadow_root) = parent.downcast::<Element>().and_then(Element::shadow_root) {
|
||||
children.push(shadow_root.upcast::<Node>().summarize());
|
||||
if !shadow_root.is_user_agent_widget() ||
|
||||
pref!(inspector_show_servo_internal_shadow_roots)
|
||||
{
|
||||
children.push(shadow_root.upcast::<Node>().summarize());
|
||||
}
|
||||
}
|
||||
let children_iter = parent.children().enumerate().filter_map(|(i, child)| {
|
||||
// Filter whitespace only text nodes that are not inline level
|
||||
|
|
|
@ -542,6 +542,7 @@ impl Element {
|
|||
mode,
|
||||
slot_assignment_mode,
|
||||
clonable,
|
||||
is_ua_widget,
|
||||
can_gc,
|
||||
);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ use selectors::matching::{
|
|||
};
|
||||
use selectors::parser::SelectorList;
|
||||
use servo_arc::Arc;
|
||||
use servo_config::pref;
|
||||
use servo_url::ServoUrl;
|
||||
use smallvec::SmallVec;
|
||||
use style::context::QuirksMode;
|
||||
|
@ -1209,9 +1210,12 @@ impl Node {
|
|||
let host = maybe_shadow_root
|
||||
.map(ShadowRoot::Host)
|
||||
.map(|host| host.upcast::<Node>().unique_id());
|
||||
let is_shadow_host = self
|
||||
.downcast::<Element>()
|
||||
.is_some_and(Element::is_shadow_host);
|
||||
let is_shadow_host = self.downcast::<Element>().is_some_and(|potential_host| {
|
||||
let Some(root) = potential_host.shadow_root() else {
|
||||
return false;
|
||||
};
|
||||
!root.is_user_agent_widget() || pref!(inspector_show_servo_internal_shadow_roots)
|
||||
});
|
||||
|
||||
let num_children = if is_shadow_host {
|
||||
// Shadow roots count as children
|
||||
|
|
|
@ -77,6 +77,8 @@ pub(crate) struct ShadowRoot {
|
|||
available_to_element_internals: Cell<bool>,
|
||||
|
||||
slots: DomRefCell<HashMap<DOMString, Vec<Dom<HTMLSlotElement>>>>,
|
||||
|
||||
is_user_agent_widget: bool,
|
||||
}
|
||||
|
||||
impl ShadowRoot {
|
||||
|
@ -87,6 +89,7 @@ impl ShadowRoot {
|
|||
mode: ShadowRootMode,
|
||||
slot_assignment_mode: SlotAssignmentMode,
|
||||
clonable: bool,
|
||||
is_user_agent_widget: IsUserAgentWidget,
|
||||
) -> ShadowRoot {
|
||||
let document_fragment = DocumentFragment::new_inherited(document);
|
||||
let node = document_fragment.upcast::<Node>();
|
||||
|
@ -109,6 +112,7 @@ impl ShadowRoot {
|
|||
clonable,
|
||||
available_to_element_internals: Cell::new(false),
|
||||
slots: Default::default(),
|
||||
is_user_agent_widget: is_user_agent_widget == IsUserAgentWidget::Yes,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +122,7 @@ impl ShadowRoot {
|
|||
mode: ShadowRootMode,
|
||||
slot_assignment_mode: SlotAssignmentMode,
|
||||
clonable: bool,
|
||||
is_user_agent_widget: IsUserAgentWidget,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<ShadowRoot> {
|
||||
reflect_dom_object(
|
||||
|
@ -127,6 +132,7 @@ impl ShadowRoot {
|
|||
mode,
|
||||
slot_assignment_mode,
|
||||
clonable,
|
||||
is_user_agent_widget,
|
||||
)),
|
||||
document.window(),
|
||||
can_gc,
|
||||
|
@ -266,6 +272,10 @@ impl ShadowRoot {
|
|||
pub(crate) fn is_available_to_element_internals(&self) -> bool {
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue