mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #19878 - emilio:slotted-slot, r=nox
selectors: Never match ::slotted on <slot>s. This fixes the test from https://github.com/w3c/web-platform-tests/pull/9212 in Gecko. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19878) <!-- Reviewable:end -->
This commit is contained in:
commit
82922c97dc
7 changed files with 36 additions and 7 deletions
|
@ -784,6 +784,13 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_html_slot_element(&self) -> bool {
|
||||||
|
unsafe {
|
||||||
|
self.element.is_html_element() &&
|
||||||
|
self.get_local_name() == &local_name!("slot")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn is_html_element_in_html_document(&self) -> bool {
|
fn is_html_element_in_html_document(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !self.element.is_html_element() {
|
if !self.element.is_html_element() {
|
||||||
|
@ -1176,6 +1183,10 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_html_slot_element(&self) -> bool {
|
||||||
|
self.element.is_html_slot_element()
|
||||||
|
}
|
||||||
|
|
||||||
fn is_html_element_in_html_document(&self) -> bool {
|
fn is_html_element_in_html_document(&self) -> bool {
|
||||||
debug!("ServoThreadSafeLayoutElement::is_html_element_in_html_document called");
|
debug!("ServoThreadSafeLayoutElement::is_html_element_in_html_document called");
|
||||||
true
|
true
|
||||||
|
|
|
@ -916,8 +916,12 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element {
|
impl Element {
|
||||||
|
pub fn is_html_element(&self) -> bool {
|
||||||
|
self.namespace == ns!(html)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn html_element_in_html_document(&self) -> bool {
|
pub fn html_element_in_html_document(&self) -> bool {
|
||||||
self.namespace == ns!(html) && self.upcast::<Node>().is_in_html_doc()
|
self.is_html_element() && self.upcast::<Node>().is_in_html_doc()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_name(&self) -> &LocalName {
|
pub fn local_name(&self) -> &LocalName {
|
||||||
|
@ -2713,6 +2717,10 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
||||||
fn is_html_element_in_html_document(&self) -> bool {
|
fn is_html_element_in_html_document(&self) -> bool {
|
||||||
self.html_element_in_html_document()
|
self.html_element_in_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_html_slot_element(&self) -> bool {
|
||||||
|
self.is_html_element() && self.local_name() == &local_name!("slot")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,7 @@ where
|
||||||
element.parent_element()
|
element.parent_element()
|
||||||
}
|
}
|
||||||
Combinator::SlotAssignment => {
|
Combinator::SlotAssignment => {
|
||||||
|
debug_assert!(element.assigned_slot().map_or(true, |s| s.is_html_slot_element()));
|
||||||
element.assigned_slot()
|
element.assigned_slot()
|
||||||
}
|
}
|
||||||
Combinator::PseudoElement => {
|
Combinator::PseudoElement => {
|
||||||
|
@ -631,6 +632,8 @@ where
|
||||||
Component::Combinator(_) => unreachable!(),
|
Component::Combinator(_) => unreachable!(),
|
||||||
Component::Slotted(ref selector) => {
|
Component::Slotted(ref selector) => {
|
||||||
context.shared.nest(|context| {
|
context.shared.nest(|context| {
|
||||||
|
// <slots> are never flattened tree slottables.
|
||||||
|
!element.is_html_slot_element() &&
|
||||||
element.assigned_slot().is_some() &&
|
element.assigned_slot().is_some() &&
|
||||||
matches_complex_selector(
|
matches_complex_selector(
|
||||||
selector.iter(),
|
selector.iter(),
|
||||||
|
|
|
@ -82,6 +82,9 @@ pub trait Element: Sized + Clone + Debug {
|
||||||
/// Whether this element is a `link`.
|
/// Whether this element is a `link`.
|
||||||
fn is_link(&self) -> bool;
|
fn is_link(&self) -> bool;
|
||||||
|
|
||||||
|
/// Returns whether the element is an HTML <slot> element.
|
||||||
|
fn is_html_slot_element(&self) -> bool;
|
||||||
|
|
||||||
/// Returns the assigned <slot> element this element is assigned to.
|
/// Returns the assigned <slot> element this element is assigned to.
|
||||||
///
|
///
|
||||||
/// Necessary for the `::slotted` pseudo-class.
|
/// Necessary for the `::slotted` pseudo-class.
|
||||||
|
|
|
@ -419,12 +419,6 @@ pub trait TElement
|
||||||
/// Return whether this element is an element in the HTML namespace.
|
/// Return whether this element is an element in the HTML namespace.
|
||||||
fn is_html_element(&self) -> bool;
|
fn is_html_element(&self) -> bool;
|
||||||
|
|
||||||
/// Returns whether this element is a <html:slot> element.
|
|
||||||
fn is_html_slot_element(&self) -> bool {
|
|
||||||
self.get_local_name() == &*local_name!("slot") &&
|
|
||||||
self.is_html_element()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the list of slotted nodes of this node.
|
/// Return the list of slotted nodes of this node.
|
||||||
fn slotted_nodes(&self) -> &[Self::ConcreteNode] {
|
fn slotted_nodes(&self) -> &[Self::ConcreteNode] {
|
||||||
&[]
|
&[]
|
||||||
|
|
|
@ -2205,6 +2205,12 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
self.as_node().owner_doc().is_html_document()
|
self.as_node().owner_doc().is_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_html_slot_element(&self) -> bool {
|
||||||
|
self.is_html_element() &&
|
||||||
|
self.get_local_name().as_ptr() == local_name!("slot").as_ptr()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ignores_nth_child_selectors(&self) -> bool {
|
fn ignores_nth_child_selectors(&self) -> bool {
|
||||||
self.is_root_of_anonymous_subtree()
|
self.is_root_of_anonymous_subtree()
|
||||||
|
|
|
@ -295,6 +295,10 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
self.element.is_html_element_in_html_document()
|
self.element.is_html_element_in_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_html_slot_element(&self) -> bool {
|
||||||
|
self.element.is_html_slot_element()
|
||||||
|
}
|
||||||
|
|
||||||
fn get_local_name(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName {
|
fn get_local_name(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName {
|
||||||
self.element.get_local_name()
|
self.element.get_local_name()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue