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

@ -251,7 +251,7 @@ fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> Borde
if required <= edge_length {
1.0
} 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
// wide.
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),
Au::from_px(image.height as isize));
match (style.get_background().background_size.clone(),
image_aspect_ratio < bounds_aspect_ratio) {
(background_size::T::Contain, false) | (background_size::T::Cover, true) => {
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) => {
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)
}
@ -373,7 +373,7 @@ impl FragmentDisplayListBuilding for Fragment {
}), _) => {
let width = MaybeAuto::from_style(width, bounds.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 {
@ -382,7 +382,7 @@ impl FragmentDisplayListBuilding for Fragment {
}), _) => {
let height = MaybeAuto::from_style(height, bounds.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 {
@ -501,10 +501,10 @@ impl FragmentDisplayListBuilding for Fragment {
// between the starting point and the ending point.
let delta = match gradient.angle_or_corner {
AngleOrCorner::Angle(angle) => {
Point2D(Au::from_frac32_px(angle.radians().sin() *
absolute_bounds.size.width.to_frac32_px() / 2.0),
Au::from_frac32_px(-angle.radians().cos() *
absolute_bounds.size.height.to_frac32_px() / 2.0))
Point2D(Au::from_f32_px(angle.radians().sin() *
absolute_bounds.size.width.to_f32_px() / 2.0),
Au::from_f32_px(-angle.radians().cos() *
absolute_bounds.size.height.to_f32_px() / 2.0))
}
AngleOrCorner::Corner(horizontal, vertical) => {
let x_factor = match horizontal {
@ -521,8 +521,8 @@ impl FragmentDisplayListBuilding for Fragment {
};
// This is the length of the gradient line.
let length = Au::from_frac32_px(
(delta.x.to_frac32_px() * 2.0).hypot(delta.y.to_frac32_px() * 2.0));
let length = Au::from_f32_px(
(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.
//
@ -1080,9 +1080,9 @@ impl FragmentDisplayListBuilding for Fragment {
let transform_origin = self.style().get_effects().transform_origin;
let transform_origin =
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,
border_box.size.height).to_frac32_px());
border_box.size.height).to_f32_px());
let transform = self.style().get_effects().transform
.unwrap_or(ComputedMatrix::identity()).to_gfx_matrix(&border_box.size);
@ -1117,10 +1117,10 @@ impl FragmentDisplayListBuilding for Fragment {
layout_context: &LayoutContext) {
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 iframe_rect = Rect(Point2D((offset.x + border_padding.left).to_frac32_px(),
(offset.y + border_padding.top).to_frac32_px()),
Size2D(content_size.width.to_frac32_px(),
content_size.height.to_frac32_px()));
let iframe_rect = Rect(Point2D((offset.x + border_padding.left).to_f32_px(),
(offset.y + border_padding.top).to_f32_px()),
Size2D(content_size.width.to_f32_px(),
content_size.height.to_f32_px()));
debug!("finalizing position and size of iframe for {:?},{:?}",
iframe_fragment.pipeline_id,

View file

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

View file

@ -966,7 +966,7 @@ impl InlineFlow {
}
// 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);
for fragment_index in line.range.each_index() {
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
let viewport_size = data.window_size.initial_viewport;
let old_screen_size = rw_data.screen_size;
let current_screen_size = Size2D(Au::from_frac32_px(viewport_size.width.get()),
Au::from_frac32_px(viewport_size.height.get()));
let current_screen_size = Size2D(Au::from_f32_px(viewport_size.width.get()),
Au::from_f32_px(viewport_size.height.get()));
rw_data.screen_size = current_screen_size;
// 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.
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 &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap();
@ -1123,7 +1123,7 @@ impl LayoutRPC for LayoutRPCImpl {
fn mouse_over(&self, _: TrustedNodeAddress, point: Point2D<f32>)
-> Result<MouseOverResponse, ()> {
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 rw_data = rw_data.lock().unwrap();

View file

@ -434,8 +434,8 @@ impl ToGfxMatrix for ComputedMatrix {
self.m12 as f32,
self.m21 as f32,
self.m22 as f32,
self.m31.to_au(containing_size.width).to_frac32_px(),
self.m32.to_au(containing_size.height).to_frac32_px())
self.m31.to_au(containing_size.width).to_f32_px(),
self.m32.to_au(containing_size.height).to_f32_px())
}
}
@ -446,7 +446,7 @@ trait ToAu {
impl ToAu for LengthAndPercentage {
#[inline]
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.
self.column_computed_inline_sizes.clear();
if num_unspecified_inline_sizes == 0 {
let ratio = content_inline_size.to_frac32_px() /
total_column_inline_size.to_frac32_px();
let ratio = content_inline_size.to_f32_px() /
total_column_inline_size.to_f32_px();
for column_inline_size in self.column_intrinsic_inline_sizes.iter() {
self.column_computed_inline_sizes.push(ColumnComputedInlineSize {
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
/// `high` as specified by INTRINSIC § 4.3.
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.
@ -653,9 +653,9 @@ impl ExcessInlineSizeDistributionInfo {
// do?
if !column_intrinsic_inline_size.constrained &&
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
.to_frac32_px()
.to_f32_px()
} else {
0.0
}
@ -663,8 +663,8 @@ impl ExcessInlineSizeDistributionInfo {
1.0 / (self.count_of_nonconstrained_columns_with_no_percentage as CSSFloat)
} else if self.preferred_inline_size_of_constrained_columns_with_no_percentage >
Au(0) {
column_intrinsic_inline_size.preferred.to_frac32_px() /
self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_frac32_px()
column_intrinsic_inline_size.preferred.to_f32_px() /
self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_f32_px()
} else if self.total_percentage > 0.0 {
column_intrinsic_inline_size.percentage / self.total_percentage
} else {