Create a new infrastructure for presentational hints.

This commit is contained in:
Ms2ger 2015-04-26 19:34:26 +02:00
parent 852d973a70
commit 582ee1c2b3
5 changed files with 41 additions and 3 deletions

View file

@ -108,6 +108,14 @@ impl PresentationalHintSynthesis for Stylist {
N::Element: TElementAttributes,
V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>> {
let element = node.as_element();
let length = matching_rules_list.vec_len();
element.synthesize_presentational_hints_for_legacy_attributes(matching_rules_list);
if matching_rules_list.vec_len() != length {
// Never share style for elements with preshints
*shareable = false;
}
match element.get_local_name() {
name if *name == atom!("td") => {
match element.get_length_attribute(LengthAttribute::Width) {

View file

@ -7,11 +7,16 @@
use cssparser::RGBA;
use legacy::{IntegerAttribute, LengthAttribute, SimpleColorAttribute, UnsignedIntegerAttribute};
use properties::PropertyDeclaration;
use util::str::LengthOrPercentageOrAuto;
use selectors::matching::DeclarationBlock;
use selectors::smallvec::VecLike;
pub use selectors::tree::{TNode, TElement};
pub trait TElementAttributes : Copy {
fn synthesize_presentational_hints_for_legacy_attributes<V>(self, &mut V)
where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
fn get_length_attribute(self, attribute: LengthAttribute) -> LengthOrPercentageOrAuto;
fn get_integer_attribute(self, attribute: IntegerAttribute) -> Option<i32>;
fn get_unsigned_integer_attribute(self, attribute: UnsignedIntegerAttribute) -> Option<u32>;