diff options
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/legacy.rs | 129 | ||||
-rw-r--r-- | components/style/node.rs | 5 |
2 files changed, 3 insertions, 131 deletions
diff --git a/components/style/legacy.rs b/components/style/legacy.rs index b10376981a8..4d6e89756af 100644 --- a/components/style/legacy.rs +++ b/components/style/legacy.rs @@ -10,39 +10,20 @@ use std::sync::Arc; use selectors::tree::{TElement, TNode}; use selectors::matching::DeclarationBlock; use node::TElementAttributes; -use values::{CSSFloat, specified}; +use values::specified; use properties::DeclaredValue::SpecifiedValue; use properties::PropertyDeclaration; -use properties::longhands::{self, border_spacing}; +use properties::longhands; use selector_matching::Stylist; use util::geometry::Au; use util::smallvec::VecLike; -use util::str::LengthOrPercentageOrAuto; - -/// Legacy presentational attributes that take a length as defined in HTML5 § 2.4.4.4. -#[derive(Copy, Clone, PartialEq, Eq)] -pub enum LengthAttribute { - /// `<td width>` - Width, -} - -/// Legacy presentational attributes that take an integer as defined in HTML5 § 2.4.4.2. -#[derive(Copy, Clone, PartialEq, Eq)] -pub enum IntegerAttribute { - /// `<input size>` - Size, - Cols, - Rows, -} /// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2. #[derive(Copy, Clone, PartialEq, Eq)] pub enum UnsignedIntegerAttribute { /// `<td border>` Border, - /// `<table cellspacing>` - CellSpacing, /// `<td colspan>` ColSpan, } @@ -75,14 +56,6 @@ pub trait PresentationalHintSynthesis { E: TElement<'a> + TElementAttributes<'a>, V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>; - /// Synthesizes rules for the legacy `width` attribute. - fn synthesize_presentational_hint_for_legacy_width_attribute<'a,E,V>( - &self, - element: E, - matching_rules_list: &mut V, - shareable: &mut bool) - where E: TElement<'a> + TElementAttributes<'a>, - V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>; } impl PresentationalHintSynthesis for Stylist { @@ -105,89 +78,16 @@ impl PresentationalHintSynthesis for Stylist { match element.get_local_name() { name if *name == atom!("td") => { - self.synthesize_presentational_hint_for_legacy_width_attribute( - element, - matching_rules_list, - shareable); self.synthesize_presentational_hint_for_legacy_border_attribute( element, matching_rules_list, shareable); } name if *name == atom!("table") => { - self.synthesize_presentational_hint_for_legacy_width_attribute( - element, - matching_rules_list, - shareable); self.synthesize_presentational_hint_for_legacy_border_attribute( element, matching_rules_list, shareable); - match element.get_unsigned_integer_attribute( - UnsignedIntegerAttribute::CellSpacing) { - None => {} - Some(length) => { - let width_value = specified::Length::Absolute(Au::from_px(length as i32)); - matching_rules_list.push(from_declaration( - PropertyDeclaration::BorderSpacing( - SpecifiedValue( - border_spacing::SpecifiedValue { - horizontal: width_value, - vertical: width_value, - })))); - *shareable = false - } - } - } - name if *name == atom!("input") => { - // FIXME(pcwalton): More use of atoms, please! - match element.get_attr(&ns!(""), &atom!("type")) { - Some("text") | Some("password") => { - match element.get_integer_attribute(IntegerAttribute::Size) { - Some(value) if value != 0 => { - let value = specified::Length::ServoCharacterWidth( - specified::CharacterWidth(value)); - matching_rules_list.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue( - specified::LengthOrPercentageOrAuto::Length(value))))); - *shareable = false - } - Some(_) | None => {} - } - } - _ => {} - }; - } - name if *name == atom!("textarea") => { - match element.get_integer_attribute(IntegerAttribute::Cols) { - Some(value) if value != 0 => { - // TODO(mttr) ServoCharacterWidth uses the size math for <input type="text">, but - // the math for <textarea> is a little different since we need to take - // scrollbar size into consideration (but we don't have a scrollbar yet!) - // - // https://html.spec.whatwg.org/multipage/#textarea-effective-width - let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(value)); - matching_rules_list.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue( - specified::LengthOrPercentageOrAuto::Length(value))))); - *shareable = false - } - Some(_) | None => {} - } - match element.get_integer_attribute(IntegerAttribute::Rows) { - Some(value) if value != 0 => { - // TODO(mttr) This should take scrollbar size into consideration. - // - // https://html.spec.whatwg.org/multipage/#textarea-effective-height - let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(value as CSSFloat)); - matching_rules_list.push(from_declaration( - PropertyDeclaration::Height(SpecifiedValue( - longhands::height::SpecifiedValue( - specified::LengthOrPercentageOrAuto::Length(value)))))); - *shareable = false - } - Some(_) | None => {} - } } _ => {} } @@ -222,31 +122,6 @@ impl PresentationalHintSynthesis for Stylist { } } } - - fn synthesize_presentational_hint_for_legacy_width_attribute<'a,E,V>( - &self, - element: E, - matching_rules_list: &mut V, - shareable: &mut bool) - where E: TElement<'a> + TElementAttributes<'a>, - V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>> { - match element.get_length_attribute(LengthAttribute::Width) { - LengthOrPercentageOrAuto::Auto => {} - LengthOrPercentageOrAuto::Percentage(percentage) => { - let width_value = specified::LengthOrPercentageOrAuto::Percentage(percentage); - matching_rules_list.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue(width_value)))); - *shareable = false - } - LengthOrPercentageOrAuto::Length(length) => { - let width_value = specified::LengthOrPercentageOrAuto::Length( - specified::Length::Absolute(length)); - matching_rules_list.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue(width_value)))); - *shareable = false - } - } - } } diff --git a/components/style/node.rs b/components/style/node.rs index ebfcf7d9068..dfe0913e12a 100644 --- a/components/style/node.rs +++ b/components/style/node.rs @@ -5,10 +5,9 @@ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency between layout and //! style. -use legacy::{IntegerAttribute, LengthAttribute, UnsignedIntegerAttribute}; +use legacy::UnsignedIntegerAttribute; use properties::PropertyDeclaration; use util::smallvec::VecLike; -use util::str::LengthOrPercentageOrAuto; use selectors::matching::DeclarationBlock; pub use selectors::tree::{TNode, TElement}; @@ -17,8 +16,6 @@ use string_cache::{Atom, Namespace}; pub trait TElementAttributes<'a> : 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>; fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str>; |