diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 0af5bdfc83a..b2e93325236 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -129,7 +129,7 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use style::attr::AttrValue; use style::context::{QuirksMode, ReflowGoal}; -use style::restyle_hints::RestyleHint; +use style::restyle_hints::{RestyleHint, RESTYLE_STYLE_ATTRIBUTE}; use style::selector_parser::{RestyleDamage, Snapshot}; use style::str::{split_html_space_chars, str_join}; use style::stylesheets::Stylesheet; @@ -2142,23 +2142,32 @@ impl Document { RefMut::map(map, |m| m.entry(JS::from_ref(el)).or_insert_with(PendingRestyle::new)) } - pub fn ensure_snapshot(&self, el: &Element) -> RefMut { + pub fn element_state_will_change(&self, el: &Element) { let mut entry = self.ensure_pending_restyle(el); if entry.snapshot.is_none() { entry.snapshot = Some(Snapshot::new(el.html_element_in_html_document())); } - RefMut::map(entry, |e| e.snapshot.as_mut().unwrap()) - } - - pub fn element_state_will_change(&self, el: &Element) { - let mut snapshot = self.ensure_snapshot(el); + let mut snapshot = entry.snapshot.as_mut().unwrap(); if snapshot.state.is_none() { snapshot.state = Some(el.state()); } } - pub fn element_attr_will_change(&self, el: &Element, _attr: &Attr) { - let mut snapshot = self.ensure_snapshot(el); + pub fn element_attr_will_change(&self, el: &Element, attr: &Attr) { + // FIXME(emilio): Kind of a shame we have to duplicate this. + // + // I'm getting rid of the whole hashtable soon anyway, since all it does + // right now is populate the element restyle data in layout, and we + // could in theory do it in the DOM I think. + let mut entry = self.ensure_pending_restyle(el); + if entry.snapshot.is_none() { + entry.snapshot = Some(Snapshot::new(el.html_element_in_html_document())); + } + if attr.local_name() == &local_name!("style") { + entry.hint |= RESTYLE_STYLE_ATTRIBUTE; + } + + let mut snapshot = entry.snapshot.as_mut().unwrap(); if snapshot.attrs.is_none() { let attrs = el.attrs() .iter()