Skip to content

Commit

Permalink
Upgrade to latest Rust.
Browse files Browse the repository at this point in the history
  • Loading branch information
metajack committed Jan 13, 2014
1 parent 728fb9a commit a7ef1cd
Show file tree
Hide file tree
Showing 127 changed files with 1,894 additions and 2,503 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Expand Up @@ -66,7 +66,7 @@
url = https://github.com/mozilla-servo/skia.git
[submodule "src/compiler/rust"]
path = src/compiler/rust
url = https://github.com/mozilla/rust.git
url = https://github.com/mozilla-servo/rust.git
[submodule "src/support/alert/rust-alert"]
path = src/support/alert/rust-alert
url = https://github.com/mozilla-servo/rust-alert.git
Expand Down Expand Up @@ -112,7 +112,7 @@
branch = rust-servo
[submodule "src/support/egl/rust-egl"]
path = src/support/egl/rust-egl
url = https://github.com/webconvforge/rust-egl.git
url = https://github.com/mozilla-servo/rust-egl.git
[submodule "src/platform/android/servo-android-glue"]
path = src/platform/android/servo-android-glue
url = https://github.com/webconvforge/servo-android-glue.git
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -615,7 +615,7 @@ then
cd ${CFG_BUILD_DIR}src/compiler/rust
RUST_CONFIGURE_ARGS="--enable-debug"
if [ $CFG_OSTYPE = "linux-androideabi" ]; then
RUST_CONFIGURE_ARGS="--target-triples=arm-linux-androideabi --android-cross-path=${CFG_ANDROID_CROSS_PATH}"
RUST_CONFIGURE_ARGS="--target=arm-linux-androideabi --android-cross-path=${CFG_ANDROID_CROSS_PATH}"
fi
${CFG_SRC_DIR}src/compiler/rust/configure ${RUST_CONFIGURE_ARGS}
cd ${CFG_BUILD_DIR}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/rust
Submodule rust updated from f6b236 to d3b3c6
2 changes: 1 addition & 1 deletion src/compiler/rust-auto-clean-trigger
@@ -1,4 +1,4 @@
# If this file is modified, then rust will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2014-01-02
2014-01-08
20 changes: 10 additions & 10 deletions src/components/gfx/display_list.rs
Expand Up @@ -150,14 +150,14 @@ pub struct ClipDisplayItem<E> {
need_clip: bool
}

pub enum DisplayItemIterator<'self,E> {
pub enum DisplayItemIterator<'a,E> {
EmptyDisplayItemIterator,
ParentDisplayItemIterator(VecIterator<'self,DisplayItem<E>>),
ParentDisplayItemIterator(VecIterator<'a,DisplayItem<E>>),
}

impl<'self,E> Iterator<&'self DisplayItem<E>> for DisplayItemIterator<'self,E> {
impl<'a,E> Iterator<&'a DisplayItem<E>> for DisplayItemIterator<'a,E> {
#[inline]
fn next(&mut self) -> Option<&'self DisplayItem<E>> {
fn next(&mut self) -> Option<&'a DisplayItem<E>> {
match *self {
EmptyDisplayItemIterator => None,
ParentDisplayItemIterator(ref mut subiterator) => subiterator.next(),
Expand Down Expand Up @@ -192,12 +192,12 @@ impl<E> DisplayItem<E> {
let text_run = text.text_run.get();
let font = render_context.font_ctx.get_font_by_descriptor(&text_run.font_descriptor).unwrap();

let font_metrics = font.with_borrow( |font| {
let font_metrics = font.borrow().with(|font| {
font.metrics.clone()
});
let origin = text.base.bounds.origin;
let baseline_origin = Point2D(origin.x, origin.y + font_metrics.ascent);
font.with_mut_borrow( |font| {
font.borrow().with_mut(|font| {
font.draw_text_into_context(render_context,
text.text_run.get(),
&text.range,
Expand Down Expand Up @@ -264,10 +264,10 @@ impl<E> DisplayItem<E> {
pub fn children<'a>(&'a self) -> DisplayItemIterator<'a,E> {
match *self {
ClipDisplayItemClass(ref clip) => ParentDisplayItemIterator(clip.child_list.iter()),
SolidColorDisplayItemClass(*) |
TextDisplayItemClass(*) |
ImageDisplayItemClass(*) |
BorderDisplayItemClass(*) => EmptyDisplayItemIterator,
SolidColorDisplayItemClass(..) |
TextDisplayItemClass(..) |
ImageDisplayItemClass(..) |
BorderDisplayItemClass(..) => EmptyDisplayItemIterator,
}
}

Expand Down
65 changes: 26 additions & 39 deletions src/components/gfx/font.rs
Expand Up @@ -10,13 +10,11 @@ use geom::{Point2D, Rect, Size2D};
use std::cast;
use std::ptr;
use std::str;
use std::vec;
use std::rc::RcMut;
use std::rc::Rc;
use std::cell::RefCell;
use servo_util::cache::{Cache, HashCache};
use servo_util::range::Range;
use servo_util::time::ProfilerChan;
use style::computed_values::{text_decoration, font_weight, font_style};

use color::Color;
use font_context::FontContext;
use servo_util::geometry::Au;
Expand Down Expand Up @@ -73,7 +71,7 @@ impl FontTableTagConversions for FontTableTag {
}

pub trait FontTableMethods {
fn with_buffer(&self, &fn(*u8, uint));
fn with_buffer(&self, |*u8, uint|);
}

#[deriving(Clone)]
Expand Down Expand Up @@ -108,12 +106,6 @@ pub struct FontStyle {
pub type SpecifiedFontStyle = FontStyle;
pub type UsedFontStyle = FontStyle;

// FIXME: move me to layout
struct ResolvedFont {
group: @FontGroup,
style: SpecifiedFontStyle,
}

// FontDescriptor serializes a specific font and used font style
// options, such as point size.

Expand Down Expand Up @@ -153,11 +145,11 @@ pub struct FontGroup {
// style of the first western font in group, which is
// used for purposes of calculating text run metrics.
style: UsedFontStyle,
fonts: ~[RcMut<Font>]
fonts: ~[Rc<RefCell<Font>>]
}

impl FontGroup {
pub fn new(families: ~[~str], style: &UsedFontStyle, fonts: ~[RcMut<Font>]) -> FontGroup {
pub fn new(families: ~[~str], style: &UsedFontStyle, fonts: ~[Rc<RefCell<Font>>]) -> FontGroup {
FontGroup {
families: families,
style: (*style).clone(),
Expand All @@ -173,7 +165,7 @@ impl FontGroup {
assert!(self.fonts.len() > 0);

// TODO(Issue #177): Actually fall back through the FontGroup when a font is unsuitable.
self.fonts[0].with_mut_borrow(|font| {
self.fonts[0].borrow().with_mut(|font| {
TextRun::new(font, text.clone(), decoration)
})
}
Expand Down Expand Up @@ -218,18 +210,16 @@ pub struct Font {
style: UsedFontStyle,
metrics: FontMetrics,
backend: BackendType,
profiler_chan: ProfilerChan,
shape_cache: HashCache<~str, Arc<GlyphStore>>,
glyph_advance_cache: HashCache<u32, FractionalPixel>,
}

impl<'self> Font {
impl<'a> Font {
pub fn new_from_buffer(ctx: &FontContext,
buffer: ~[u8],
style: &SpecifiedFontStyle,
backend: BackendType,
profiler_chan: ProfilerChan)
-> Result<RcMut<Font>, ()> {
backend: BackendType)
-> Result<Rc<RefCell<Font>>, ()> {
let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style);
let handle: FontHandle = if handle.is_ok() {
handle.unwrap()
Expand All @@ -240,22 +230,21 @@ impl<'self> Font {
let metrics = handle.get_metrics();
// TODO(Issue #179): convert between specified and used font style here?

return Ok(RcMut::new(Font {
return Ok(Rc::from_mut(RefCell::new(Font {
handle: handle,
azure_font: None,
shaper: None,
style: (*style).clone(),
metrics: metrics,
backend: backend,
profiler_chan: profiler_chan,
shape_cache: HashCache::new(),
glyph_advance_cache: HashCache::new(),
}));
})));
}

pub fn new_from_adopted_handle(_fctx: &FontContext, handle: FontHandle,
style: &SpecifiedFontStyle, backend: BackendType,
profiler_chan: ProfilerChan) -> Font {
style: &SpecifiedFontStyle, backend: BackendType)
-> Font {
let metrics = handle.get_metrics();

Font {
Expand All @@ -265,31 +254,30 @@ impl<'self> Font {
style: (*style).clone(),
metrics: metrics,
backend: backend,
profiler_chan: profiler_chan,
shape_cache: HashCache::new(),
glyph_advance_cache: HashCache::new(),
}
}

pub fn new_from_existing_handle(fctx: &FontContext, handle: &FontHandle,
style: &SpecifiedFontStyle, backend: BackendType,
profiler_chan: ProfilerChan) -> Result<RcMut<Font>,()> {
style: &SpecifiedFontStyle, backend: BackendType)
-> Result<Rc<RefCell<Font>>,()> {

// TODO(Issue #179): convert between specified and used font style here?
let styled_handle = match handle.clone_with_style(&fctx.handle, style) {
Ok(result) => result,
Err(()) => return Err(())
};

return Ok(RcMut::new(Font::new_from_adopted_handle(fctx, styled_handle, style, backend, profiler_chan)));
return Ok(Rc::from_mut(RefCell::new(Font::new_from_adopted_handle(fctx, styled_handle, style, backend))));
}

fn make_shaper(&'self mut self) -> &'self Shaper {
fn make_shaper(&'a mut self) -> &'a Shaper {
// fast path: already created a shaper
match self.shaper {
Some(ref shaper) => {
let s: &'self Shaper = shaper;
return s;
Some(ref shaper) => {
let s: &'a Shaper = shaper;
return s;
},
None => {}
}
Expand Down Expand Up @@ -349,7 +337,6 @@ impl<'self> Font {


impl Font {
#[fixed_stack_segment]
pub fn draw_text_into_context(&mut self,
rctx: &RenderContext,
run: &~TextRun,
Expand Down Expand Up @@ -399,8 +386,8 @@ impl Font {
if azglyph_buf_len == 0 { return; } // Otherwise the Quartz backend will assert.

let glyphbuf = struct__AzGlyphBuffer {
mGlyphs: vec::raw::to_ptr(azglyphs),
mNumGlyphs: azglyph_buf_len as uint32_t
mGlyphs: azglyphs.as_ptr(),
mNumGlyphs: azglyph_buf_len as uint32_t
};

unsafe {
Expand Down Expand Up @@ -441,11 +428,11 @@ impl Font {

//FIXME (ksh8281)
self.make_shaper();
do self.shape_cache.find_or_create(&text) |txt| {
self.shape_cache.find_or_create(&text, |txt| {
let mut glyphs = GlyphStore::new(text.char_len(), is_whitespace);
self.shaper.get_ref().shape_text(*txt, &mut glyphs);
Arc::new(glyphs)
}
})
}

pub fn get_descriptor(&self) -> FontDescriptor {
Expand All @@ -457,12 +444,12 @@ impl Font {
}

pub fn glyph_h_advance(&mut self, glyph: GlyphIndex) -> FractionalPixel {
do self.glyph_advance_cache.find_or_create(&glyph) |glyph| {
self.glyph_advance_cache.find_or_create(&glyph, |glyph| {
match self.handle.glyph_h_advance(*glyph) {
Some(adv) => adv,
None => /* FIXME: Need fallback strategy */ 10f64 as FractionalPixel
}
}
})
}
}

Expand Down

9 comments on commit a7ef1cd

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at metajack@a7ef1cd

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging metajack/servo/rustup-20131219 = a7ef1cd into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metajack/servo/rustup-20131219 = a7ef1cd merged ok, testing candidate = 8c33953

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at metajack@a7ef1cd

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging metajack/servo/rustup-20131219 = a7ef1cd into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metajack/servo/rustup-20131219 = a7ef1cd merged ok, testing candidate = 943ab4a

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 943ab4a

Please sign in to comment.