Rename Au methods with f32/f64 instead of frac32/frac/subpx

This commit is contained in:
Simon Sapin 2015-05-05 18:23:29 +02:00
parent 32d5e24922
commit 8b522f2e7d
23 changed files with 99 additions and 99 deletions

View file

@ -489,9 +489,9 @@ impl StackingContext {
point = point - self.bounds.origin; point = point - self.bounds.origin;
debug_assert!(!topmost_only || result.is_empty()); debug_assert!(!topmost_only || result.is_empty());
let frac_point = self.transform.transform_point(&Point2D(point.x.to_frac32_px(), let frac_point = self.transform.transform_point(&Point2D(point.x.to_f32_px(),
point.y.to_frac32_px())); point.y.to_f32_px()));
point = Point2D(Au::from_frac32_px(frac_point.x), Au::from_frac32_px(frac_point.y)); point = Point2D(Au::from_f32_px(frac_point.x), Au::from_f32_px(frac_point.y));
// Iterate through display items in reverse stacking order. Steps here refer to the // Iterate through display items in reverse stacking order. Steps here refer to the
// painting steps in CSS 2.1 Appendix E. // painting steps in CSS 2.1 Appendix E.

View file

@ -95,7 +95,7 @@ pub fn create_filters(draw_target: &DrawTarget,
} }
filter::Filter::Blur(amount) => { filter::Filter::Blur(amount) => {
*accumulated_blur_radius = accumulated_blur_radius.clone() + amount; *accumulated_blur_radius = accumulated_blur_radius.clone() + amount;
let amount = amount.to_frac32_px(); let amount = amount.to_f32_px();
let blur = draw_target.create_filter(FilterType::GaussianBlur); let blur = draw_target.create_filter(FilterType::GaussianBlur);
blur.set_attribute(GaussianBlurAttribute::StdDeviation(amount)); blur.set_attribute(GaussianBlurAttribute::StdDeviation(amount));
blur.set_input(GaussianBlurInput, &filter); blur.set_input(GaussianBlurInput, &filter);

View file

@ -36,13 +36,13 @@ use azure::scaled_font::FontInfo;
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os="linux", target_os = "android"))]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes), ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes),
pt_size.to_subpx() as AzFloat) pt_size.to_f64_px() as AzFloat)
} }
#[cfg(target_os="macos")] #[cfg(target_os="macos")]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
let cgfont = template.ctfont.as_ref().unwrap().copy_to_CGFont(); let cgfont = template.ctfont.as_ref().unwrap().copy_to_CGFont();
ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_subpx() as AzFloat) ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f64_px() as AzFloat)
} }
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)

View file

@ -826,16 +826,16 @@ impl<'a> PaintContext<'a> {
let baseline_origin = match text.orientation { let baseline_origin = match text.orientation {
Upright => text.baseline_origin, Upright => text.baseline_origin,
SidewaysLeft => { SidewaysLeft => {
let x = text.baseline_origin.x.to_subpx() as AzFloat; let x = text.baseline_origin.x.to_f64_px() as AzFloat;
let y = text.baseline_origin.y.to_subpx() as AzFloat; let y = text.baseline_origin.y.to_f64_px() as AzFloat;
self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., -1., self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., -1.,
1., 0., 1., 0.,
x, y))); x, y)));
Point2D::zero() Point2D::zero()
} }
SidewaysRight => { SidewaysRight => {
let x = text.baseline_origin.x.to_subpx() as AzFloat; let x = text.baseline_origin.x.to_f64_px() as AzFloat;
let y = text.baseline_origin.y.to_subpx() as AzFloat; let y = text.baseline_origin.y.to_f64_px() as AzFloat;
self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., 1., self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., 1.,
-1., 0., -1., 0.,
x, y))); x, y)));
@ -1060,7 +1060,7 @@ impl<'a> PaintContext<'a> {
} }
let blur_filter = self.draw_target.create_filter(FilterType::GaussianBlur); let blur_filter = self.draw_target.create_filter(FilterType::GaussianBlur);
blur_filter.set_attribute(GaussianBlurAttribute::StdDeviation(blur_radius.to_subpx() as blur_filter.set_attribute(GaussianBlurAttribute::StdDeviation(blur_radius.to_f64_px() as
AzFloat)); AzFloat));
blur_filter.set_input(GaussianBlurInput, &temporary_draw_target.draw_target.snapshot()); blur_filter.set_input(GaussianBlurInput, &temporary_draw_target.draw_target.snapshot());
temporary_draw_target.draw_filter(&self.draw_target, blur_filter); temporary_draw_target.draw_filter(&self.draw_target, blur_filter);
@ -1104,21 +1104,21 @@ impl<'a> PaintContext<'a> {
pub trait ToAzurePoint { pub trait ToAzurePoint {
fn to_azure_point(&self) -> Point2D<AzFloat>; fn to_azure_point(&self) -> Point2D<AzFloat>;
fn to_subpx_azure_point(&self) -> Point2D<AzFloat>; fn to_f64_px_azure_point(&self) -> Point2D<AzFloat>;
} }
impl ToAzurePoint for Point2D<Au> { impl ToAzurePoint for Point2D<Au> {
fn to_azure_point(&self) -> Point2D<AzFloat> { fn to_azure_point(&self) -> Point2D<AzFloat> {
Point2D(self.x.to_nearest_px() as AzFloat, self.y.to_nearest_px() as AzFloat) Point2D(self.x.to_nearest_px() as AzFloat, self.y.to_nearest_px() as AzFloat)
} }
fn to_subpx_azure_point(&self) -> Point2D<AzFloat> { fn to_f64_px_azure_point(&self) -> Point2D<AzFloat> {
Point2D(self.x.to_subpx() as AzFloat, self.y.to_subpx() as AzFloat) Point2D(self.x.to_f64_px() as AzFloat, self.y.to_f64_px() as AzFloat)
} }
} }
pub trait ToAzureRect { pub trait ToAzureRect {
fn to_azure_rect(&self) -> Rect<AzFloat>; fn to_azure_rect(&self) -> Rect<AzFloat>;
fn to_subpx_azure_rect(&self) -> Rect<AzFloat>; fn to_f64_px_azure_rect(&self) -> Rect<AzFloat>;
} }
impl ToAzureRect for Rect<Au> { impl ToAzureRect for Rect<Au> {
@ -1127,9 +1127,9 @@ impl ToAzureRect for Rect<Au> {
self.size.height.to_nearest_px() as AzFloat)) self.size.height.to_nearest_px() as AzFloat))
} }
fn to_subpx_azure_rect(&self) -> Rect<AzFloat> { fn to_f64_px_azure_rect(&self) -> Rect<AzFloat> {
Rect(self.origin.to_subpx_azure_point(), Size2D(self.size.width.to_subpx() as AzFloat, Rect(self.origin.to_f64_px_azure_point(), Size2D(self.size.width.to_f64_px() as AzFloat,
self.size.height.to_subpx() as AzFloat)) self.size.height.to_f64_px() as AzFloat))
} }
} }
@ -1241,8 +1241,8 @@ impl ScaledFontExtensionMethods for ScaledFont {
let azglyph = struct__AzGlyph { let azglyph = struct__AzGlyph {
mIndex: glyph.id() as uint32_t, mIndex: glyph.id() as uint32_t,
mPosition: struct__AzPoint { mPosition: struct__AzPoint {
x: (origin.x + glyph_offset.x).to_subpx() as AzFloat, x: (origin.x + glyph_offset.x).to_f64_px() as AzFloat,
y: (origin.y + glyph_offset.y).to_subpx() as AzFloat y: (origin.y + glyph_offset.y).to_f64_px() as AzFloat
} }
}; };
origin = Point2D(origin.x + glyph_advance, origin.y); origin = Point2D(origin.x + glyph_advance, origin.y);
@ -1385,7 +1385,7 @@ impl TemporaryDrawTarget {
fn from_bounds(main_draw_target: &DrawTarget, bounds: &Rect<Au>) -> TemporaryDrawTarget { fn from_bounds(main_draw_target: &DrawTarget, bounds: &Rect<Au>) -> TemporaryDrawTarget {
let draw_target_transform = main_draw_target.get_transform(); let draw_target_transform = main_draw_target.get_transform();
let temporary_draw_target_bounds = let temporary_draw_target_bounds =
draw_target_transform.transform_rect(&bounds.to_subpx_azure_rect()); draw_target_transform.transform_rect(&bounds.to_f64_px_azure_rect());
let temporary_draw_target_size = let temporary_draw_target_size =
Size2D(temporary_draw_target_bounds.size.width.ceil() as i32, Size2D(temporary_draw_target_bounds.size.width.ceil() as i32,
temporary_draw_target_bounds.size.height.ceil() as i32); temporary_draw_target_bounds.size.height.ceil() as i32);

View file

@ -546,8 +546,8 @@ impl WorkerThread {
// Apply a translation to start at the boundaries of the stacking context, since the // Apply a translation to start at the boundaries of the stacking context, since the
// layer's origin starts at its overflow rect's origin. // layer's origin starts at its overflow rect's origin.
let tile_bounds = tile.page_rect.translate( let tile_bounds = tile.page_rect.translate(
&Point2D(stacking_context.overflow.origin.x.to_subpx() as AzFloat, &Point2D(stacking_context.overflow.origin.x.to_f64_px() as AzFloat,
stacking_context.overflow.origin.y.to_subpx() as AzFloat)); stacking_context.overflow.origin.y.to_f64_px() as AzFloat));
// Apply the translation to paint the tile we want. // Apply the translation to paint the tile we want.
let matrix: Matrix2D<AzFloat> = Matrix2D::identity(); let matrix: Matrix2D<AzFloat> = Matrix2D::identity();

View file

@ -257,7 +257,7 @@ impl FontHandleMethods for FontHandle {
line_gap: height, line_gap: height,
}; };
debug!("Font metrics (@{}px): {:?}", em_size.to_frac32_px(), metrics); debug!("Font metrics (@{}px): {:?}", em_size.to_f32_px(), metrics);
return metrics; return metrics;
} }
@ -268,7 +268,7 @@ impl FontHandleMethods for FontHandle {
impl<'a> FontHandle { impl<'a> FontHandle {
fn set_char_size(face: FT_Face, pt_size: Au) -> Result<(), ()>{ fn set_char_size(face: FT_Face, pt_size: Au) -> Result<(), ()>{
let char_width = float_to_fixed_ft((0.5f64 + pt_size.to_subpx()).floor()) as FT_F26Dot6; let char_width = float_to_fixed_ft((0.5f64 + pt_size.to_f64_px()).floor()) as FT_F26Dot6;
unsafe { unsafe {
let result = FT_Set_Char_Size(face, char_width, 0, 0, 0); let result = FT_Set_Char_Size(face, char_width, 0, 0, 0);
@ -296,6 +296,6 @@ impl<'a> FontHandle {
// If this isn't true then we're scaling one of the axes wrong // If this isn't true then we're scaling one of the axes wrong
assert!(metrics.x_ppem == metrics.y_ppem); assert!(metrics.x_ppem == metrics.y_ppem);
return Au::from_frac_px(value * x_scale); return Au::from_f64_px(value * x_scale);
} }
} }

View file

@ -62,7 +62,7 @@ impl FontHandleMethods for FontHandle {
pt_size: Option<Au>) pt_size: Option<Au>)
-> Result<FontHandle, ()> { -> Result<FontHandle, ()> {
let size = match pt_size { let size = match pt_size {
Some(s) => s.to_subpx(), Some(s) => s.to_f64_px(),
None => 0.0 None => 0.0
}; };
match template.ctfont { match template.ctfont {
@ -162,7 +162,7 @@ impl FontHandleMethods for FontHandle {
let bounding_rect: CGRect = self.ctfont.bounding_box(); let bounding_rect: CGRect = self.ctfont.bounding_box();
let ascent = self.ctfont.ascent() as f64; let ascent = self.ctfont.ascent() as f64;
let descent = self.ctfont.descent() as f64; let descent = self.ctfont.descent() as f64;
let em_size = Au::from_frac_px(self.ctfont.pt_size() as f64); let em_size = Au::from_f64_px(self.ctfont.pt_size() as f64);
let leading = self.ctfont.leading() as f64; let leading = self.ctfont.leading() as f64;
let scale = px_to_pt(self.ctfont.pt_size() as f64) / (ascent + descent); let scale = px_to_pt(self.ctfont.pt_size() as f64) / (ascent + descent);
@ -171,7 +171,7 @@ impl FontHandleMethods for FontHandle {
let max_advance_width = Au::from_pt(bounding_rect.size.width as f64); let max_advance_width = Au::from_pt(bounding_rect.size.width as f64);
let average_advance = self.glyph_index('0') let average_advance = self.glyph_index('0')
.and_then(|idx| self.glyph_h_advance(idx)) .and_then(|idx| self.glyph_h_advance(idx))
.map(|advance| Au::from_frac_px(advance)) .map(|advance| Au::from_f64_px(advance))
.unwrap_or(max_advance_width); .unwrap_or(max_advance_width);
let metrics = FontMetrics { let metrics = FontMetrics {
@ -191,7 +191,7 @@ impl FontHandleMethods for FontHandle {
descent: Au::from_pt(descent * scale), descent: Au::from_pt(descent * scale),
max_advance: max_advance_width, max_advance: max_advance_width,
average_advance: average_advance, average_advance: average_advance,
line_gap: Au::from_frac_px(line_gap), line_gap: Au::from_f64_px(line_gap),
}; };
debug!("Font metrics (@{} pt): {:?}", self.ctfont.pt_size() as f64, metrics); debug!("Font metrics (@{} pt): {:?}", self.ctfont.pt_size() as f64, metrics);
return metrics; return metrics;

View file

@ -728,7 +728,7 @@ impl<'a> GlyphStore {
// FIXME(pcwalton): This can overflow for very large font-sizes. // FIXME(pcwalton): This can overflow for very large font-sizes.
let advance = let advance =
((entry.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) + ((entry.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) +
Au::from_frac_px(space).0 as u32; Au::from_f64_px(space).0 as u32;
entry.value = (entry.value & !GLYPH_ADVANCE_MASK) | entry.value = (entry.value & !GLYPH_ADVANCE_MASK) |
(advance << GLYPH_ADVANCE_SHIFT); (advance << GLYPH_ADVANCE_SHIFT);
} }

View file

@ -117,10 +117,10 @@ impl ShapedGlyphData {
let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance);
let y_advance = Shaper::fixed_to_float((*pos_info_i).y_advance); let y_advance = Shaper::fixed_to_float((*pos_info_i).y_advance);
let x_offset = Au::from_frac_px(x_offset); let x_offset = Au::from_f64_px(x_offset);
let y_offset = Au::from_frac_px(y_offset); let y_offset = Au::from_f64_px(y_offset);
let x_advance = Au::from_frac_px(x_advance); let x_advance = Au::from_f64_px(x_advance);
let y_advance = Au::from_frac_px(y_advance); let y_advance = Au::from_f64_px(y_advance);
let offset = if x_offset == Au(0) && y_offset == Au(0) && y_advance == Au(0) { let offset = if x_offset == Au(0) && y_offset == Au(0) && y_advance == Au(0) {
None None
@ -185,7 +185,7 @@ impl Shaper {
let hb_font: *mut hb_font_t = RUST_hb_font_create(hb_face); let hb_font: *mut hb_font_t = RUST_hb_font_create(hb_face);
// Set points-per-em. if zero, performs no hinting in that direction. // Set points-per-em. if zero, performs no hinting in that direction.
let pt_size = font.actual_pt_size.to_subpx(); let pt_size = font.actual_pt_size.to_f64_px();
RUST_hb_font_set_ppem(hb_font, pt_size as c_uint, pt_size as c_uint); RUST_hb_font_set_ppem(hb_font, pt_size as c_uint, pt_size as c_uint);
// Set scaling. Note that this takes 16.16 fixed point. // Set scaling. Note that this takes 16.16 fixed point.
@ -518,7 +518,7 @@ impl Shaper {
advance = advance + options.word_spacing advance = advance + options.word_spacing
} else if character == '\t' { } else if character == '\t' {
let tab_size = 8f64; let tab_size = 8f64;
advance = Au::from_frac_px(tab_size * glyph_space_advance(self.font_and_shaping_options.font)); advance = Au::from_f64_px(tab_size * glyph_space_advance(self.font_and_shaping_options.font));
} }
advance advance

View file

@ -251,7 +251,7 @@ fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> Borde
if required <= edge_length { if required <= edge_length {
1.0 1.0
} else { } else {
edge_length.to_frac32_px() / required.to_frac32_px() edge_length.to_f32_px() / required.to_f32_px()
} }
} }
@ -352,18 +352,18 @@ impl FragmentDisplayListBuilding for Fragment {
// If `image_aspect_ratio` < `bounds_aspect_ratio`, the image is tall; otherwise, it is // If `image_aspect_ratio` < `bounds_aspect_ratio`, the image is tall; otherwise, it is
// wide. // wide.
let image_aspect_ratio = (image.width as f64) / (image.height as f64); let image_aspect_ratio = (image.width as f64) / (image.height as f64);
let bounds_aspect_ratio = bounds.size.width.to_subpx() / bounds.size.height.to_subpx(); let bounds_aspect_ratio = bounds.size.width.to_f64_px() / bounds.size.height.to_f64_px();
let intrinsic_size = Size2D(Au::from_px(image.width as isize), let intrinsic_size = Size2D(Au::from_px(image.width as isize),
Au::from_px(image.height as isize)); Au::from_px(image.height as isize));
match (style.get_background().background_size.clone(), match (style.get_background().background_size.clone(),
image_aspect_ratio < bounds_aspect_ratio) { image_aspect_ratio < bounds_aspect_ratio) {
(background_size::T::Contain, false) | (background_size::T::Cover, true) => { (background_size::T::Contain, false) | (background_size::T::Cover, true) => {
Size2D(bounds.size.width, Size2D(bounds.size.width,
Au::from_frac_px(bounds.size.width.to_subpx() / image_aspect_ratio)) Au::from_f64_px(bounds.size.width.to_f64_px() / image_aspect_ratio))
} }
(background_size::T::Contain, true) | (background_size::T::Cover, false) => { (background_size::T::Contain, true) | (background_size::T::Cover, false) => {
Size2D(Au::from_frac_px(bounds.size.height.to_subpx() * image_aspect_ratio), Size2D(Au::from_f64_px(bounds.size.height.to_f64_px() * image_aspect_ratio),
bounds.size.height) bounds.size.height)
} }
@ -373,7 +373,7 @@ impl FragmentDisplayListBuilding for Fragment {
}), _) => { }), _) => {
let width = MaybeAuto::from_style(width, bounds.size.width) let width = MaybeAuto::from_style(width, bounds.size.width)
.specified_or_default(intrinsic_size.width); .specified_or_default(intrinsic_size.width);
Size2D(width, Au::from_frac_px(width.to_subpx() / image_aspect_ratio)) Size2D(width, Au::from_f64_px(width.to_f64_px() / image_aspect_ratio))
} }
(background_size::T::Explicit(background_size::ExplicitSize { (background_size::T::Explicit(background_size::ExplicitSize {
@ -382,7 +382,7 @@ impl FragmentDisplayListBuilding for Fragment {
}), _) => { }), _) => {
let height = MaybeAuto::from_style(height, bounds.size.height) let height = MaybeAuto::from_style(height, bounds.size.height)
.specified_or_default(intrinsic_size.height); .specified_or_default(intrinsic_size.height);
Size2D(Au::from_frac_px(height.to_subpx() * image_aspect_ratio), height) Size2D(Au::from_f64_px(height.to_f64_px() * image_aspect_ratio), height)
} }
(background_size::T::Explicit(background_size::ExplicitSize { (background_size::T::Explicit(background_size::ExplicitSize {
@ -501,10 +501,10 @@ impl FragmentDisplayListBuilding for Fragment {
// between the starting point and the ending point. // between the starting point and the ending point.
let delta = match gradient.angle_or_corner { let delta = match gradient.angle_or_corner {
AngleOrCorner::Angle(angle) => { AngleOrCorner::Angle(angle) => {
Point2D(Au::from_frac32_px(angle.radians().sin() * Point2D(Au::from_f32_px(angle.radians().sin() *
absolute_bounds.size.width.to_frac32_px() / 2.0), absolute_bounds.size.width.to_f32_px() / 2.0),
Au::from_frac32_px(-angle.radians().cos() * Au::from_f32_px(-angle.radians().cos() *
absolute_bounds.size.height.to_frac32_px() / 2.0)) absolute_bounds.size.height.to_f32_px() / 2.0))
} }
AngleOrCorner::Corner(horizontal, vertical) => { AngleOrCorner::Corner(horizontal, vertical) => {
let x_factor = match horizontal { let x_factor = match horizontal {
@ -521,8 +521,8 @@ impl FragmentDisplayListBuilding for Fragment {
}; };
// This is the length of the gradient line. // This is the length of the gradient line.
let length = Au::from_frac32_px( let length = Au::from_f32_px(
(delta.x.to_frac32_px() * 2.0).hypot(delta.y.to_frac32_px() * 2.0)); (delta.x.to_f32_px() * 2.0).hypot(delta.y.to_f32_px() * 2.0));
// Determine the position of each stop per CSS-IMAGES § 3.4. // Determine the position of each stop per CSS-IMAGES § 3.4.
// //
@ -1080,9 +1080,9 @@ impl FragmentDisplayListBuilding for Fragment {
let transform_origin = self.style().get_effects().transform_origin; let transform_origin = self.style().get_effects().transform_origin;
let transform_origin = let transform_origin =
Point2D(model::specified(transform_origin.horizontal, Point2D(model::specified(transform_origin.horizontal,
border_box.size.width).to_frac32_px(), border_box.size.width).to_f32_px(),
model::specified(transform_origin.vertical, model::specified(transform_origin.vertical,
border_box.size.height).to_frac32_px()); border_box.size.height).to_f32_px());
let transform = self.style().get_effects().transform let transform = self.style().get_effects().transform
.unwrap_or(ComputedMatrix::identity()).to_gfx_matrix(&border_box.size); .unwrap_or(ComputedMatrix::identity()).to_gfx_matrix(&border_box.size);
@ -1117,10 +1117,10 @@ impl FragmentDisplayListBuilding for Fragment {
layout_context: &LayoutContext) { layout_context: &LayoutContext) {
let border_padding = (self.border_padding).to_physical(self.style.writing_mode); let border_padding = (self.border_padding).to_physical(self.style.writing_mode);
let content_size = self.content_box().size.to_physical(self.style.writing_mode); let content_size = self.content_box().size.to_physical(self.style.writing_mode);
let iframe_rect = Rect(Point2D((offset.x + border_padding.left).to_frac32_px(), let iframe_rect = Rect(Point2D((offset.x + border_padding.left).to_f32_px(),
(offset.y + border_padding.top).to_frac32_px()), (offset.y + border_padding.top).to_f32_px()),
Size2D(content_size.width.to_frac32_px(), Size2D(content_size.width.to_f32_px(),
content_size.height.to_frac32_px())); content_size.height.to_f32_px()));
debug!("finalizing position and size of iframe for {:?},{:?}", debug!("finalizing position and size of iframe for {:?},{:?}",
iframe_fragment.pipeline_id, iframe_fragment.pipeline_id,

View file

@ -451,8 +451,8 @@ impl ReplacedImageFragmentInfo {
if intrinsic_height == Au(0) { if intrinsic_height == Au(0) {
intrinsic_width intrinsic_width
} else { } else {
let ratio = intrinsic_width.to_frac32_px() / let ratio = intrinsic_width.to_f32_px() /
intrinsic_height.to_frac32_px(); intrinsic_height.to_f32_px();
let specified_height = ReplacedImageFragmentInfo::style_length( let specified_height = ReplacedImageFragmentInfo::style_length(
style_block_size, style_block_size,
@ -466,7 +466,7 @@ impl ReplacedImageFragmentInfo {
style_min_block_size, style_min_block_size,
style_max_block_size, style_max_block_size,
Au(0)); Au(0));
Au::from_frac32_px(specified_height.to_frac32_px() * ratio) Au::from_f32_px(specified_height.to_f32_px() * ratio)
} }
}, },
MaybeAuto::Specified(w) => w, MaybeAuto::Specified(w) => w,
@ -503,8 +503,8 @@ impl ReplacedImageFragmentInfo {
MaybeAuto::Auto => { MaybeAuto::Auto => {
let intrinsic_width = fragment_inline_size; let intrinsic_width = fragment_inline_size;
let intrinsic_height = fragment_block_size; let intrinsic_height = fragment_block_size;
let scale = intrinsic_width.to_frac32_px() / inline_size.to_frac32_px(); let scale = intrinsic_width.to_f32_px() / inline_size.to_f32_px();
Au::from_frac32_px(intrinsic_height.to_frac32_px() / scale) Au::from_f32_px(intrinsic_height.to_f32_px() / scale)
}, },
MaybeAuto::Specified(h) => { MaybeAuto::Specified(h) => {
h h

View file

@ -966,7 +966,7 @@ impl InlineFlow {
} }
// Then distribute all the space across the expansion opportunities. // Then distribute all the space across the expansion opportunities.
let space_per_expansion_opportunity = slack_inline_size.to_subpx() / let space_per_expansion_opportunity = slack_inline_size.to_f64_px() /
(expansion_opportunities as f64); (expansion_opportunities as f64);
for fragment_index in line.range.each_index() { for fragment_index in line.range.each_index() {
let fragment = fragments.get_mut(fragment_index.to_usize()); let fragment = fragments.get_mut(fragment_index.to_usize());

View file

@ -851,8 +851,8 @@ impl LayoutTask {
// http://www.w3.org/TR/css-device-adapt/#actual-viewport // http://www.w3.org/TR/css-device-adapt/#actual-viewport
let viewport_size = data.window_size.initial_viewport; let viewport_size = data.window_size.initial_viewport;
let old_screen_size = rw_data.screen_size; let old_screen_size = rw_data.screen_size;
let current_screen_size = Size2D(Au::from_frac32_px(viewport_size.width.get()), let current_screen_size = Size2D(Au::from_f32_px(viewport_size.width.get()),
Au::from_frac32_px(viewport_size.height.get())); Au::from_f32_px(viewport_size.height.get()));
rw_data.screen_size = current_screen_size; rw_data.screen_size = current_screen_size;
// Handle conditions where the entire flow tree is invalid. // Handle conditions where the entire flow tree is invalid.
@ -1096,7 +1096,7 @@ impl LayoutRPC for LayoutRPCImpl {
/// Requests the node containing the point of interest. /// Requests the node containing the point of interest.
fn hit_test(&self, _: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()> { fn hit_test(&self, _: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()> {
let point = Point2D(Au::from_frac32_px(point.x), Au::from_frac32_px(point.y)); let point = Point2D(Au::from_f32_px(point.x), Au::from_f32_px(point.y));
let resp = { let resp = {
let &LayoutRPCImpl(ref rw_data) = self; let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap(); let rw_data = rw_data.lock().unwrap();
@ -1123,7 +1123,7 @@ impl LayoutRPC for LayoutRPCImpl {
fn mouse_over(&self, _: TrustedNodeAddress, point: Point2D<f32>) fn mouse_over(&self, _: TrustedNodeAddress, point: Point2D<f32>)
-> Result<MouseOverResponse, ()> { -> Result<MouseOverResponse, ()> {
let mut mouse_over_list: Vec<DisplayItemMetadata> = vec!(); let mut mouse_over_list: Vec<DisplayItemMetadata> = vec!();
let point = Point2D(Au::from_frac32_px(point.x), Au::from_frac32_px(point.y)); let point = Point2D(Au::from_f32_px(point.x), Au::from_f32_px(point.y));
{ {
let &LayoutRPCImpl(ref rw_data) = self; let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap(); let rw_data = rw_data.lock().unwrap();

View file

@ -434,8 +434,8 @@ impl ToGfxMatrix for ComputedMatrix {
self.m12 as f32, self.m12 as f32,
self.m21 as f32, self.m21 as f32,
self.m22 as f32, self.m22 as f32,
self.m31.to_au(containing_size.width).to_frac32_px(), self.m31.to_au(containing_size.width).to_f32_px(),
self.m32.to_au(containing_size.height).to_frac32_px()) self.m32.to_au(containing_size.height).to_f32_px())
} }
} }
@ -446,7 +446,7 @@ trait ToAu {
impl ToAu for LengthAndPercentage { impl ToAu for LengthAndPercentage {
#[inline] #[inline]
fn to_au(&self, containing_size: Au) -> Au { fn to_au(&self, containing_size: Au) -> Au {
self.length + Au::from_frac32_px(self.percentage * containing_size.to_frac32_px()) self.length + Au::from_f32_px(self.percentage * containing_size.to_f32_px())
} }
} }

View file

@ -430,8 +430,8 @@ impl Flow for TableFlow {
// if there are any, or among all the columns if all are specified. // if there are any, or among all the columns if all are specified.
self.column_computed_inline_sizes.clear(); self.column_computed_inline_sizes.clear();
if num_unspecified_inline_sizes == 0 { if num_unspecified_inline_sizes == 0 {
let ratio = content_inline_size.to_frac32_px() / let ratio = content_inline_size.to_f32_px() /
total_column_inline_size.to_frac32_px(); total_column_inline_size.to_f32_px();
for column_inline_size in self.column_intrinsic_inline_sizes.iter() { for column_inline_size in self.column_intrinsic_inline_sizes.iter() {
self.column_computed_inline_sizes.push(ColumnComputedInlineSize { self.column_computed_inline_sizes.push(ColumnComputedInlineSize {
size: column_inline_size.minimum_length.scale_by(ratio), size: column_inline_size.minimum_length.scale_by(ratio),

View file

@ -590,7 +590,7 @@ impl SelectedAutoLayoutCandidateGuess {
/// Computes the weight needed to linearly interpolate `middle` between two guesses `low` and /// Computes the weight needed to linearly interpolate `middle` between two guesses `low` and
/// `high` as specified by INTRINSIC § 4.3. /// `high` as specified by INTRINSIC § 4.3.
fn weight(low: Au, middle: Au, high: Au) -> CSSFloat { fn weight(low: Au, middle: Au, high: Au) -> CSSFloat {
(middle - low).to_frac32_px() / (high - low).to_frac32_px() (middle - low).to_f32_px() / (high - low).to_f32_px()
} }
/// Linearly interpolates between two guesses, as specified by INTRINSIC § 4.3. /// Linearly interpolates between two guesses, as specified by INTRINSIC § 4.3.
@ -653,9 +653,9 @@ impl ExcessInlineSizeDistributionInfo {
// do? // do?
if !column_intrinsic_inline_size.constrained && if !column_intrinsic_inline_size.constrained &&
column_intrinsic_inline_size.percentage == 0.0 { column_intrinsic_inline_size.percentage == 0.0 {
column_intrinsic_inline_size.preferred.to_frac32_px() / column_intrinsic_inline_size.preferred.to_f32_px() /
self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage
.to_frac32_px() .to_f32_px()
} else { } else {
0.0 0.0
} }
@ -663,8 +663,8 @@ impl ExcessInlineSizeDistributionInfo {
1.0 / (self.count_of_nonconstrained_columns_with_no_percentage as CSSFloat) 1.0 / (self.count_of_nonconstrained_columns_with_no_percentage as CSSFloat)
} else if self.preferred_inline_size_of_constrained_columns_with_no_percentage > } else if self.preferred_inline_size_of_constrained_columns_with_no_percentage >
Au(0) { Au(0) {
column_intrinsic_inline_size.preferred.to_frac32_px() / column_intrinsic_inline_size.preferred.to_f32_px() /
self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_frac32_px() self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_f32_px()
} else if self.total_percentage > 0.0 { } else if self.total_percentage > 0.0 {
column_intrinsic_inline_size.percentage / self.total_percentage column_intrinsic_inline_size.percentage / self.total_percentage
} else { } else {

View file

@ -135,8 +135,8 @@ impl<'a> Activatable for JSRef<'a, HTMLAnchorElement> {
let target_node = NodeCast::to_ref(target).unwrap(); let target_node = NodeCast::to_ref(target).unwrap();
let rect = window_from_node(target_node).root().r().content_box_query(target_node.to_trusted_node_address()); let rect = window_from_node(target_node).root().r().content_box_query(target_node.to_trusted_node_address());
ismap_suffix = Some( ismap_suffix = Some(
format!("?{},{}", mouse_event.ClientX().to_f32().unwrap() - rect.origin.x.to_frac32_px(), format!("?{},{}", mouse_event.ClientX().to_f32().unwrap() - rect.origin.x.to_f32_px(),
mouse_event.ClientY().to_f32().unwrap() - rect.origin.y.to_frac32_px()) mouse_event.ClientY().to_f32().unwrap() - rect.origin.y.to_f32_px())
) )
} }
} }

View file

@ -917,10 +917,10 @@ impl Window {
} }
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool{ fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool{
let clip_rect = Rect(Point2D(clip_rect.origin.x.to_frac32_px(), let clip_rect = Rect(Point2D(clip_rect.origin.x.to_f32_px(),
clip_rect.origin.y.to_frac32_px()), clip_rect.origin.y.to_f32_px()),
Size2D(clip_rect.size.width.to_frac32_px(), Size2D(clip_rect.size.width.to_f32_px(),
clip_rect.size.height.to_frac32_px())); clip_rect.size.height.to_f32_px()));
// We only need to move the clip rect if the viewport is getting near the edge of // We only need to move the clip rect if the viewport is getting near the edge of
// our preexisting clip rect. We use half of the size of the viewport as a heuristic // our preexisting clip rect. We use half of the size of the viewport as a heuristic

View file

@ -1180,7 +1180,7 @@ impl ScriptTask {
fn scroll_fragment_point(&self, pipeline_id: PipelineId, node: JSRef<Element>) { fn scroll_fragment_point(&self, pipeline_id: PipelineId, node: JSRef<Element>) {
let node: JSRef<Node> = NodeCast::from_ref(node); let node: JSRef<Node> = NodeCast::from_ref(node);
let rect = node.get_bounding_content_box(); let rect = node.get_bounding_content_box();
let point = Point2D(rect.origin.x.to_frac32_px(), rect.origin.y.to_frac32_px()); let point = Point2D(rect.origin.x.to_f32_px(), rect.origin.y.to_f32_px());
// FIXME(#2003, pcwalton): This is pretty bogus when multiple layers are involved. // FIXME(#2003, pcwalton): This is pretty bogus when multiple layers are involved.
// Really what needs to happen is that this needs to go through layout to ask which // Really what needs to happen is that this needs to go through layout to ask which
// layer the element belongs to, and have it send the scroll message to the // layer the element belongs to, and have it send the scroll message to the

View file

@ -203,8 +203,8 @@ pub fn parse_media_query_list(input: &mut Parser) -> MediaQueryList {
impl MediaQueryList { impl MediaQueryList {
pub fn evaluate(&self, device: &Device) -> bool { pub fn evaluate(&self, device: &Device) -> bool {
let viewport_size = Size2D(Au::from_frac32_px(device.viewport_size.width.get()), let viewport_size = Size2D(Au::from_f32_px(device.viewport_size.width.get()),
Au::from_frac32_px(device.viewport_size.height.get())); Au::from_f32_px(device.viewport_size.height.get()));
// Check if any queries match (OR condition) // Check if any queries match (OR condition)
self.media_queries.iter().any(|mq| { self.media_queries.iter().any(|mq| {

View file

@ -3313,8 +3313,8 @@ pub mod longhands {
return Err(()) return Err(())
} }
let (tx, ty) = let (tx, ty) =
(specified::Length::Absolute(Au::from_frac32_px(values[4])), (specified::Length::Absolute(Au::from_f32_px(values[4])),
specified::Length::Absolute(Au::from_frac32_px(values[5]))); specified::Length::Absolute(Au::from_f32_px(values[5])));
let (tx, ty) = let (tx, ty) =
(specified::LengthAndPercentage::from_length(tx), (specified::LengthAndPercentage::from_length(tx),
specified::LengthAndPercentage::from_length(ty)); specified::LengthAndPercentage::from_length(ty));

View file

@ -187,7 +187,7 @@ pub mod specified {
pub fn to_computed_value(&self, viewport_size: Size2D<Au>) -> Au { pub fn to_computed_value(&self, viewport_size: Size2D<Au>) -> Au {
macro_rules! to_unit { macro_rules! to_unit {
($viewport_dimension:expr) => { ($viewport_dimension:expr) => {
$viewport_dimension.to_frac32_px() / 100.0 $viewport_dimension.to_f32_px() / 100.0
} }
} }
@ -201,7 +201,7 @@ pub mod specified {
&ViewportPercentageLength::Vmax(length) => &ViewportPercentageLength::Vmax(length) =>
length * to_unit!(cmp::max(viewport_size.width, viewport_size.height)), length * to_unit!(cmp::max(viewport_size.width, viewport_size.height)),
}; };
Au::from_frac32_px(value) Au::from_f32_px(value)
} }
} }
@ -236,7 +236,7 @@ pub mod specified {
impl ToCss for Length { impl ToCss for Length {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match self { match self {
&Length::Absolute(length) => write!(dest, "{}px", length.to_frac32_px()), &Length::Absolute(length) => write!(dest, "{}px", length.to_f32_px()),
&Length::FontRelative(length) => length.to_css(dest), &Length::FontRelative(length) => length.to_css(dest),
&Length::ViewportPercentage(length) => length.to_css(dest), &Length::ViewportPercentage(length) => length.to_css(dest),
&Length::ServoCharacterWidth(_) &Length::ServoCharacterWidth(_)
@ -1114,7 +1114,7 @@ pub mod computed {
fn mul(self, scalar: CSSFloat) -> LengthAndPercentage { fn mul(self, scalar: CSSFloat) -> LengthAndPercentage {
LengthAndPercentage { LengthAndPercentage {
length: Au::from_frac32_px(self.length.to_frac32_px() * scalar), length: Au::from_f32_px(self.length.to_f32_px() * scalar),
percentage: self.percentage * scalar, percentage: self.percentage * scalar,
} }
} }

View file

@ -115,13 +115,13 @@ pub const MAX_AU: Au = Au(i32::MAX);
impl Encodable for Au { impl Encodable for Au {
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> { fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_f64(self.to_subpx()) e.emit_f64(self.to_f64_px())
} }
} }
impl fmt::Debug for Au { impl fmt::Debug for Au {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}px", self.to_subpx()) write!(f, "{}px", self.to_f64_px())
}} }}
impl Add for Au { impl Add for Au {
@ -238,13 +238,13 @@ impl Au {
} }
#[inline] #[inline]
pub fn to_frac32_px(&self) -> f32 { pub fn to_f32_px(&self) -> f32 {
let Au(s) = *self; let Au(s) = *self;
(s as f32) / 60f32 (s as f32) / 60f32
} }
#[inline] #[inline]
pub fn to_subpx(&self) -> f64 { pub fn to_f64_px(&self) -> f64 {
let Au(s) = *self; let Au(s) = *self;
(s as f64) / 60f64 (s as f64) / 60f64
} }
@ -258,17 +258,17 @@ impl Au {
} }
#[inline] #[inline]
pub fn from_frac32_px(px: f32) -> Au { pub fn from_f32_px(px: f32) -> Au {
Au((px * 60f32) as i32) Au((px * 60f32) as i32)
} }
#[inline] #[inline]
pub fn from_pt(pt: f64) -> Au { pub fn from_pt(pt: f64) -> Au {
Au::from_frac_px(pt_to_px(pt)) Au::from_f64_px(pt_to_px(pt))
} }
#[inline] #[inline]
pub fn from_frac_px(px: f64) -> Au { pub fn from_f64_px(px: f64) -> Au {
Au((px * 60.) as i32) Au((px * 60.) as i32)
} }
} }
@ -293,7 +293,7 @@ pub fn rect_contains_point<T:PartialOrd + Add<T, Output=T>>(rect: Rect<T>, point
/// A helper function to convert a rect of `f32` pixels to a rect of app units. /// A helper function to convert a rect of `f32` pixels to a rect of app units.
pub fn f32_rect_to_au_rect(rect: Rect<f32>) -> Rect<Au> { pub fn f32_rect_to_au_rect(rect: Rect<f32>) -> Rect<Au> {
Rect(Point2D(Au::from_frac32_px(rect.origin.x), Au::from_frac32_px(rect.origin.y)), Rect(Point2D(Au::from_f32_px(rect.origin.x), Au::from_f32_px(rect.origin.y)),
Size2D(Au::from_frac32_px(rect.size.width), Au::from_frac32_px(rect.size.height))) Size2D(Au::from_f32_px(rect.size.width), Au::from_f32_px(rect.size.height)))
} }