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:
Emilio Cobos Álvarez 2017-06-09 17:16:29 +02:00
parent 8449eb4a62
commit 262f6adc30
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 50 additions and 0 deletions

View file

@ -545,6 +545,12 @@ pub struct ServoElementSnapshot {
pub attrs: Option<Vec<(AttrIdentifier, AttrValue)>>,
/// Whether this element is an HTML element in an HTML document.
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 {
@ -554,9 +560,27 @@ impl ServoElementSnapshot {
state: None,
attrs: None,
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> {
self.attrs.as_ref().unwrap().iter()
.find(|&&(ref ident, _)| ident.local_name == *name &&