mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Remove get_ prefix from get_state and get_id.
This commit is contained in:
parent
b8fb41da0c
commit
98c9292ecb
10 changed files with 27 additions and 25 deletions
|
@ -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()
|
self.element.get_state_for_layout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_id(&self) -> Option<Atom> {
|
fn id(&self) -> Option<Atom> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.element.id_attribute()).clone()
|
(*self.element.id_attribute()).clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ where
|
||||||
f(element.local_name().get_hash());
|
f(element.local_name().get_hash());
|
||||||
f(element.namespace().get_hash());
|
f(element.namespace().get_hash());
|
||||||
|
|
||||||
if let Some(id) = element.get_id() {
|
if let Some(id) = element.id() {
|
||||||
f(id.get_hash());
|
f(id.get_hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -461,13 +461,13 @@ pub trait TElement
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get this element's state, for non-tree-structural pseudos.
|
/// 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.
|
/// Whether this element has an attribute with a given namespace.
|
||||||
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
|
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
|
||||||
|
|
||||||
/// The ID for this element.
|
/// The ID for this element.
|
||||||
fn get_id(&self) -> Option<Atom>;
|
fn id(&self) -> Option<Atom>;
|
||||||
|
|
||||||
/// Internal iterator for the classes of this element.
|
/// Internal iterator for the classes of this element.
|
||||||
fn each_class<F>(&self, callback: F) where F: FnMut(&Atom);
|
fn each_class<F>(&self, callback: F) where F: FnMut(&Atom);
|
||||||
|
|
|
@ -456,7 +456,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.local_name())?;
|
write!(f, "<{}", self.local_name())?;
|
||||||
if let Some(id) = self.get_id() {
|
if let Some(id) = self.id() {
|
||||||
write!(f, " id={}", id)?;
|
write!(f, " id={}", id)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ impl<'le> GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_state_internal(&self) -> u64 {
|
fn state_internal(&self) -> u64 {
|
||||||
if !self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates) {
|
if !self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates) {
|
||||||
return self.0.mState.mStates;
|
return self.0.mState.mStates;
|
||||||
}
|
}
|
||||||
|
@ -1163,8 +1163,8 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_state(&self) -> ElementState {
|
fn state(&self) -> ElementState {
|
||||||
ElementState::from_bits_truncate(self.get_state_internal())
|
ElementState::from_bits_truncate(self.state_internal())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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() {
|
if !self.has_id() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1261,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_visited_link(&self) -> bool {
|
fn is_visited_link(&self) -> bool {
|
||||||
self.get_state().intersects(ElementState::IN_VISITED_STATE)
|
self.state().intersects(ElementState::IN_VISITED_STATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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 {
|
if active {
|
||||||
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) };
|
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) };
|
||||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
||||||
|
@ -2021,7 +2023,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
NonTSPseudoClass::Active |
|
NonTSPseudoClass::Active |
|
||||||
NonTSPseudoClass::Hover |
|
NonTSPseudoClass::Hover |
|
||||||
NonTSPseudoClass::MozAutofillPreview => {
|
NonTSPseudoClass::MozAutofillPreview => {
|
||||||
self.get_state().intersects(pseudo_class.state_flag())
|
self.state().intersects(pseudo_class.state_flag())
|
||||||
},
|
},
|
||||||
NonTSPseudoClass::AnyLink => self.is_link(),
|
NonTSPseudoClass::AnyLink => self.is_link(),
|
||||||
NonTSPseudoClass::Link => {
|
NonTSPseudoClass::Link => {
|
||||||
|
@ -2114,8 +2116,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
NonTSPseudoClass::Dir(ref dir) => {
|
NonTSPseudoClass::Dir(ref dir) => {
|
||||||
match **dir {
|
match **dir {
|
||||||
Direction::Ltr => self.get_state().intersects(ElementState::IN_LTR_STATE),
|
Direction::Ltr => self.state().intersects(ElementState::IN_LTR_STATE),
|
||||||
Direction::Rtl => self.get_state().intersects(ElementState::IN_RTL_STATE),
|
Direction::Rtl => self.state().intersects(ElementState::IN_RTL_STATE),
|
||||||
Direction::Other(..) => false,
|
Direction::Other(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2138,7 +2140,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_link(&self) -> bool {
|
fn is_link(&self) -> bool {
|
||||||
self.get_state().intersects(NonTSPseudoClass::AnyLink.state_flag())
|
self.state().intersects(NonTSPseudoClass::AnyLink.state_flag())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -109,7 +109,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
match snapshot.state() {
|
match snapshot.state() {
|
||||||
Some(state) => state ^ self.element.get_state(),
|
Some(state) => state ^ self.element.state(),
|
||||||
None => ElementState::empty(),
|
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()) {
|
let state = match self.snapshot().and_then(|s| s.state()) {
|
||||||
Some(snapshot_state) => snapshot_state,
|
Some(snapshot_state) => snapshot_state,
|
||||||
None => self.element.get_state(),
|
None => self.element.state(),
|
||||||
};
|
};
|
||||||
return state.contains(selector_flag);
|
return state.contains(selector_flag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ where
|
||||||
let mut id_added = None;
|
let mut id_added = None;
|
||||||
if snapshot.id_changed() {
|
if snapshot.id_changed() {
|
||||||
let old_id = snapshot.id_attr();
|
let old_id = snapshot.id_attr();
|
||||||
let current_id = element.get_id();
|
let current_id = element.id();
|
||||||
|
|
||||||
if old_id != current_id {
|
if old_id != current_id {
|
||||||
id_removed = old_id;
|
id_removed = old_id;
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl Invalidation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Invalidation::ID(ref id) => {
|
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) {
|
if case_sensitivity.eq_atom(element_id, id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ impl SelectorMap<Rule> {
|
||||||
// At the end, we're going to sort the rules that we added, so remember
|
// At the end, we're going to sort the rules that we added, so remember
|
||||||
// where we began.
|
// where we began.
|
||||||
let init_len = matching_rules_list.len();
|
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) {
|
if let Some(rules) = self.id_hash.get(&id, quirks_mode) {
|
||||||
SelectorMap::get_matching_rules(
|
SelectorMap::get_matching_rules(
|
||||||
element,
|
element,
|
||||||
|
@ -315,7 +315,7 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
|
||||||
F: FnMut(&'a T) -> bool
|
F: FnMut(&'a T) -> bool
|
||||||
{
|
{
|
||||||
// Id.
|
// 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) {
|
if let Some(v) = self.id_hash.get(&id, quirks_mode) {
|
||||||
for entry in v.iter() {
|
for entry in v.iter() {
|
||||||
if !f(&entry) {
|
if !f(&entry) {
|
||||||
|
|
|
@ -145,8 +145,8 @@ pub fn may_match_different_id_rules<E>(
|
||||||
where
|
where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
{
|
{
|
||||||
let element_id = element.get_id();
|
let element_id = element.id();
|
||||||
let candidate_id = candidate.get_id();
|
let candidate_id = candidate.id();
|
||||||
|
|
||||||
if element_id == candidate_id {
|
if element_id == candidate_id {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -700,7 +700,7 @@ impl<E: TElement> StyleSharingCache<E> {
|
||||||
// We do not ignore visited state here, because Gecko
|
// We do not ignore visited state here, because Gecko
|
||||||
// needs to store extra bits on visited style contexts,
|
// needs to store extra bits on visited style contexts,
|
||||||
// so these contexts cannot be shared
|
// 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");
|
trace!("Miss: User and Author State");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue