mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
script: insert the restyle attribute restyle hint when a style attribute is modified.
This commit is contained in:
parent
d37e6f8c66
commit
cb304fd42c
1 changed files with 18 additions and 9 deletions
|
@ -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<Snapshot> {
|
||||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue