mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
selectors: Remove the get_ prefix from get_local_name and get_namespace.
This commit is contained in:
parent
da99f159f4
commit
7ab4b21bc3
12 changed files with 60 additions and 55 deletions
|
@ -692,12 +692,12 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name(&self) -> &LocalName {
|
fn local_name(&self) -> &LocalName {
|
||||||
self.element.local_name()
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace(&self) -> &Namespace {
|
fn namespace(&self) -> &Namespace {
|
||||||
self.element.namespace()
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,7 +787,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
fn is_html_slot_element(&self) -> bool {
|
fn is_html_slot_element(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.element.is_html_element() &&
|
self.element.is_html_element() &&
|
||||||
self.get_local_name() == &local_name!("slot")
|
self.local_name() == &local_name!("slot")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,8 +1025,8 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
||||||
loop {
|
loop {
|
||||||
let next_node = if let Some(ref node) = current_node {
|
let next_node = if let Some(ref node) = current_node {
|
||||||
if let Some(element) = node.as_element() {
|
if let Some(element) = node.as_element() {
|
||||||
if element.get_local_name() == &local_name!("summary") &&
|
if element.local_name() == &local_name!("summary") &&
|
||||||
element.get_namespace() == &ns!(html) {
|
element.namespace() == &ns!(html) {
|
||||||
self.current_node = None;
|
self.current_node = None;
|
||||||
return Some(node.clone());
|
return Some(node.clone());
|
||||||
}
|
}
|
||||||
|
@ -1044,8 +1044,8 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
||||||
let node = self.current_node.clone();
|
let node = self.current_node.clone();
|
||||||
let node = node.and_then(|node| {
|
let node = node.and_then(|node| {
|
||||||
if node.is_element() &&
|
if node.is_element() &&
|
||||||
node.as_element().unwrap().get_local_name() == &local_name!("summary") &&
|
node.as_element().unwrap().local_name() == &local_name!("summary") &&
|
||||||
node.as_element().unwrap().get_namespace() == &ns!(html) {
|
node.as_element().unwrap().namespace() == &ns!(html) {
|
||||||
unsafe { node.dangerous_next_sibling() }
|
unsafe { node.dangerous_next_sibling() }
|
||||||
} else {
|
} else {
|
||||||
Some(node)
|
Some(node)
|
||||||
|
@ -1193,13 +1193,13 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name(&self) -> &LocalName {
|
fn local_name(&self) -> &LocalName {
|
||||||
self.element.get_local_name()
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace(&self) -> &Namespace {
|
fn namespace(&self) -> &Namespace {
|
||||||
self.element.get_namespace()
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_pseudo_element(
|
fn match_pseudo_element(
|
||||||
|
|
|
@ -2628,12 +2628,12 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name(&self) -> &LocalName {
|
fn local_name(&self) -> &LocalName {
|
||||||
self.local_name()
|
Element::local_name(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace(&self) -> &Namespace {
|
fn namespace(&self) -> &Namespace {
|
||||||
self.namespace()
|
Element::namespace(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_non_ts_pseudo_class<F>(
|
fn match_non_ts_pseudo_class<F>(
|
||||||
|
|
|
@ -347,8 +347,8 @@ pub trait ThreadSafeLayoutElement
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_details_summary_pseudo(&self) -> Option<Self> {
|
fn get_details_summary_pseudo(&self) -> Option<Self> {
|
||||||
if self.get_local_name() == &local_name!("details") &&
|
if self.local_name() == &local_name!("details") &&
|
||||||
self.get_namespace() == &ns!(html) {
|
self.namespace() == &ns!(html) {
|
||||||
Some(self.with_pseudo(PseudoElementType::DetailsSummary))
|
Some(self.with_pseudo(PseudoElementType::DetailsSummary))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -357,8 +357,8 @@ pub trait ThreadSafeLayoutElement
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_details_content_pseudo(&self) -> Option<Self> {
|
fn get_details_content_pseudo(&self) -> Option<Self> {
|
||||||
if self.get_local_name() == &local_name!("details") &&
|
if self.local_name() == &local_name!("details") &&
|
||||||
self.get_namespace() == &ns!(html) &&
|
self.namespace() == &ns!(html) &&
|
||||||
self.get_attr(&ns!(), &local_name!("open")).is_some() {
|
self.get_attr(&ns!(), &local_name!("open")).is_some() {
|
||||||
Some(self.with_pseudo(PseudoElementType::DetailsContent))
|
Some(self.with_pseudo(PseudoElementType::DetailsContent))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -553,7 +553,7 @@ where
|
||||||
&local_name.name,
|
&local_name.name,
|
||||||
&local_name.lower_name
|
&local_name.lower_name
|
||||||
).borrow();
|
).borrow();
|
||||||
element.get_local_name() == name
|
element.local_name() == name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines whether the given element matches the given compound selector.
|
/// Determines whether the given element matches the given compound selector.
|
||||||
|
@ -655,11 +655,11 @@ where
|
||||||
}
|
}
|
||||||
Component::Namespace(_, ref url) |
|
Component::Namespace(_, ref url) |
|
||||||
Component::DefaultNamespace(ref url) => {
|
Component::DefaultNamespace(ref url) => {
|
||||||
element.get_namespace() == url.borrow()
|
element.namespace() == url.borrow()
|
||||||
}
|
}
|
||||||
Component::ExplicitNoNamespace => {
|
Component::ExplicitNoNamespace => {
|
||||||
let ns = ::parser::namespace_empty_string::<E::Impl>();
|
let ns = ::parser::namespace_empty_string::<E::Impl>();
|
||||||
element.get_namespace() == ns.borrow()
|
element.namespace() == ns.borrow()
|
||||||
}
|
}
|
||||||
Component::ID(ref id) => {
|
Component::ID(ref id) => {
|
||||||
element.has_id(id, context.shared.classes_and_ids_case_sensitivity())
|
element.has_id(id, context.shared.classes_and_ids_case_sensitivity())
|
||||||
|
@ -860,8 +860,8 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn same_type<E: Element>(a: &E, b: &E) -> bool {
|
fn same_type<E: Element>(a: &E, b: &E) -> bool {
|
||||||
a.get_local_name() == b.get_local_name() &&
|
a.local_name() == b.local_name() &&
|
||||||
a.get_namespace() == b.get_namespace()
|
a.namespace() == b.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -53,10 +53,10 @@ pub trait Element: Sized + Clone + Debug {
|
||||||
|
|
||||||
fn is_html_element_in_html_document(&self) -> bool;
|
fn is_html_element_in_html_document(&self) -> bool;
|
||||||
|
|
||||||
fn get_local_name(&self) -> &<Self::Impl as SelectorImpl>::BorrowedLocalName;
|
fn local_name(&self) -> &<Self::Impl as SelectorImpl>::BorrowedLocalName;
|
||||||
|
|
||||||
/// Empty string for no namespace
|
/// Empty string for no namespace
|
||||||
fn get_namespace(&self) -> &<Self::Impl as SelectorImpl>::BorrowedNamespaceUrl;
|
fn namespace(&self) -> &<Self::Impl as SelectorImpl>::BorrowedNamespaceUrl;
|
||||||
|
|
||||||
fn attr_matches(&self,
|
fn attr_matches(&self,
|
||||||
ns: &NamespaceConstraint<&<Self::Impl as SelectorImpl>::NamespaceUrl>,
|
ns: &NamespaceConstraint<&<Self::Impl as SelectorImpl>::NamespaceUrl>,
|
||||||
|
|
|
@ -98,8 +98,8 @@ where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
F: FnMut(u32),
|
F: FnMut(u32),
|
||||||
{
|
{
|
||||||
f(element.get_local_name().get_hash());
|
f(element.local_name().get_hash());
|
||||||
f(element.get_namespace().get_hash());
|
f(element.namespace().get_hash());
|
||||||
|
|
||||||
if let Some(id) = element.get_id() {
|
if let Some(id) = element.get_id() {
|
||||||
f(id.get_hash());
|
f(id.get_hash());
|
||||||
|
|
|
@ -349,9 +349,9 @@ where
|
||||||
Component::LocalName(LocalName { ref name, ref lower_name }) => {
|
Component::LocalName(LocalName { ref name, ref lower_name }) => {
|
||||||
collect_all_elements::<E, Q, _>(root, results, |element| {
|
collect_all_elements::<E, Q, _>(root, results, |element| {
|
||||||
if element.is_html_element_in_html_document() {
|
if element.is_html_element_in_html_document() {
|
||||||
element.get_local_name() == lower_name.borrow()
|
element.local_name() == lower_name.borrow()
|
||||||
} else {
|
} else {
|
||||||
element.get_local_name() == name.borrow()
|
element.local_name() == name.borrow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,7 +455,7 @@ pub struct GeckoElement<'le>(pub &'le RawGeckoElement);
|
||||||
|
|
||||||
impl<'le> fmt::Debug for GeckoElement<'le> {
|
impl<'le> fmt::Debug for GeckoElement<'le> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "<{}", self.get_local_name())?;
|
write!(f, "<{}", self.local_name())?;
|
||||||
if let Some(id) = self.get_id() {
|
if let Some(id) = self.get_id() {
|
||||||
write!(f, " id={}", id)?;
|
write!(f, " id={}", id)?;
|
||||||
}
|
}
|
||||||
|
@ -1621,7 +1621,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_html_document_body_element(&self) -> bool {
|
fn is_html_document_body_element(&self) -> bool {
|
||||||
if self.get_local_name() != &*local_name!("body") {
|
if self.local_name() != &*local_name!("body") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1687,15 +1687,15 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
let ns = self.namespace_id();
|
let ns = self.namespace_id();
|
||||||
// <th> elements get a default MozCenterOrInherit which may get overridden
|
// <th> elements get a default MozCenterOrInherit which may get overridden
|
||||||
if ns == structs::kNameSpaceID_XHTML as i32 {
|
if ns == structs::kNameSpaceID_XHTML as i32 {
|
||||||
if self.get_local_name().as_ptr() == atom!("th").as_ptr() {
|
if self.local_name().as_ptr() == atom!("th").as_ptr() {
|
||||||
hints.push(TH_RULE.clone());
|
hints.push(TH_RULE.clone());
|
||||||
} else if self.get_local_name().as_ptr() == atom!("table").as_ptr() &&
|
} else if self.local_name().as_ptr() == atom!("table").as_ptr() &&
|
||||||
self.as_node().owner_doc().quirks_mode() == QuirksMode::Quirks {
|
self.as_node().owner_doc().quirks_mode() == QuirksMode::Quirks {
|
||||||
hints.push(TABLE_COLOR_RULE.clone());
|
hints.push(TABLE_COLOR_RULE.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ns == structs::kNameSpaceID_SVG as i32 {
|
if ns == structs::kNameSpaceID_SVG as i32 {
|
||||||
if self.get_local_name().as_ptr() == atom!("text").as_ptr() {
|
if self.local_name().as_ptr() == atom!("text").as_ptr() {
|
||||||
hints.push(SVG_TEXT_DISABLE_ZOOM_RULE.clone());
|
hints.push(SVG_TEXT_DISABLE_ZOOM_RULE.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1772,7 +1772,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
// MathML's default lang has precedence over both `lang` and `xml:lang`
|
// MathML's default lang has precedence over both `lang` and `xml:lang`
|
||||||
if ns == structs::kNameSpaceID_MathML as i32 {
|
if ns == structs::kNameSpaceID_MathML as i32 {
|
||||||
if self.get_local_name().as_ptr() == atom!("math").as_ptr() {
|
if self.local_name().as_ptr() == atom!("math").as_ptr() {
|
||||||
hints.push(MATHML_LANG_RULE.clone());
|
hints.push(MATHML_LANG_RULE.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1965,14 +1965,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name(&self) -> &WeakAtom {
|
fn local_name(&self) -> &WeakAtom {
|
||||||
unsafe {
|
unsafe {
|
||||||
WeakAtom::new(self.as_node().node_info().mInner.mName)
|
WeakAtom::new(self.as_node().node_info().mInner.mName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace(&self) -> &WeakNamespace {
|
fn namespace(&self) -> &WeakNamespace {
|
||||||
unsafe {
|
unsafe {
|
||||||
let namespace_manager = structs::nsContentUtils_sNameSpaceManager;
|
let namespace_manager = structs::nsContentUtils_sNameSpaceManager;
|
||||||
WeakNamespace::new((*namespace_manager).mURIArray[self.namespace_id() as usize].mRawPtr)
|
WeakNamespace::new((*namespace_manager).mURIArray[self.namespace_id() as usize].mRawPtr)
|
||||||
|
@ -2198,7 +2198,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_html_slot_element(&self) -> bool {
|
fn is_html_slot_element(&self) -> bool {
|
||||||
self.is_html_element() &&
|
self.is_html_element() &&
|
||||||
self.get_local_name().as_ptr() == local_name!("slot").as_ptr()
|
self.local_name().as_ptr() == local_name!("slot").as_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -2217,8 +2217,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
// If this element is the shadow root of an use-element shadow
|
// If this element is the shadow root of an use-element shadow
|
||||||
// tree, according to the spec, we should not match rules
|
// tree, according to the spec, we should not match rules
|
||||||
// cross the shadow DOM boundary.
|
// cross the shadow DOM boundary.
|
||||||
e.get_local_name() == &*local_name!("use") &&
|
e.local_name() == &*local_name!("use") &&
|
||||||
e.get_namespace() == &*ns!("http://www.w3.org/2000/svg")
|
e.namespace() == &*ns!("http://www.w3.org/2000/svg")
|
||||||
},
|
},
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,27 +291,32 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
.map(|e| ElementWrapper::new(e, self.snapshot_map))
|
.map(|e| ElementWrapper::new(e, self.snapshot_map))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_html_element_in_html_document(&self) -> bool {
|
fn is_html_element_in_html_document(&self) -> bool {
|
||||||
self.element.is_html_element_in_html_document()
|
self.element.is_html_element_in_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_html_slot_element(&self) -> bool {
|
fn is_html_slot_element(&self) -> bool {
|
||||||
self.element.is_html_slot_element()
|
self.element.is_html_slot_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName {
|
#[inline]
|
||||||
self.element.get_local_name()
|
fn local_name(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedLocalName {
|
||||||
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedNamespaceUrl {
|
#[inline]
|
||||||
self.element.get_namespace()
|
fn namespace(&self) -> &<Self::Impl as ::selectors::SelectorImpl>::BorrowedNamespaceUrl {
|
||||||
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attr_matches(&self,
|
fn attr_matches(
|
||||||
ns: &NamespaceConstraint<&Namespace>,
|
&self,
|
||||||
local_name: &LocalName,
|
ns: &NamespaceConstraint<&Namespace>,
|
||||||
operation: &AttrSelectorOperation<&AttrValue>)
|
local_name: &LocalName,
|
||||||
-> bool {
|
operation: &AttrSelectorOperation<&AttrValue>,
|
||||||
|
) -> bool {
|
||||||
match self.snapshot() {
|
match self.snapshot() {
|
||||||
Some(snapshot) if snapshot.has_attrs() => {
|
Some(snapshot) if snapshot.has_attrs() => {
|
||||||
snapshot.attr_matches(ns, local_name, operation)
|
snapshot.attr_matches(ns, local_name, operation)
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl Invalidation {
|
||||||
// This could look at the quirks mode of the document, instead
|
// This could look at the quirks mode of the document, instead
|
||||||
// of testing against both names, but it's probably not worth
|
// of testing against both names, but it's probably not worth
|
||||||
// it.
|
// it.
|
||||||
let local_name = element.get_local_name();
|
let local_name = element.local_name();
|
||||||
return *local_name == **name || *local_name == **lower_name
|
return *local_name == **name || *local_name == **lower_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl SelectorMap<Rule> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(rules) = self.local_name_hash.get(rule_hash_target.get_local_name()) {
|
if let Some(rules) = self.local_name_hash.get(rule_hash_target.local_name()) {
|
||||||
SelectorMap::get_matching_rules(
|
SelectorMap::get_matching_rules(
|
||||||
element,
|
element,
|
||||||
rules,
|
rules,
|
||||||
|
@ -344,7 +344,7 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local name.
|
// Local name.
|
||||||
if let Some(v) = self.local_name_hash.get(element.get_local_name()) {
|
if let Some(v) = self.local_name_hash.get(element.local_name()) {
|
||||||
for entry in v.iter() {
|
for entry in v.iter() {
|
||||||
if !f(&entry) {
|
if !f(&entry) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -676,12 +676,12 @@ impl<E: TElement> StyleSharingCache<E> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if *target.get_local_name() != *candidate.element.get_local_name() {
|
if *target.local_name() != *candidate.element.local_name() {
|
||||||
trace!("Miss: Local Name");
|
trace!("Miss: Local Name");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if *target.get_namespace() != *candidate.element.get_namespace() {
|
if *target.namespace() != *candidate.element.namespace() {
|
||||||
trace!("Miss: Namespace");
|
trace!("Miss: Namespace");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue