mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Replace Au-related free functions in util::geometry with Au methods.
This commit is contained in:
parent
49aed6555d
commit
32d5e24922
12 changed files with 50 additions and 92 deletions
|
@ -933,7 +933,7 @@ impl BlockFlow {
|
|||
if is_root {
|
||||
let screen_size = LogicalSize::from_physical(self.fragment.style.writing_mode,
|
||||
layout_context.shared.screen_size);
|
||||
block_size = Au::max(screen_size.block, block_size)
|
||||
block_size = max(screen_size.block, block_size)
|
||||
}
|
||||
|
||||
if is_root || self.formatting_context_type() != FormattingContextType::None ||
|
||||
|
@ -1478,11 +1478,11 @@ impl Flow for BlockFlow {
|
|||
child_base.intrinsic_inline_sizes.minimum_inline_size);
|
||||
|
||||
if child_base.flags.contains(CLEARS_LEFT) {
|
||||
left_float_width = Au::max(left_float_width, left_float_width_accumulator);
|
||||
left_float_width = max(left_float_width, left_float_width_accumulator);
|
||||
left_float_width_accumulator = Au(0)
|
||||
}
|
||||
if child_base.flags.contains(CLEARS_RIGHT) {
|
||||
right_float_width = Au::max(right_float_width, right_float_width_accumulator);
|
||||
right_float_width = max(right_float_width, right_float_width_accumulator);
|
||||
right_float_width_accumulator = Au(0)
|
||||
}
|
||||
|
||||
|
@ -1509,8 +1509,8 @@ impl Flow for BlockFlow {
|
|||
// FIXME(pcwalton): This should consider all float descendants, not just children.
|
||||
// FIXME(pcwalton): This is not well-spec'd; INTRINSIC specifies to do this, but CSS-SIZING
|
||||
// says not to. In practice, Gecko and WebKit both do this.
|
||||
left_float_width = Au::max(left_float_width, left_float_width_accumulator);
|
||||
right_float_width = Au::max(right_float_width, right_float_width_accumulator);
|
||||
left_float_width = max(left_float_width, left_float_width_accumulator);
|
||||
right_float_width = max(right_float_width, right_float_width_accumulator);
|
||||
computation.content_intrinsic_sizes.preferred_inline_size =
|
||||
max(computation.content_intrinsic_sizes.preferred_inline_size,
|
||||
left_float_width + right_float_width);
|
||||
|
|
|
@ -52,7 +52,7 @@ use style::values::computed::{Image, LinearGradient, LengthOrPercentage, LengthO
|
|||
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
|
||||
use url::Url;
|
||||
use util::cursor::Cursor;
|
||||
use util::geometry::{self, Au, ZERO_POINT, to_px, to_frac_px};
|
||||
use util::geometry::{Au, ZERO_POINT};
|
||||
use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use util::opts;
|
||||
|
||||
|
@ -1025,9 +1025,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
}
|
||||
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
|
||||
let width = canvas_fragment_info.replaced_image_fragment_info
|
||||
.computed_inline_size.map_or(0, |w| to_px(w) as usize);
|
||||
.computed_inline_size.map_or(0, |w| w.to_px() as usize);
|
||||
let height = canvas_fragment_info.replaced_image_fragment_info
|
||||
.computed_block_size.map_or(0, |h| to_px(h) as usize);
|
||||
.computed_block_size.map_or(0, |h| h.to_px() as usize);
|
||||
|
||||
let (sender, receiver) = channel::<Vec<u8>>();
|
||||
let canvas_data = match canvas_fragment_info.renderer {
|
||||
|
@ -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(geometry::to_frac_px(offset.x + border_padding.left) as f32,
|
||||
geometry::to_frac_px(offset.y + border_padding.top) as f32),
|
||||
Size2D(geometry::to_frac_px(content_size.width) as f32,
|
||||
geometry::to_frac_px(content_size.height) as f32));
|
||||
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()));
|
||||
|
||||
debug!("finalizing position and size of iframe for {:?},{:?}",
|
||||
iframe_fragment.pipeline_id,
|
||||
|
|
|
@ -47,7 +47,7 @@ use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
|||
use style::values::computed::{LengthOrPercentageOrNone};
|
||||
use text::TextRunScanner;
|
||||
use url::Url;
|
||||
use util::geometry::{self, Au, ZERO_POINT};
|
||||
use util::geometry::{Au, ZERO_POINT};
|
||||
use util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin, WritingMode};
|
||||
use util::range::*;
|
||||
use util::str::is_whitespace;
|
||||
|
@ -213,9 +213,9 @@ fn clamp_size(size: Au,
|
|||
let min_size = model::specified(min_size, container_inline_size);
|
||||
let max_size = model::specified_or_none(max_size, container_inline_size);
|
||||
|
||||
Au::max(min_size, match max_size {
|
||||
max(min_size, match max_size {
|
||||
None => size,
|
||||
Some(max_size) => Au::min(size, max_size),
|
||||
Some(max_size) => min(size, max_size),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ impl ImageFragmentInfo {
|
|||
pub fn tile_image(position: &mut Au, size: &mut Au,
|
||||
virtual_position: Au, image_size: u32) {
|
||||
let image_size = image_size as isize;
|
||||
let delta_pixels = geometry::to_px(virtual_position - *position);
|
||||
let delta_pixels = (virtual_position - *position).to_px();
|
||||
let tile_count = (delta_pixels + image_size - 1) / image_size;
|
||||
let offset = Au::from_px(image_size * tile_count);
|
||||
let new_position = virtual_position - offset;
|
||||
|
@ -967,8 +967,8 @@ impl Fragment {
|
|||
let flags = self.quantities_included_in_intrinsic_inline_size();
|
||||
let style = self.style();
|
||||
let specified = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) {
|
||||
Au::max(model::specified(style.min_inline_size(), Au(0)),
|
||||
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero())
|
||||
max(model::specified(style.min_inline_size(), Au(0)),
|
||||
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero())
|
||||
} else {
|
||||
Au(0)
|
||||
};
|
||||
|
|
|
@ -397,8 +397,8 @@ impl LineBreaker {
|
|||
|
||||
fn new_block_size_for_line(&self, new_fragment: &Fragment, layout_context: &LayoutContext)
|
||||
-> Au {
|
||||
Au::max(self.pending_line.bounds.size.block,
|
||||
self.new_inline_metrics_for_line(new_fragment, layout_context).block_size())
|
||||
max(self.pending_line.bounds.size.block,
|
||||
self.new_inline_metrics_for_line(new_fragment, layout_context).block_size())
|
||||
}
|
||||
|
||||
/// Computes the position of a line that has only the provided fragment. Returns the bounding
|
||||
|
@ -1589,10 +1589,10 @@ impl InlineMetrics {
|
|||
|
||||
pub fn max(&self, other: &InlineMetrics) -> InlineMetrics {
|
||||
InlineMetrics {
|
||||
block_size_above_baseline: Au::max(self.block_size_above_baseline,
|
||||
other.block_size_above_baseline),
|
||||
depth_below_baseline: Au::max(self.depth_below_baseline, other.depth_below_baseline),
|
||||
ascent: Au::max(self.ascent, other.ascent),
|
||||
block_size_above_baseline: max(self.block_size_above_baseline,
|
||||
other.block_size_above_baseline),
|
||||
depth_below_baseline: max(self.depth_below_baseline, other.depth_below_baseline),
|
||||
ascent: max(self.ascent, other.ascent),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -695,11 +695,10 @@ fn initial_computed_inline_size(block: &mut BlockFlow,
|
|||
containing_block_inline_size);
|
||||
match inline_size_from_style {
|
||||
MaybeAuto::Auto => {
|
||||
MaybeAuto::Specified(Au::max(containing_block_inline_size,
|
||||
minimum_width_of_all_columns))
|
||||
MaybeAuto::Specified(max(containing_block_inline_size, minimum_width_of_all_columns))
|
||||
}
|
||||
MaybeAuto::Specified(inline_size_from_style) => {
|
||||
MaybeAuto::Specified(Au::max(inline_size_from_style, minimum_width_of_all_columns))
|
||||
MaybeAuto::Specified(max(inline_size_from_style, minimum_width_of_all_columns))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue