use crate::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use crate::matching::{ElementSelectorFlags, MatchingContext};
use crate::parser::SelectorImpl;
use std::fmt::Debug;
use std::ptr::NonNull;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct OpaqueElement(NonNull<()>);
unsafe impl Send for OpaqueElement {}
impl OpaqueElement {
pub fn new<T>(ptr: &T) -> Self {
unsafe { OpaqueElement(NonNull::new_unchecked(ptr as *const T as *const () as *mut ())) }
}
}
pub trait Element<'i>: Sized + Clone + Debug {
type Impl: SelectorImpl<'i>;
fn opaque(&self) -> OpaqueElement;
fn parent_element(&self) -> Option<Self>;
fn parent_node_is_shadow_root(&self) -> bool;
fn containing_shadow_host(&self) -> Option<Self>;
fn pseudo_element_originating_element(&self) -> Option<Self> {
debug_assert!(self.is_pseudo_element());
self.parent_element()
}
fn is_pseudo_element(&self) -> bool;
fn prev_sibling_element(&self) -> Option<Self>;
fn next_sibling_element(&self) -> Option<Self>;
fn is_html_element_in_html_document(&self) -> bool;
fn has_local_name(&self, local_name: &<Self::Impl as SelectorImpl<'i>>::BorrowedLocalName) -> bool;
fn has_namespace(&self, ns: &<Self::Impl as SelectorImpl<'i>>::BorrowedNamespaceUrl) -> bool;
fn is_same_type(&self, other: &Self) -> bool;
fn attr_matches(
&self,
ns: &NamespaceConstraint<&<Self::Impl as SelectorImpl<'i>>::NamespaceUrl>,
local_name: &<Self::Impl as SelectorImpl<'i>>::LocalName,
operation: &AttrSelectorOperation<&<Self::Impl as SelectorImpl<'i>>::AttrValue>,
) -> bool;
fn match_non_ts_pseudo_class<F>(
&self,
pc: &<Self::Impl as SelectorImpl<'i>>::NonTSPseudoClass,
context: &mut MatchingContext<'_, 'i, Self::Impl>,
flags_setter: &mut F,
) -> bool
where
F: FnMut(&Self, ElementSelectorFlags);
fn match_pseudo_element(
&self,
pe: &<Self::Impl as SelectorImpl<'i>>::PseudoElement,
context: &mut MatchingContext<'_, 'i, Self::Impl>,
) -> bool;
fn is_link(&self) -> bool;
fn is_html_slot_element(&self) -> bool;
fn assigned_slot(&self) -> Option<Self> {
None
}
fn has_id(&self, id: &<Self::Impl as SelectorImpl<'i>>::Identifier, case_sensitivity: CaseSensitivity) -> bool;
fn has_class(
&self,
name: &<Self::Impl as SelectorImpl<'i>>::Identifier,
case_sensitivity: CaseSensitivity,
) -> bool;
fn imported_part(
&self,
name: &<Self::Impl as SelectorImpl<'i>>::Identifier,
) -> Option<<Self::Impl as SelectorImpl<'i>>::Identifier>;
fn is_part(&self, name: &<Self::Impl as SelectorImpl<'i>>::Identifier) -> bool;
fn is_empty(&self) -> bool;
fn is_root(&self) -> bool;
fn ignores_nth_child_selectors(&self) -> bool {
false
}
}