style: Rewrite the restyle hints code to allow different kinds of element snapshots, and use it for Gecko.

This is a rewrite for how style interfaces with its consumers in order to allow
different representations for an element snapshot.

This also changes the requirements of an element snapshot, requiring them to
only implement MatchAttr, instead of MatchAttrGeneric. This is important for
stylo since implementing MatchAttrGeneric is way more difficult for us given the
atom limitations. This also allows for more performant implementations in the
Gecko side of things.
This commit is contained in:
Emilio Cobos Álvarez 2016-07-15 16:31:20 -07:00
parent ca9bc23b39
commit 611e611215
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
15 changed files with 565 additions and 246 deletions

View file

@ -89,8 +89,7 @@ use string_cache::{Atom, Namespace, QualName};
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*;
use style::properties::PropertyDeclarationBlock;
use style::restyle_hints::ElementSnapshot;
use style::selector_impl::PseudoElement;
use style::selector_impl::{PseudoElement, ElementSnapshot};
use style::values::specified::Length;
use url::Origin as UrlOrigin;
use url::Url;

View file

@ -122,7 +122,7 @@ use std::sync::Arc;
use string_cache::{Atom, QualName};
use style::attr::AttrValue;
use style::context::ReflowGoal;
use style::restyle_hints::ElementSnapshot;
use style::selector_impl::ElementSnapshot;
use style::str::{split_html_space_chars, str_join};
use style::stylesheets::Stylesheet;
use time;
@ -1851,7 +1851,10 @@ impl Document {
pub fn element_state_will_change(&self, el: &Element) {
let mut map = self.modified_elements.borrow_mut();
let snapshot = map.entry(JS::from_ref(el)).or_insert(ElementSnapshot::new());
let snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| {
ElementSnapshot::new(el.html_element_in_html_document())
});
if snapshot.state.is_none() {
snapshot.state = Some(el.state());
}
@ -1859,7 +1862,10 @@ impl Document {
pub fn element_attr_will_change(&self, el: &Element) {
let mut map = self.modified_elements.borrow_mut();
let mut snapshot = map.entry(JS::from_ref(el)).or_insert(ElementSnapshot::new());
let mut snapshot = map.entry(JS::from_ref(el))
.or_insert_with(|| {
ElementSnapshot::new(el.html_element_in_html_document())
});
if snapshot.attrs.is_none() {
let attrs = el.attrs()
.iter()

View file

@ -60,8 +60,7 @@ use style::dom::{PresentationalHintsSynthetizer, OpaqueNode, TDocument, TElement
use style::element_state::*;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use style::refcell::{Ref, RefCell, RefMut};
use style::restyle_hints::ElementSnapshot;
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
use style::selector_impl::{ElementSnapshot, NonTSPseudoClass, ServoSelectorImpl};
use style::sink::Push;
use style::str::is_whitespace;
use url::Url;