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::Stylist;
use style::selector_matching::UserAgentOrigin;
use style::UserAgentOrigin;
pub fn new_stylist() -> Stylist {
let mut stylist = Stylist::new();

View file

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

View file

@ -61,7 +61,7 @@ pub trait ToGfxColor {
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 {
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 style::Stylist;
use style::Stylesheet;
use style::selector_matching::AuthorOrigin;
use style::AuthorOrigin;
use script::dom::event::ReflowEvent;
use script::dom::node::{AbstractNode, LayoutView};
use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery};

View file

@ -8,7 +8,7 @@ use std::num::Zero;
use geom::side_offsets::SideOffsets2D;
use servo_util::geometry::Au;
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".
#[deriving(Clone)]

View file

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

View file

@ -402,6 +402,7 @@ pub mod longhands {
<%self:longhand name="font-family" inherited="True">
pub use to_computed_value = super::computed_as_specified;
pub mod computed_value {
#[deriving(Eq, Clone)]
pub enum FontFamily {
FamilyName(~str),
@ -412,10 +413,9 @@ pub mod longhands {
// Fantasy,
// Monospace,
}
pub type SpecifiedValue = ~[FontFamily];
pub mod computed_value {
pub type T = super::SpecifiedValue;
pub type T = ~[FontFamily];
}
pub type SpecifiedValue = computed_value::T;
#[inline] pub fn get_initial_value() -> computed_value::T { ~[FamilyName(~"serif")] }
/// <familiy-name>#
/// <familiy-name> = <string> | [ <ident>+ ]
@ -1119,4 +1119,9 @@ pub mod computed_values {
% endfor
// Don't use a side-specific name needlessly:
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");
// The "real" public API
// Public API
pub use stylesheets::Stylesheet;
pub use selector_matching::{Stylist, StylesheetOrigin};
pub use properties::{cascade, ComputedValues, computed_values};
pub use selector_matching::{Stylist, StylesheetOrigin, UserAgentOrigin, AuthorOrigin, UserOrigin};
pub use properties::{cascade, PropertyDeclaration, ComputedValues, computed_values};
pub use properties::{PropertyDeclarationBlock, parse_style_attribute}; // Style attributes
// Things that need to be public to make the compiler happy
pub mod stylesheets;
pub mod errors;
pub mod selectors;
pub mod selector_matching;
pub mod properties;
pub mod namespaces;
pub mod media_queries;
pub mod parsing_utils;
mod stylesheets;
mod errors;
mod selectors;
mod selector_matching;
mod properties;
mod namespaces;
mod media_queries;
mod parsing_utils;
#[cfg(test)]
mod tests;