mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +01:00
style: Do not use borrowed types in the selectors::Element trait.
Closes #22972 Closes #23463
This commit is contained in:
parent
2e5078e9c5
commit
6f1df517e0
8 changed files with 100 additions and 42 deletions
|
@ -882,6 +882,13 @@ pub trait TElement:
|
|||
hints: &mut V,
|
||||
) where
|
||||
V: Push<ApplicableDeclarationBlock>;
|
||||
|
||||
/// Returns element's local name.
|
||||
fn local_name(&self) -> &<SelectorImpl as selectors::parser::SelectorImpl>::BorrowedLocalName;
|
||||
|
||||
/// Returns element's namespace.
|
||||
fn namespace(&self)
|
||||
-> &<SelectorImpl as selectors::parser::SelectorImpl>::BorrowedNamespaceUrl;
|
||||
}
|
||||
|
||||
/// TNode and TElement aren't Send because we want to be careful and explicit
|
||||
|
|
|
@ -1166,6 +1166,19 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
self.namespace_id() == structs::root::kNameSpaceID_XUL as i32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn local_name(&self) -> &WeakAtom {
|
||||
unsafe { WeakAtom::new(self.as_node().node_info().mInner.mName) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn namespace(&self) -> &WeakNamespace {
|
||||
unsafe {
|
||||
let namespace_manager = structs::nsContentUtils_sNameSpaceManager;
|
||||
WeakNamespace::new((*namespace_manager).mURIArray[self.namespace_id() as usize].mRawPtr)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the list of slotted nodes of this node.
|
||||
#[inline]
|
||||
fn slotted_nodes(&self) -> &[Self::ConcreteNode] {
|
||||
|
@ -2071,16 +2084,18 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn local_name(&self) -> &WeakAtom {
|
||||
unsafe { WeakAtom::new(self.as_node().node_info().mInner.mName) }
|
||||
fn has_local_name(&self, name: &WeakAtom) -> bool {
|
||||
self.local_name() == name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn namespace(&self) -> &WeakNamespace {
|
||||
unsafe {
|
||||
let namespace_manager = structs::nsContentUtils_sNameSpaceManager;
|
||||
WeakNamespace::new((*namespace_manager).mURIArray[self.namespace_id() as usize].mRawPtr)
|
||||
}
|
||||
fn has_namespace(&self, ns: &WeakNamespace) -> bool {
|
||||
self.namespace() == ns
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_same_type(&self, other: &Self) -> bool {
|
||||
self.local_name() == other.local_name() && self.namespace() == other.namespace()
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(
|
||||
|
|
|
@ -312,13 +312,24 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn local_name(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName {
|
||||
self.element.local_name()
|
||||
fn has_local_name(
|
||||
&self,
|
||||
local_name: &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName,
|
||||
) -> bool {
|
||||
self.element.has_local_name(local_name)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn namespace(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedNamespaceUrl {
|
||||
self.element.namespace()
|
||||
fn has_namespace(
|
||||
&self,
|
||||
ns: &<Self::Impl as ::selectors::SelectorImpl>::BorrowedNamespaceUrl,
|
||||
) -> bool {
|
||||
self.element.has_namespace(ns)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_same_type(&self, other: &Self) -> bool {
|
||||
self.element.is_same_type(&other.element)
|
||||
}
|
||||
|
||||
fn attr_matches(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue