style: Document the restyle hints code, and make it operate on TElement.

This removes the annoying constraint of having to provide the current state from
outside of the restyle hints code.
This commit is contained in:
Emilio Cobos Álvarez 2017-01-01 23:53:34 +01:00
parent c5f2142d8f
commit fa8874fb14
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 101 additions and 53 deletions

View file

@ -8,8 +8,7 @@
use {Atom, LocalName};
use data::ComputedStyle;
use dom::PresentationalHintsSynthetizer;
use element_state::*;
use dom::{PresentationalHintsSynthetizer, TElement};
use error_reporting::StdoutErrorReporter;
use keyframes::KeyframesAnimation;
use media_queries::{Device, MediaType};
@ -662,16 +661,11 @@ impl Stylist {
/// restyle we need to do.
pub fn compute_restyle_hint<E>(&self,
element: &E,
snapshot: &Snapshot,
// NB: We need to pass current_state as an argument because
// selectors::Element doesn't provide access to ElementState
// directly, and computing it from the ElementState would be
// more expensive than getting it directly from the caller.
current_state: ElementState)
snapshot: &Snapshot)
-> RestyleHint
where E: ElementExt + Clone,
where E: TElement,
{
self.state_deps.compute_hint(element, snapshot, current_state)
self.state_deps.compute_hint(element, snapshot)
}
}