mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
servo: Merge #1067 - Rust upgrade (from metajack:rust-up-20131014); r=jdm
This upgrades to this morning's master. We have unfortunately broken the Android build, but I will update that in a second pull request as I think it's more than a single upgrade behind. Source-Repo: https://github.com/servo/servo Source-Revision: 797143a1d3e09b4ddd35a1ce5948be424ec3f9ef
This commit is contained in:
parent
ef05d248e9
commit
b40ed3e857
@ -254,7 +254,7 @@ DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
.PHONY: all
|
||||
all: servo package
|
||||
all: servo
|
||||
|
||||
# Servo helper libraries
|
||||
|
||||
|
@ -56,6 +56,7 @@ check-test:
|
||||
@$(call E, check:)
|
||||
@$(call E, " $(DEPS_CHECK_TARGETS_ALL)")
|
||||
|
||||
ifeq ($(CFG_OSTYPE),apple-darwin)
|
||||
.PHONY: check
|
||||
check: $(DEPS_CHECK_TARGETS_FAST) check-servo check-content tidy
|
||||
@$(call E, check: all)
|
||||
@ -63,6 +64,15 @@ check: $(DEPS_CHECK_TARGETS_FAST) check-servo check-content tidy
|
||||
.PHONY: check-all
|
||||
check-all: $(DEPS_CHECK_TARGETS_ALL) check-servo check-content tidy
|
||||
@$(call E, check: all)
|
||||
else
|
||||
.PHONY: check
|
||||
check: $(DEPS_CHECK_TARGETS_FAST) check-servo tidy
|
||||
@$(call E, check: all)
|
||||
|
||||
.PHONY: check-all
|
||||
check-all: $(DEPS_CHECK_TARGETS_ALL) check-servo tidy
|
||||
@$(call E, check: all)
|
||||
endif
|
||||
|
||||
.PHONY: check-servo
|
||||
check-servo: $(foreach lib_crate,$(SERVO_LIB_CRATES),check-servo-$(lib_crate)) servo-test
|
||||
|
@ -1,3 +1,5 @@
|
||||
NULL =
|
||||
|
||||
# Tests for these submodules will not be run by the default `make check` target.
|
||||
SLOW_TESTS += \
|
||||
mozjs \
|
||||
@ -216,7 +218,6 @@ CFLAGS_fontconfig += \
|
||||
"-I$(S)src/platform/android/libexpat/expat/lib" \
|
||||
"-I$(S)src/platform/android/libfreetype2/include" \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
DEPS_skia += \
|
||||
libfreetype2 \
|
||||
@ -231,3 +232,4 @@ NATIVE_BUILD += \
|
||||
libexpat \
|
||||
fontconfig \
|
||||
$(NULL)
|
||||
endif
|
||||
|
@ -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.
|
||||
2013-10-14
|
||||
2013-10-18
|
||||
|
@ -11,7 +11,7 @@ pub fn rgb(r: u8, g: u8, b: u8) -> AzColor {
|
||||
rgba(r, g, b, 1.0)
|
||||
}
|
||||
|
||||
pub fn rgba(r: u8, g: u8, b: u8, a: float) -> AzColor {
|
||||
pub fn rgba(r: u8, g: u8, b: u8, a: f64) -> AzColor {
|
||||
AzColor {
|
||||
r: (r as AzFloat) / (255.0 as AzFloat),
|
||||
g: (g as AzFloat) / (255.0 as AzFloat),
|
||||
|
@ -55,7 +55,7 @@ pub trait FontHandleMethods {
|
||||
}
|
||||
|
||||
// Used to abstract over the shaper's choice of fixed int representation.
|
||||
pub type FractionalPixel = float;
|
||||
pub type FractionalPixel = f64;
|
||||
|
||||
pub type FontTableTag = u32;
|
||||
|
||||
@ -123,7 +123,7 @@ impl CSSFontWeight {
|
||||
// For now, the cases are differentiated with a typedef
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct FontStyle {
|
||||
pt_size: float,
|
||||
pt_size: f64,
|
||||
weight: CSSFontWeight,
|
||||
italic: bool,
|
||||
oblique: bool,
|
||||
@ -391,7 +391,7 @@ impl Font {
|
||||
assert!(azure_pattern.is_not_null());
|
||||
|
||||
let options = struct__AzDrawOptions {
|
||||
mAlpha: 1f as AzFloat,
|
||||
mAlpha: 1f64 as AzFloat,
|
||||
fields: 0x0200 as uint16_t
|
||||
};
|
||||
|
||||
@ -402,7 +402,7 @@ impl Font {
|
||||
for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
|
||||
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(&slice_range) {
|
||||
let glyph_advance = glyph.advance();
|
||||
let glyph_offset = glyph.offset().unwrap_or_default(Au::zero_point());
|
||||
let glyph_offset = glyph.offset().unwrap_or(Au::zero_point());
|
||||
|
||||
let azglyph = struct__AzGlyph {
|
||||
mIndex: glyph.index() as uint32_t,
|
||||
@ -481,7 +481,7 @@ impl Font {
|
||||
do self.glyph_advance_cache.find_or_create(&glyph) |glyph| {
|
||||
match self.handle.glyph_h_advance(*glyph) {
|
||||
Some(adv) => adv,
|
||||
None => /* FIXME: Need fallback strategy */ 10f as FractionalPixel
|
||||
None => /* FIXME: Need fallback strategy */ 10f64 as FractionalPixel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use std::hashmap::HashMap;
|
||||
pub fn dummy_style() -> FontStyle {
|
||||
use font::FontWeight300;
|
||||
return FontStyle {
|
||||
pt_size: 20f,
|
||||
pt_size: 20f64,
|
||||
weight: FontWeight300,
|
||||
italic: false,
|
||||
oblique: false,
|
||||
@ -131,8 +131,9 @@ impl<'self> FontContext {
|
||||
let transformed_family_name = self.transform_family(family_name);
|
||||
debug!("(create font group) transformed family is `%s`", transformed_family_name);
|
||||
|
||||
let result = do self.font_list.chain_ref |fl| {
|
||||
fl.find_font_in_family(transformed_family_name, style)
|
||||
let result = match self.font_list {
|
||||
Some(ref fl) => fl.find_font_in_family(transformed_family_name, style),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let mut found = false;
|
||||
@ -156,8 +157,9 @@ impl<'self> FontContext {
|
||||
let last_resort = FontList::get_last_resort_font_families();
|
||||
|
||||
for family in last_resort.iter() {
|
||||
let result = do self.font_list.chain_ref |fl| {
|
||||
fl.find_font_in_family(*family, style)
|
||||
let result = match self.font_list {
|
||||
Some(ref fl) => fl.find_font_in_family(*family, style),
|
||||
None => None,
|
||||
};
|
||||
|
||||
for font_entry in result.iter() {
|
||||
@ -188,7 +190,7 @@ impl<'self> FontContext {
|
||||
&SelectorPlatformIdentifier(ref identifier) => {
|
||||
let result_handle = self.handle.create_font_from_identifier((*identifier).clone(),
|
||||
desc.style.clone());
|
||||
do result_handle.chain |handle| {
|
||||
do result_handle.and_then |handle| {
|
||||
Ok(Font::new_from_adopted_handle(self,
|
||||
handle,
|
||||
&desc.style,
|
||||
|
@ -84,7 +84,7 @@ impl FontList {
|
||||
debug!("FontList: %s font family with name=%s", decision, family_name);
|
||||
|
||||
// TODO(Issue #188): look up localized font family names if canonical name not found
|
||||
family.map(|f| **f)
|
||||
family.map(|f| *f)
|
||||
}
|
||||
|
||||
pub fn get_last_resort_font_families() -> ~[~str] {
|
||||
|
@ -8,6 +8,8 @@
|
||||
url = "http://servo.org/")];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(globs)];
|
||||
|
||||
extern mod azure;
|
||||
extern mod geom;
|
||||
extern mod newcss (name = "css");
|
||||
|
@ -8,9 +8,7 @@
|
||||
use azure::azure_hl::{BackendType, CairoBackend, CoreGraphicsBackend};
|
||||
use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
|
||||
|
||||
use std::float;
|
||||
use std::result;
|
||||
use std::uint;
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct Opts {
|
||||
@ -18,7 +16,7 @@ pub struct Opts {
|
||||
render_backend: BackendType,
|
||||
n_render_threads: uint,
|
||||
tile_size: uint,
|
||||
profiler_period: Option<float>,
|
||||
profiler_period: Option<f64>,
|
||||
exit_after_load: bool,
|
||||
output_file: Option<~str>,
|
||||
}
|
||||
@ -39,7 +37,7 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
|
||||
|
||||
let opt_match = match getopts::getopts(args, opts) {
|
||||
result::Ok(m) => m,
|
||||
result::Err(f) => fail!(getopts::fail_str(f.clone())),
|
||||
result::Err(f) => fail!(f.to_err_msg()),
|
||||
};
|
||||
|
||||
let urls = if opt_match.free.is_empty() {
|
||||
@ -48,7 +46,7 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
|
||||
opt_match.free.clone()
|
||||
};
|
||||
|
||||
let render_backend = match getopts::opt_maybe_str(&opt_match, "r") {
|
||||
let render_backend = match opt_match.opt_str("r") {
|
||||
Some(backend_str) => {
|
||||
if backend_str == ~"direct2d" {
|
||||
Direct2DBackend
|
||||
@ -67,24 +65,24 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
|
||||
None => SkiaBackend
|
||||
};
|
||||
|
||||
let tile_size: uint = match getopts::opt_maybe_str(&opt_match, "s") {
|
||||
Some(tile_size_str) => uint::from_str(tile_size_str).unwrap(),
|
||||
let tile_size: uint = match opt_match.opt_str("s") {
|
||||
Some(tile_size_str) => from_str(tile_size_str).unwrap(),
|
||||
None => 512,
|
||||
};
|
||||
|
||||
let n_render_threads: uint = match getopts::opt_maybe_str(&opt_match, "t") {
|
||||
Some(n_render_threads_str) => uint::from_str(n_render_threads_str).unwrap(),
|
||||
let n_render_threads: uint = match opt_match.opt_str("t") {
|
||||
Some(n_render_threads_str) => from_str(n_render_threads_str).unwrap(),
|
||||
None => 1, // FIXME: Number of cores.
|
||||
};
|
||||
|
||||
// if only flag is present, default to 5 second period
|
||||
let profiler_period = do getopts::opt_default(&opt_match, "p", "5").map |period| {
|
||||
float::from_str(*period).unwrap()
|
||||
let profiler_period = do opt_match.opt_default("p", "5").map |period| {
|
||||
from_str(period).unwrap()
|
||||
};
|
||||
|
||||
let exit_after_load = getopts::opt_present(&opt_match, "x");
|
||||
let exit_after_load = opt_match.opt_present("x");
|
||||
|
||||
let output_file = getopts::opt_maybe_str(&opt_match, "o");
|
||||
let output_file = opt_match.opt_str("o");
|
||||
|
||||
Opts {
|
||||
urls: urls,
|
||||
|
@ -29,11 +29,11 @@ use std::cast;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
|
||||
fn float_to_fixed_ft(f: float) -> i32 {
|
||||
fn float_to_fixed_ft(f: f64) -> i32 {
|
||||
float_to_fixed(6, f)
|
||||
}
|
||||
|
||||
fn fixed_to_float_ft(f: i32) -> float {
|
||||
fn fixed_to_float_ft(f: i32) -> f64 {
|
||||
fixed_to_float(6, f)
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ pub struct FontHandle {
|
||||
#[unsafe_destructor]
|
||||
impl Drop for FontHandle {
|
||||
#[fixed_stack_segment]
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
assert!(self.face.is_not_null());
|
||||
unsafe {
|
||||
if !FT_Done_Face(self.face).succeeded() {
|
||||
@ -102,7 +102,7 @@ impl FontHandleMethods for FontHandle {
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn create_face_from_buffer(lib: FT_Library,
|
||||
cbuf: *u8, cbuflen: uint, pt_size: float)
|
||||
cbuf: *u8, cbuflen: uint, pt_size: f64)
|
||||
-> Result<FT_Face, ()> {
|
||||
|
||||
unsafe {
|
||||
@ -224,12 +224,12 @@ impl FontHandleMethods for FontHandle {
|
||||
/* TODO(Issue #76): complete me */
|
||||
let face = self.get_face_rec();
|
||||
|
||||
let underline_size = self.font_units_to_au(face.underline_thickness as float);
|
||||
let underline_offset = self.font_units_to_au(face.underline_position as float);
|
||||
let em_size = self.font_units_to_au(face.units_per_EM as float);
|
||||
let ascent = self.font_units_to_au(face.ascender as float);
|
||||
let descent = self.font_units_to_au(face.descender as float);
|
||||
let max_advance = self.font_units_to_au(face.max_advance_width as float);
|
||||
let underline_size = self.font_units_to_au(face.underline_thickness as f64);
|
||||
let underline_offset = self.font_units_to_au(face.underline_position as f64);
|
||||
let em_size = self.font_units_to_au(face.units_per_EM as f64);
|
||||
let ascent = self.font_units_to_au(face.ascender as f64);
|
||||
let descent = self.font_units_to_au(face.descender as f64);
|
||||
let max_advance = self.font_units_to_au(face.max_advance_width as f64);
|
||||
|
||||
let mut strikeout_size = geometry::from_pt(0.0);
|
||||
let mut strikeout_offset = geometry::from_pt(0.0);
|
||||
@ -238,9 +238,9 @@ impl FontHandleMethods for FontHandle {
|
||||
let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *TT_OS2;
|
||||
let valid = os2.is_not_null() && (*os2).version != 0xffff;
|
||||
if valid {
|
||||
strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as float);
|
||||
strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as float);
|
||||
x_height = self.font_units_to_au((*os2).sxHeight as float);
|
||||
strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64);
|
||||
strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64);
|
||||
x_height = self.font_units_to_au((*os2).sxHeight as f64);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ impl FontHandleMethods for FontHandle {
|
||||
|
||||
impl<'self> FontHandle {
|
||||
#[fixed_stack_segment]
|
||||
fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{
|
||||
fn set_char_size(face: FT_Face, pt_size: f64) -> Result<(), ()>{
|
||||
let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6;
|
||||
let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6;
|
||||
let h_dpi = 72;
|
||||
@ -336,7 +336,7 @@ impl<'self> FontHandle {
|
||||
}
|
||||
}
|
||||
|
||||
fn font_units_to_au(&self, value: float) -> Au {
|
||||
fn font_units_to_au(&self, value: f64) -> Au {
|
||||
let face = self.get_face_rec();
|
||||
|
||||
// face.size is a *c_void in the bindings, presumably to avoid
|
||||
@ -344,8 +344,8 @@ impl<'self> FontHandle {
|
||||
let size: &FT_SizeRec = unsafe { cast::transmute(&(*face.size)) };
|
||||
let metrics: &FT_Size_Metrics = &(*size).metrics;
|
||||
|
||||
let em_size = face.units_per_EM as float;
|
||||
let x_scale = (metrics.x_ppem as float) / em_size as float;
|
||||
let em_size = face.units_per_EM as f64;
|
||||
let x_scale = (metrics.x_ppem as f64) / em_size as f64;
|
||||
|
||||
// If this isn't true then we're scaling one of the axes wrong
|
||||
assert!(metrics.x_ppem == metrics.y_ppem);
|
||||
|
@ -18,7 +18,7 @@ struct FreeTypeLibraryHandle {
|
||||
|
||||
impl Drop for FreeTypeLibraryHandle {
|
||||
#[fixed_stack_segment]
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
assert!(self.ctx.is_not_null());
|
||||
unsafe {
|
||||
FT_Done_FreeType(self.ctx);
|
||||
@ -53,9 +53,9 @@ impl FontContextHandleMethods for FontContextHandle {
|
||||
fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
debug!("Creating font handle for %s", name);
|
||||
do path_from_identifier(name, &style).chain |file_name| {
|
||||
do path_from_identifier(name, &style).and_then |file_name| {
|
||||
debug!("Opening font face %s", file_name);
|
||||
FontHandle::new_from_file(self, file_name, &style)
|
||||
FontHandle::new_from_file(self, file_name.to_owned(), &style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ struct AutoPattern {
|
||||
|
||||
impl Drop for AutoPattern {
|
||||
#[fixed_stack_segment]
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
FcPatternDestroy(self.pattern);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub struct FontTable {
|
||||
|
||||
// Noncopyable.
|
||||
impl Drop for FontTable {
|
||||
fn drop(&self) {}
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
impl FontTable {
|
||||
@ -158,39 +158,39 @@ impl FontHandleMethods for FontHandle {
|
||||
|
||||
fn get_metrics(&self) -> FontMetrics {
|
||||
let bounding_rect: CGRect = self.ctfont.bounding_box();
|
||||
let ascent = Au::from_pt(self.ctfont.ascent() as float);
|
||||
let descent = Au::from_pt(self.ctfont.descent() as float);
|
||||
let em_size = Au::from_frac_px(self.ctfont.pt_size() as float);
|
||||
let ascent = Au::from_pt(self.ctfont.ascent() as f64);
|
||||
let descent = Au::from_pt(self.ctfont.descent() as f64);
|
||||
let em_size = Au::from_frac_px(self.ctfont.pt_size() as f64);
|
||||
|
||||
let scale = px_to_pt(self.ctfont.pt_size() as float) / (self.ctfont.ascent() as float + self.ctfont.descent() as float);
|
||||
let scale = px_to_pt(self.ctfont.pt_size() as f64) / (self.ctfont.ascent() as f64 + self.ctfont.descent() as f64);
|
||||
|
||||
let metrics = FontMetrics {
|
||||
underline_size: Au::from_pt(self.ctfont.underline_thickness() as float),
|
||||
underline_size: Au::from_pt(self.ctfont.underline_thickness() as f64),
|
||||
// TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table
|
||||
// directly.
|
||||
//
|
||||
// see also: https://bugs.webkit.org/show_bug.cgi?id=16768
|
||||
// see also: https://bugreports.qt-project.org/browse/QTBUG-13364
|
||||
underline_offset: Au::from_pt(self.ctfont.underline_position() as float),
|
||||
underline_offset: Au::from_pt(self.ctfont.underline_position() as f64),
|
||||
strikeout_size: geometry::from_pt(0.0), // FIXME(Issue #942)
|
||||
strikeout_offset: geometry::from_pt(0.0), // FIXME(Issue #942)
|
||||
leading: Au::from_pt(self.ctfont.leading() as float),
|
||||
x_height: Au::from_pt(self.ctfont.x_height() as float),
|
||||
leading: Au::from_pt(self.ctfont.leading() as f64),
|
||||
x_height: Au::from_pt(self.ctfont.x_height() as f64),
|
||||
em_size: em_size,
|
||||
ascent: ascent.scale_by(scale),
|
||||
descent: descent.scale_by(scale),
|
||||
max_advance: Au::from_pt(bounding_rect.size.width as float)
|
||||
max_advance: Au::from_pt(bounding_rect.size.width as f64)
|
||||
};
|
||||
|
||||
debug!("Font metrics (@%f pt): %?", self.ctfont.pt_size() as float, metrics);
|
||||
debug!("Font metrics (@%f pt): %?", self.ctfont.pt_size() as f64, metrics);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
fn get_table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
|
||||
let result: Option<CFData> = self.ctfont.get_font_table(tag);
|
||||
result.chain(|data| {
|
||||
do result.and_then |data| {
|
||||
Some(FontTable::wrap(data))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn face_identifier(&self) -> ~str {
|
||||
|
@ -31,7 +31,7 @@ impl FontContextHandleMethods for FontContextHandle {
|
||||
style: UsedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
let ctfont_result = core_text::font::new_from_name(name, style.pt_size);
|
||||
do ctfont_result.chain |ctfont| {
|
||||
do ctfont_result.and_then |ctfont| {
|
||||
FontHandle::new_from_CTFont(self, ctfont)
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ impl<'self> RenderContext<'self> {
|
||||
Size2D(image.width as AzFloat, image.height as AzFloat));
|
||||
let dest_rect = bounds.to_azure_rect();
|
||||
let draw_surface_options = DrawSurfaceOptions(Linear, true);
|
||||
let draw_options = DrawOptions(1.0f as AzFloat, 0);
|
||||
let draw_options = DrawOptions(1.0f64 as AzFloat, 0);
|
||||
draw_target_ref.draw_surface(azure_surface,
|
||||
dest_rect,
|
||||
source_rect,
|
||||
@ -171,12 +171,12 @@ impl<'self> RenderContext<'self> {
|
||||
}
|
||||
|
||||
trait to_float {
|
||||
fn to_float(&self) -> float;
|
||||
fn to_float(&self) -> f64;
|
||||
}
|
||||
|
||||
impl to_float for u8 {
|
||||
fn to_float(&self) -> float {
|
||||
(*self as float) / 255f
|
||||
fn to_float(&self) -> f64 {
|
||||
(*self as f64) / 255f64
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ impl<T: Send> GenericSmartChan<Msg<T>> for RenderChan<T> {
|
||||
}
|
||||
}
|
||||
|
||||
struct RenderTask<C,T> {
|
||||
pub struct RenderTask<C,T> {
|
||||
id: PipelineId,
|
||||
port: Port<Msg<T>>,
|
||||
compositor: C,
|
||||
|
@ -12,7 +12,7 @@ use std::num::NumCast;
|
||||
use std::u16;
|
||||
use std::vec;
|
||||
use std::util;
|
||||
use std::iterator;
|
||||
use std::iter;
|
||||
use geom::point::Point2D;
|
||||
use extra::sort;
|
||||
|
||||
@ -157,7 +157,7 @@ fn is_simple_glyph_id(glyphId: GlyphIndex) -> bool {
|
||||
}
|
||||
|
||||
fn is_simple_advance(advance: Au) -> bool {
|
||||
let unsignedAu = advance.to_int() as u32;
|
||||
let unsignedAu = advance.to_u32().unwrap();
|
||||
(unsignedAu & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT)) == unsignedAu
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ impl GlyphEntry {
|
||||
// getter methods
|
||||
#[inline(always)]
|
||||
fn advance(&self) -> Au {
|
||||
NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT)
|
||||
NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT).unwrap()
|
||||
}
|
||||
|
||||
fn index(&self) -> GlyphIndex {
|
||||
@ -678,8 +678,8 @@ impl<'self> GlyphStore {
|
||||
pub struct GlyphIterator<'self> {
|
||||
priv store: &'self GlyphStore,
|
||||
priv char_index: uint,
|
||||
priv char_range: iterator::Range<uint>,
|
||||
priv glyph_range: Option<iterator::Range<uint>>,
|
||||
priv char_range: iter::Range<uint>,
|
||||
priv glyph_range: Option<iter::Range<uint>>,
|
||||
}
|
||||
|
||||
impl<'self> Iterator<(uint, GlyphInfo<'self>)> for GlyphIterator<'self> {
|
||||
|
@ -145,7 +145,7 @@ pub struct Shaper {
|
||||
#[unsafe_destructor]
|
||||
impl Drop for Shaper {
|
||||
#[fixed_stack_segment]
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
assert!(self.hb_face.is_not_null());
|
||||
hb_face_destroy(self.hb_face);
|
||||
@ -198,11 +198,11 @@ impl Shaper {
|
||||
}
|
||||
}
|
||||
|
||||
fn float_to_fixed(f: float) -> i32 {
|
||||
fn float_to_fixed(f: f64) -> i32 {
|
||||
float_to_fixed(16, f)
|
||||
}
|
||||
|
||||
fn fixed_to_float(i: hb_position_t) -> float {
|
||||
fn fixed_to_float(i: hb_position_t) -> f64 {
|
||||
fixed_to_float(16, i)
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ impl Shaper {
|
||||
if glyph_span.length() == 1 { break; }
|
||||
|
||||
// if no glyphs were found yet, extend the char byte range more.
|
||||
if glyph_span.length() == 0 { loop; }
|
||||
if glyph_span.length() == 0 { continue; }
|
||||
|
||||
debug!("Complex (multi-glyph to multi-char) association found. This case \
|
||||
probably doesn't work.");
|
||||
|
@ -61,7 +61,7 @@ impl<'self> Iterator<(&'self GlyphStore, uint, Range)> for SliceIterator<'self>
|
||||
|
||||
let slice_range = Range::new(self.offset, slice_glyphs.char_len());
|
||||
let mut char_range = self.range.intersect(&slice_range);
|
||||
char_range.shift_by(-(self.offset.to_int()));
|
||||
char_range.shift_by(-(self.offset.to_int().unwrap()));
|
||||
|
||||
let old_offset = self.offset;
|
||||
self.offset += slice_glyphs.char_len();
|
||||
@ -86,11 +86,11 @@ impl<'self> Iterator<Range> for LineIterator<'self> {
|
||||
Some((glyphs, offset, slice_range)) => {
|
||||
match (glyphs.is_whitespace(), self.clump) {
|
||||
(false, Some(ref mut c)) => {
|
||||
c.extend_by(slice_range.length().to_int());
|
||||
c.extend_by(slice_range.length().to_int().unwrap());
|
||||
}
|
||||
(false, None) => {
|
||||
let mut c = slice_range;
|
||||
c.shift_by(offset.to_int());
|
||||
c.shift_by(offset.to_int().unwrap());
|
||||
self.clump = Some(c);
|
||||
}
|
||||
(true, None) => { /* chomp whitespace */ }
|
||||
|
@ -95,12 +95,12 @@ pub fn transform_text(text: &str, mode: CompressionMode, incoming_whitespace: bo
|
||||
}
|
||||
}
|
||||
|
||||
pub fn float_to_fixed(before: int, f: float) -> i32 {
|
||||
pub fn float_to_fixed(before: int, f: f64) -> i32 {
|
||||
(1i32 << before) * (f as i32)
|
||||
}
|
||||
|
||||
pub fn fixed_to_float(before: int, f: i32) -> float {
|
||||
f as float * 1.0f / ((1i32 << before) as float)
|
||||
pub fn fixed_to_float(before: int, f: i32) -> f64 {
|
||||
f as f64 * 1.0f64 / ((1i32 << before) as f64)
|
||||
}
|
||||
|
||||
pub fn fixed_to_rounded_int(before: int, f: i32) -> int {
|
||||
|
@ -235,7 +235,7 @@ impl CompositorLayer {
|
||||
self.pipeline.render_chan.send(UnusedBufferMsg(unused));
|
||||
}
|
||||
if !request.is_empty() { // ask for tiles
|
||||
self.pipeline.render_chan.send(ReRenderMsg(request, scale, self.epoch));
|
||||
self.pipeline.render_chan.try_send(ReRenderMsg(request, scale, self.epoch));
|
||||
}
|
||||
}
|
||||
if redisplay {
|
||||
|
@ -22,7 +22,7 @@ use std::comm;
|
||||
use std::comm::{Chan, SharedChan, Port};
|
||||
use std::num::Orderable;
|
||||
use std::vec;
|
||||
use std::rt::rtio::RtioTimer;
|
||||
use std::path::Path;
|
||||
use std::rt::io::timer::Timer;
|
||||
use geom::matrix::identity;
|
||||
use geom::point::Point2D;
|
||||
@ -38,7 +38,7 @@ use servo_util::{time, url};
|
||||
use servo_util::time::profile;
|
||||
use servo_util::time::ProfilerChan;
|
||||
|
||||
use extra::future::from_value;
|
||||
use extra::future::Future;
|
||||
use extra::time::precise_time_s;
|
||||
|
||||
use constellation::SendableFrameTree;
|
||||
@ -226,7 +226,7 @@ impl CompositorTask {
|
||||
// Keeps track of the current zoom factor
|
||||
let mut world_zoom = 1f32;
|
||||
let mut zoom_action = false;
|
||||
let mut zoom_time = 0f;
|
||||
let mut zoom_time = 0f64;
|
||||
|
||||
// The root CompositorLayer
|
||||
let mut compositor_layer: Option<CompositorLayer> = None;
|
||||
@ -395,7 +395,7 @@ impl CompositorTask {
|
||||
match constellation_chan {
|
||||
Some(ref chan) => chan.send(LoadUrlMsg(root_pipeline_id,
|
||||
url::make_url(url_string.to_str(), None),
|
||||
from_value(window_size))),
|
||||
Future::from_value(window_size))),
|
||||
None => error!("Compositor: Recieved loadurl event without initialized layout chan"),
|
||||
}
|
||||
}
|
||||
@ -488,7 +488,7 @@ impl CompositorTask {
|
||||
// window.present()) as OpenGL ES 2 does not have glReadBuffer().
|
||||
if write_png {
|
||||
let (width, height) = (window_size.width as uint, window_size.height as uint);
|
||||
let path = Path(*self.opts.output_file.get_ref());
|
||||
let path = from_str::<Path>(*self.opts.output_file.get_ref()).unwrap();
|
||||
let mut pixels = gl2::read_pixels(0, 0,
|
||||
width as gl2::GLsizei,
|
||||
height as gl2::GLsizei,
|
||||
|
@ -9,7 +9,7 @@ use geom::point::Point2D;
|
||||
use geom::size::Size2D;
|
||||
use geom::rect::Rect;
|
||||
use std::uint::{div_ceil, next_power_of_two};
|
||||
use std::vec::build_sized;
|
||||
use std::vec;
|
||||
use std::util::replace;
|
||||
use gfx::render_task::BufferRequest;
|
||||
use servo_msg::compositor_msg::Tile;
|
||||
@ -622,7 +622,7 @@ impl<T: Tile> QuadtreeNode<T> {
|
||||
}
|
||||
};
|
||||
|
||||
let quads_to_check = build_sized(4, builder);
|
||||
let quads_to_check = vec::build(Some(4), builder);
|
||||
|
||||
let mut request = ~[];
|
||||
let mut unused = ~[];
|
||||
|
@ -25,7 +25,7 @@ use servo_util::url::make_url;
|
||||
use std::hashmap::{HashMap, HashSet};
|
||||
use std::util::replace;
|
||||
use extra::url::Url;
|
||||
use extra::future::{Future, from_value};
|
||||
use extra::future::Future;
|
||||
|
||||
/// Maintains the pipelines and navigation context and grants permission to composite
|
||||
pub struct Constellation {
|
||||
@ -377,7 +377,7 @@ impl Constellation {
|
||||
self.opts.clone(),
|
||||
{
|
||||
let size = self.compositor_chan.get_size();
|
||||
from_value(Size2D(size.width as uint, size.height as uint))
|
||||
Future::from_value(Size2D(size.width as uint, size.height as uint))
|
||||
});
|
||||
let failure = ~"about:failure";
|
||||
let url = make_url(failure, None);
|
||||
@ -402,7 +402,7 @@ impl Constellation {
|
||||
self.opts.clone(),
|
||||
{
|
||||
let size = self.compositor_chan.get_size();
|
||||
from_value(Size2D(size.width as uint, size.height as uint))
|
||||
Future::from_value(Size2D(size.width as uint, size.height as uint))
|
||||
});
|
||||
pipeline.load(url);
|
||||
|
||||
@ -458,7 +458,7 @@ impl Constellation {
|
||||
for source_frame in source_frame.iter() {
|
||||
let found_child = source_frame.children.mut_iter()
|
||||
.find(|child| subpage_eq(child));
|
||||
found_child.map_move(|child| update_child_rect(child, true));
|
||||
found_child.map(|child| update_child_rect(child, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ impl Constellation {
|
||||
for frame_tree in frames.iter() {
|
||||
let found_child = frame_tree.children.mut_iter()
|
||||
.find(|child| subpage_eq(child));
|
||||
found_child.map_move(|child| update_child_rect(child, false));
|
||||
found_child.map(|child| update_child_rect(child, false));
|
||||
}
|
||||
|
||||
// At this point, if no pipelines were sent a resize msg, then this subpage id
|
||||
|
@ -61,8 +61,8 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> {
|
||||
|
||||
do self.read_layout_data |layout_data| {
|
||||
layout_data.restyle_damage
|
||||
.map(|&x| RestyleDamage::from_int(x))
|
||||
.unwrap_or_default(default)
|
||||
.map(|x| RestyleDamage::from_int(x))
|
||||
.unwrap_or(default)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,14 +30,24 @@ fn default_url(name: &str) -> Url {
|
||||
FromStr::from_str(fmt!("http://%s", name)).unwrap()
|
||||
}
|
||||
|
||||
fn style_stream(style: &str) -> DataStream {
|
||||
fn style_stream(style: &str) -> @mut DataStream {
|
||||
let style = Cell::new(style.as_bytes().to_owned());
|
||||
let d: DataStream = || if !style.is_empty() {
|
||||
Some(style.take())
|
||||
} else {
|
||||
None
|
||||
struct StyleDataStream {
|
||||
style: Cell<~[u8]>,
|
||||
}
|
||||
impl DataStream for StyleDataStream {
|
||||
fn read(&mut self) -> Option<~[u8]> {
|
||||
if !self.style.is_empty() {
|
||||
Some(self.style.take())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
let stream = @mut StyleDataStream {
|
||||
style: style,
|
||||
};
|
||||
return d;
|
||||
stream as @mut DataStream
|
||||
}
|
||||
|
||||
fn html4_default_style_str() -> &'static str {
|
||||
|
@ -31,7 +31,7 @@ impl SelectHandler<AbstractNode<LayoutView>> for NodeSelectHandler {
|
||||
|
||||
fn named_parent_node(&self, node: &AbstractNode<LayoutView>, name: &str)
|
||||
-> Option<AbstractNode<LayoutView>> {
|
||||
do node.parent_node().chain |parent| {
|
||||
do node.parent_node().and_then |parent| {
|
||||
do with_node_name(parent) |node_name| {
|
||||
if eq_slice(name, node_name) {
|
||||
Some(parent)
|
||||
|
@ -106,10 +106,10 @@ impl BlockFlowData {
|
||||
|
||||
/* if not an anonymous block context, add in block box's widths.
|
||||
these widths will not include child elements, just padding etc. */
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.iter() {
|
||||
min_width = min_width.add(&box.get_min_width(ctx));
|
||||
pref_width = pref_width.add(&box.get_pref_width(ctx));
|
||||
});
|
||||
}
|
||||
|
||||
self.common.min_width = min_width;
|
||||
self.common.pref_width = pref_width;
|
||||
@ -409,7 +409,7 @@ impl BlockFlowData {
|
||||
}
|
||||
|
||||
let mut noncontent_height = Au(0);
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.mut_iter() {
|
||||
do box.with_mut_base |base| {
|
||||
//The associated box is the border box of this flow
|
||||
base.model.margin.top = margin_top;
|
||||
@ -424,7 +424,7 @@ impl BlockFlowData {
|
||||
noncontent_height = noncontent_height + clearance +
|
||||
base.model.margin.top + base.model.margin.bottom;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//TODO(eatkinson): compute heights using the 'height' property.
|
||||
self.common.position.size.height = height + noncontent_height;
|
||||
@ -444,16 +444,16 @@ impl BlockFlowData {
|
||||
-> bool {
|
||||
|
||||
if self.common.node.is_iframe_element() {
|
||||
let x = self.common.abs_position.x + do self.box.map_default(Au(0)) |box| {
|
||||
let x = self.common.abs_position.x + do self.box.as_ref().map_default(Au(0)) |box| {
|
||||
box.with_model(|model| model.margin.left + model.border.left + model.padding.left)
|
||||
};
|
||||
let y = self.common.abs_position.y + do self.box.map_default(Au(0)) |box| {
|
||||
let y = self.common.abs_position.y + do self.box.as_ref().map_default(Au(0)) |box| {
|
||||
box.with_model(|model| model.margin.top + model.border.top + model.padding.top)
|
||||
};
|
||||
let w = self.common.position.size.width - do self.box.map_default(Au(0)) |box| {
|
||||
let w = self.common.position.size.width - do self.box.as_ref().map_default(Au(0)) |box| {
|
||||
box.with_model(|model| model.noncontent_width())
|
||||
};
|
||||
let h = self.common.position.size.height - do self.box.map_default(Au(0)) |box| {
|
||||
let h = self.common.position.size.height - do self.box.as_ref().map_default(Au(0)) |box| {
|
||||
box.with_model(|model| model.noncontent_height())
|
||||
};
|
||||
do self.common.node.with_mut_iframe_element |iframe_element| {
|
||||
@ -472,10 +472,9 @@ impl BlockFlowData {
|
||||
debug!("build_display_list_block: adding display element");
|
||||
|
||||
// add box that starts block context
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.iter() {
|
||||
box.build_display_list(builder, dirty, &self.common.abs_position, list)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// TODO: handle any out-of-flow elements
|
||||
let this_position = self.common.abs_position;
|
||||
|
@ -362,10 +362,10 @@ impl RenderBox {
|
||||
None
|
||||
};
|
||||
|
||||
let right_box = do right_range.map_default(None) |range: &Range| {
|
||||
let right_box = do right_range.map_default(None) |range: Range| {
|
||||
let new_text_box = @mut text::adapt_textbox_with_range(text_box.base,
|
||||
text_box.run,
|
||||
*range);
|
||||
range);
|
||||
Some(TextRenderBoxClass(new_text_box))
|
||||
};
|
||||
|
||||
@ -498,7 +498,7 @@ impl RenderBox {
|
||||
let px_width = if attr_width.is_some() {
|
||||
attr_width.unwrap()
|
||||
} else {
|
||||
image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width
|
||||
image_box.image.get_size().unwrap_or(Size2D(0, 0)).width
|
||||
};
|
||||
|
||||
Au::from_px(px_width)
|
||||
@ -524,7 +524,7 @@ impl RenderBox {
|
||||
let px_height = if attr_height.is_some() {
|
||||
attr_height.unwrap()
|
||||
} else {
|
||||
image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).height
|
||||
image_box.image.get_size().unwrap_or(Size2D(0, 0)).height
|
||||
};
|
||||
|
||||
Au::from_px(px_height)
|
||||
@ -852,10 +852,10 @@ impl RenderBox {
|
||||
debug!("(font style) font families: `%s`", font_families);
|
||||
|
||||
let font_size = match my_style.font_size() {
|
||||
CSSFontSizeLength(Px(length)) => length,
|
||||
CSSFontSizeLength(Px(length)) => length as f64,
|
||||
// todo: this is based on a hard coded font size, should be the parent element's font size
|
||||
CSSFontSizeLength(Em(length)) => length * 16f,
|
||||
_ => 16f // px units
|
||||
CSSFontSizeLength(Em(length)) => (length as f64) * 16f64,
|
||||
_ => 16f64 // px units
|
||||
};
|
||||
debug!("(font style) font size: `%fpx`", font_size);
|
||||
|
||||
|
@ -405,7 +405,7 @@ impl LayoutTreeBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
let sibling_flow: Option<&mut FlowContext> = sibling_generator.map_mut(|gen| &mut *gen.flow);
|
||||
let sibling_flow: Option<&mut FlowContext> = sibling_generator.as_mut().map(|gen| &mut *gen.flow);
|
||||
|
||||
// TODO(eatkinson): use the value of the float property to
|
||||
// determine whether to float left or right.
|
||||
|
@ -63,7 +63,7 @@ pub trait ToGfxColor {
|
||||
|
||||
impl ToGfxColor for newcss::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 as f64)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl FloatFlowData {
|
||||
self.floated_children = num_floats;
|
||||
|
||||
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.iter() {
|
||||
let style = box.style();
|
||||
do box.with_model |model| {
|
||||
model.compute_borders(style)
|
||||
@ -89,7 +89,7 @@ impl FloatFlowData {
|
||||
|
||||
min_width = min_width.add(&box.get_min_width(ctx));
|
||||
pref_width = pref_width.add(&box.get_pref_width(ctx));
|
||||
});
|
||||
}
|
||||
|
||||
self.common.min_width = min_width;
|
||||
self.common.pref_width = pref_width;
|
||||
@ -185,7 +185,7 @@ impl FloatFlowData {
|
||||
let mut full_noncontent_width = Au(0);
|
||||
let mut margin_height = Au(0);
|
||||
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.iter() {
|
||||
height = do box.with_base |base| {
|
||||
base.position.size.height
|
||||
};
|
||||
@ -204,7 +204,7 @@ impl FloatFlowData {
|
||||
margin_height = base.model.margin.top + base.model.margin.bottom;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
let info = PlacementInfo {
|
||||
width: self.common.position.size.width + full_noncontent_width,
|
||||
@ -257,7 +257,7 @@ impl FloatFlowData {
|
||||
|
||||
let mut noncontent_width = Au(0);
|
||||
let mut noncontent_height = Au(0);
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.mut_iter() {
|
||||
do box.with_mut_base |base| {
|
||||
//The associated box is the border box of this flow
|
||||
base.position.origin.y = base.model.margin.top;
|
||||
@ -269,8 +269,7 @@ impl FloatFlowData {
|
||||
base.position.size.height = height + noncontent_height;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//TODO(eatkinson): compute heights properly using the 'height' property.
|
||||
for &box in self.box.iter() {
|
||||
@ -305,10 +304,9 @@ impl FloatFlowData {
|
||||
|
||||
let offset = self.common.abs_position + self.rel_pos;
|
||||
// add box that starts block context
|
||||
self.box.map(|&box| {
|
||||
for box in self.box.iter() {
|
||||
box.build_display_list(builder, dirty, &offset, list)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// TODO: handle any out-of-flow elements
|
||||
|
||||
|
@ -300,7 +300,7 @@ impl FloatContextBase{
|
||||
f_data.bounds.origin.x + f_data.bounds.size.width > left &&
|
||||
f_data.bounds.origin.x < left + width {
|
||||
let new_y = f_data.bounds.origin.y;
|
||||
max_height = Some(min(max_height.unwrap_or_default(new_y), new_y));
|
||||
max_height = Some(min(max_height.unwrap_or(new_y), new_y));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -340,7 +340,7 @@ impl FloatContextBase{
|
||||
let height = self.max_height_for_bounds(rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.size.width);
|
||||
let height = height.unwrap_or_default(Au(max_value));
|
||||
let height = height.unwrap_or(Au(max_value));
|
||||
return match info.f_type {
|
||||
FloatLeft => Rect(Point2D(rect.origin.x, float_y),
|
||||
Size2D(rect.size.width, height)),
|
||||
|
@ -425,7 +425,7 @@ impl<'self> FlowContext {
|
||||
pub fn foldl_all_boxes<B:Clone>(&mut self, seed: B, cb: &fn(a: B, b: RenderBox) -> B) -> B {
|
||||
match *self {
|
||||
BlockFlow(ref mut block) => {
|
||||
do block.box.map_default(seed.clone()) |box| {
|
||||
do block.box.as_ref().map_default(seed.clone()) |box| {
|
||||
cb(seed.clone(), *box)
|
||||
}
|
||||
}
|
||||
@ -455,7 +455,7 @@ impl<'self> FlowContext {
|
||||
pub fn iter_all_boxes(&mut self) -> BoxIterator {
|
||||
BoxIterator {
|
||||
boxes: match *self {
|
||||
BlockFlow (ref mut block) => block.box.map_default(~[], |&x| ~[x]),
|
||||
BlockFlow(ref mut block) => block.box.as_ref().map_default(~[], |&x| ~[x]),
|
||||
InlineFlow(ref mut inline) => inline.boxes.clone(),
|
||||
_ => fail!(fmt!("Don't know how to iterate node's RenderBoxes for %?", self))
|
||||
},
|
||||
|
@ -112,9 +112,10 @@ impl RestyleDamage {
|
||||
// version of this macro might be safe anyway, but we want to avoid silent
|
||||
// breakage on modifications.
|
||||
macro_rules! add_if_not_equal(
|
||||
([ $($effect:ident),* ], [ $($getter:ident),* ]) => ({
|
||||
if $( (old.$getter() != new.$getter()) )||* {
|
||||
damage.union_in_place( restyle_damage!( $($effect),* ) );
|
||||
($old:ident, $new:ident, $damage:ident,
|
||||
[ $($effect:ident),* ], [ $($getter:ident),* ]) => ({
|
||||
if $( ($old.$getter() != $new.$getter()) )||* {
|
||||
$damage.union_in_place( restyle_damage!( $($effect),* ) );
|
||||
}
|
||||
})
|
||||
)
|
||||
@ -132,11 +133,11 @@ pub fn compute_damage(node: &AbstractNode<LayoutView>,
|
||||
|
||||
// FIXME: We can short-circuit more of this.
|
||||
|
||||
add_if_not_equal!([ Repaint ],
|
||||
add_if_not_equal!(old, new, damage, [ Repaint ],
|
||||
[ color, background_color, border_top_color, border_right_color,
|
||||
border_bottom_color, border_left_color ]);
|
||||
|
||||
add_if_not_equal!([ Repaint, BubbleWidths, Reflow ],
|
||||
add_if_not_equal!(old, new, damage, [ Repaint, BubbleWidths, Reflow ],
|
||||
[ border_top_width, border_right_width, border_bottom_width,
|
||||
border_left_width, margin_top, margin_right, margin_bottom, margin_left,
|
||||
padding_top, padding_right, padding_bottom, padding_left, position,
|
||||
|
@ -171,11 +171,11 @@ impl LineboxScanner {
|
||||
|
||||
fn calculate_line_height(&self, box: RenderBox, font_size: Au) -> Au {
|
||||
match box.line_height() {
|
||||
CSSLineHeightNormal => font_size.scale_by(1.14f),
|
||||
CSSLineHeightNumber(l) => font_size.scale_by(l),
|
||||
CSSLineHeightLength(Em(l)) => font_size.scale_by(l),
|
||||
CSSLineHeightLength(Px(l)) => Au::from_frac_px(l),
|
||||
CSSLineHeightPercentage(p) => font_size.scale_by(p / 100.0f)
|
||||
CSSLineHeightNormal => font_size.scale_by(1.14f64),
|
||||
CSSLineHeightNumber(l) => font_size.scale_by(l as f64),
|
||||
CSSLineHeightLength(Em(l)) => font_size.scale_by(l as f64),
|
||||
CSSLineHeightLength(Px(l)) => Au::from_frac_px(l as f64),
|
||||
CSSLineHeightPercentage(p) => font_size.scale_by(p as f64 / 100.0f64)
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ impl LineboxScanner {
|
||||
match box {
|
||||
ImageRenderBoxClass(image_box) => {
|
||||
let size = image_box.image.get_size();
|
||||
let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height);
|
||||
let height = Au::from_px(size.unwrap_or(Size2D(0, 0)).height);
|
||||
image_box.base.position.size.height = height;
|
||||
debug!("box_height: found image height: %?", height);
|
||||
height
|
||||
@ -645,7 +645,7 @@ impl InlineFlowData {
|
||||
}
|
||||
}
|
||||
CSSTextAlignCenter => {
|
||||
offset_x = offset_x + slack_width.scale_by(0.5f);
|
||||
offset_x = offset_x + slack_width.scale_by(0.5f64);
|
||||
for i in line.range.eachi() {
|
||||
do self.boxes[i].with_mut_base |base| {
|
||||
base.position.origin.x = offset_x;
|
||||
@ -715,7 +715,7 @@ impl InlineFlowData {
|
||||
let text_ascent = text_box.run.font.metrics.ascent;
|
||||
|
||||
// Offset from the top of the box is 1/2 of the leading + ascent
|
||||
let text_offset = text_ascent + (line_height - em_size).scale_by(0.5f);
|
||||
let text_offset = text_ascent + (line_height - em_size).scale_by(0.5f64);
|
||||
text_bounds.translate(&Point2D(text_box.base.position.origin.x, Au(0)));
|
||||
|
||||
(text_offset, line_height - text_offset, text_ascent)
|
||||
@ -746,13 +746,17 @@ impl InlineFlowData {
|
||||
let parent_text_bottom = Au(0);
|
||||
do cur_box.with_mut_base |base| {
|
||||
// Get parent node
|
||||
let parent = base.node.parent_node().map_default(base.node, |parent| *parent);
|
||||
let parent = match base.node.parent_node() {
|
||||
None => base.node,
|
||||
Some(parent) => parent,
|
||||
};
|
||||
|
||||
// TODO: When the calculation of font-size style is supported, it should be updated.
|
||||
let font_size = match parent.style().font_size() {
|
||||
CSSFontSizeLength(Px(length)) => length,
|
||||
CSSFontSizeLength(Px(length)) => length as f64,
|
||||
// todo: this is based on a hard coded font size, should be the parent element's font size
|
||||
CSSFontSizeLength(Em(length)) => length * 16f,
|
||||
_ => 16f // px units
|
||||
CSSFontSizeLength(Em(length)) => length as f64 * 16f64,
|
||||
_ => 16f64 // px units
|
||||
};
|
||||
parent_text_top = Au::from_frac_px(font_size);
|
||||
}
|
||||
@ -814,15 +818,15 @@ impl InlineFlowData {
|
||||
},
|
||||
CSSVerticalAlignLength(length) => {
|
||||
let length_offset = match length {
|
||||
Em(l) => Au::from_frac_px(cur_box.font_style().pt_size * l),
|
||||
Px(l) => Au::from_frac_px(l),
|
||||
Em(l) => Au::from_frac_px(cur_box.font_style().pt_size * l as f64),
|
||||
Px(l) => Au::from_frac_px(l as f64),
|
||||
};
|
||||
-(length_offset + ascent)
|
||||
},
|
||||
CSSVerticalAlignPercentage(p) => {
|
||||
let pt_size = cur_box.font_style().pt_size;
|
||||
let line_height = scanner.calculate_line_height(cur_box, Au::from_pt(pt_size));
|
||||
let percent_offset = line_height.scale_by(p / 100.0f);
|
||||
let percent_offset = line_height.scale_by(p as f64 / 100.0f64);
|
||||
-(percent_offset + ascent)
|
||||
}
|
||||
};
|
||||
|
@ -391,7 +391,7 @@ impl LayoutTask {
|
||||
for child in node.children() {
|
||||
let rect = box_for_node(child);
|
||||
match rect {
|
||||
None => loop,
|
||||
None => continue,
|
||||
Some(rect) => acc = match acc {
|
||||
Some(acc) => Some(acc.union(&rect)),
|
||||
None => Some(rect)
|
||||
@ -404,8 +404,8 @@ impl LayoutTask {
|
||||
}
|
||||
}
|
||||
|
||||
let rect = box_for_node(node).unwrap_or_default(Rect(Point2D(Au(0), Au(0)),
|
||||
Size2D(Au(0), Au(0))));
|
||||
let rect = box_for_node(node).unwrap_or(Rect(Point2D(Au(0), Au(0)),
|
||||
Size2D(Au(0), Au(0))));
|
||||
reply_chan.send(ContentBoxResponse(rect))
|
||||
}
|
||||
ContentBoxesQuery(node, reply_chan) => {
|
||||
@ -444,8 +444,8 @@ impl LayoutTask {
|
||||
match self.display_list {
|
||||
Some(ref list) => {
|
||||
let display_list = list.get();
|
||||
let (x, y) = (Au::from_frac_px(point.x as float),
|
||||
Au::from_frac_px(point.y as float));
|
||||
let (x, y) = (Au::from_frac_px(point.x as f64),
|
||||
Au::from_frac_px(point.y as f64));
|
||||
let mut resp = Err(());
|
||||
// iterate in reverse to ensure we have the most recently painted render box
|
||||
for display_item in display_list.list.rev_iter() {
|
||||
@ -482,13 +482,13 @@ impl LayoutTask {
|
||||
// re-requested. We probably don't need to go all the way back to
|
||||
// the script task for this.
|
||||
fn make_on_image_available_cb(&self, script_chan: ScriptChan)
|
||||
-> @fn() -> ~fn(ImageResponseMsg) {
|
||||
-> ~fn() -> ~fn(ImageResponseMsg) {
|
||||
// This has a crazy signature because the image cache needs to
|
||||
// make multiple copies of the callback, and the dom event
|
||||
// channel is not a copyable type, so this is actually a
|
||||
// little factory to produce callbacks
|
||||
let id = self.id.clone();
|
||||
let f: @fn() -> ~fn(ImageResponseMsg) = || {
|
||||
let f: ~fn() -> ~fn(ImageResponseMsg) = || {
|
||||
let script_chan = script_chan.clone();
|
||||
let f: ~fn(ImageResponseMsg) = |_| {
|
||||
script_chan.send(SendEventMsg(id.clone(), ReflowEvent))
|
||||
|
@ -26,10 +26,10 @@ pub struct BoxModel {
|
||||
|
||||
fn from_length(length: Length, font_size: CSSFontSize) -> Au {
|
||||
match length {
|
||||
Px(v) => Au::from_frac_px(v),
|
||||
Px(v) => Au::from_frac_px(v as f64),
|
||||
Em(em) => {
|
||||
match font_size {
|
||||
CSSFontSizeLength(Px(v)) => Au::from_frac_px(em * v),
|
||||
CSSFontSizeLength(Px(v)) => Au::from_frac_px((em * v) as f64),
|
||||
_ => fail!("expected non-relative font size")
|
||||
}
|
||||
}
|
||||
@ -46,7 +46,7 @@ impl MaybeAuto {
|
||||
pub fn from_margin(margin: CSSMargin, containing_width: Au, font_size: CSSFontSize) -> MaybeAuto {
|
||||
match margin {
|
||||
CSSMarginAuto => Auto,
|
||||
CSSMarginPercentage(percent) => Specified(containing_width.scale_by(percent/100.0)),
|
||||
CSSMarginPercentage(percent) => Specified(containing_width.scale_by(percent as f64 / 100.0f64)),
|
||||
CSSMarginLength(length) => Specified(from_length(length, font_size))
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ impl MaybeAuto {
|
||||
pub fn from_width(width: CSSWidth, containing_width: Au, font_size: CSSFontSize) -> MaybeAuto {
|
||||
match width {
|
||||
CSSWidthAuto => Auto,
|
||||
CSSWidthPercentage(percent) => Specified(containing_width.scale_by(percent/100.0)),
|
||||
CSSWidthPercentage(percent) => Specified(containing_width.scale_by(percent as f64 / 100.0f64)),
|
||||
CSSWidthLength(length) => Specified(from_length(length, font_size))
|
||||
}
|
||||
}
|
||||
@ -62,7 +62,7 @@ impl MaybeAuto {
|
||||
pub fn from_height(height: CSSHeight, cb_height: Au, font_size: CSSFontSize) -> MaybeAuto {
|
||||
match height {
|
||||
CSSHeightAuto => Auto,
|
||||
CSSHeightPercentage(percent) => Specified(cb_height.scale_by(percent/100.0)),
|
||||
CSSHeightPercentage(percent) => Specified(cb_height.scale_by(percent as f64 / 100.0f64)),
|
||||
CSSHeightLength(length) => Specified(from_length(length, font_size))
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ impl BoxModel {
|
||||
pub fn compute_padding_length(&self, padding: CSSPadding, content_box_width: Au, font_size: CSSFontSize) -> Au {
|
||||
match padding {
|
||||
CSSPaddingLength(length) => from_length(length, font_size),
|
||||
CSSPaddingPercentage(p) => content_box_width.scale_by(p/100.0)
|
||||
CSSPaddingPercentage(p) => content_box_width.scale_by(p as f64 / 100.0f64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ impl TextRunScanner {
|
||||
debug!("Elided an `UnscannedTextbox` because it was zero-length after \
|
||||
compression; %s",
|
||||
in_boxes[i].debug_str());
|
||||
loop
|
||||
continue
|
||||
}
|
||||
|
||||
do in_boxes[i].with_base |base| {
|
||||
|
@ -6,7 +6,7 @@ use layout::box::{RenderBox};
|
||||
use script::dom::node::{AbstractNode, LayoutView};
|
||||
use servo_util::range::Range;
|
||||
|
||||
use std::iterator::Enumerate;
|
||||
use std::iter::Enumerate;
|
||||
use std::vec::VecIterator;
|
||||
|
||||
pub struct NodeRange {
|
||||
|
@ -180,7 +180,7 @@ impl Pipeline {
|
||||
}
|
||||
|
||||
pub fn reload(&mut self) {
|
||||
do self.url.clone().map_move() |url| {
|
||||
do self.url.clone().map() |url| {
|
||||
self.load(url);
|
||||
};
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ impl ApplicationMethods for Application {
|
||||
}
|
||||
|
||||
impl Drop for Application {
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
drop_local_window();
|
||||
glfw::terminate();
|
||||
}
|
||||
@ -52,7 +52,7 @@ pub struct Window {
|
||||
|
||||
drag_origin: Point2D<c_int>,
|
||||
|
||||
mouse_down_button: @mut c_int,
|
||||
mouse_down_button: @mut Option<glfw::MouseButton>,
|
||||
mouse_down_point: @mut Point2D<c_int>,
|
||||
|
||||
ready_state: ReadyState,
|
||||
@ -76,7 +76,7 @@ impl WindowMethods<Application> for Window {
|
||||
|
||||
drag_origin: Point2D(0 as c_int, 0),
|
||||
|
||||
mouse_down_button: @mut 0,
|
||||
mouse_down_button: @mut None,
|
||||
mouse_down_point: @mut Point2D(0 as c_int, 0),
|
||||
|
||||
ready_state: Blank,
|
||||
@ -91,7 +91,7 @@ impl WindowMethods<Application> for Window {
|
||||
local_window().event_queue.push(ResizeWindowEvent(width as uint, height as uint))
|
||||
}
|
||||
do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| {
|
||||
if action == glfw::PRESS {
|
||||
if action == glfw::Press {
|
||||
local_window().handle_key(key, mods)
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ impl WindowMethods<Application> for Window {
|
||||
let hidpi = (backing_size as f32) / (window_size as f32);
|
||||
let x = x as f32 * hidpi;
|
||||
let y = y as f32 * hidpi;
|
||||
if button < 3 {
|
||||
if button == glfw::MouseButtonLeft || button == glfw::MouseButtonRight {
|
||||
local_window().handle_mouse(button, action, x as i32, y as i32);
|
||||
}
|
||||
}
|
||||
@ -206,21 +206,20 @@ impl Window {
|
||||
}
|
||||
|
||||
/// Helper function to handle keyboard events.
|
||||
fn handle_key(&self, key: c_int, mods: glfw::KeyMods) {
|
||||
let mods = *mods;
|
||||
fn handle_key(&self, key: glfw::Key, mods: glfw::Modifiers) {
|
||||
match key {
|
||||
glfw::KEY_ESCAPE => self.glfw_window.set_should_close(true),
|
||||
glfw::KEY_L if mods & glfw::MOD_CONTROL != 0 => self.load_url(), // Ctrl+L
|
||||
glfw::KEY_EQUAL if mods & glfw::MOD_CONTROL != 0 => { // Ctrl-+
|
||||
glfw::KeyEscape => self.glfw_window.set_should_close(true),
|
||||
glfw::KeyL if mods.contains(glfw::Control) => self.load_url(), // Ctrl+L
|
||||
glfw::KeyEqual if mods.contains(glfw::Control) => { // Ctrl-+
|
||||
self.event_queue.push(ZoomWindowEvent(1.1));
|
||||
}
|
||||
glfw::KEY_MINUS if mods & glfw::MOD_CONTROL != 0 => { // Ctrl--
|
||||
glfw::KeyMinus if mods.contains(glfw::Control) => { // Ctrl--
|
||||
self.event_queue.push(ZoomWindowEvent(0.90909090909));
|
||||
}
|
||||
glfw::KEY_BACKSPACE if mods & glfw::MOD_SHIFT != 0 => { // Shift-Backspace
|
||||
glfw::KeyBackspace if mods.contains(glfw::Shift) => { // Shift-Backspace
|
||||
self.event_queue.push(NavigationWindowEvent(Forward));
|
||||
}
|
||||
glfw::KEY_BACKSPACE => { // Backspace
|
||||
glfw::KeyBackspace => { // Backspace
|
||||
self.event_queue.push(NavigationWindowEvent(Back));
|
||||
}
|
||||
_ => {}
|
||||
@ -228,25 +227,29 @@ impl Window {
|
||||
}
|
||||
|
||||
/// Helper function to handle a click
|
||||
fn handle_mouse(&self, button: c_int, action: c_int, x: c_int, y: c_int) {
|
||||
fn handle_mouse(&self, button: glfw::MouseButton, action: glfw::Action, x: c_int, y: c_int) {
|
||||
// FIXME(tkuehn): max pixel dist should be based on pixel density
|
||||
let max_pixel_dist = 10f;
|
||||
let max_pixel_dist = 10f64;
|
||||
let event = match action {
|
||||
glfw::PRESS => {
|
||||
glfw::Press => {
|
||||
*self.mouse_down_point = Point2D(x, y);
|
||||
*self.mouse_down_button = button;
|
||||
*self.mouse_down_button = Some(button);
|
||||
MouseWindowMouseDownEvent(button as uint, Point2D(x as f32, y as f32))
|
||||
}
|
||||
glfw::RELEASE => {
|
||||
if *self.mouse_down_button == button {
|
||||
let pixel_dist = *self.mouse_down_point - Point2D(x, y);
|
||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||
pixel_dist.y * pixel_dist.y) as float).sqrt();
|
||||
if pixel_dist < max_pixel_dist {
|
||||
let click_event = MouseWindowClickEvent(button as uint,
|
||||
Point2D(x as f32, y as f32));
|
||||
self.event_queue.push(MouseWindowEventClass(click_event));
|
||||
glfw::Release => {
|
||||
match *self.mouse_down_button {
|
||||
None => (),
|
||||
Some(but) if button == but => {
|
||||
let pixel_dist = *self.mouse_down_point - Point2D(x, y);
|
||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
||||
if pixel_dist < max_pixel_dist {
|
||||
let click_event = MouseWindowClickEvent(button as uint,
|
||||
Point2D(x as f32, y as f32));
|
||||
self.event_queue.push(MouseWindowEventClass(click_event));
|
||||
}
|
||||
}
|
||||
Some(_) => (),
|
||||
}
|
||||
MouseWindowMouseUpEvent(button as uint, Point2D(x as f32, y as f32))
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ impl Window {
|
||||
/// Helper function to handle a click
|
||||
fn handle_mouse(&self, button: c_int, state: c_int, x: c_int, y: c_int) {
|
||||
// FIXME(tkuehn): max pixel dist should be based on pixel density
|
||||
let max_pixel_dist = 10f;
|
||||
let max_pixel_dist = 10f64;
|
||||
let event = match state {
|
||||
glut::MOUSE_DOWN => {
|
||||
*self.mouse_down_point = Point2D(x, y);
|
||||
|
@ -11,6 +11,8 @@
|
||||
#[license = "MPL"];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(globs, macro_rules)];
|
||||
|
||||
extern mod alert;
|
||||
extern mod azure;
|
||||
extern mod geom;
|
||||
@ -55,7 +57,6 @@ pub use servo_util::url::make_url;
|
||||
use std::comm;
|
||||
#[cfg(not(test))]
|
||||
use std::os;
|
||||
use std::rt::rtio::RtioTimer;
|
||||
use std::task::spawn_with;
|
||||
|
||||
#[path="compositing/mod.rs"]
|
||||
@ -103,7 +104,7 @@ pub mod util;
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[start]
|
||||
fn start(argc: int, argv: **u8, crate_map: *u8) -> int {
|
||||
fn start(argc: int, argv: **u8) -> int {
|
||||
#[cfg(target_os="linux")]
|
||||
#[cfg(target_os="macos")]
|
||||
fn getopts() -> Opts {
|
||||
@ -120,7 +121,7 @@ fn start(argc: int, argv: **u8, crate_map: *u8) -> int {
|
||||
}
|
||||
opts::from_cmdline_args(args)
|
||||
}
|
||||
do std::rt::start_on_main_thread(argc, argv, crate_map) {
|
||||
do std::rt::start_on_main_thread(argc, argv) {
|
||||
run(getopts())
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ pub enum Msg {
|
||||
|
||||
/// Represents the two different ways to which a page can be navigated
|
||||
#[deriving(Clone, Eq, IterBytes)]
|
||||
enum NavigationType {
|
||||
pub enum NavigationType {
|
||||
Load, // entered or clicked on a url
|
||||
Navigate, // browser forward/back buttons
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ pub fn factory() -> LoaderTask {
|
||||
assert!("file" == url.scheme);
|
||||
let progress_chan = start_sending(start_chan, Metadata::default(url.clone()));
|
||||
do task::spawn {
|
||||
match file_reader(&Path(url.path)) {
|
||||
match file_reader(&from_str(url.path).unwrap()) {
|
||||
Ok(reader) => {
|
||||
while !reader.eof() {
|
||||
let data = reader.read_bytes(READ_SIZE);
|
||||
|
@ -29,7 +29,7 @@ pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache {
|
||||
pub struct LocalImageCache {
|
||||
priv image_cache_task: ImageCacheTask,
|
||||
priv round_number: uint,
|
||||
priv on_image_available: Option<@fn() -> ~fn(ImageResponseMsg)>,
|
||||
priv on_image_available: Option<~fn() -> ~fn(ImageResponseMsg)>,
|
||||
priv state_map: UrlMap<@mut ImageState>
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ struct ImageState {
|
||||
impl LocalImageCache {
|
||||
/// The local cache will only do a single remote request for a given
|
||||
/// URL in each 'round'. Layout should call this each time it begins
|
||||
pub fn next_round(&mut self, on_image_available: @fn() -> ~fn(ImageResponseMsg)) {
|
||||
pub fn next_round(&mut self, on_image_available: ~fn() -> ~fn(ImageResponseMsg)) {
|
||||
self.round_number += 1;
|
||||
self.on_image_available = Some(on_image_available);
|
||||
}
|
||||
@ -109,7 +109,7 @@ impl LocalImageCache {
|
||||
// on the image to load and triggering layout
|
||||
let image_cache_task = self.image_cache_task.clone();
|
||||
assert!(self.on_image_available.is_some());
|
||||
let on_image_available = self.on_image_available.unwrap()();
|
||||
let on_image_available = (*self.on_image_available.get_ref())();
|
||||
let url = (*url).clone();
|
||||
do task::spawn {
|
||||
let (response_port, response_chan) = comm::stream();
|
||||
|
@ -8,6 +8,8 @@
|
||||
url = "http://servo.org/")];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(globs)];
|
||||
|
||||
extern mod geom;
|
||||
extern mod http;
|
||||
extern mod servo_util (name = "util");
|
||||
|
@ -16,7 +16,7 @@ use std::cast;
|
||||
use std::libc;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
use std::sys::size_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
type c_bool = libc::c_int;
|
||||
|
||||
|
@ -39,7 +39,7 @@ use js;
|
||||
static TOSTRING_CLASS_RESERVED_SLOT: libc::size_t = 0;
|
||||
static TOSTRING_NAME_RESERVED_SLOT: libc::size_t = 1;
|
||||
|
||||
struct GlobalStaticData {
|
||||
pub struct GlobalStaticData {
|
||||
proxy_handlers: HashMap<uint, *libc::c_void>,
|
||||
attribute_ids: HashMap<uint, ~[jsid]>,
|
||||
method_ids: HashMap<uint, ~[jsid]>,
|
||||
@ -165,7 +165,7 @@ pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
|
||||
|
||||
pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<T, ()> {
|
||||
unsafe {
|
||||
do get_dom_class(obj).chain |dom_class| {
|
||||
do get_dom_class(obj).and_then |dom_class| {
|
||||
if dom_class.interface_chain[proto_depth] == proto_id {
|
||||
debug!("good prototype");
|
||||
Ok(unwrap(obj))
|
||||
@ -671,7 +671,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
|
||||
for &elem in attrs.iter() {
|
||||
let (attr, attr_id) = elem;
|
||||
if attr_id == JSID_VOID || attr_id != id {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
|
||||
(*desc).attrs = (attr.flags & !(JSPROP_NATIVE_ACCESSORS as u8)) as u32;
|
||||
@ -783,7 +783,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
|
||||
}
|
||||
for (i, value) in values.iter().enumerate() {
|
||||
if value.length != length as uint {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
let mut equal = true;
|
||||
for j in range(0, length as int) {
|
||||
|
@ -254,7 +254,10 @@ impl Document {
|
||||
let key: &~str = &null_str_as_empty(id);
|
||||
// TODO: "in tree order, within the context object's tree"
|
||||
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
|
||||
self.idmap.find_equiv(key).map(|node| **node)
|
||||
match self.idmap.find_equiv(key) {
|
||||
None => None,
|
||||
Some(node) => Some(*node),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
|
||||
@ -321,7 +324,7 @@ impl Document {
|
||||
Some(root) => {
|
||||
for node in root.traverse_preorder() {
|
||||
if node.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
for child in node.children() {
|
||||
if child.is_text() {
|
||||
@ -355,12 +358,12 @@ impl Document {
|
||||
Some(root) => {
|
||||
for node in root.traverse_preorder() {
|
||||
if node.type_id() != ElementNodeTypeId(HTMLHeadElementTypeId) {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
let mut has_title = false;
|
||||
for child in node.children() {
|
||||
if child.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
has_title = true;
|
||||
for title_child in child.children() {
|
||||
@ -526,7 +529,7 @@ fn foreach_ided_elements(root: &AbstractNode<ScriptView>,
|
||||
callback: &fn(&~str, &AbstractNode<ScriptView>)) {
|
||||
for node in root.traverse_preorder() {
|
||||
if !node.is_element() {
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
|
||||
do node.with_imm_element |element| {
|
||||
|
@ -133,7 +133,7 @@ impl ElementLike for Element {
|
||||
fn get_attr<'a>(&'a self, name: &str) -> Option<&'a str> {
|
||||
// FIXME: only case-insensitive in the HTML namespace (as opposed to SVG, etc.)
|
||||
let name = name.to_ascii_lower();
|
||||
let value: Option<&str> = self.attrs.find_equiv(&name).map(|&value| {
|
||||
let value: Option<&str> = self.attrs.find_equiv(&name).map(|value| {
|
||||
let value: &str = *value;
|
||||
value
|
||||
});
|
||||
@ -296,10 +296,10 @@ impl Element {
|
||||
let scope = win.reflector().get_jsobject();
|
||||
let rects = do rects.map |r| {
|
||||
ClientRect::new(
|
||||
r.origin.y.to_f32(),
|
||||
(r.origin.y + r.size.height).to_f32(),
|
||||
r.origin.x.to_f32(),
|
||||
(r.origin.x + r.size.width).to_f32(),
|
||||
r.origin.y.to_f32().unwrap(),
|
||||
(r.origin.y + r.size.height).to_f32().unwrap(),
|
||||
r.origin.x.to_f32().unwrap(),
|
||||
(r.origin.x + r.size.width).to_f32().unwrap(),
|
||||
cx,
|
||||
scope)
|
||||
};
|
||||
@ -320,10 +320,10 @@ impl Element {
|
||||
let cx = win.get_cx();
|
||||
let scope = win.reflector().get_jsobject();
|
||||
ClientRect::new(
|
||||
rect.origin.y.to_f32(),
|
||||
(rect.origin.y + rect.size.height).to_f32(),
|
||||
rect.origin.x.to_f32(),
|
||||
(rect.origin.x + rect.size.width).to_f32(),
|
||||
rect.origin.y.to_f32().unwrap(),
|
||||
(rect.origin.y + rect.size.height).to_f32().unwrap(),
|
||||
rect.origin.x.to_f32().unwrap(),
|
||||
(rect.origin.x + rect.size.width).to_f32().unwrap(),
|
||||
cx,
|
||||
scope)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl FormData {
|
||||
pub fn Append(&mut self, name: &DOMString, value: @mut Blob, filename: Option<DOMString>) {
|
||||
let blob = BlobData {
|
||||
blob: value,
|
||||
name: filename.unwrap_or_default(Some(~"default"))
|
||||
name: filename.unwrap_or(Some(~"default"))
|
||||
};
|
||||
self.data.insert(null_str_as_empty(name), blob);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ struct IFrameSize {
|
||||
impl IFrameSize {
|
||||
pub fn set_rect(&mut self, rect: Rect<f32>) {
|
||||
let future_chan = replace(&mut self.future_chan, None);
|
||||
do future_chan.map_move |future_chan| {
|
||||
do future_chan.map |future_chan| {
|
||||
let Size2D { width, height } = rect.size;
|
||||
future_chan.send(Size2D(width as uint, height as uint));
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ impl HTMLImageElement {
|
||||
if "src" == name {
|
||||
let document = self.htmlelement.element.node.owner_doc();
|
||||
let window = document.document().window;
|
||||
let url = window.page.url.map(|&(ref url, _)| url.clone());
|
||||
let url = window.page.url.as_ref().map(|&(ref url, _)| url.clone());
|
||||
self.update_image(window.image_cache_task.clone(), url);
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +455,9 @@ impl<'self, View> AbstractNode<View> {
|
||||
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
|
||||
fn next(&mut self) -> Option<AbstractNode<View>> {
|
||||
let node = self.current_node;
|
||||
self.current_node = self.current_node.chain(|node| node.next_sibling());
|
||||
self.current_node = do self.current_node.and_then |node| {
|
||||
node.next_sibling()
|
||||
};
|
||||
node
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ use std::io;
|
||||
use std::ptr;
|
||||
use std::int;
|
||||
use std::libc;
|
||||
use std::rt::rtio::RtioTimer;
|
||||
use std::rt::io::timer::Timer;
|
||||
use std::task::spawn_with;
|
||||
use js::jsapi::JSVal;
|
||||
@ -58,7 +57,7 @@ impl Window {
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for Window {
|
||||
fn drop(&self) {
|
||||
fn drop(&mut self) {
|
||||
self.timer_chan.send(TimerMessage_Close);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use std::comm::Port;
|
||||
use std::task;
|
||||
use newcss::stylesheet::Stylesheet;
|
||||
use newcss::util::DataStream;
|
||||
use servo_net::resource_task::{Load, LoadResponse, Payload, Done, ResourceTask};
|
||||
use servo_net::resource_task::{Load, LoadResponse, Payload, Done, ResourceTask, ProgressMsg};
|
||||
use extra::url::Url;
|
||||
|
||||
/// Where a style sheet comes from.
|
||||
@ -41,7 +41,7 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
|
||||
return result_port;
|
||||
}
|
||||
|
||||
fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream {
|
||||
fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> @mut DataStream {
|
||||
match provenance {
|
||||
UrlProvenance(url) => {
|
||||
debug!("cssparse: loading style sheet at %s", url.to_str());
|
||||
@ -55,26 +55,44 @@ fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) ->
|
||||
}
|
||||
}
|
||||
|
||||
fn resource_port_to_data_stream(input_port: Port<LoadResponse>) -> DataStream {
|
||||
fn resource_port_to_data_stream(input_port: Port<LoadResponse>) -> @mut DataStream {
|
||||
let progress_port = input_port.recv().progress_port;
|
||||
return || {
|
||||
match progress_port.recv() {
|
||||
Payload(data) => Some(data),
|
||||
Done(*) => None
|
||||
struct ResourcePortDataStream {
|
||||
progress_port: Port<ProgressMsg>,
|
||||
};
|
||||
impl DataStream for ResourcePortDataStream {
|
||||
fn read(&mut self) -> Option<~[u8]> {
|
||||
match self.progress_port.recv() {
|
||||
Payload(data) => Some(data),
|
||||
Done(*) => None
|
||||
}
|
||||
}
|
||||
}
|
||||
let stream = @mut ResourcePortDataStream {
|
||||
progress_port: progress_port,
|
||||
};
|
||||
stream as @mut DataStream
|
||||
}
|
||||
|
||||
fn data_to_data_stream(data: ~str) -> DataStream {
|
||||
fn data_to_data_stream(data: ~str) -> @mut DataStream {
|
||||
let data_cell = Cell::new(data);
|
||||
return || {
|
||||
if data_cell.is_empty() {
|
||||
None
|
||||
} else {
|
||||
// FIXME: Blech, a copy.
|
||||
let data = data_cell.take();
|
||||
Some(data.as_bytes().to_owned())
|
||||
struct DataDataStream {
|
||||
data_cell: Cell<~str>,
|
||||
};
|
||||
impl DataStream for DataDataStream {
|
||||
fn read(&mut self) -> Option<~[u8]> {
|
||||
if self.data_cell.is_empty() {
|
||||
None
|
||||
} else {
|
||||
// FIXME: Blech, a copy.
|
||||
let data = self.data_cell.take();
|
||||
Some(data.as_bytes().to_owned())
|
||||
}
|
||||
}
|
||||
}
|
||||
let stream = @mut DataDataStream {
|
||||
data_cell: data_cell,
|
||||
};
|
||||
stream as @mut DataStream
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_res
|
||||
use servo_util::tree::{TreeNodeRef, ElementLike};
|
||||
use servo_util::url::make_url;
|
||||
use extra::url::Url;
|
||||
use extra::future::{Future, from_port};
|
||||
use extra::future::Future;
|
||||
use geom::size::Size2D;
|
||||
|
||||
macro_rules! handle_element(
|
||||
@ -431,7 +431,7 @@ pub fn parse_html(cx: *JSContext,
|
||||
|
||||
// Size future
|
||||
let (port, chan) = comm::oneshot();
|
||||
let size_future = from_port(port);
|
||||
let size_future = Future::from_port(port);
|
||||
|
||||
// Subpage Id
|
||||
let subpage_id = next_subpage_id.take();
|
||||
|
@ -11,6 +11,8 @@
|
||||
#[license = "MPL"];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(globs, macro_rules, struct_variant)];
|
||||
|
||||
extern mod geom;
|
||||
extern mod gfx (name = "gfx");
|
||||
extern mod hubbub;
|
||||
|
@ -48,7 +48,7 @@ use servo_net::resource_task::ResourceTask;
|
||||
use servo_util::tree::{TreeNodeRef, ElementLike};
|
||||
use servo_util::url::make_url;
|
||||
use extra::url::Url;
|
||||
use extra::future::{from_value, Future};
|
||||
use extra::future::Future;
|
||||
|
||||
/// Messages used to control the script task.
|
||||
pub enum ScriptMsg {
|
||||
@ -178,7 +178,7 @@ impl PageTree {
|
||||
self.inner.mut_iter()
|
||||
.enumerate()
|
||||
.find(|&(_idx, ref page_tree)| page_tree.page.id == id)
|
||||
.map(|&(idx, _)| idx)
|
||||
.map(|(idx, _)| idx)
|
||||
};
|
||||
match remove_idx {
|
||||
Some(idx) => return Some(self.inner.remove(idx)),
|
||||
@ -608,7 +608,7 @@ impl ScriptTask {
|
||||
fn handle_resize_inactive_msg(&mut self, id: PipelineId, new_size: Size2D<uint>) {
|
||||
let page = self.page_tree.find(id).expect("Received resize message for PipelineId not associated
|
||||
with a page in the page tree. This is a bug.").page;
|
||||
page.window_size = from_value(new_size);
|
||||
page.window_size = Future::from_value(new_size);
|
||||
let last_loaded_url = replace(&mut page.url, None);
|
||||
for url in last_loaded_url.iter() {
|
||||
page.url = Some((url.first(), true));
|
||||
@ -780,7 +780,7 @@ impl ScriptTask {
|
||||
ResizeEvent(new_width, new_height) => {
|
||||
debug!("script got resize event: %u, %u", new_width, new_height);
|
||||
|
||||
page.window_size = from_value(Size2D(new_width, new_height));
|
||||
page.window_size = Future::from_value(Size2D(new_width, new_height));
|
||||
|
||||
if page.frame.is_some() {
|
||||
page.damage(ReflowDocumentDamage);
|
||||
@ -845,12 +845,12 @@ impl ScriptTask {
|
||||
let attr = element.get_attr("href");
|
||||
for href in attr.iter() {
|
||||
debug!("ScriptTask: clicked on link to %s", *href);
|
||||
let current_url = do page.url.map |&(ref url, _)| {
|
||||
let current_url = do page.url.as_ref().map |&(ref url, _)| {
|
||||
url.clone()
|
||||
};
|
||||
debug!("ScriptTask: current url is %?", current_url);
|
||||
let url = make_url(href.to_owned(), current_url);
|
||||
self.constellation_chan.send(LoadUrlMsg(page.id, url, from_value(page.window_size.get())));
|
||||
self.constellation_chan.send(LoadUrlMsg(page.id, url, Future::from_value(page.window_size.get())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ pub mod specified {
|
||||
-> Option<LengthOrPercentage> {
|
||||
match input {
|
||||
&Dimension(ref value, ref unit) if negative_ok || value.value >= 0.
|
||||
=> Length::parse_dimension(value.value, unit.as_slice()).map_move(LP_Length),
|
||||
=> Length::parse_dimension(value.value, unit.as_slice()).map(LP_Length),
|
||||
&ast::Percentage(ref value) if negative_ok || value.value >= 0.
|
||||
=> Some(LP_Percentage(value.value / 100.)),
|
||||
&Number(ref value) if value.value == 0. => Some(LP_Length(Au_(Au(0)))),
|
||||
@ -105,7 +105,7 @@ pub mod specified {
|
||||
-> Option<LengthOrPercentageOrAuto> {
|
||||
match input {
|
||||
&Dimension(ref value, ref unit) if negative_ok || value.value >= 0.
|
||||
=> Length::parse_dimension(value.value, unit.as_slice()).map_move(LPA_Length),
|
||||
=> Length::parse_dimension(value.value, unit.as_slice()).map(LPA_Length),
|
||||
&ast::Percentage(ref value) if negative_ok || value.value >= 0.
|
||||
=> Some(LPA_Percentage(value.value / 100.)),
|
||||
&Number(ref value) if value.value == 0. => Some(LPA_Length(Au_(Au(0)))),
|
||||
|
@ -91,11 +91,15 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
|
||||
};
|
||||
match iter.next() {
|
||||
None => {
|
||||
mq.map_move(|mq| queries.push(mq));
|
||||
for mq in mq.move_iter() {
|
||||
queries.push(mq);
|
||||
}
|
||||
return MediaQueryList{ media_queries: queries }
|
||||
},
|
||||
Some(&Comma) => {
|
||||
mq.map_move(|mq| queries.push(mq));
|
||||
for mq in mq.move_iter() {
|
||||
queries.push(mq);
|
||||
}
|
||||
},
|
||||
// Ingnore this comma-separated part
|
||||
_ => loop {
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This file is a Mako template: http://www.makotemplates.org/
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
pub use std::iterator;
|
||||
pub use std::iter;
|
||||
pub use cssparser::*;
|
||||
pub use errors::{ErrorLoggerIterator, log_css_error};
|
||||
pub use parsing_utils::*;
|
||||
@ -86,7 +86,7 @@ pub mod longhands {
|
||||
${caller.body()}
|
||||
pub fn parse_specified(input: &[ComponentValue])
|
||||
-> Option<DeclaredValue<SpecifiedValue>> {
|
||||
parse(input).map_move(super::SpecifiedValue)
|
||||
parse(input).map(super::SpecifiedValue)
|
||||
}
|
||||
</%self:raw_longhand>
|
||||
</%def>
|
||||
@ -95,7 +95,7 @@ pub mod longhands {
|
||||
<%self:longhand name="${name}" inherited="${inherited}">
|
||||
${caller.body()}
|
||||
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
|
||||
one_component_value(input).chain(from_component_value)
|
||||
one_component_value(input).and_then(from_component_value)
|
||||
}
|
||||
</%self:longhand>
|
||||
</%def>
|
||||
@ -117,7 +117,7 @@ pub mod longhands {
|
||||
${to_rust_ident(values.split()[0])}
|
||||
}
|
||||
pub fn from_component_value(v: &ComponentValue) -> Option<SpecifiedValue> {
|
||||
do get_ident_lower(v).chain |keyword| {
|
||||
do get_ident_lower(v).and_then |keyword| {
|
||||
match keyword.as_slice() {
|
||||
% for value in values.split():
|
||||
"${value}" => Some(${to_rust_ident(value)}),
|
||||
@ -201,7 +201,7 @@ pub mod longhands {
|
||||
Au::from_px(3) // medium
|
||||
}
|
||||
pub fn parse(input: &[ComponentValue]) -> Option<SpecifiedValue> {
|
||||
one_component_value(input).chain(parse_border_width)
|
||||
one_component_value(input).and_then(parse_border_width)
|
||||
}
|
||||
pub fn to_computed_value(value: SpecifiedValue, context: &computed::Context)
|
||||
-> computed_value::T {
|
||||
@ -252,7 +252,7 @@ pub mod longhands {
|
||||
=> Some(SpecifiedLength(specified::Em(value.value / 100.))),
|
||||
&Dimension(ref value, ref unit) if value.value >= 0.
|
||||
=> specified::Length::parse_dimension(value.value, unit.as_slice())
|
||||
.map_move(SpecifiedLength),
|
||||
.map(SpecifiedLength),
|
||||
&Ident(ref value) if value.eq_ignore_ascii_case("normal")
|
||||
=> Some(SpecifiedNormal),
|
||||
_ => None,
|
||||
@ -299,7 +299,7 @@ pub mod longhands {
|
||||
_ => None,
|
||||
},
|
||||
_ => specified::LengthOrPercentage::parse_non_negative(input)
|
||||
.map_move(SpecifiedLengthOrPercentage)
|
||||
.map(SpecifiedLengthOrPercentage)
|
||||
}
|
||||
}
|
||||
pub mod computed_value {
|
||||
@ -356,7 +356,7 @@ pub mod longhands {
|
||||
RGBA { red: 0., green: 0., blue: 0., alpha: 1. } /* black */
|
||||
}
|
||||
pub fn parse_specified(input: &[ComponentValue]) -> Option<DeclaredValue<SpecifiedValue>> {
|
||||
match one_component_value(input).chain(Color::parse) {
|
||||
match one_component_value(input).and_then(Color::parse) {
|
||||
Some(RGBA(rgba)) => Some(SpecifiedValue(rgba)),
|
||||
Some(CurrentColor) => Some(CSSWideKeyword(Inherit)),
|
||||
None => None,
|
||||
@ -535,7 +535,7 @@ pub mod longhands {
|
||||
/// <length> | <percentage>
|
||||
/// TODO: support <absolute-size> and <relative-size>
|
||||
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
|
||||
do specified::LengthOrPercentage::parse_non_negative(input).map_move |value| {
|
||||
do specified::LengthOrPercentage::parse_non_negative(input).map |value| {
|
||||
match value {
|
||||
specified::LP_Length(value) => value,
|
||||
specified::LP_Percentage(value) => specified::Em(value),
|
||||
@ -633,10 +633,10 @@ pub mod shorthands {
|
||||
// two values set (top, bottom) and (left, right)
|
||||
// three values set top, (left, right) and bottom
|
||||
// four values set them in order
|
||||
let top = iter.next().unwrap_or_default(None);
|
||||
let right = iter.next().unwrap_or_default(top);
|
||||
let bottom = iter.next().unwrap_or_default(top);
|
||||
let left = iter.next().unwrap_or_default(right);
|
||||
let top = iter.next().unwrap_or(None);
|
||||
let right = iter.next().unwrap_or(top);
|
||||
let bottom = iter.next().unwrap_or(top);
|
||||
let left = iter.next().unwrap_or(right);
|
||||
if top.is_some() && right.is_some() && bottom.is_some() && left.is_some()
|
||||
&& iter.next().is_none() {
|
||||
Some(Longhands {
|
||||
@ -653,7 +653,7 @@ pub mod shorthands {
|
||||
|
||||
// TODO: other background-* properties
|
||||
<%self:shorthand name="background" sub_properties="background-color">
|
||||
do one_component_value(input).chain(specified::CSSColor::parse).map_move |color| {
|
||||
do one_component_value(input).and_then(specified::CSSColor::parse).map |color| {
|
||||
Longhands { background_color: Some(color) }
|
||||
}
|
||||
</%self:shorthand>
|
||||
@ -677,19 +677,19 @@ pub mod shorthands {
|
||||
for component_value in input.skip_whitespace() {
|
||||
if color.is_none() {
|
||||
match specified::CSSColor::parse(component_value) {
|
||||
Some(c) => { color = Some(c); any = true; loop },
|
||||
Some(c) => { color = Some(c); any = true; continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
if style.is_none() {
|
||||
match border_top_style::from_component_value(component_value) {
|
||||
Some(s) => { style = Some(s); any = true; loop },
|
||||
Some(s) => { style = Some(s); any = true; continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
if width.is_none() {
|
||||
match parse_border_width(component_value) {
|
||||
Some(w) => { width = Some(w); any = true; loop },
|
||||
Some(w) => { width = Some(w); any = true; continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
@ -704,7 +704,7 @@ pub mod shorthands {
|
||||
'border-%s-%s' % (side, prop)
|
||||
for prop in ['color', 'style', 'width']
|
||||
)}">
|
||||
do parse_border(input).map_move |(color, style, width)| {
|
||||
do parse_border(input).map |(color, style, width)| {
|
||||
Longhands {
|
||||
% for prop in ["color", "style", "width"]:
|
||||
${"border_%s_%s: %s," % (side, prop, prop)}
|
||||
@ -719,7 +719,7 @@ pub mod shorthands {
|
||||
for side in ['top', 'right', 'bottom', 'left']
|
||||
for prop in ['color', 'style', 'width']
|
||||
)}">
|
||||
do parse_border(input).map_move |(color, style, width)| {
|
||||
do parse_border(input).map |(color, style, width)| {
|
||||
Longhands {
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
% for prop in ["color", "style", "width"]:
|
||||
@ -746,23 +746,23 @@ pub mod shorthands {
|
||||
if get_ident_lower(component_value).filtered(
|
||||
|v| v.eq_ignore_ascii_case("normal")).is_some() {
|
||||
nb_normals += 1;
|
||||
loop;
|
||||
continue;
|
||||
}
|
||||
if style.is_none() {
|
||||
match font_style::from_component_value(component_value) {
|
||||
Some(s) => { style = Some(s); loop },
|
||||
Some(s) => { style = Some(s); continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
if weight.is_none() {
|
||||
match font_weight::from_component_value(component_value) {
|
||||
Some(w) => { weight = Some(w); loop },
|
||||
Some(w) => { weight = Some(w); continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
if variant.is_none() {
|
||||
match font_variant::from_component_value(component_value) {
|
||||
Some(v) => { variant = Some(v); loop },
|
||||
Some(v) => { variant = Some(v); continue },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
@ -852,7 +852,7 @@ struct Unset;
|
||||
|
||||
impl CSSWideKeyword {
|
||||
pub fn parse(input: &[ComponentValue]) -> Option<Either<CSSWideKeyword, Unset>> {
|
||||
do one_component_value(input).chain(get_ident_lower).chain |keyword| {
|
||||
do one_component_value(input).and_then(get_ident_lower).and_then |keyword| {
|
||||
match keyword.as_slice() {
|
||||
"initial" => Some(Left(Initial)),
|
||||
"inherit" => Some(Left(Inherit)),
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::{vec, iterator};
|
||||
use std::{vec, iter};
|
||||
use std::ascii::StrAsciiExt;
|
||||
use cssparser::*;
|
||||
use namespaces::NamespaceMap;
|
||||
@ -73,7 +73,7 @@ pub struct AttrSelector {
|
||||
}
|
||||
|
||||
|
||||
type Iter = iterator::Peekable<ComponentValue, vec::MoveIterator<ComponentValue>>;
|
||||
type Iter = iter::Peekable<ComponentValue, vec::MoveIterator<ComponentValue>>;
|
||||
|
||||
|
||||
// None means invalid selector
|
||||
@ -310,7 +310,7 @@ fn parse_qualified_name(iter: &mut Iter, allow_universal: bool, namespaces: &Nam
|
||||
#[inline]
|
||||
fn default_namespace(namespaces: &NamespaceMap, local_name: Option<~str>)
|
||||
-> Option<Option<(Option<~str>, Option<~str>)>> {
|
||||
Some(Some((namespaces.default.map(|url| url.to_owned()), local_name)))
|
||||
Some(Some((namespaces.default.as_ref().map(|url| url.to_owned()), local_name)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -11,6 +11,7 @@
|
||||
#[license = "MPL"];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(globs, macro_rules)];
|
||||
|
||||
extern mod extra;
|
||||
extern mod cssparser;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::str;
|
||||
use std::iterator::Iterator;
|
||||
use std::iter::Iterator;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use cssparser::*;
|
||||
use selectors;
|
||||
|
@ -5,7 +5,7 @@
|
||||
use std::io;
|
||||
use std::vec::raw::buf_as_slice;
|
||||
use std::cast::transmute;
|
||||
use std::sys::size_of;
|
||||
use std::mem::size_of;
|
||||
|
||||
fn hexdump_slice(buf: &[u8]) {
|
||||
let stderr = io::stderr();
|
||||
|
@ -57,23 +57,19 @@ pub fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }
|
||||
pub fn max(x: Au, y: Au) -> Au { if x > y { x } else { y } }
|
||||
|
||||
impl NumCast for Au {
|
||||
fn from<T:NumCast>(n: T) -> Au { Au(n.to_i32()) }
|
||||
fn from<T:ToPrimitive>(n: T) -> Option<Au> {
|
||||
Some(Au(n.to_i32().unwrap()))
|
||||
}
|
||||
}
|
||||
|
||||
fn to_u8(&self) -> u8 { (**self).to_u8() }
|
||||
fn to_u16(&self) -> u16 { (**self).to_u16() }
|
||||
fn to_u32(&self) -> u32 { (**self).to_u32() }
|
||||
fn to_u64(&self) -> u64 { (**self).to_u64() }
|
||||
fn to_uint(&self) -> uint { (**self).to_uint() }
|
||||
impl ToPrimitive for Au {
|
||||
fn to_i64(&self) -> Option<i64> {
|
||||
Some(**self as i64)
|
||||
}
|
||||
|
||||
fn to_i8(&self) -> i8 { (**self).to_i8() }
|
||||
fn to_i16(&self) -> i16 { (**self).to_i16() }
|
||||
fn to_i32(&self) -> i32 { (**self).to_i32() }
|
||||
fn to_i64(&self) -> i64 { (**self).to_i64() }
|
||||
fn to_int(&self) -> int { (**self).to_int() }
|
||||
|
||||
fn to_f32(&self) -> f32 { (**self).to_f32() }
|
||||
fn to_f64(&self) -> f64 { (**self).to_f64() }
|
||||
fn to_float(&self) -> float { (**self).to_float() }
|
||||
fn to_u64(&self) -> Option<u64> {
|
||||
Some(**self as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn box<T:Clone + Ord + Add<T,T> + Sub<T,T>>(x: T, y: T, w: T, h: T) -> Rect<T> {
|
||||
@ -81,16 +77,16 @@ pub fn box<T:Clone + Ord + Add<T,T> + Sub<T,T>>(x: T, y: T, w: T, h: T) -> Rect<
|
||||
}
|
||||
|
||||
impl Au {
|
||||
pub fn scale_by(self, factor: float) -> Au {
|
||||
Au(((*self as float) * factor).round() as i32)
|
||||
pub fn scale_by(self, factor: f64) -> Au {
|
||||
Au(((*self as f64) * factor).round() as i32)
|
||||
}
|
||||
|
||||
pub fn from_px(px: int) -> Au {
|
||||
NumCast::from(px * 60)
|
||||
NumCast::from(px * 60).unwrap()
|
||||
}
|
||||
|
||||
pub fn to_nearest_px(&self) -> int {
|
||||
((**self as float) / 60f).round() as int
|
||||
((**self as f64) / 60f64).round() as int
|
||||
}
|
||||
|
||||
pub fn to_snapped(&self) -> Au {
|
||||
@ -108,12 +104,12 @@ impl Au {
|
||||
Rect(Point2D(z, z), Size2D(z, z))
|
||||
}
|
||||
|
||||
pub fn from_pt(pt: float) -> Au {
|
||||
pub fn from_pt(pt: f64) -> Au {
|
||||
from_px(pt_to_px(pt) as int)
|
||||
}
|
||||
|
||||
pub fn from_frac_px(px: float) -> Au {
|
||||
Au((px * 60f) as i32)
|
||||
pub fn from_frac_px(px: f64) -> Au {
|
||||
Au((px * 60f64) as i32)
|
||||
}
|
||||
|
||||
pub fn min(x: Au, y: Au) -> Au { if *x < *y { x } else { y } }
|
||||
@ -121,13 +117,13 @@ impl Au {
|
||||
}
|
||||
|
||||
// assumes 72 points per inch, and 96 px per inch
|
||||
pub fn pt_to_px(pt: float) -> float {
|
||||
pt / 72f * 96f
|
||||
pub fn pt_to_px(pt: f64) -> f64 {
|
||||
pt / 72f64 * 96f64
|
||||
}
|
||||
|
||||
// assumes 72 points per inch, and 96 px per inch
|
||||
pub fn px_to_pt(px: float) -> float {
|
||||
px / 96f * 72f
|
||||
pub fn px_to_pt(px: f64) -> f64 {
|
||||
px / 96f64 * 72f64
|
||||
}
|
||||
|
||||
pub fn zero_rect() -> Rect<Au> {
|
||||
@ -143,23 +139,23 @@ pub fn zero_size() -> Size2D<Au> {
|
||||
Size2D(Au(0), Au(0))
|
||||
}
|
||||
|
||||
pub fn from_frac_px(px: float) -> Au {
|
||||
Au((px * 60f) as i32)
|
||||
pub fn from_frac_px(px: f64) -> Au {
|
||||
Au((px * 60f64) as i32)
|
||||
}
|
||||
|
||||
pub fn from_px(px: int) -> Au {
|
||||
NumCast::from(px * 60)
|
||||
NumCast::from(px * 60).unwrap()
|
||||
}
|
||||
|
||||
pub fn to_px(au: Au) -> int {
|
||||
(*au / 60) as int
|
||||
}
|
||||
|
||||
pub fn to_frac_px(au: Au) -> float {
|
||||
(*au as float) / 60f
|
||||
pub fn to_frac_px(au: Au) -> f64 {
|
||||
(*au as f64) / 60f64
|
||||
}
|
||||
|
||||
// assumes 72 points per inch, and 96 px per inch
|
||||
pub fn from_pt(pt: float) -> Au {
|
||||
from_px((pt / 72f * 96f) as int)
|
||||
pub fn from_pt(pt: f64) -> Au {
|
||||
from_px((pt / 72f64 * 96f64) as int)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cmp::{max, min};
|
||||
use std::iterator;
|
||||
use std::iter;
|
||||
|
||||
enum RangeRelation {
|
||||
OverlapsBegin(/* overlap */ uint),
|
||||
@ -36,7 +36,7 @@ impl Range {
|
||||
pub fn length(&self) -> uint { self.len }
|
||||
pub fn end(&self) -> uint { self.off + self.len }
|
||||
|
||||
pub fn eachi(&self) -> iterator::Range<uint> {
|
||||
pub fn eachi(&self) -> iter::Range<uint> {
|
||||
range(self.off, self.off + self.len)
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Timing functions.
|
||||
use std::comm::{Port, SharedChan};
|
||||
use std::iterator::AdditiveIterator;
|
||||
use std::iter::AdditiveIterator;
|
||||
use std::rt::io::timer::Timer;
|
||||
use std::task::spawn_with;
|
||||
|
||||
@ -23,7 +23,7 @@ impl ProfilerChan {
|
||||
|
||||
pub enum ProfilerMsg {
|
||||
// Normal message used for reporting time
|
||||
TimeMsg(ProfilerCategory, float),
|
||||
TimeMsg(ProfilerCategory, f64),
|
||||
// Message used to force print the profiling metrics
|
||||
PrintMsg,
|
||||
}
|
||||
@ -85,7 +85,7 @@ impl ProfilerCategory {
|
||||
}
|
||||
}
|
||||
|
||||
type ProfilerBuckets = TreeMap<ProfilerCategory, ~[float]>;
|
||||
type ProfilerBuckets = TreeMap<ProfilerCategory, ~[f64]>;
|
||||
|
||||
// back end of the profiler that handles data aggregation and performance metrics
|
||||
pub struct Profiler {
|
||||
@ -95,10 +95,10 @@ pub struct Profiler {
|
||||
}
|
||||
|
||||
impl Profiler {
|
||||
pub fn create(port: Port<ProfilerMsg>, chan: ProfilerChan, period: Option<float>) {
|
||||
pub fn create(port: Port<ProfilerMsg>, chan: ProfilerChan, period: Option<f64>) {
|
||||
match period {
|
||||
Some(period) => {
|
||||
let period = (period * 1000f) as u64;
|
||||
let period = (period * 1000f64) as u64;
|
||||
do spawn {
|
||||
let mut timer = Timer::new().unwrap();
|
||||
loop {
|
||||
@ -164,7 +164,7 @@ impl Profiler {
|
||||
let data_len = data.len();
|
||||
if data_len > 0 {
|
||||
let (mean, median, &min, &max) =
|
||||
(data.iter().map(|&x|x).sum() / (data_len as float),
|
||||
(data.iter().map(|&x|x).sum() / (data_len as f64),
|
||||
data[data_len / 2],
|
||||
data.iter().min().unwrap(),
|
||||
data.iter().max().unwrap());
|
||||
@ -184,7 +184,7 @@ pub fn profile<T>(category: ProfilerCategory,
|
||||
let start_time = precise_time_ns();
|
||||
let val = callback();
|
||||
let end_time = precise_time_ns();
|
||||
let ms = ((end_time - start_time) as float / 1000000f);
|
||||
let ms = ((end_time - start_time) as f64 / 1000000f64);
|
||||
profiler_chan.send(TimeMsg(category, ms));
|
||||
return val;
|
||||
}
|
||||
@ -193,8 +193,8 @@ pub fn time<T>(msg: &str, callback: &fn() -> T) -> T{
|
||||
let start_time = precise_time_ns();
|
||||
let val = callback();
|
||||
let end_time = precise_time_ns();
|
||||
let ms = ((end_time - start_time) as float / 1000000f);
|
||||
if ms >= 5f {
|
||||
let ms = ((end_time - start_time) as f64 / 1000000f64);
|
||||
if ms >= 5f64 {
|
||||
debug!("%s took %? ms", msg, ms);
|
||||
}
|
||||
return val;
|
||||
|
@ -27,7 +27,10 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||
if str_url.starts_with("/") {
|
||||
~"file://" + str_url
|
||||
} else {
|
||||
~"file://" + os::getcwd().push(str_url).to_str()
|
||||
let mut path = os::getcwd();
|
||||
path.push(str_url);
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
~"file://" + path.display().to_str()
|
||||
}
|
||||
} else {
|
||||
let current_url = current_url.unwrap();
|
||||
@ -57,7 +60,12 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||
match scheme {
|
||||
~"about" => {
|
||||
match page {
|
||||
~"failure" => ~"file://" + os::getcwd().push("../src/test/html/failure.html").to_str(),
|
||||
~"failure" => {
|
||||
let mut path = os::getcwd();
|
||||
path.push("../src/test/html/failure.html");
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
~"file://" + path.display().to_str()
|
||||
}
|
||||
// TODO: handle the rest of the about: pages
|
||||
_ => str_url
|
||||
}
|
||||
@ -88,7 +96,9 @@ mod make_url_tests {
|
||||
let url = make_url(file, None);
|
||||
debug!("url: %?", url);
|
||||
assert!(url.scheme == ~"file");
|
||||
assert!(url.path.contains(os::getcwd().to_str()));
|
||||
let path = os::getcwd();
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
assert!(url.path.contains(path.display().to_str()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -8,6 +8,8 @@
|
||||
url = "http://servo.org/")];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
#[feature(macro_rules)];
|
||||
|
||||
extern mod extra;
|
||||
extern mod geom;
|
||||
|
||||
|
@ -11,7 +11,7 @@ pub trait BinarySearchMethods<'self, T: Ord + Eq> {
|
||||
|
||||
impl<'self, T: Ord + Eq> BinarySearchMethods<'self, T> for &'self [T] {
|
||||
fn binary_search(&self, key: &T) -> Option<&'self T> {
|
||||
self.binary_search_index(key).map(|i| &self[*i])
|
||||
self.binary_search_index(key).map(|i| &self[i])
|
||||
}
|
||||
|
||||
fn binary_search_index(&self, key: &T) -> Option<uint> {
|
||||
|
@ -11,7 +11,7 @@ extern mod std;
|
||||
extern mod extra;
|
||||
|
||||
use extra::test::{TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName};
|
||||
use extra::getopts::{getopts, reqopt, opt_str, fail_str};
|
||||
use extra::getopts::{getopts, reqopt};
|
||||
use std::{os, run, io, str};
|
||||
use std::cell::Cell;
|
||||
use std::os::list_dir_path;
|
||||
@ -35,11 +35,11 @@ fn parse_config(args: ~[~str]) -> Config {
|
||||
let opts = ~[reqopt("source-dir")];
|
||||
let matches = match getopts(args, opts) {
|
||||
Ok(m) => m,
|
||||
Err(f) => fail!(fail_str(f))
|
||||
Err(f) => fail!(f.to_err_msg())
|
||||
};
|
||||
|
||||
Config {
|
||||
source_dir: opt_str(&matches, "source-dir"),
|
||||
source_dir: matches.opt_str("source-dir").unwrap(),
|
||||
filter: if matches.free.is_empty() {
|
||||
None
|
||||
} else {
|
||||
@ -63,9 +63,10 @@ fn test_options(config: Config) -> TestOpts {
|
||||
}
|
||||
|
||||
fn find_tests(config: Config) -> ~[TestDescAndFn] {
|
||||
let mut files = list_dir_path(&Path(config.source_dir));
|
||||
files.retain( |file| file.to_str().ends_with(".html") );
|
||||
return files.map(|file| make_test((*file).to_str()) );
|
||||
let mut files = list_dir_path(&Path::new(config.source_dir));
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
files.retain( |file| file.display().to_str().ends_with(".html") );
|
||||
return files.map(|file| make_test(file.display().to_str()) );
|
||||
}
|
||||
|
||||
fn make_test(file: ~str) -> TestDescAndFn {
|
||||
@ -81,7 +82,9 @@ fn make_test(file: ~str) -> TestDescAndFn {
|
||||
}
|
||||
|
||||
fn run_test(file: ~str) {
|
||||
let infile = ~"file://" + os::make_absolute(&Path(file)).to_str();
|
||||
let path = os::make_absolute(&Path::new(file));
|
||||
// FIXME (#1094): not the right way to transform a path
|
||||
let infile = ~"file://" + path.display().to_str();
|
||||
let res = run::process_output("./servo", [infile]);
|
||||
let out = str::from_utf8(res.output);
|
||||
io::print(out);
|
||||
|
@ -37,6 +37,7 @@ fn main() {
|
||||
ratchet_noise_percent: None,
|
||||
ratchet_metrics: None,
|
||||
save_metrics: None,
|
||||
test_shard: None,
|
||||
};
|
||||
|
||||
if !run_tests_console(&test_opts, tests) {
|
||||
@ -59,7 +60,7 @@ struct Reftest {
|
||||
fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] {
|
||||
let mut tests: ~[TestDescAndFn] = ~[];
|
||||
for file in filenames.iter() {
|
||||
let file_path = Path(*file);
|
||||
let file_path = Path::new(file.clone());
|
||||
let contents = match io::read_whole_file_str(&file_path) {
|
||||
Ok(x) => x,
|
||||
Err(s) => fail!(s)
|
||||
@ -78,8 +79,8 @@ fn parse_lists(filenames: &[~str]) -> ~[TestDescAndFn] {
|
||||
_ => fail!(fmt!("reftest line: '%s' has invalid kind '%s'",
|
||||
line, parts[0]))
|
||||
};
|
||||
let src_dir = file_path.dirname();
|
||||
let file_left = src_dir + "/" + parts[1];
|
||||
let src_dir = file_path.dirname().to_str();
|
||||
let file_left = src_dir + "/" + parts[1];
|
||||
let file_right = src_dir + "/" + parts[2];
|
||||
|
||||
let reftest = Reftest {
|
||||
@ -114,17 +115,16 @@ fn check_reftest(reftest: Reftest) {
|
||||
let id = gen_id(&reftest);
|
||||
let left_filename = fmt!("/tmp/%s-left.png", id);
|
||||
let right_filename = fmt!("/tmp/%s-right.png", id);
|
||||
let left_path = Path(left_filename);
|
||||
let right_path = Path(right_filename);
|
||||
let left_path = Path::new(left_filename.clone());
|
||||
let right_path = Path::new(right_filename.clone());
|
||||
|
||||
let options = run::ProcessOptions::new();
|
||||
let args = ~[~"-o", left_filename.clone(), reftest.left.clone()];
|
||||
let mut process = run::Process::new("./servo", args, options);
|
||||
let mut process = run::Process::new("./servo", args, run::ProcessOptions::new());
|
||||
let _retval = process.finish();
|
||||
// assert!(retval == 0);
|
||||
|
||||
let args = ~[~"-o", right_filename.clone(), reftest.right.clone()];
|
||||
let mut process = run::Process::new("./servo", args, options);
|
||||
let mut process = run::Process::new("./servo", args, run::ProcessOptions::new());
|
||||
let _retval = process.finish();
|
||||
// assert!(retval == 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user