mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Lay out Shadow DOM elements (#34701)
When an element is a shadow root, lay out the shadow root elements instead of the non-shadow children. This fixes some tests and introduces some failures, due to bugs in the Shadow DOM implementation. In general, this is very low impact as the Shadow DOM is still disabled by default. At least this gets elements rendering when the preference is turned on though. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
b7460bcb84
commit
50c9c72778
31 changed files with 32 additions and 67 deletions
|
@ -10,6 +10,7 @@ use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSaf
|
||||||
use script_layout_interface::{LayoutElementType, LayoutNodeType};
|
use script_layout_interface::{LayoutElementType, LayoutNodeType};
|
||||||
use selectors::Element as SelectorsElement;
|
use selectors::Element as SelectorsElement;
|
||||||
use servo_arc::Arc as ServoArc;
|
use servo_arc::Arc as ServoArc;
|
||||||
|
use style::dom::{TElement, TShadowRoot};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style::values::generics::counters::{Content, ContentItem};
|
use style::values::generics::counters::{Content, ContentItem};
|
||||||
|
@ -467,6 +468,10 @@ pub(crate) fn iter_child_nodes<'dom, Node>(parent: Node) -> impl Iterator<Item =
|
||||||
where
|
where
|
||||||
Node: NodeExt<'dom>,
|
Node: NodeExt<'dom>,
|
||||||
{
|
{
|
||||||
|
if let Some(shadow) = parent.as_element().and_then(|e| e.shadow_root()) {
|
||||||
|
return iter_child_nodes(shadow.as_node());
|
||||||
|
};
|
||||||
|
|
||||||
let mut next = parent.first_child();
|
let mut next = parent.first_child();
|
||||||
std::iter::from_fn(move || {
|
std::iter::from_fn(move || {
|
||||||
next.inspect(|child| {
|
next.inspect(|child| {
|
||||||
|
|
|
@ -558,19 +558,24 @@ impl Element {
|
||||||
};
|
};
|
||||||
shadow_root.bind_to_tree(&bind_context);
|
shadow_root.bind_to_tree(&bind_context);
|
||||||
|
|
||||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
let node = self.upcast::<Node>();
|
||||||
|
node.dirty(NodeDamage::OtherNodeDamage);
|
||||||
|
node.rev_version();
|
||||||
|
|
||||||
Ok(shadow_root)
|
Ok(shadow_root)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn detach_shadow(&self) {
|
pub fn detach_shadow(&self) {
|
||||||
if let Some(ref shadow_root) = self.shadow_root() {
|
let Some(ref shadow_root) = self.shadow_root() else {
|
||||||
self.upcast::<Node>().note_dirty_descendants();
|
unreachable!("Trying to detach a non-attached shadow root");
|
||||||
shadow_root.detach();
|
};
|
||||||
self.ensure_rare_data().shadow_root = None;
|
|
||||||
} else {
|
let node = self.upcast::<Node>();
|
||||||
debug_assert!(false, "Trying to detach a non-attached shadow root");
|
node.note_dirty_descendants();
|
||||||
}
|
node.rev_version();
|
||||||
|
|
||||||
|
shadow_root.detach();
|
||||||
|
self.ensure_rare_data().shadow_root = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#translation-mode
|
// https://html.spec.whatwg.org/multipage/#translation-mode
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cancel-animation-shadow-slot-invalidation.html]
|
|
||||||
expected: TIMEOUT
|
|
|
@ -1,2 +1,2 @@
|
||||||
[quotes-slot-scoping.html]
|
[quotes-slot-scoping.html]
|
||||||
expected: PASS
|
expected: FAIL
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[display-contents-shadow-host-whitespace.html]
|
|
||||||
expected: FAIL
|
|
2
tests/wpt/meta/css/css-display/display-contents-slot-attach-whitespace.html.ini
vendored
Normal file
2
tests/wpt/meta/css/css-display/display-contents-slot-attach-whitespace.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[display-contents-slot-attach-whitespace.html]
|
||||||
|
expected: FAIL
|
2
tests/wpt/meta/css/css-pseudo/file-selector-button-after-part.html.ini
vendored
Normal file
2
tests/wpt/meta/css/css-pseudo/file-selector-button-after-part.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[file-selector-button-after-part.html]
|
||||||
|
expected: FAIL
|
2
tests/wpt/meta/css/css-text-decor/text-decoration-propagation-shadow.html.ini
vendored
Normal file
2
tests/wpt/meta/css/css-text-decor/text-decoration-propagation-shadow.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[text-decoration-propagation-shadow.html]
|
||||||
|
expected: FAIL
|
2
tests/wpt/meta/dom/slot-recalc.html.ini
vendored
2
tests/wpt/meta/dom/slot-recalc.html.ini
vendored
|
@ -1,2 +0,0 @@
|
||||||
[slot-recalc.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +1,2 @@
|
||||||
[2d.text-outside-of-the-flat-tree.html]
|
[2d.text-outside-of-the-flat-tree.html]
|
||||||
expected: PASS
|
expected: FAIL
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-1.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-2.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-3.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-4.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-5.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-img.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-select-document.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[cross-shadow-boundary-select-root.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[focus-pseudo-on-shadow-host-2.html]
|
|
||||||
expected: FAIL
|
|
2
tests/wpt/meta/shadow-dom/layout-slot-no-longer-fallback.html.ini
vendored
Normal file
2
tests/wpt/meta/shadow-dom/layout-slot-no-longer-fallback.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[layout-slot-no-longer-fallback.html]
|
||||||
|
expected: FAIL
|
|
@ -1,16 +1,4 @@
|
||||||
[offsetParent-across-shadow-boundaries.html]
|
[offsetParent-across-shadow-boundaries.html]
|
||||||
[offsetParent must return the offset parent in the same shadow tree of open mode]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[offsetParent must return the offset parent in the same shadow tree of closed mode]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[offsetParent must return the offset parent in the same shadow tree of open mode even when nested]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[offsetParent must return the offset parent in the same shadow tree of closed mode even when nested]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[offsetParent must skip offset parents of an element when the context object is assigned to a slot in a shadow tree of open mode]
|
[offsetParent must skip offset parents of an element when the context object is assigned to a slot in a shadow tree of open mode]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[shadow-style-invalidation-vw-units.html]
|
|
||||||
expected: FAIL
|
|
2
tests/wpt/meta/shadow-dom/slot-fallback-content-001.html.ini
vendored
Normal file
2
tests/wpt/meta/shadow-dom/slot-fallback-content-001.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[slot-fallback-content-001.html]
|
||||||
|
expected: FAIL
|
2
tests/wpt/meta/shadow-dom/slot-fallback-content-002.html.ini
vendored
Normal file
2
tests/wpt/meta/shadow-dom/slot-fallback-content-002.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[slot-fallback-content-002.html]
|
||||||
|
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
||||||
[slot-fallback-content-003.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[slot-fallback-content-004.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[slot-fallback-content-005.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[test-002.html]
|
|
||||||
[A_10_02_02_02_T01]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[nested_tree_reftest.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[shadow-root-001.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,6 +0,0 @@
|
||||||
[test-001.html]
|
|
||||||
[A_06_00_01_T01]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A_06_00_01_T02]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue