diff options
39 files changed, 159 insertions, 169 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index c0495a2f479..b54d7a553b5 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -40,7 +40,7 @@ use util::smallvec::{SmallVec, SmallVec8}; use std::fmt; use std::slice::Iter; use std::sync::Arc; -use style::ComputedValues; +use style::properties::ComputedValues; use style::computed_values::{border_style, cursor, filter, mix_blend_mode, pointer_events}; // It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 366deb5e589..15eebedbc09 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -11,7 +11,7 @@ use std::cell::RefCell; use util::cache::HashCache; use util::smallvec::{SmallVec, SmallVec8}; use style::computed_values::{font_stretch, font_variant, font_weight}; -use style::style_structs::Font as FontStyle; +use style::properties::style_structs::Font as FontStyle; use std::sync::Arc; use std::hash::Hash; diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index 6084f54c710..782c68dd4b2 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -18,7 +18,7 @@ use platform::font_template::FontTemplateData; use servo_net::resource_task::{ResourceTask, load_whole_resource}; use util::task::spawn_named; use util::str::LowercaseString; -use style::Source; +use style::font_face::Source; /// A list of font templates that make up a given font family. struct FontFamily { diff --git a/components/layout/block.rs b/components/layout/block.rs index d1ffc16a111..f7f7dde2b48 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -57,10 +57,9 @@ use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize}; use servo_util::opts; use std::cmp::{max, min}; use std::fmt; -use style::ComputedValues; -use style::computed_values::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; -use style::computed_values::{LengthOrPercentage, box_sizing, display, float}; -use style::computed_values::{overflow, position}; +use style::properties::ComputedValues; +use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; +use style::computed_values::{overflow, position, box_sizing, display, float}; use std::sync::Arc; /// Information specific to floated blocks. diff --git a/components/layout/construct.rs b/components/layout/construct.rs index eb241630dba..c94ec8e9296 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -56,7 +56,7 @@ use std::mem; use std::sync::atomic::Ordering; use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; use style::computed_values::{position}; -use style::{self, ComputedValues}; +use style::properties::{ComputedValues, make_inline}; use std::sync::Arc; use url::Url; @@ -707,7 +707,7 @@ impl<'a> FlowConstructor<'a> { // `baz` had better not be absolutely positioned! let mut style = (*node.style()).clone(); if style.get_box().display != display::T::inline { - style = Arc::new(style::make_inline(&*style)) + style = Arc::new(make_inline(&*style)) } // If this is generated content, then we need to initialize the accumulator with the diff --git a/components/layout/context.rs b/components/layout/context.rs index e3df7a1a8b5..29a96358ff5 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -19,7 +19,7 @@ use std::cell::Cell; use std::mem; use std::ptr; use std::sync::{Arc, Mutex}; -use style::Stylist; +use style::selector_matching::Stylist; use url::Url; struct LocalLayoutContext { diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 0f1931c3efb..6a491eabd79 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -19,8 +19,12 @@ use std::mem; use std::hash::{Hash, Hasher, Writer}; use std::slice::Iter; use string_cache::{Atom, Namespace}; -use style::{self, PseudoElement, ComputedValues, DeclarationBlock, Stylist, TElement, TNode}; -use style::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes, cascade}; +use style::selectors::PseudoElement; +use style::selector_matching::{Stylist, DeclarationBlock}; +use style::node::{TElement, TNode}; +use style::properties::{ComputedValues, cascade}; +use style::selector_matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes}; +use style::selector_matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use std::sync::Arc; pub struct ApplicableDeclarations { @@ -156,7 +160,7 @@ pub struct StyleSharingCandidateCache { fn create_common_style_affecting_attributes_from_element(element: &LayoutElement) -> CommonStyleAffectingAttributes { let mut flags = CommonStyleAffectingAttributes::empty(); - for attribute_info in style::common_style_affecting_attributes().iter() { + for attribute_info in common_style_affecting_attributes().iter() { match attribute_info.mode { CommonStyleAffectingAttributeMode::IsPresent(flag) => { if element.get_attr(&ns!(""), &attribute_info.atom).is_some() { @@ -276,7 +280,7 @@ impl StyleSharingCandidate { // FIXME(pcwalton): It's probably faster to iterate over all the element's attributes and // use the {common, rare}-style-affecting-attributes tables as lookup tables. - for attribute_info in style::common_style_affecting_attributes().iter() { + for attribute_info in common_style_affecting_attributes().iter() { match attribute_info.mode { CommonStyleAffectingAttributeMode::IsPresent(flag) => { if self.common_style_affecting_attributes.contains(flag) != @@ -303,7 +307,7 @@ impl StyleSharingCandidate { } } - for attribute_name in style::rare_style_affecting_attributes().iter() { + for attribute_name in rare_style_affecting_attributes().iter() { if element.get_attr(&ns!(""), attribute_name).is_some() { return false } diff --git a/components/layout/css/node_style.rs b/components/layout/css/node_style.rs index d2cbf029b1a..a153447f7a3 100644 --- a/components/layout/css/node_style.rs +++ b/components/layout/css/node_style.rs @@ -7,7 +7,7 @@ use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use std::mem; -use style::ComputedValues; +use style::properties::ComputedValues; use std::sync::Arc; /// Node mixin providing `style` method that returns a `NodeStyle` diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 1c81e65459b..6ec6f4a317b 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -47,12 +47,13 @@ use std::default::Default; use std::iter::repeat; use std::num::Float; use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection}; -use style::computed::{Image, LinearGradient, LengthOrPercentage}; +use style::values::computed::{Image, LinearGradient, LengthOrPercentage}; +use style::values::RGBA; use style::computed_values::filter::Filter; use style::computed_values::{background_attachment, background_repeat, border_style, overflow}; use style::computed_values::{position, visibility}; -use style::style_structs::Border; -use style::{ComputedValues, RGBA}; +use style::properties::style_structs::Border; +use style::properties::ComputedValues; use std::num::ToPrimitive; use std::sync::Arc; use std::sync::mpsc::channel; diff --git a/components/layout/flow.rs b/components/layout/flow.rs index c87088bf829..9ca0446b9c4 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -60,7 +60,7 @@ use std::raw; use std::sync::atomic::{AtomicUint, Ordering}; use std::slice::IterMut; use style::computed_values::{clear, empty_cells, float, position, text_align}; -use style::ComputedValues; +use style::properties::ComputedValues; use std::sync::Arc; /// Virtual methods that make up a float context. diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 2b802c43cdd..9ca946d8ded 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -46,9 +46,10 @@ use std::str::FromStr; use std::sync::{Arc, Mutex}; use std::sync::mpsc::Sender; use string_cache::Atom; -use style::{ComputedValues, TElement, TNode, cascade_anonymous}; -use style::computed_values::{LengthOrPercentage, LengthOrPercentageOrAuto}; -use style::computed_values::{LengthOrPercentageOrNone, clear, mix_blend_mode, overflow_wrap}; +use style::properties::{ComputedValues, cascade_anonymous}; +use style::node::{TElement, TNode}; +use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; +use style::computed_values::{clear, mix_blend_mode, overflow_wrap}; use style::computed_values::{position, text_align, text_decoration, vertical_align, white_space}; use style::computed_values::{word_break}; use text::TextRunScanner; diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 1b89015e6aa..2ad6177c497 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -8,7 +8,7 @@ use flow::{IS_ABSOLUTELY_POSITIONED}; use std::fmt; use std::sync::Arc; use style::computed_values::float; -use style::ComputedValues; +use style::properties::ComputedValues; bitflags! { #[doc = "Individual layout actions that may be necessary after restyling."] diff --git a/components/layout/inline.rs b/components/layout/inline.rs index c864b56e111..b90d2f71f93 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -36,7 +36,7 @@ use std::ops::{Add, Sub, Mul, Div, Rem, Neg, Shl, Shr, Not, BitOr, BitAnd, BitXo use std::u16; use style::computed_values::{overflow, text_align, text_justify, text_overflow, vertical_align}; use style::computed_values::{white_space}; -use style::ComputedValues; +use style::properties::ComputedValues; use std::sync::Arc; // From gfxFontConstants.h in Firefox diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 53491dfdc5e..9523585785f 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -65,9 +65,11 @@ use std::ops::{Deref, DerefMut}; use std::sync::mpsc::{channel, Sender, Receiver, Select}; use std::mem; use std::ptr; +use style::selector_matching::Stylist; use style::computed_values::{filter, mix_blend_mode}; -use style::{StylesheetOrigin, Stylesheet, Stylist, TNode, iter_font_face_rules}; -use style::{MediaType, Device}; +use style::stylesheets::{Origin, Stylesheet, iter_font_face_rules}; +use style::node::TNode; +use style::media_queries::{MediaType, Device}; use std::sync::{Arc, Mutex, MutexGuard}; use url::Url; @@ -488,7 +490,7 @@ impl LayoutTask { final_url, protocol_encoding_label, Some(environment_encoding), - StylesheetOrigin::Author); + Origin::Author); self.handle_add_stylesheet(sheet, possibly_locked_rw_data); } diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index 4c6bc9bc3b7..c14588c3d02 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -21,7 +21,7 @@ use gfx::display_list::DisplayList; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use servo_util::opts; -use style::ComputedValues; +use style::properties::ComputedValues; use style::computed_values::list_style_type; use std::sync::Arc; diff --git a/components/layout/model.rs b/components/layout/model.rs index b83585906ad..1cbb54aa99a 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -8,10 +8,9 @@ use fragment::Fragment; -use style::computed_values as computed; use geom::SideOffsets2D; -use style::computed_values::{LengthOrPercentageOrAuto, LengthOrPercentage}; -use style::ComputedValues; +use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, LengthOrPercentage}; +use style::properties::ComputedValues; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalMargin; use std::cmp::{max, min}; @@ -333,14 +332,14 @@ pub enum MaybeAuto { impl MaybeAuto { #[inline] - pub fn from_style(length: computed::LengthOrPercentageOrAuto, containing_length: Au) + pub fn from_style(length: LengthOrPercentageOrAuto, containing_length: Au) -> MaybeAuto { match length { - computed::LengthOrPercentageOrAuto::Auto => MaybeAuto::Auto, - computed::LengthOrPercentageOrAuto::Percentage(percent) => { + LengthOrPercentageOrAuto::Auto => MaybeAuto::Auto, + LengthOrPercentageOrAuto::Percentage(percent) => { MaybeAuto::Specified(containing_length.scale_by(percent)) } - computed::LengthOrPercentageOrAuto::Length(length) => MaybeAuto::Specified(length) + LengthOrPercentageOrAuto::Length(length) => MaybeAuto::Specified(length) } } @@ -366,18 +365,18 @@ impl MaybeAuto { } } -pub fn specified_or_none(length: computed::LengthOrPercentageOrNone, containing_length: Au) -> Option<Au> { +pub fn specified_or_none(length: LengthOrPercentageOrNone, containing_length: Au) -> Option<Au> { match length { - computed::LengthOrPercentageOrNone::None => None, - computed::LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent)), - computed::LengthOrPercentageOrNone::Length(length) => Some(length), + LengthOrPercentageOrNone::None => None, + LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent)), + LengthOrPercentageOrNone::Length(length) => Some(length), } } -pub fn specified(length: computed::LengthOrPercentage, containing_length: Au) -> Au { +pub fn specified(length: LengthOrPercentage, containing_length: Au) -> Au { match length { - computed::LengthOrPercentage::Length(length) => length, - computed::LengthOrPercentage::Percentage(p) => containing_length.scale_by(p) + LengthOrPercentage::Length(length) => length, + LengthOrPercentage::Percentage(p) => containing_length.scale_by(p) } } diff --git a/components/layout/table.rs b/components/layout/table.rs index 533d5166dbd..791ce834ccd 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -25,8 +25,10 @@ use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use std::cmp::max; use std::fmt; -use style::{ComputedValues, CSSFloat}; -use style::computed_values::{LengthOrPercentageOrAuto, table_layout}; +use style::properties::ComputedValues; +use style::values::CSSFloat; +use style::values::computed::{LengthOrPercentageOrAuto}; +use style::computed_values::table_layout; use std::sync::Arc; /// A table flow corresponded to the table's internal table fragment under a table wrapper flow. diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 17512755f87..d539d1b6c6f 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -17,7 +17,7 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use std::fmt; -use style::ComputedValues; +use style::properties::ComputedValues; use std::sync::Arc; /// A table formatting context. diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index dd6a74d5efd..5a11243dd38 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -19,7 +19,8 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use std::fmt; -use style::{UnsignedIntegerAttribute, ComputedValues}; +use style::properties::ComputedValues; +use style::legacy::UnsignedIntegerAttribute; use std::sync::Arc; /// A table formatting context. diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index f828bcc658a..8dfe070da03 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -17,8 +17,8 @@ use geom::{Point2D, Rect}; use servo_util::geometry::{Au, ZERO_RECT}; use std::cmp::max; use std::fmt; -use style::computed_values::LengthOrPercentageOrAuto; -use style::ComputedValues; +use style::values::computed::LengthOrPercentageOrAuto; +use style::properties::ComputedValues; use std::sync::Arc; /// A table formatting context. diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 0b4f06cee4d..317e0909735 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -23,8 +23,8 @@ use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use std::cmp::max; use std::fmt; -use style::ComputedValues; -use style::computed_values::LengthOrPercentageOrAuto; +use style::properties::ComputedValues; +use style::values::computed::LengthOrPercentageOrAuto; use std::sync::Arc; /// A single row of a table. diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index be014330208..377684b6917 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -19,7 +19,7 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalRect; use std::fmt; -use style::ComputedValues; +use style::properties::ComputedValues; use std::sync::Arc; /// A table formatting context. diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 6cb69a8b216..99f10710ff8 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -28,8 +28,10 @@ use servo_util::geometry::Au; use std::cmp::{max, min}; use std::fmt; use std::ops::Add; -use style::{ComputedValues, CSSFloat}; -use style::computed_values::{table_layout, LengthOrPercentageOrAuto}; +use style::properties::ComputedValues; +use style::computed_values::table_layout; +use style::values::CSSFloat; +use style::values::computed::LengthOrPercentageOrAuto; use std::sync::Arc; #[derive(Copy, RustcEncodable, Show)] diff --git a/components/layout/text.rs b/components/layout/text.rs index 7727c59a7c6..4c900b01449 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -22,10 +22,10 @@ use servo_util::range::Range; use servo_util::smallvec::{SmallVec, SmallVec1}; use std::collections::DList; use std::mem; -use style::ComputedValues; use style::computed_values::{line_height, text_orientation, text_rendering, text_transform}; use style::computed_values::{white_space}; -use style::style_structs::Font as FontStyle; +use style::properties::ComputedValues; +use style::properties::style_structs::Font as FontStyle; use std::sync::Arc; /// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextFragment`s. diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index c76c654dcf5..d0123afdcf7 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -19,7 +19,7 @@ use wrapper::{PreorderDomTraversal, PostorderDomTraversal}; use servo_util::bloom::BloomFilter; use servo_util::opts; use servo_util::tid::tid; -use style::TNode; +use style::node::TNode; use std::cell::RefCell; use std::mem; diff --git a/components/layout/util.rs b/components/layout/util.rs index 206590d7c23..e04bbfbbd7e 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -17,7 +17,7 @@ use script::layout_interface::{LayoutChan, TrustedNodeAddress}; use script_traits::UntrustedNodeAddress; use std::mem; use std::cell::{Ref, RefMut}; -use style::ComputedValues; +use style::properties::ComputedValues; use style; use std::sync::Arc; @@ -176,7 +176,7 @@ pub trait ToGfxColor { fn to_gfx_color(&self) -> gfx::color::Color; } -impl ToGfxColor for style::computed_values::RGBA { +impl ToGfxColor for style::values::RGBA { fn to_gfx_color(&self) -> gfx::color::Color { gfx::color::rgba(self.red, self.green, self.blue, self.alpha) } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index da89ab15e4a..039073e8795 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -66,9 +66,10 @@ use std::mem; use std::sync::mpsc::Sender; use string_cache::{Atom, Namespace}; use style::computed_values::{content, display, white_space}; -use style::{NamespaceConstraint, AttrSelector, IntegerAttribute}; -use style::{LengthAttribute, PropertyDeclarationBlock, SimpleColorAttribute}; -use style::{TElement, TElementAttributes, TNode, UnsignedIntegerAttribute}; +use style::selectors::{NamespaceConstraint, AttrSelector}; +use style::legacy::{LengthAttribute, SimpleColorAttribute, UnsignedIntegerAttribute, IntegerAttribute}; +use style::node::{TElement, TElementAttributes, TNode}; +use style::properties::PropertyDeclarationBlock; use url::Url; /// Allows some convenience methods on generic layout nodes. diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index d2af1ebe968..d814b3b6d12 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -58,7 +58,7 @@ use std::io::timer::Timer; use std::rc::Rc; use std::sync::mpsc::{Receiver, Sender}; use string_cache::{Atom, Namespace}; -use style::PropertyDeclarationBlock; +use style::properties::PropertyDeclarationBlock; use url::Url; diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 49a6bfbeae3..2de0942f968 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -17,8 +17,8 @@ use dom::node::{window_from_node, document_from_node, NodeDamage, Node}; use dom::window::Window; use util::str::DOMString; use string_cache::Atom; -use style::{is_supported_property, longhands_from_shorthand, parse_style_attribute}; -use style::PropertyDeclaration; +use style::properties::{is_supported_property, longhands_from_shorthand, parse_style_attribute}; +use style::properties::PropertyDeclaration; use std::ascii::AsciiExt; use std::borrow::ToOwned; diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 540916c027e..84f3d88ac7d 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -50,8 +50,11 @@ use dom::node::{window_from_node}; use dom::nodelist::NodeList; use dom::virtualmethods::{VirtualMethods, vtable_for}; use devtools_traits::AttrInfo; -use style::{self, SimpleColorAttribute, UnsignedIntegerAttribute}; -use style::{IntegerAttribute, LengthAttribute, matches}; +use style::legacy::{SimpleColorAttribute, UnsignedIntegerAttribute, IntegerAttribute, LengthAttribute}; +use style::selector_matching::matches; +use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute}; +use style::selectors::parse_author_origin_selector_list_from_str; +use style; use util::namespace; use util::str::{DOMString, LengthOrPercentageOrAuto}; @@ -74,7 +77,7 @@ pub struct Element { namespace: Namespace, prefix: Option<DOMString>, attrs: DOMRefCell<Vec<JS<Attr>>>, - style_attribute: DOMRefCell<Option<style::PropertyDeclarationBlock>>, + style_attribute: DOMRefCell<Option<PropertyDeclarationBlock>>, attr_list: MutNullableJS<NamedNodeMap>, class_list: MutNullableJS<DOMTokenList>, } @@ -152,7 +155,7 @@ pub trait RawLayoutElementHelpers { -> Option<RGBA>; fn local_name<'a>(&'a self) -> &'a Atom; fn namespace<'a>(&'a self) -> &'a Namespace; - fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>>; + fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>>; } #[inline] @@ -363,7 +366,7 @@ impl RawLayoutElementHelpers for Element { &self.namespace } - fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>> { + fn style_attribute<'a>(&'a self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>> { &self.style_attribute } } @@ -402,13 +405,13 @@ pub trait ElementHelpers<'a> { fn prefix(self) -> &'a Option<DOMString>; fn attrs(&self) -> Ref<Vec<JS<Attr>>>; fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>>; - fn style_attribute(self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>>; + fn style_attribute(self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>>; fn summarize(self) -> Vec<AttrInfo>; fn is_void(self) -> bool; fn remove_inline_style_property(self, property: DOMString); - fn update_inline_style(self, property_decl: style::PropertyDeclaration, style_priority: StylePriority); - fn get_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration>; - fn get_important_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration>; + fn update_inline_style(self, property_decl: PropertyDeclaration, style_priority: StylePriority); + fn get_inline_style_declaration(self, property: &Atom) -> Option<PropertyDeclaration>; + fn get_important_inline_style_declaration(self, property: &Atom) -> Option<PropertyDeclaration>; } impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { @@ -446,7 +449,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { self.extended_deref().attrs.borrow_mut() } - fn style_attribute(self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>> { + fn style_attribute(self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>> { &self.extended_deref().style_attribute } @@ -503,7 +506,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { }); } - fn update_inline_style(self, property_decl: style::PropertyDeclaration, style_priority: StylePriority) { + fn update_inline_style(self, property_decl: PropertyDeclaration, style_priority: StylePriority) { let mut inline_declarations = self.style_attribute().borrow_mut(); if let &mut Some(ref mut declarations) = &mut *inline_declarations { let existing_declarations = if style_priority == StylePriority::Important { @@ -528,13 +531,13 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { (vec!(), vec!(property_decl)) }; - *inline_declarations = Some(style::PropertyDeclarationBlock { + *inline_declarations = Some(PropertyDeclarationBlock { important: Arc::new(important), normal: Arc::new(normal), }); } - fn get_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration> { + fn get_inline_style_declaration(self, property: &Atom) -> Option<PropertyDeclaration> { let inline_declarations = self.style_attribute.borrow(); inline_declarations.as_ref().and_then(|declarations| { declarations.normal @@ -545,7 +548,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { }) } - fn get_important_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration> { + fn get_important_inline_style_declaration(self, property: &Atom) -> Option<PropertyDeclaration> { let inline_declarations = self.style_attribute.borrow(); inline_declarations.as_ref().and_then(|declarations| { declarations.important @@ -1117,7 +1120,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> { // http://dom.spec.whatwg.org/#dom-element-matches fn Matches(self, selectors: DOMString) -> Fallible<bool> { - match style::parse_author_origin_selector_list_from_str(selectors.as_slice()) { + match parse_author_origin_selector_list_from_str(selectors.as_slice()) { Err(()) => Err(Syntax), Ok(ref selectors) => { let root: JSRef<Node> = NodeCast::from_ref(self); @@ -1128,7 +1131,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> { // https://dom.spec.whatwg.org/#dom-element-closest fn Closest(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> { - match style::parse_author_origin_selector_list_from_str(selectors.as_slice()) { + match parse_author_origin_selector_list_from_str(selectors.as_slice()) { Err(()) => Err(Syntax), Ok(ref selectors) => { let root: JSRef<Node> = NodeCast::from_ref(self); @@ -1173,7 +1176,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { let doc = document_from_node(*self).root(); let base_url = doc.r().url().clone(); let value = attr.value(); - let style = Some(style::parse_style_attribute(value.as_slice(), &base_url)); + let style = Some(parse_style_attribute(value.as_slice(), &base_url)); *self.style_attribute.borrow_mut() = style; if node.is_in_doc() { @@ -1312,7 +1315,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { } } -impl<'a> style::TElement<'a> for JSRef<'a, Element> { +impl<'a> style::node::TElement<'a> for JSRef<'a, Element> { #[allow(unsafe_blocks)] fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> { self.get_attribute(namespace.clone(), attr).root().map(|attr| { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 5769ed56142..e39915ad848 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -14,7 +14,7 @@ use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node}; use dom::virtualmethods::VirtualMethods; use layout_interface::{LayoutChan, Msg}; use util::str::DOMString; -use style::{StylesheetOrigin, Stylesheet}; +use style::stylesheets::{Origin, Stylesheet}; #[dom_struct] pub struct HTMLStyleElement { @@ -55,8 +55,7 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> { let url = win.page().get_url(); let data = node.GetTextContent().expect("Element.textContent must be a string"); - let sheet = Stylesheet::from_str(data.as_slice(), url, - StylesheetOrigin::Author); + let sheet = Stylesheet::from_str(data.as_slice(), url, Origin::Author); let LayoutChan(ref layout_chan) = win.page().layout_chan; layout_chan.send(Msg::AddStylesheet(sheet)); } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index bd262ae2aaa..6c19a95e525 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -48,7 +48,11 @@ use devtools_traits::NodeInfo; use script_traits::UntrustedNodeAddress; use util::geometry::Au; use util::str::{DOMString, null_str_as_empty}; -use style::{matches, SelectorList}; +use style::selectors::{Selector, AttrSelector, NamespaceConstraint}; +use style::selectors::parse_author_origin_selector_list_from_str; +use style::selector_matching::matches; +use style::properties::ComputedValues; +use style; use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime}; use js::jsfriendapi; @@ -60,7 +64,6 @@ use std::cell::{Cell, RefCell, Ref, RefMut}; use std::default::Default; use std::iter::{FilterMap, Peekable}; use std::mem; -use style::{self, ComputedValues}; use std::sync::Arc; use uuid; use string_cache::QualName; @@ -376,12 +379,12 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> { } pub struct QuerySelectorIterator<'a> { - selectors: SelectorList, + selectors: Vec<Selector>, iterator: TreeIterator<'a>, } impl<'a> QuerySelectorIterator<'a> { - unsafe fn new(iter: TreeIterator<'a>, selectors: SelectorList) -> QuerySelectorIterator<'a> { + unsafe fn new(iter: TreeIterator<'a>, selectors: Vec<Selector>) -> QuerySelectorIterator<'a> { QuerySelectorIterator { selectors: selectors, iterator: iter, @@ -746,7 +749,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> { // http://dom.spec.whatwg.org/#dom-parentnode-queryselector fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> { // Step 1. - match style::parse_author_origin_selector_list_from_str(selectors.as_slice()) { + match parse_author_origin_selector_list_from_str(selectors.as_slice()) { // Step 2. Err(()) => return Err(Syntax), // Step 3. @@ -768,7 +771,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> { // Step 1. let nodes; let root = self.ancestors().last().unwrap_or(self.clone()); - match style::parse_author_origin_selector_list_from_str(selectors.as_slice()) { + match parse_author_origin_selector_list_from_str(selectors.as_slice()) { // Step 2. Err(()) => return Err(Syntax), // Step 3. @@ -2229,7 +2232,7 @@ impl<'a> VirtualMethods for JSRef<'a, Node> { } } -impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { +impl<'a> style::node::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { fn parent_node(self) -> Option<JSRef<'a, Node>> { // FIXME(zwarich): Remove this when UFCS lands and there is a better way // of disambiguating methods. @@ -2304,7 +2307,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { ElementCast::to_ref(self).unwrap() } - fn match_attr<F>(self, attr: &style::AttrSelector, test: F) -> bool + fn match_attr<F>(self, attr: &AttrSelector, test: F) -> bool where F: Fn(&str) -> bool { let name = { @@ -2315,11 +2318,11 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { } }; match attr.namespace { - style::NamespaceConstraint::Specific(ref ns) => { + NamespaceConstraint::Specific(ref ns) => { self.as_element().get_attribute(ns.clone(), name).root() .map_or(false, |attr| test(attr.r().value().as_slice())) }, - style::NamespaceConstraint::Any => { + NamespaceConstraint::Any => { self.as_element().get_attributes(name).into_iter() .map(|attr| attr.root()) .any(|attr| test(attr.r().value().as_slice())) diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index e4c6231b649..4dfa9ac658a 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -16,7 +16,7 @@ use util::geometry::Au; use std::any::Any; use std::sync::mpsc::{channel, Receiver, Sender}; use std::boxed::BoxAny; -use style::Stylesheet; +use style::stylesheets::Stylesheet; use url::Url; pub use dom::node::TrustedNodeAddress; diff --git a/components/style/font_face.rs b/components/style/font_face.rs index a731f9462e0..6012e0618ea 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -6,7 +6,7 @@ use cssparser::{Token, Parser, DeclarationListParser, AtRuleParser, DeclarationP use std::ascii::AsciiExt; use stylesheets::CSSRule; use properties::longhands::font_family::parse_one_family; -use properties::computed_values::font_family::FontFamily; +use computed_values::font_family::FontFamily; use media_queries::Device; use url::{Url, UrlParser}; use parser::{ParserContext, log_css_error}; diff --git a/components/style/lib.rs b/components/style/lib.rs index 0ad51ef559e..2c5380216f8 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -35,40 +35,27 @@ extern crate lazy_static; extern crate util; -pub use media_queries::{Device, MediaType}; -pub use stylesheets::{Stylesheet, iter_font_face_rules}; -pub use selector_matching::{Stylist}; -pub use selector_matching::{DeclarationBlock, CommonStyleAffectingAttributes}; -pub use selector_matching::{CommonStyleAffectingAttributeInfo, CommonStyleAffectingAttributeMode}; -pub use selector_matching::{matches, matches_simple_selector, common_style_affecting_attributes}; -pub use selector_matching::{rare_style_affecting_attributes}; -pub use selector_matching::{RECOMMENDED_SELECTOR_BLOOM_FILTER_SIZE, SELECTOR_WHITESPACE}; -pub use properties::{cascade, cascade_anonymous, longhands_from_shorthand}; -pub use properties::{is_supported_property, make_inline}; -pub use properties::{PropertyDeclaration}; -pub use properties::{computed_values, ComputedValues, style_structs}; -pub use properties::{PropertyDeclarationBlock, parse_style_attribute}; // Style attributes -pub use properties::{DeclaredValue, PropertyDeclarationParseResult}; -pub use values::CSSFloat; -pub use values::specified::{Angle, AngleOrCorner, HorizontalDirection, VerticalDirection}; -pub use values::computed; -pub use node::{TElement, TElementAttributes, TNode}; -pub use selectors::{PseudoElement, SelectorList}; -pub use selectors::{AttrSelector, NamespaceConstraint}; -pub use selectors::{SimpleSelector, parse_author_origin_selector_list_from_str}; -pub use cssparser::{Color, RGBA}; -pub use legacy::{IntegerAttribute, LengthAttribute}; -pub use legacy::{SimpleColorAttribute, UnsignedIntegerAttribute}; -pub use font_face::Source; -pub use stylesheets::Origin as StylesheetOrigin; - pub mod stylesheets; pub mod parser; pub mod selectors; pub mod selector_matching; #[macro_use] pub mod values; -pub mod properties; +#[macro_use] pub mod properties; pub mod node; pub mod media_queries; pub mod font_face; pub mod legacy; + +macro_rules! reexport_computed_values { + ( $( $name: ident )+ ) => { + pub mod computed_values { + $( + pub use properties::longhands::$name::computed_value as $name; + )+ + // Don't use a side-specific name needlessly: + pub use properties::longhands::border_top_style::computed_value as border_style; + } + } +} +longhand_properties_idents!(reexport_computed_values); + diff --git a/components/style/properties/mod.rs.mako b/components/style/properties/mod.rs.mako index fada051ebc1..92af5f05bb0 100644 --- a/components/style/properties/mod.rs.mako +++ b/components/style/properties/mod.rs.mako @@ -22,6 +22,7 @@ use values::computed; use selector_matching::DeclarationBlock; use parser::{ParserContext, log_css_error}; use stylesheets::Origin; +use computed_values; use self::property_bit_field::PropertyBitField; @@ -2629,43 +2630,43 @@ impl ComputedValues { } #[inline] - pub fn content_inline_size(&self) -> computed_values::LengthOrPercentageOrAuto { + pub fn content_inline_size(&self) -> computed::LengthOrPercentageOrAuto { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.height } else { box_style.width } } #[inline] - pub fn content_block_size(&self) -> computed_values::LengthOrPercentageOrAuto { + pub fn content_block_size(&self) -> computed::LengthOrPercentageOrAuto { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.width } else { box_style.height } } #[inline] - pub fn min_inline_size(&self) -> computed_values::LengthOrPercentage { + pub fn min_inline_size(&self) -> computed::LengthOrPercentage { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.min_height } else { box_style.min_width } } #[inline] - pub fn min_block_size(&self) -> computed_values::LengthOrPercentage { + pub fn min_block_size(&self) -> computed::LengthOrPercentage { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.min_width } else { box_style.min_height } } #[inline] - pub fn max_inline_size(&self) -> computed_values::LengthOrPercentageOrNone { + pub fn max_inline_size(&self) -> computed::LengthOrPercentageOrNone { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.max_height } else { box_style.max_width } } #[inline] - pub fn max_block_size(&self) -> computed_values::LengthOrPercentageOrNone { + pub fn max_block_size(&self) -> computed::LengthOrPercentageOrNone { let box_style = self.get_box(); if self.writing_mode.is_vertical() { box_style.max_width } else { box_style.max_height } } #[inline] - pub fn logical_padding(&self) -> LogicalMargin<computed_values::LengthOrPercentage> { + pub fn logical_padding(&self) -> LogicalMargin<computed::LengthOrPercentage> { let padding_style = self.get_padding(); LogicalMargin::from_physical(self.writing_mode, SideOffsets2D::new( padding_style.padding_top, @@ -2687,7 +2688,7 @@ impl ComputedValues { } #[inline] - pub fn logical_margin(&self) -> LogicalMargin<computed_values::LengthOrPercentageOrAuto> { + pub fn logical_margin(&self) -> LogicalMargin<computed::LengthOrPercentageOrAuto> { let margin_style = self.get_margin(); LogicalMargin::from_physical(self.writing_mode, SideOffsets2D::new( margin_style.margin_top, @@ -2698,7 +2699,7 @@ impl ComputedValues { } #[inline] - pub fn logical_position(&self) -> LogicalMargin<computed_values::LengthOrPercentageOrAuto> { + pub fn logical_position(&self) -> LogicalMargin<computed::LengthOrPercentageOrAuto> { // FIXME(SimonSapin): should be the writing mode of the containing block, maybe? let position_style = self.get_positionoffsets(); LogicalMargin::from_physical(self.writing_mode, SideOffsets2D::new( @@ -3169,6 +3170,17 @@ macro_rules! css_properties_accessors { } } + +macro_rules! longhand_properties_idents { + ($macro_name: ident) => { + $macro_name! { + % for property in LONGHANDS: + ${property.ident} + % endfor + } + } +} + pub fn longhands_from_shorthand(shorthand: &str) -> Option<Vec<String>> { match shorthand { % for property in SHORTHANDS: @@ -3181,18 +3193,3 @@ pub fn longhands_from_shorthand(shorthand: &str) -> Option<Vec<String>> { _ => None, } } - -// Only re-export the types for computed values. -pub mod computed_values { - % for property in LONGHANDS: - pub use super::longhands::${property.ident}::computed_value as ${property.ident}; - % endfor - // Don't use a side-specific name needlessly: - pub use super::longhands::border_top_style::computed_value as border_style; - - pub use cssparser::RGBA; - pub use values::computed::{ - LengthOrPercentage, - LengthOrPercentageOrAuto, - LengthOrPercentageOrNone}; -} diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 9b81f20060a..f1c96e2ec95 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -21,8 +21,7 @@ use media_queries::Device; use node::{TElement, TElementAttributes, TNode}; use properties::{PropertyDeclaration, PropertyDeclarationBlock}; use selectors::{CaseSensitivity, Combinator, CompoundSelector, LocalName}; -use selectors::{PseudoElement, SelectorList, SimpleSelector}; -use selectors::{get_selector_list_selectors}; +use selectors::{PseudoElement, SimpleSelector, Selector}; use stylesheets::{Stylesheet, iter_stylesheet_media_rules, iter_stylesheet_style_rules, Origin}; @@ -549,14 +548,15 @@ impl DeclarationBlock { } } -pub fn matches<'a,E,N>(selector_list: &SelectorList, +pub fn matches<'a,E,N>(selector_list: &Vec<Selector>, element: &N, parent_bf: &Option<Box<BloomFilter>>) -> bool where E: TElement<'a>, N: TNode<'a,E> { - get_selector_list_selectors(selector_list).iter().any(|selector| + selector_list.iter().any(|selector| { selector.pseudo_element.is_none() && - matches_compound_selector(&*selector.compound_selectors, element, parent_bf, &mut false)) + matches_compound_selector(&*selector.compound_selectors, element, parent_bf, &mut false) + }) } /// Determines whether the given element matches the given single or compound selector. diff --git a/components/style/selectors.rs b/components/style/selectors.rs index 98eb186eb67..1ab50f943e4 100644 --- a/components/style/selectors.rs +++ b/components/style/selectors.rs @@ -111,17 +111,6 @@ pub enum NamespaceConstraint { } -/// Re-exported to script, but opaque. -pub struct SelectorList { - selectors: Vec<Selector> -} - -/// Public to the style crate, but not re-exported to script -pub fn get_selector_list_selectors<'a>(selector_list: &'a SelectorList) -> &'a [Selector] { - selector_list.selectors.as_slice() -} - - fn compute_specificity(mut selector: &CompoundSelector, pseudo_element: &Option<PseudoElement>) -> u32 { struct Specificity { @@ -193,12 +182,10 @@ fn compute_specificity(mut selector: &CompoundSelector, -pub fn parse_author_origin_selector_list_from_str(input: &str) - -> Result<SelectorList,()> { +pub fn parse_author_origin_selector_list_from_str(input: &str) -> Result<Vec<Selector>, ()> { let url = Url::parse("about:blank").unwrap(); let context = ParserContext::new(Origin::Author, &url); parse_selector_list(&context, &mut Parser::new(input)) - .map(|s| SelectorList { selectors: s }) } /// Parse a comma-separated list of Selectors. diff --git a/components/style/values.rs b/components/style/values.rs index 2772bb7dcde..82e7a543f6e 100644 --- a/components/style/values.rs +++ b/components/style/values.rs @@ -4,6 +4,8 @@ #![allow(non_camel_case_types)] +pub use cssparser::RGBA; + macro_rules! define_css_keyword_enum { ($name: ident: $( $css: expr => $variant: ident ),+,) => { |