style: Remove get_ prefix from get_state and get_id.

This commit is contained in:
Emilio Cobos Álvarez 2018-02-24 21:25:16 +01:00
parent b8fb41da0c
commit 98c9292ecb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 27 additions and 25 deletions

View file

@ -372,7 +372,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
}
fn get_state(&self) -> ElementState {
fn state(&self) -> ElementState {
self.element.get_state_for_layout()
}
@ -382,7 +382,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
#[inline]
fn get_id(&self) -> Option<Atom> {
fn id(&self) -> Option<Atom> {
unsafe {
(*self.element.id_attribute()).clone()
}

View file

@ -101,7 +101,7 @@ where
f(element.local_name().get_hash());
f(element.namespace().get_hash());
if let Some(id) = element.get_id() {
if let Some(id) = element.id() {
f(id.get_hash());
}

View file

@ -461,13 +461,13 @@ pub trait TElement
}
/// Get this element's state, for non-tree-structural pseudos.
fn get_state(&self) -> ElementState;
fn state(&self) -> ElementState;
/// Whether this element has an attribute with a given namespace.
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
/// The ID for this element.
fn get_id(&self) -> Option<Atom>;
fn id(&self) -> Option<Atom>;
/// Internal iterator for the classes of this element.
fn each_class<F>(&self, callback: F) where F: FnMut(&Atom);

View file

@ -456,7 +456,7 @@ pub struct GeckoElement<'le>(pub &'le RawGeckoElement);
impl<'le> fmt::Debug for GeckoElement<'le> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<{}", self.local_name())?;
if let Some(id) = self.get_id() {
if let Some(id) = self.id() {
write!(f, " id={}", id)?;
}
@ -645,7 +645,7 @@ impl<'le> GeckoElement<'le> {
}
#[inline]
fn get_state_internal(&self) -> u64 {
fn state_internal(&self) -> u64 {
if !self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates) {
return self.0.mState.mStates;
}
@ -1163,8 +1163,8 @@ impl<'le> TElement for GeckoElement<'le> {
}
#[inline]
fn get_state(&self) -> ElementState {
ElementState::from_bits_truncate(self.get_state_internal())
fn state(&self) -> ElementState {
ElementState::from_bits_truncate(self.state_internal())
}
#[inline]
@ -1174,7 +1174,9 @@ impl<'le> TElement for GeckoElement<'le> {
}
}
fn get_id(&self) -> Option<Atom> {
// FIXME(emilio): we should probably just return a reference to the Atom.
#[inline]
fn id(&self) -> Option<Atom> {
if !self.has_id() {
return None;
}
@ -1259,7 +1261,7 @@ impl<'le> TElement for GeckoElement<'le> {
}
fn is_visited_link(&self) -> bool {
self.get_state().intersects(ElementState::IN_VISITED_STATE)
self.state().intersects(ElementState::IN_VISITED_STATE)
}
#[inline]
@ -1723,7 +1725,7 @@ impl<'le> TElement for GeckoElement<'le> {
);
}
let active = self.get_state().intersects(NonTSPseudoClass::Active.state_flag());
let active = self.state().intersects(NonTSPseudoClass::Active.state_flag());
if active {
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) };
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
@ -2021,7 +2023,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::Active |
NonTSPseudoClass::Hover |
NonTSPseudoClass::MozAutofillPreview => {
self.get_state().intersects(pseudo_class.state_flag())
self.state().intersects(pseudo_class.state_flag())
},
NonTSPseudoClass::AnyLink => self.is_link(),
NonTSPseudoClass::Link => {
@ -2114,8 +2116,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
}
NonTSPseudoClass::Dir(ref dir) => {
match **dir {
Direction::Ltr => self.get_state().intersects(ElementState::IN_LTR_STATE),
Direction::Rtl => self.get_state().intersects(ElementState::IN_RTL_STATE),
Direction::Ltr => self.state().intersects(ElementState::IN_LTR_STATE),
Direction::Rtl => self.state().intersects(ElementState::IN_RTL_STATE),
Direction::Other(..) => false,
}
}
@ -2138,7 +2140,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
#[inline]
fn is_link(&self) -> bool {
self.get_state().intersects(NonTSPseudoClass::AnyLink.state_flag())
self.state().intersects(NonTSPseudoClass::AnyLink.state_flag())
}
#[inline]

View file

@ -109,7 +109,7 @@ where
};
match snapshot.state() {
Some(state) => state ^ self.element.get_state(),
Some(state) => state ^ self.element.state(),
None => ElementState::empty(),
}
}
@ -186,7 +186,7 @@ impl<'a, E> Element for ElementWrapper<'a, E>
}
let state = match self.snapshot().and_then(|s| s.state()) {
Some(snapshot_state) => snapshot_state,
None => self.element.get_state(),
None => self.element.state(),
};
return state.contains(selector_flag);
}

View file

@ -200,7 +200,7 @@ where
let mut id_added = None;
if snapshot.id_changed() {
let old_id = snapshot.id_attr();
let current_id = element.get_id();
let current_id = element.id();
if old_id != current_id {
id_removed = old_id;

View file

@ -66,7 +66,7 @@ impl Invalidation {
}
}
Invalidation::ID(ref id) => {
if let Some(ref element_id) = element.get_id() {
if let Some(ref element_id) = element.id() {
if case_sensitivity.eq_atom(element_id, id) {
return true;
}

View file

@ -175,7 +175,7 @@ impl SelectorMap<Rule> {
// At the end, we're going to sort the rules that we added, so remember
// where we began.
let init_len = matching_rules_list.len();
if let Some(id) = rule_hash_target.get_id() {
if let Some(id) = rule_hash_target.id() {
if let Some(rules) = self.id_hash.get(&id, quirks_mode) {
SelectorMap::get_matching_rules(
element,
@ -315,7 +315,7 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
F: FnMut(&'a T) -> bool
{
// Id.
if let Some(id) = element.get_id() {
if let Some(id) = element.id() {
if let Some(v) = self.id_hash.get(&id, quirks_mode) {
for entry in v.iter() {
if !f(&entry) {

View file

@ -145,8 +145,8 @@ pub fn may_match_different_id_rules<E>(
where
E: TElement,
{
let element_id = element.get_id();
let candidate_id = candidate.get_id();
let element_id = element.id();
let candidate_id = candidate.id();
if element_id == candidate_id {
return false;

View file

@ -700,7 +700,7 @@ impl<E: TElement> StyleSharingCache<E> {
// We do not ignore visited state here, because Gecko
// needs to store extra bits on visited style contexts,
// so these contexts cannot be shared
if target.element.get_state() != candidate.get_state() {
if target.element.state() != candidate.state() {
trace!("Miss: User and Author State");
return None;
}