Only export an explicit public API in the style crate

I.e. make every module private by default.
This commit is contained in:
Simon Sapin 2013-10-24 16:09:46 +02:00
parent 23e3757db6
commit 7a48cb6815
8 changed files with 39 additions and 43 deletions

View file

@ -4,7 +4,7 @@
use style::Stylesheet; use style::Stylesheet;
use style::Stylist; use style::Stylist;
use style::selector_matching::UserAgentOrigin; use style::UserAgentOrigin;
pub fn new_stylist() -> Stylist { pub fn new_stylist() -> Stylist {
let mut stylist = Stylist::new(); let mut stylist = Stylist::new();

View file

@ -26,16 +26,9 @@ use std::cmp::ApproxEq;
use std::num::Zero; use std::num::Zero;
use std::unstable::raw::Box; use std::unstable::raw::Box;
use style::ComputedValues; use style::ComputedValues;
use style::computed_values::border_style; use style::computed_values::{
use style::computed_values::clear; border_style, clear, float, font_family, font_style, line_height,
use style::computed_values::float; position, text_align, text_decoration, vertical_align};
use style::properties::longhands::font_family::FamilyName;
use style::computed_values::font_style;
use style::computed_values::line_height;
use style::computed_values::position;
use style::computed_values::text_align;
use style::computed_values::text_decoration;
use style::computed_values::vertical_align;
use css::node_style::StyledNode; use css::node_style::StyledNode;
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData, ToGfxColor}; use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData, ToGfxColor};
@ -733,7 +726,7 @@ impl RenderBoxBase {
// FIXME: Too much allocation here. // FIXME: Too much allocation here.
let font_families = do my_style.Font.font_family.map |family| { let font_families = do my_style.Font.font_family.map |family| {
match *family { match *family {
FamilyName(ref name) => (*name).clone(), font_family::FamilyName(ref name) => (*name).clone(),
} }
}; };
let font_families = font_families.connect(", "); let font_families = font_families.connect(", ");

View file

@ -23,7 +23,7 @@ pub type Nothing = ();
impl ExtraDisplayListData for AbstractNode<()> { impl ExtraDisplayListData for AbstractNode<()> {
fn new(box: &@RenderBox) -> AbstractNode<()> { fn new(box: &@RenderBox) -> AbstractNode<()> {
unsafe { unsafe {
transmute(box.base().node) transmute(box.base().node)
} }
} }
@ -61,7 +61,7 @@ pub trait ToGfxColor {
fn to_gfx_color(&self) -> gfx::color::Color; fn to_gfx_color(&self) -> gfx::color::Color;
} }
impl ToGfxColor for style::properties::RGBA { impl ToGfxColor for style::computed_values::RGBA {
fn to_gfx_color(&self) -> gfx::color::Color { fn to_gfx_color(&self) -> gfx::color::Color {
gfx::color::rgba(self.red, self.green, self.blue, self.alpha) gfx::color::rgba(self.red, self.green, self.blue, self.alpha)
} }

View file

@ -32,7 +32,7 @@ use gfx::render_task::{RenderMsg, RenderChan, RenderLayer};
use gfx::render_task; use gfx::render_task;
use style::Stylist; use style::Stylist;
use style::Stylesheet; use style::Stylesheet;
use style::selector_matching::AuthorOrigin; use style::AuthorOrigin;
use script::dom::event::ReflowEvent; use script::dom::event::ReflowEvent;
use script::dom::node::{AbstractNode, LayoutView}; use script::dom::node::{AbstractNode, LayoutView};
use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery}; use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery};
@ -240,7 +240,7 @@ impl LayoutTask {
screen_size: None, screen_size: None,
display_list: None, display_list: None,
stylist: RWArc::new(new_stylist()), stylist: RWArc::new(new_stylist()),
profiler_chan: profiler_chan, profiler_chan: profiler_chan,
} }

View file

@ -8,7 +8,7 @@ use std::num::Zero;
use geom::side_offsets::SideOffsets2D; use geom::side_offsets::SideOffsets2D;
use servo_util::geometry::Au; use servo_util::geometry::Au;
use style::ComputedValues; use style::ComputedValues;
use style::properties::common_types::computed; use computed = style::computed_values;
/// Encapsulates the borders, padding, and margins, which we collectively call the "box model". /// Encapsulates the borders, padding, and margins, which we collectively call the "box model".
#[deriving(Clone)] #[deriving(Clone)]

View file

@ -23,8 +23,7 @@ use std::cast::transmute;
use std::unstable::raw::Box; use std::unstable::raw::Box;
use extra::arc::Arc; use extra::arc::Arc;
use js::jsapi::{JSObject, JSContext}; use js::jsapi::{JSObject, JSContext};
use style::ComputedValues; use style::{ComputedValues, PropertyDeclaration};
use style::properties::PropertyDeclaration;
use servo_util::tree::{TreeNode, TreeNodeRef, TreeNodeRefAsElement}; use servo_util::tree::{TreeNode, TreeNodeRef, TreeNodeRefAsElement};
use servo_util::range::Range; use servo_util::range::Range;
use gfx::display_list::DisplayList; use gfx::display_list::DisplayList;

View file

@ -402,20 +402,20 @@ pub mod longhands {
<%self:longhand name="font-family" inherited="True"> <%self:longhand name="font-family" inherited="True">
pub use to_computed_value = super::computed_as_specified; pub use to_computed_value = super::computed_as_specified;
#[deriving(Eq, Clone)]
pub enum FontFamily {
FamilyName(~str),
// Generic
// Serif,
// SansSerif,
// Cursive,
// Fantasy,
// Monospace,
}
pub type SpecifiedValue = ~[FontFamily];
pub mod computed_value { pub mod computed_value {
pub type T = super::SpecifiedValue; #[deriving(Eq, Clone)]
pub enum FontFamily {
FamilyName(~str),
// Generic
// Serif,
// SansSerif,
// Cursive,
// Fantasy,
// Monospace,
}
pub type T = ~[FontFamily];
} }
pub type SpecifiedValue = computed_value::T;
#[inline] pub fn get_initial_value() -> computed_value::T { ~[FamilyName(~"serif")] } #[inline] pub fn get_initial_value() -> computed_value::T { ~[FamilyName(~"serif")] }
/// <familiy-name># /// <familiy-name>#
/// <familiy-name> = <string> | [ <ident>+ ] /// <familiy-name> = <string> | [ <ident>+ ]
@ -1119,4 +1119,9 @@ pub mod computed_values {
% endfor % endfor
// Don't use a side-specific name needlessly: // Don't use a side-specific name needlessly:
pub use border_style = super::longhands::border_top_style::computed_value; pub use border_style = super::longhands::border_top_style::computed_value;
pub use cssparser::RGBA;
pub use super::common_types::computed::{
LengthOrPercentage, LP_Length, LP_Percentage,
LengthOrPercentageOrAuto, LPA_Length, LPA_Percentage, LPA_Auto};
} }

View file

@ -18,21 +18,20 @@ extern mod cssparser;
extern mod servo_util (name = "util"); extern mod servo_util (name = "util");
// The "real" public API // Public API
pub use stylesheets::Stylesheet; pub use stylesheets::Stylesheet;
pub use selector_matching::{Stylist, StylesheetOrigin}; pub use selector_matching::{Stylist, StylesheetOrigin, UserAgentOrigin, AuthorOrigin, UserOrigin};
pub use properties::{cascade, ComputedValues, computed_values}; pub use properties::{cascade, PropertyDeclaration, ComputedValues, computed_values};
pub use properties::{PropertyDeclarationBlock, parse_style_attribute}; // Style attributes pub use properties::{PropertyDeclarationBlock, parse_style_attribute}; // Style attributes
// Things that need to be public to make the compiler happy mod stylesheets;
pub mod stylesheets; mod errors;
pub mod errors; mod selectors;
pub mod selectors; mod selector_matching;
pub mod selector_matching; mod properties;
pub mod properties; mod namespaces;
pub mod namespaces; mod media_queries;
pub mod media_queries; mod parsing_utils;
pub mod parsing_utils;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;