diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 33e343df99f..c6549fde57c 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -60,7 +60,7 @@ use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DES use script::dom::text::Text; use script::layout_interface::LayoutChan; use msg::constellation_msg::{PipelineId, SubpageId}; -use util::str::{LengthOrPercentageOrAuto, is_whitespace}; +use util::str::is_whitespace; use std::borrow::ToOwned; use std::cell::{Ref, RefMut}; use std::marker::PhantomData; @@ -71,8 +71,7 @@ use style::computed_values::content::ContentItem; use style::computed_values::{content, display, white_space}; use selectors::matching::DeclarationBlock; use selectors::parser::{NamespaceConstraint, AttrSelector}; -use style::legacy::{IntegerAttribute, LengthAttribute}; -use style::legacy::{UnsignedIntegerAttribute}; +use style::legacy::{IntegerAttribute, UnsignedIntegerAttribute}; use style::node::{TElement, TElementAttributes, TNode}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock}; use util::smallvec::VecLike; @@ -657,12 +656,6 @@ impl<'le> TElementAttributes<'le> for LayoutElement<'le> { } } - fn get_length_attribute(self, length_attribute: LengthAttribute) -> LengthOrPercentageOrAuto { - unsafe { - self.element.get_length_attribute_for_layout(length_attribute) - } - } - fn get_integer_attribute(self, integer_attribute: IntegerAttribute) -> Option { unsafe { self.element.get_integer_attribute_for_layout(integer_attribute) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 4fbb432614c..5034da72235 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -59,7 +59,7 @@ use dom::virtualmethods::{VirtualMethods, vtable_for}; use devtools_traits::AttrInfo; use style; -use style::legacy::{UnsignedIntegerAttribute, IntegerAttribute, LengthAttribute, from_declaration}; +use style::legacy::{UnsignedIntegerAttribute, IntegerAttribute, from_declaration}; use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute}; use style::properties::DeclaredValue::SpecifiedValue; use style::properties::longhands::border_spacing; @@ -164,8 +164,6 @@ pub trait RawLayoutElementHelpers { unsafe fn synthesize_presentational_hints_for_legacy_attributes(&self, &mut V) where V: VecLike>>; - unsafe fn get_length_attribute_for_layout(&self, length_attribute: LengthAttribute) - -> LengthOrPercentageOrAuto; unsafe fn get_integer_attribute_for_layout(&self, integer_attribute: IntegerAttribute) -> Option; unsafe fn get_checked_state_for_layout(&self) -> bool; @@ -307,22 +305,29 @@ impl RawLayoutElementHelpers for Element { PropertyDeclaration::Width(SpecifiedValue( specified::LengthOrPercentageOrAuto::Length(value))))); } - } - #[inline] - unsafe fn get_length_attribute_for_layout(&self, length_attribute: LengthAttribute) - -> LengthOrPercentageOrAuto { - match length_attribute { - LengthAttribute::Width => { - if self.is_htmltableelement() { - let this: &HTMLTableElement = mem::transmute(self); - this.get_width() - } else if self.is_htmltablecellelement() { - let this: &HTMLTableCellElement = mem::transmute(self); - this.get_width() - } else { - panic!("I'm not a table or table cell!") - } + + let width = if self.is_htmltableelement() { + let this: &HTMLTableElement = mem::transmute(self); + this.get_width() + } else if self.is_htmltabledatacellelement() { + let this: &HTMLTableCellElement = mem::transmute(self); + this.get_width() + } else { + LengthOrPercentageOrAuto::Auto + }; + + match width { + LengthOrPercentageOrAuto::Auto => {} + LengthOrPercentageOrAuto::Percentage(percentage) => { + let width_value = specified::LengthOrPercentageOrAuto::Percentage(percentage); + hints.push(from_declaration( + PropertyDeclaration::Width(SpecifiedValue(width_value)))); + } + LengthOrPercentageOrAuto::Length(length) => { + let width_value = specified::LengthOrPercentageOrAuto::Length(specified::Length::Absolute(length)); + hints.push(from_declaration( + PropertyDeclaration::Width(SpecifiedValue(width_value)))); } } } diff --git a/components/style/legacy.rs b/components/style/legacy.rs index 8c4ed130916..18b28ec7fa5 100644 --- a/components/style/legacy.rs +++ b/components/style/legacy.rs @@ -18,14 +18,6 @@ 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 { - /// `` - Width, -} /// Legacy presentational attributes that take an integer as defined in HTML5 § 2.4.4.2. #[derive(Copy, Clone, PartialEq, Eq)] @@ -71,14 +63,6 @@ pub trait PresentationalHintSynthesis { E: TElement<'a> + TElementAttributes<'a>, V: VecLike>>; - /// 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>>; } impl PresentationalHintSynthesis for Stylist { @@ -101,20 +85,12 @@ 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, @@ -184,31 +160,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>> { - 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..f01da162364 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::{IntegerAttribute, UnsignedIntegerAttribute}; use properties::PropertyDeclaration; use util::smallvec::VecLike; -use util::str::LengthOrPercentageOrAuto; use selectors::matching::DeclarationBlock; pub use selectors::tree::{TNode, TElement}; @@ -17,7 +16,6 @@ use string_cache::{Atom, Namespace}; pub trait TElementAttributes<'a> : Copy { fn synthesize_presentational_hints_for_legacy_attributes(self, &mut V) where V: VecLike>>; - fn get_length_attribute(self, attribute: LengthAttribute) -> LengthOrPercentageOrAuto; fn get_integer_attribute(self, attribute: IntegerAttribute) -> Option; fn get_unsigned_integer_attribute(self, attribute: UnsignedIntegerAttribute) -> Option;