mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Record whether an snapshot is recording a class attribute change or id change.
I'll use this information in order to get fewer dependencies out of the dependency set. Bug: 1368240 MozReview-Commit-ID: 5HlmKmSNO8p
This commit is contained in:
parent
8449eb4a62
commit
262f6adc30
3 changed files with 50 additions and 0 deletions
|
@ -2387,6 +2387,13 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut snapshot = entry.snapshot.as_mut().unwrap();
|
let mut snapshot = entry.snapshot.as_mut().unwrap();
|
||||||
|
if attr.local_name() == &local_name!("id") {
|
||||||
|
snapshot.id_changed = true;
|
||||||
|
} else if attr.local_name() == &local_name!("class") {
|
||||||
|
snapshot.class_changed = true;
|
||||||
|
} else {
|
||||||
|
snapshot.other_attributes_changed = true;
|
||||||
|
}
|
||||||
if snapshot.attrs.is_none() {
|
if snapshot.attrs.is_none() {
|
||||||
let attrs = el.attrs()
|
let attrs = el.attrs()
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -62,6 +62,25 @@ impl GeckoElementSnapshot {
|
||||||
self.has_any(Flags::OtherPseudoClassState)
|
self.has_any(Flags::OtherPseudoClassState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the snapshot recorded an id change.
|
||||||
|
#[inline]
|
||||||
|
pub fn id_changed(&self) -> bool {
|
||||||
|
self.mIdAttributeChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the snapshot recorded a class attribute change.
|
||||||
|
#[inline]
|
||||||
|
pub fn class_changed(&self) -> bool {
|
||||||
|
self.mClassAttributeChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if the snapshot recorded an attribute change which isn't a
|
||||||
|
/// class or id change.
|
||||||
|
#[inline]
|
||||||
|
pub fn other_attr_changed(&self) -> bool {
|
||||||
|
self.mOtherAttributeChanged()
|
||||||
|
}
|
||||||
|
|
||||||
/// selectors::Element::attr_matches
|
/// selectors::Element::attr_matches
|
||||||
pub fn attr_matches(&self,
|
pub fn attr_matches(&self,
|
||||||
ns: &NamespaceConstraint<&Namespace>,
|
ns: &NamespaceConstraint<&Namespace>,
|
||||||
|
|
|
@ -545,6 +545,12 @@ pub struct ServoElementSnapshot {
|
||||||
pub attrs: Option<Vec<(AttrIdentifier, AttrValue)>>,
|
pub attrs: Option<Vec<(AttrIdentifier, AttrValue)>>,
|
||||||
/// Whether this element is an HTML element in an HTML document.
|
/// Whether this element is an HTML element in an HTML document.
|
||||||
pub is_html_element_in_html_document: bool,
|
pub is_html_element_in_html_document: bool,
|
||||||
|
/// Whether the class attribute changed or not.
|
||||||
|
pub class_changed: bool,
|
||||||
|
/// Whether the id attribute changed or not.
|
||||||
|
pub id_changed: bool,
|
||||||
|
/// Whether other attributes other than id or class changed or not.
|
||||||
|
pub other_attributes_changed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServoElementSnapshot {
|
impl ServoElementSnapshot {
|
||||||
|
@ -554,9 +560,27 @@ impl ServoElementSnapshot {
|
||||||
state: None,
|
state: None,
|
||||||
attrs: None,
|
attrs: None,
|
||||||
is_html_element_in_html_document: is_html_element_in_html_document,
|
is_html_element_in_html_document: is_html_element_in_html_document,
|
||||||
|
class_changed: false,
|
||||||
|
id_changed: false,
|
||||||
|
other_attributes_changed: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the id attribute changed or not.
|
||||||
|
pub fn id_changed(&self) -> bool {
|
||||||
|
self.id_changed
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether the class attribute changed or not.
|
||||||
|
pub fn class_changed(&self) -> bool {
|
||||||
|
self.class_changed
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether other attributes other than id or class changed or not.
|
||||||
|
pub fn other_attr_changed(&self) -> bool {
|
||||||
|
self.other_attributes_changed
|
||||||
|
}
|
||||||
|
|
||||||
fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
|
fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
|
||||||
self.attrs.as_ref().unwrap().iter()
|
self.attrs.as_ref().unwrap().iter()
|
||||||
.find(|&&(ref ident, _)| ident.local_name == *name &&
|
.find(|&&(ref ident, _)| ident.local_name == *name &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue