diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 963a7981562..eda755f177c 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -20,7 +20,6 @@ use model::MaybeAuto; use std::fmt; use std::sync::Arc; use style::computed_values::{border_collapse, border_top_style}; -use style::legacy::UnsignedIntegerAttribute; use style::properties::ComputedValues; use table::InternalTable; use table_row::{CollapsedBorder, CollapsedBorderProvenance}; @@ -52,8 +51,7 @@ impl TableCellFlow { TableCellFlow { block_flow: BlockFlow::from_fragment(fragment, None), collapsed_borders: CollapsedBordersForCell::new(), - column_span: node.get_unsigned_integer_attribute(UnsignedIntegerAttribute::ColSpan) - .unwrap_or(1), + column_span: node.get_colspan(), visible: visible, } } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index b5f507f0108..96bf3927381 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -64,7 +64,6 @@ use std::sync::Arc; use string_cache::{Atom, Namespace}; use style::computed_values::content::ContentItem; use style::computed_values::{content, display, white_space}; -use style::legacy::UnsignedIntegerAttribute; use style::node::TElementAttributes; use style::properties::ComputedValues; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock}; @@ -643,12 +642,6 @@ impl<'le> TElementAttributes for LayoutElement<'le> { } } - fn get_unsigned_integer_attribute(&self, attribute: UnsignedIntegerAttribute) -> Option { - unsafe { - self.element.get_unsigned_integer_attribute_for_layout(attribute) - } - } - #[inline] fn get_attr<'a>(&'a self, namespace: &Namespace, name: &Atom) -> Option<&'a str> { unsafe { @@ -885,18 +878,6 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { } } - pub fn get_unsigned_integer_attribute(self, attribute: UnsignedIntegerAttribute) - -> Option { - unsafe { - match self.get_jsmanaged().downcast::() { - Some(element) => { - element.get_unsigned_integer_attribute_for_layout(attribute) - } - None => panic!("not an element!") - } - } - } - /// Get the description of how to account for recent style changes. /// This is a simple bitfield and fine to copy by value. pub fn restyle_damage(self) -> RestyleDamage { @@ -1039,6 +1020,12 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { iframe_element.pipeline_id().unwrap() } } + + pub fn get_colspan(&self) -> u32 { + unsafe { + self.get_jsmanaged().downcast::().unwrap().get_colspan() + } + } } pub struct ThreadSafeLayoutNodeChildrenIterator<'a> { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index a6a98d91178..c7e87a1535d 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -75,7 +75,6 @@ use std::default::Default; use std::mem; use std::sync::Arc; use string_cache::{Atom, Namespace, QualName}; -use style::legacy::{UnsignedIntegerAttribute, from_declaration}; use style::properties::DeclaredValue; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; @@ -225,8 +224,7 @@ pub trait LayoutElementHelpers { unsafe fn synthesize_presentational_hints_for_legacy_attributes(&self, &mut V) where V: VecLike>>; #[allow(unsafe_code)] - unsafe fn get_unsigned_integer_attribute_for_layout(&self, attribute: UnsignedIntegerAttribute) - -> Option; + unsafe fn get_colspan(self) -> u32; #[allow(unsafe_code)] unsafe fn html_element_in_html_document_for_layout(&self) -> bool; fn id_attribute(&self) -> *const Option; @@ -260,6 +258,12 @@ impl LayoutElementHelpers for LayoutJS { unsafe fn synthesize_presentational_hints_for_legacy_attributes(&self, hints: &mut V) where V: VecLike>> { + #[inline] + fn from_declaration(rule: PropertyDeclaration) + -> DeclarationBlock> { + DeclarationBlock::from_declarations(Arc::new(vec![rule])) + } + let bgcolor = if let Some(this) = self.downcast::() { this.get_background_color() } else if let Some(this) = self.downcast::() { @@ -503,19 +507,13 @@ impl LayoutElementHelpers for LayoutJS { } #[allow(unsafe_code)] - unsafe fn get_unsigned_integer_attribute_for_layout(&self, - attribute: UnsignedIntegerAttribute) - -> Option { - match attribute { - UnsignedIntegerAttribute::ColSpan => { - if let Some(this) = self.downcast::() { - this.get_colspan() - } else { - // Don't panic since `display` can cause this to be called on arbitrary - // elements. - None - } - } + unsafe fn get_colspan(self) -> u32 { + if let Some(this) = self.downcast::() { + this.get_colspan().unwrap_or(1) + } else { + // Don't panic since `display` can cause this to be called on arbitrary + // elements. + 1 } } diff --git a/components/style/legacy.rs b/components/style/legacy.rs deleted file mode 100644 index ffaaaadcab6..00000000000 --- a/components/style/legacy.rs +++ /dev/null @@ -1,60 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Legacy presentational attributes defined in the HTML5 specification: ``, -//! ``, and so forth. - -use node::TElementAttributes; -use properties::PropertyDeclaration; -use selector_matching::Stylist; -use selectors::Element; -use selectors::matching::DeclarationBlock; -use smallvec::VecLike; -use std::sync::Arc; - - -/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 ยง 2.4.4.2. -#[derive(Copy, Clone, PartialEq, Eq)] -pub enum UnsignedIntegerAttribute { - /// `` - ColSpan, -} - -/// Extension methods for `Stylist` that cause rules to be synthesized for legacy attributes. -pub trait PresentationalHintSynthesis { - /// Synthesizes rules from various HTML attributes (mostly legacy junk from HTML4) that confer - /// *presentational hints* as defined in the HTML5 specification. This handles stuff like - /// ``, ``, ``, and so forth. - /// - /// NB: Beware! If you add an attribute to this list, be sure to add it to - /// `common_style_affecting_attributes` or `rare_style_affecting_attributes` as appropriate. If - /// you don't, you risk strange random nondeterministic failures due to false positives in - /// style sharing. - fn synthesize_presentational_hints_for_legacy_attributes( - &self, element: &E, matching_rules_list: &mut V, shareable: &mut bool) - where E: Element + TElementAttributes, - V: VecLike>>; -} - -impl PresentationalHintSynthesis for Stylist { - fn synthesize_presentational_hints_for_legacy_attributes( - &self, element: &E, matching_rules_list: &mut V, shareable: &mut bool) - where E: Element + TElementAttributes, - V: VecLike>> { - let length = matching_rules_list.len(); - element.synthesize_presentational_hints_for_legacy_attributes(matching_rules_list); - if matching_rules_list.len() != length { - // Never share style for elements with preshints - *shareable = false; - } - } -} - - -/// A convenience function to create a declaration block from a single declaration. This is -/// primarily used in `synthesize_rules_for_legacy_attributes`. -#[inline] -pub fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock> { - DeclarationBlock::from_declarations(Arc::new(vec![rule])) -} diff --git a/components/style/lib.rs b/components/style/lib.rs index a30274233d9..230a6cd0e28 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -45,7 +45,6 @@ pub mod animation; pub mod attr; mod custom_properties; pub mod font_face; -pub mod legacy; pub mod media_queries; pub mod node; pub mod parser; diff --git a/components/style/node.rs b/components/style/node.rs index aa764f5f662..302ad48fd80 100644 --- a/components/style/node.rs +++ b/components/style/node.rs @@ -5,7 +5,6 @@ //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency between layout and //! style. -use legacy::UnsignedIntegerAttribute; use properties::PropertyDeclaration; use selectors::matching::DeclarationBlock; use smallvec::VecLike; @@ -14,7 +13,6 @@ use string_cache::{Atom, Namespace}; pub trait TElementAttributes { fn synthesize_presentational_hints_for_legacy_attributes(&self, &mut V) where V: VecLike>>; - fn get_unsigned_integer_attribute(&self, attribute: UnsignedIntegerAttribute) -> Option; fn get_attr<'a>(&'a self, namespace: &Namespace, attr: &Atom) -> Option<&'a str>; fn get_attrs<'a>(&'a self, attr: &Atom) -> Vec<&'a str>; diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 5a4b1734917..e8887163b61 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use legacy::PresentationalHintSynthesis; use media_queries::{Device, MediaType}; use node::TElementAttributes; use properties::{PropertyDeclaration, PropertyDeclarationBlock}; @@ -277,9 +276,12 @@ impl Stylist { &mut shareable); // Step 2: Presentational hints. - self.synthesize_presentational_hints_for_legacy_attributes(element, - applicable_declarations, - &mut shareable); + let length = applicable_declarations.len(); + element.synthesize_presentational_hints_for_legacy_attributes(applicable_declarations); + if applicable_declarations.len() != length { + // Never share style for elements with preshints + shareable = false; + } // Step 3: User and author normal rules. map.user.normal.get_all_matching_rules(element,