servo: Move shaper and textrun back to src/servo/text/. Add a text redirector.
authorBrian J. Burg <>
Wed, 07 Nov 2012 12:27:13 -0800
changeset 333217 6e6882b97cd8c1194f983b3b4cdadcf826969c1c
parent 333216 d7159f8f67e41edd7803915b6ace84275f3f2568
child 333218 c345eb6f1c8aaec41cb844eabf0048c41b64f0d2
push id31307
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
servo: Move shaper and textrun back to src/servo/text/. Add a text redirector. Source-Repo: Source-Revision: 72c11b6fba879489d023959f2e9e7b910ebcd71d
--- a/servo/src/servo/
+++ b/servo/src/servo/
@@ -3,24 +3,22 @@
 Note that you still must define each of the files as a module in
 servo.rc. This is not ideal and may be changed in the future. */
 // shortcut names
 pub use au = geometry;
 pub use dl = display_list;
+pub use display_list::DisplayItem;
 pub use display_list::DisplayList;
 pub use font::Font;
 pub use font::FontDescriptor;
 pub use font::FontGroup;
 pub use font::FontSelector;
 pub use font::FontStyle;
 pub use font::RunMetrics;
 pub use font_context::FontContext;
 pub use font_matcher::FontMatcher;
 pub use geometry::Au;
-pub use shaper::Shaper;
-pub use text_run::TextRun;
-pub use text_run::SendableTextRun;
 pub use render_context::RenderContext;
 pub use render_layers::RenderLayer;
\ No newline at end of file
--- a/servo/src/servo/gfx/
+++ b/servo/src/servo/gfx/
@@ -1,18 +1,19 @@
 use azure::azure_hl::DrawTarget;
-use au = gfx::geometry;
-use au::Au;
-use geom::rect::Rect;
-use geom::point::Point2D;
-use gfx::SendableTextRun;
+use geom::Rect;
+use geom::Point2D;
+use gfx::{au, Au};
+use color::{Color, rgb};
 use image::base::Image;
 use render_context::RenderContext;
+use text::SendableTextRun;
 use util::range::Range;
-use color::{Color, rgb};
 use std::arc::ARC;
 use clone_arc = std::arc::clone;
 use dvec::DVec;
 pub use layout::display_list_builder::DisplayListBuilder;
 struct DisplayItemData {
--- a/servo/src/servo/gfx/
+++ b/servo/src/servo/gfx/
@@ -1,19 +1,24 @@
-use au = gfx::geometry;
-use au::Au;
 use azure::{
-use core::dvec::DVec;
-use gfx::RenderContext;
+use gfx::au;
+use gfx::{Au, RenderContext};
 use geom::{Point2D, Rect, Size2D};
-use glyph::{GlyphStore, GlyphIndex};
-use servo_util::range::Range;
+use util::range::Range;
+use text::glyph::{GlyphStore, GlyphIndex};
+use text::{
+    Shaper,
+    TextRun,
+use core::dvec::DVec;
 use native::FontHandle;
 // Used to abstract over the shaper's choice of fixed int representation.
 type FractionalPixel = float;
 struct FontMetrics {
     underline_size:   Au,
--- a/servo/src/servo/gfx/quartz/
+++ b/servo/src/servo/gfx/quartz/
@@ -1,20 +1,18 @@
 extern mod core_foundation;
 extern mod core_graphics;
 extern mod core_text;
 use font::{FontMetrics, FractionalPixel};
 use font_context::QuartzFontContext;
+use gfx::au;
+use text::glyph::GlyphIndex;
-use au = gfx::geometry;
-use cast::transmute;
-use glyph::GlyphIndex;
 use libc::size_t;
-use ptr::null;
 use cf = core_foundation;
 use cf::base::{
 use cf::string::UniChar;
@@ -68,20 +66,20 @@ pub struct QuartzFontHandle {
 pub impl QuartzFontHandle {
     static pub fn new(_fctx: &QuartzFontContext, buf: @~[u8], pt_size: float) -> Result<QuartzFontHandle, ()> {
         let fontprov = vec::as_imm_buf(*buf, |cbuf, len| {
-                null(),
-                unsafe { transmute(copy cbuf) },
+                ptr::null(),
+                unsafe { cast::transmute(copy cbuf) },
                 len as size_t,
-                null())
+                ptr::null())
         if fontprov.is_null() { return Err(()); }
         let cgfont = CGFontCreateWithDataProvider(fontprov);
         if cgfont.is_null() { return Err(()); }
         let ctfont = ctfont_from_cgfont(cgfont, pt_size);
         if ctfont.is_null() { return Err(()); }
@@ -115,17 +113,17 @@ pub impl QuartzFontHandle {
         return Some(glyphs[0] as GlyphIndex);
     fn glyph_h_advance(glyph: GlyphIndex) -> Option<FractionalPixel> {
         assert self.ctfont.is_not_null();
         let glyphs = ~[glyph as CGGlyph];
         let advance = do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
-            CTFontGetAdvancesForGlyphs(self.ctfont, kCTFontDefaultOrientation, glyph_buf, null(), 1)
+            CTFontGetAdvancesForGlyphs(self.ctfont, kCTFontDefaultOrientation, glyph_buf, ptr::null(), 1)
         return Some(advance as FractionalPixel);
     fn get_metrics() -> FontMetrics {
         let ctfont = self.ctfont;
         assert ctfont.is_not_null();
@@ -151,10 +149,10 @@ pub impl QuartzFontHandle {
         debug!("Font metrics (@%f pt): %?", CTFontGetSize(ctfont) as float, metrics);
         return metrics;
 fn ctfont_from_cgfont(cgfont: CGFontRef, pt_size: float) -> CTFontRef {
     assert cgfont.is_not_null();
-    CTFontCreateWithGraphicsFont(cgfont, pt_size as CGFloat, null(), null())
+    CTFontCreateWithGraphicsFont(cgfont, pt_size as CGFloat, ptr::null(), ptr::null())
\ No newline at end of file
--- a/servo/src/servo/gfx/
+++ b/servo/src/servo/gfx/
@@ -1,17 +1,17 @@
 use compositor::LayerBuffer;
 use gfx::au;
 use gfx::{
-    TextRun,
 use image::base::Image;
+use text::TextRun;
 use util::range::Range;
 use cairo::cairo_hl::ImageSurface;
 use core::libc::types::common::c99::uint16_t;
 use core::ptr::to_unsafe_ptr;
 use core::dvec::DVec;
 use std::arc::ARC;
 use geom::size::Size2D;
--- a/servo/src/servo/layout/
+++ b/servo/src/servo/layout/
@@ -1,41 +1,43 @@
 /* Fundamental layout structures and algorithms. */
-use newcss::color::rgb;
+use geom::{Rect, Size2D, Point2D};
+use css::node_style::{NodeStyle, StyledNode};
+use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
+use dom::node::{Element, Node, NodeData, NodeKind, NodeTree};
+use gfx::{au, dl};
+use gfx::{
+    Au,
+    DisplayItem,
+    DisplayList,
+use image::{Image, ImageHolder};
+use layout::context::LayoutContext;
+use layout::debug::BoxedDebugMethods;
+use layout::display_list_builder::DisplayListBuilder;
+use layout::flow::FlowContext;
+use layout::text::TextBoxData;
+use newcss::color::{Color, rgba, rgb};
+use newcss::units::{BoxSizing, Length, Px};
+use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
+use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
+use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
+use servo_text::TextRun;
+use util::range::*;
+use util::tree;
 use arc = std::arc;
 use arc::ARC;
-use au = gfx::geometry;
-use au::Au;
 use core::dvec::DVec;
 use core::to_str::ToStr;
 use core::rand;
-use css::node_style::StyledNode;
-use newcss::complete::CompleteStyle;
-use newcss::units::{BoxSizing, Length, Px};
-use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
-use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
-use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
-use newcss::color::{Color, rgba};
-use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
-use dom::node::{Element, Node, NodeData, NodeKind, NodeTree};
-use geom::rect::Rect;
-use geom::size::Size2D;
-use geom::point::Point2D;
-use gfx::display_list::{DisplayItem, DisplayList, DisplayListBuilder};
-use image::{Image, ImageHolder};
-use layout::context::LayoutContext;
-use layout::debug::BoxedDebugMethods;
-use layout::flow::FlowContext;
-use layout::text::TextBoxData;
-use gfx::TextRun;
 use std::net::url::Url;
 use task::spawn;
-use util::range::*;
-use util::tree;
 Render boxes (`struct RenderBox`) are the leafs of the layout
 tree. They cannot position themselves. In general, render boxes do not
 have a simple correspondence with CSS boxes as in the specification:
  * Several render boxes may correspond to the same CSS box or DOM
    node. For example, a CSS text box broken across two lines is
--- a/servo/src/servo/layout/
+++ b/servo/src/servo/layout/
@@ -1,28 +1,30 @@
 use au = gfx::geometry;
-use core::dlist::DList;
-use core::dvec::DVec;
-use newcss::values::{BoxAuto, BoxLength, Px};
+use geom::{Point2D, Rect, Size2D};
 use dom::node::Node;
-use geom::point::Point2D;
-use geom::rect::Rect;
-use geom::size::Size2D;
-use gfx::display_list::{DisplayList, DisplayListBuilder};
-use gfx::font::FontStyle;
-use gfx::geometry::Au;
+use gfx::dl;
+use gfx::{
+    Au,
+    FontStyle,
 use layout::box::*;
 use layout::context::LayoutContext;
 use layout::flow::{FlowContext, InlineFlow};
 use layout::text::TextBoxData;
+use newcss::values::{BoxAuto, BoxLength, Px};
+use servo_text::util::*;
+use util::range::{MutableRange, Range};
+use util::tree;
+use core::dlist::DList;
+use core::dvec::DVec;
 use num::Num;
 use std::arc;
-use util::range::{MutableRange, Range};
-use util::text::*;
-use util::tree;
 Lineboxes are represented as offsets into the child list, rather than
 as an object that "owns" boxes. Choosing a different set of line
 breaks requires a new list of offsets, and possibly some splitting and
 merging of TextBoxes.
 A similar list will keep track of the mapping between CSS boxes and
--- a/servo/src/servo/layout/
+++ b/servo/src/servo/layout/
@@ -1,11 +1,11 @@
 /** Text layout. */
-use gfx::TextRun;
+use servo_text::TextRun;
 use layout::box::{TextBox, RenderBox, RenderBoxData, UnscannedTextBox};
 use util::range::Range;
 pub struct TextBoxData {
     run: @TextRun,
     range: Range,
--- a/servo/src/servo/servo.rc
+++ b/servo/src/servo/servo.rc
@@ -80,30 +80,22 @@ pub mod gfx {
     pub mod render_layers;
     pub mod render_task;
     pub mod surface;
     // fonts
     pub mod font;
     pub mod font_cache;
     pub mod font_matcher;
-    pub mod glyph;
-    pub mod text_run;
     // Typedefs and pub-uses for multiple implementations.
     // native contains redirects, so one can write native::FontHandle.
     pub mod native;
     pub mod font_context;
     pub mod font_handle;
-    pub mod shaper;
-    // Below are the actual platform-specific parts.
-    pub mod harfbuzz {
-        pub mod shaper;
-    }
     #[cfg(target_os = "macos")]
     pub mod quartz {
         pub mod font_context;
         pub mod font_handle;
     #[cfg(target_os = "linux")]
@@ -135,22 +127,34 @@ pub mod platform {
 pub mod resource {
     pub mod file_loader;
     pub mod http_loader;
     pub mod image_cache_task;
     pub mod local_image_cache;
     pub mod resource_task;
+pub mod text {
+    pub mod glyph;
+    pub mod text_run;
+    pub mod util;
+    pub mod shaper;
+    // Below are the actual platform-specific parts.
+    pub mod harfbuzz {
+        pub mod shaper;
+    }
 pub mod util {
     pub mod actor;
     pub mod cache;
     pub mod range;
-    pub mod text;
     pub mod time;
     pub mod tree;
     pub mod url;
     pub mod vec;
 pub mod opts;
 use servo_util = util;
+use servo_text = text;
new file mode 100644
--- /dev/null
+++ b/servo/src/servo/
@@ -0,0 +1,9 @@
+/* This file exists just to make it easier to import things inside of
+ ./text/ without specifying the file they came out of imports.
+Note that you still must define each of the files as a module in
+servo.rc. This is not ideal and may be changed in the future. */
+pub use shaper::Shaper;
+pub use text_run::TextRun;
+pub use text_run::SendableTextRun;
rename from servo/src/servo/gfx/
rename to servo/src/servo/text/
rename from servo/src/servo/gfx/harfbuzz/
rename to servo/src/servo/text/harfbuzz/
--- a/servo/src/servo/gfx/harfbuzz/
+++ b/servo/src/servo/text/harfbuzz/
@@ -1,23 +1,23 @@
 extern mod harfbuzz;
+use geom::Point2D;
 use gfx::au;
 use gfx::{
+use glyph::{GlyphStore, GlyphIndex, GlyphData};
-use geom::point::Point2D;
-use glyph::{GlyphStore, GlyphIndex, GlyphData};
 use libc::types::common::c99::int32_t;
 use libc::{c_uint, c_int, c_void, c_char};
 use ptr::{null, to_unsafe_ptr, offset};
 use std::arc;
-use util = util::text;
 use harfbuzz::{HB_MEMORY_MODE_READONLY,
 use harfbuzz::{hb_blob_t, hb_face_t, hb_font_t, hb_font_funcs_t, hb_buffer_t,
                   hb_codepoint_t, hb_bool_t, hb_glyph_position_t,
 		  hb_glyph_info_t, hb_var_int_t, hb_position_t};
 use harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
                            hb_face_create, hb_face_destroy,
rename from servo/src/servo/gfx/
rename to servo/src/servo/text/
--- a/servo/src/servo/gfx/
+++ b/servo/src/servo/text/
@@ -1,15 +1,15 @@
 Shaper encapsulates a specific shaper, such as Harfbuzz, 
 Uniscribe, Pango, or Coretext.
 Currently, only harfbuzz bindings are implemented.
-use font::Font;
+use gfx::Font;
 pub type Shaper/& = harfbuzz::shaper::HarfbuzzShaper;
 // TODO(Issue #163): this is a workaround for static methods and
 // typedefs not working well together. It should be removed.
 impl Shaper {
     static pub fn new(font: @Font) -> Shaper {
rename from servo/src/servo/gfx/
rename to servo/src/servo/text/
rename from servo/src/servo/util/
rename to servo/src/servo/text/