diff --git a/src/servo/gfx.rs b/src/servo/gfx.rs new file mode 100644 index 00000000000..5e16ad50d70 --- /dev/null +++ b/src/servo/gfx.rs @@ -0,0 +1,23 @@ +/* This file exists just to make it easier to import things inside of + ./gfx/ 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. */ + +// shortcut names +pub use au = geometry; +pub use dl = display_list; + +pub use display_list::DisplayList; +pub use font::Font; +pub use font_cache::FontCache; +pub use font_context::FontContext; +pub use font_matcher::FontMatcher; +pub use geometry::Au; +pub use native_font::NativeFont; +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 diff --git a/src/servo/gfx/display_list.rs b/src/servo/gfx/display_list.rs index 2c9ac70ea6c..fbdc3ee58a5 100644 --- a/src/servo/gfx/display_list.rs +++ b/src/servo/gfx/display_list.rs @@ -3,10 +3,9 @@ use au = gfx::geometry; use au::Au; use geom::rect::Rect; use geom::point::Point2D; +use gfx::SendableTextRun; use image::base::Image; use render_context::RenderContext; -use servo_text::text_run; -use text::text_run::SendableTextRun; use util::range::Range; use color::{Color, rgb}; diff --git a/src/servo/text/font.rs b/src/servo/gfx/font.rs similarity index 98% rename from src/servo/text/font.rs rename to src/servo/gfx/font.rs index 3c279267240..102912aab1e 100644 --- a/src/servo/text/font.rs +++ b/src/servo/gfx/font.rs @@ -1,5 +1,3 @@ -pub use font_cache::FontCache; - use au = gfx::geometry; use au::Au; use azure::{ @@ -7,15 +5,12 @@ use azure::{ AzScaledFontRef, }; use core::dvec::DVec; -use gfx::render_context::RenderContext; +use gfx::RenderContext; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; use glyph::{GlyphStore, GlyphIndex}; -use native_font::NativeFont; use servo_util::range::Range; -use shaper::Shaper; -use text::text_run::TextRun; // Used to abstract over the shaper's choice of fixed int representation. type FractionalPixel = float; diff --git a/src/servo/text/font_cache.rs b/src/servo/gfx/font_cache.rs similarity index 100% rename from src/servo/text/font_cache.rs rename to src/servo/gfx/font_cache.rs diff --git a/src/servo/text/font_context.rs b/src/servo/gfx/font_context.rs similarity index 100% rename from src/servo/text/font_context.rs rename to src/servo/gfx/font_context.rs diff --git a/src/servo/text/font_matcher.rs b/src/servo/gfx/font_matcher.rs similarity index 100% rename from src/servo/text/font_matcher.rs rename to src/servo/gfx/font_matcher.rs diff --git a/src/servo/text/freetype/font_context.rs b/src/servo/gfx/freetype/font_context.rs similarity index 100% rename from src/servo/text/freetype/font_context.rs rename to src/servo/gfx/freetype/font_context.rs diff --git a/src/servo/text/freetype/native_font.rs b/src/servo/gfx/freetype/native_font.rs similarity index 100% rename from src/servo/text/freetype/native_font.rs rename to src/servo/gfx/freetype/native_font.rs diff --git a/src/servo/text/glyph.rs b/src/servo/gfx/glyph.rs similarity index 100% rename from src/servo/text/glyph.rs rename to src/servo/gfx/glyph.rs diff --git a/src/servo/text/harfbuzz/shaper.rs b/src/servo/gfx/harfbuzz/shaper.rs similarity index 98% rename from src/servo/text/harfbuzz/shaper.rs rename to src/servo/gfx/harfbuzz/shaper.rs index b75eb5e573d..9f878f1fe7d 100644 --- a/src/servo/text/harfbuzz/shaper.rs +++ b/src/servo/gfx/harfbuzz/shaper.rs @@ -1,17 +1,20 @@ extern mod harfbuzz; -use font::Font; -use font_cache::FontCache; +use gfx::{ + au, + + Au, + Font, + FontCache, +}; -use au = gfx::geometry; -use au::Au; 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::*; +use util = util::text; use harfbuzz::{HB_MEMORY_MODE_READONLY, HB_DIRECTION_LTR}; diff --git a/src/servo/text/native_font.rs b/src/servo/gfx/native_font.rs similarity index 100% rename from src/servo/text/native_font.rs rename to src/servo/gfx/native_font.rs diff --git a/src/servo/text/quartz/font_context.rs b/src/servo/gfx/quartz/font_context.rs similarity index 100% rename from src/servo/text/quartz/font_context.rs rename to src/servo/gfx/quartz/font_context.rs diff --git a/src/servo/text/quartz/native_font.rs b/src/servo/gfx/quartz/native_font.rs similarity index 100% rename from src/servo/text/quartz/native_font.rs rename to src/servo/gfx/quartz/native_font.rs diff --git a/src/servo/gfx/render_context.rs b/src/servo/gfx/render_context.rs index 2c58546e863..054114bda67 100644 --- a/src/servo/gfx/render_context.rs +++ b/src/servo/gfx/render_context.rs @@ -1,9 +1,10 @@ use au = geometry; - use compositor::LayerBuffer; -use text::font::Font; -use text::text_run::TextRun; -use text::font_cache::FontCache; +use gfx::{ + Font, + FontCache, + TextRun, +}; use image::base::Image; use au::Au; use util::range::Range; diff --git a/src/servo/gfx/render_task.rs b/src/servo/gfx/render_task.rs index 2df891d8f6e..295be058583 100644 --- a/src/servo/gfx/render_task.rs +++ b/src/servo/gfx/render_task.rs @@ -1,21 +1,27 @@ -use au = gfx::geometry; -use au::Au; -use azure::AzFloat; use comm::*; -use compositor::{Compositor, LayerBufferSet}; -use dl = display_list; -use geom::matrix2d::Matrix2D; -use gfx::render_layers::RenderLayer; use libc::size_t; use libc::types::common::c99::uint16_t; -use mod gfx::render_layers; use pipes::{Port, Chan}; -use platform::osmain; -use render_context::RenderContext; -use render_layers::render_layers; use std::cell::Cell; -use text::font_cache::FontCache; -use text::font_context::FontContext; + +use azure::AzFloat; +use geom::matrix2d::Matrix2D; + +use dl = display_list; +use gfx::{ + FontCache, + FontContext, + RenderContext, + RenderLayer, +}; +use gfx::compositor::{ + Compositor, + LayerBufferSet, +}; +use mod gfx::render_layers; +use platform::osmain; +use render_layers::render_layers; + pub enum Msg { RenderMsg(RenderLayer), diff --git a/src/servo/text/shaper.rs b/src/servo/gfx/shaper.rs similarity index 100% rename from src/servo/text/shaper.rs rename to src/servo/gfx/shaper.rs diff --git a/src/servo/text/text_run.rs b/src/servo/gfx/text_run.rs similarity index 99% rename from src/servo/text/text_run.rs rename to src/servo/gfx/text_run.rs index f217db53f06..9a28d38e596 100644 --- a/src/servo/text/text_run.rs +++ b/src/servo/gfx/text_run.rs @@ -40,8 +40,6 @@ impl SendableTextRun { impl TextRun { static fn new(font: @Font, text: ~str) -> TextRun { - use shaper::Shaper; - let glyph_store = font.shape_text(text); let run = TextRun { text: move text, diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs index 4934f82f2f7..7fe2b1991ae 100644 --- a/src/servo/layout/box.rs +++ b/src/servo/layout/box.rs @@ -25,8 +25,7 @@ use layout::context::LayoutContext; use layout::debug::BoxedDebugMethods; use layout::flow::FlowContext; use layout::text::TextBoxData; -use servo_text::text_run; -use servo_text::text_run::TextRun; +use gfx::TextRun; use std::net::url::Url; use task::spawn; use util::range::*; diff --git a/src/servo/layout/context.rs b/src/servo/layout/context.rs index af686ae42c6..0b258c5bab8 100644 --- a/src/servo/layout/context.rs +++ b/src/servo/layout/context.rs @@ -1,8 +1,10 @@ -use resource::local_image_cache::LocalImageCache; -use servo_text::font_cache::FontCache; -use std::net::url::Url; use geom::rect::Rect; -use gfx::geometry::Au; +use gfx::{ + Au, + FontCache, +}; +use resource::local_image_cache::LocalImageCache; +use std::net::url::Url; /* Represents layout task context. */ diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index d30f402c2ce..164cc55454d 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -16,7 +16,6 @@ use layout::box::{RenderBox, TextBox}; use layout::context::LayoutContext; use layout::flow::FlowContext; use layout::text::TextBoxData; -use servo_text::text_run::TextRun; use util::tree; use vec::push; diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index 3363e04942a..77cd0433786 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -13,10 +13,9 @@ use layout::context::LayoutContext; use layout::flow::{FlowContext, InlineFlow}; use layout::text::TextBoxData; use num::Num; -use servo_text::text_run::TextRun; -use servo_text::util::*; use std::arc; use util::range::{MutableRange, Range}; +use util::text::*; use util::tree; /* @@ -270,7 +269,7 @@ impl TextRunScanner { // create the run, then make new boxes with the run and adjusted text indices // TODO(Issue #116): use actual font for corresponding DOM node to create text run. - let run = @TextRun::new(ctx.font_cache.get_test_font(), move run_str); + let run = @gfx::TextRun::new(ctx.font_cache.get_test_font(), move run_str); debug!("TextRunScanner: pushing box(es) in range: %?", self.clump); for self.clump.eachi |i| { let range = new_ranges[i - self.clump.begin()]; diff --git a/src/servo/layout/layout_task.rs b/src/servo/layout/layout_task.rs index 0034f20fb25..30f01bf1349 100644 --- a/src/servo/layout/layout_task.rs +++ b/src/servo/layout/layout_task.rs @@ -3,20 +3,24 @@ rendered. */ -use au = gfx::geometry; -use au::Au; use content::content_task; use core::dvec::DVec; use newcss::stylesheet::Stylesheet; -use dl = gfx::display_list; use dom::event::{Event, ReflowEvent}; use dom::node::{Node, LayoutData}; use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; -use gfx::display_list::DisplayList; +use gfx::{ + au, dl, + Au, + DisplayList, + FontCache, + FontContext, + FontMatcher, + RenderLayer, +}; use gfx::render_task; -use gfx::render_layers::RenderLayer; use layout::box::RenderBox; use layout::box_builder::LayoutTreeBuilder; use layout::context::LayoutContext; @@ -24,9 +28,6 @@ use opt = core::option; use render_task::RenderTask; use resource::image_cache_task::{ImageCacheTask, ImageResponseMsg}; use resource::local_image_cache::LocalImageCache; -use servo_text::font_context::FontContext; -use servo_text::font_cache::FontCache; -use servo_text::font_matcher::FontMatcher; use std::arc::ARC; use std::net::url::Url; use core::util::replace; diff --git a/src/servo/layout/text.rs b/src/servo/layout/text.rs index 2277de9c89a..85e5e4d9679 100644 --- a/src/servo/layout/text.rs +++ b/src/servo/layout/text.rs @@ -1,6 +1,6 @@ /** Text layout. */ -use servo_text::text_run::TextRun; +use gfx::TextRun; use layout::box::{TextBox, RenderBox, RenderBoxData, UnscannedTextBox}; use util::range::Range; diff --git a/src/servo/servo.rc b/src/servo/servo.rc index 1f35a90dcf9..44220302010 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -16,41 +16,42 @@ extern mod hubbub; extern mod js; extern mod layers; extern mod opengles; +extern mod newcss (name = "css"); extern mod sharegl; extern mod stb_image; extern mod std; -extern mod newcss (name = "css"); - -pub mod engine; - -pub mod dom { - pub mod bindings { - pub mod document; - pub mod element; - pub mod utils; - pub mod node; - pub mod window; - } - pub mod document; - pub mod element; - pub mod event; - pub mod node; - pub mod cow; - pub mod window; -} pub mod content { pub mod content_task; } pub mod css { - pub mod node_style; - pub mod matching; priv mod select_handler; priv mod node_util; priv mod node_void_ptr; + + pub mod matching; + pub mod node_style; } +pub mod dom { + pub mod bindings { + pub mod document; + pub mod element; + pub mod node; + pub mod utils; + pub mod window; + } + pub mod cow; + pub mod document; + pub mod element; + pub mod event; + pub mod node; + pub mod window; +} + +pub mod engine; + pub mod layout { pub mod block; pub mod box; @@ -68,48 +69,32 @@ pub mod layout { } pub mod gfx { + priv mod render_context; + + // rendering pub mod color; - pub mod geometry; - pub mod surface; - pub mod render_task; pub mod compositor; pub mod display_list; + pub mod geometry; pub mod render_layers; - priv mod render_context; -} + pub mod render_task; + pub mod surface; -pub mod image { - pub mod base; - pub mod holder; - pub mod encode { - pub mod tga; - } -} - -pub mod html { - pub mod hubbub_html_parser; - pub mod cssparse; -} - -pub mod platform { - pub mod base; - pub mod osmain; - priv mod resize_rate_limiter; -} - -pub mod text { + // fonts pub mod font; pub mod font_cache; pub mod font_matcher; pub mod glyph; pub mod text_run; - pub mod util; - // platform and library-specific implementations. + // Typedefs and pub-uses for multiple implementations. If prefixed + // with 'native', then the specific implementataion is composed by + // a non-prefixed version, listed above. pub mod font_context; pub mod native_font; pub mod shaper; + // Below are the actual platform-specific parts. pub mod harfbuzz { pub mod shaper; } @@ -127,24 +112,43 @@ pub mod text { } } +pub mod image { + pub mod base; + pub mod encode { + pub mod tga; + } + pub mod holder; +} + +pub mod html { + pub mod cssparse; + pub mod hubbub_html_parser; +} + +pub mod platform { + pub mod base; + pub mod osmain; + priv mod resize_rate_limiter; +} + pub mod resource { - pub mod resource_task; pub mod file_loader; pub mod http_loader; pub mod image_cache_task; pub mod local_image_cache; + pub mod resource_task; } pub mod util { - pub mod tree; + pub mod actor; + pub mod range; + pub mod text; pub mod time; + pub mod tree; pub mod url; pub mod vec; - pub mod range; - pub mod actor; } pub mod opts; use servo_util = util; -use servo_text = text; diff --git a/src/servo/text/JosefinSans-SemiBold.ttf b/src/servo/text/JosefinSans-SemiBold.ttf deleted file mode 100644 index f58d378543e..00000000000 Binary files a/src/servo/text/JosefinSans-SemiBold.ttf and /dev/null differ diff --git a/src/servo/text/OFL.txt b/src/servo/text/OFL.txt deleted file mode 100644 index d0a273c523b..00000000000 --- a/src/servo/text/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright (c) 2009, 2010, 2011 Daniel Johnson (). - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/servo/text/util.rs b/src/servo/util/text.rs similarity index 100% rename from src/servo/text/util.rs rename to src/servo/util/text.rs