Introduce CSSPixelLength and update NonNegativeLength.

First, we define computed::CSSPixelLength which contains a CSSFloat, a
pixel value, and then we replace computed::Length with CSSPixelLength.
Therefore, the |ComputedValue| of NoCalcLength, AbsoluteLength,
FontRelativeLength, ViewportPercentageLength, CharacterWidth, and
PhysicalLength is CSSPixelLength.

Besides, we drop NonNegativeAu, and replace computed::NonNegativeLength
with NonNegative<computed::Length>. (i.e. NonNegative<CSSPixelLength>)
This commit is contained in:
Boris Chiou 2017-09-13 14:26:51 +08:00
parent cad3aff508
commit a949e2a057
40 changed files with 502 additions and 406 deletions

View file

@ -26,7 +26,7 @@ use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::{Color, LengthOrPercentageOrAuto, NonNegativeAu};
use style::values::computed::{Color, LengthOrPercentageOrAuto, NonNegativeLength};
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow};
@ -94,8 +94,8 @@ impl TableRowFlow {
column_computed_inline_sizes: Vec::new(),
incoming_rowspan: Vec::new(),
spacing: border_spacing::T {
horizontal: NonNegativeAu::zero(),
vertical: NonNegativeAu::zero(),
horizontal: NonNegativeLength::zero(),
vertical: NonNegativeLength::zero(),
},
table_writing_mode: writing_mode,
preliminary_collapsed_borders: CollapsedBordersForRow::new(),
@ -396,7 +396,7 @@ impl Flow for TableRowFlow {
None => break,
};
column_computed_inline_size.size = column_computed_inline_size.size +
extra_column_computed_inline_size.size + self.spacing.horizontal.0;
extra_column_computed_inline_size.size + Au::from(self.spacing.horizontal);
col += 1;
}
@ -625,7 +625,7 @@ impl CollapsedBorder {
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_top_style,
width: css_style.get_border().border_top_width.0,
width: Au::from(css_style.get_border().border_top_width),
color: css_style.get_border().border_top_color,
provenance: provenance,
}
@ -637,7 +637,7 @@ impl CollapsedBorder {
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_right_style,
width: css_style.get_border().border_right_width.0,
width: Au::from(css_style.get_border().border_right_width),
color: css_style.get_border().border_right_color,
provenance: provenance,
}
@ -649,7 +649,7 @@ impl CollapsedBorder {
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_bottom_style,
width: css_style.get_border().border_bottom_width.0,
width: Au::from(css_style.get_border().border_bottom_width),
color: css_style.get_border().border_bottom_color,
provenance: provenance,
}
@ -661,7 +661,7 @@ impl CollapsedBorder {
-> CollapsedBorder {
CollapsedBorder {
style: css_style.get_border().border_left_style,
width: css_style.get_border().border_left_width.0,
width: Au::from(css_style.get_border().border_left_width),
color: css_style.get_border().border_left_color,
provenance: provenance,
}
@ -827,7 +827,7 @@ fn set_inline_position_of_child_flow(
let column_inline_size = column_computed_inline_sizes[*column_index].size;
let border_inline_size = match *border_collapse_info {
Some(_) => Au(0), // FIXME: Make collapsed borders account for colspan/rowspan.
None => border_spacing.horizontal.0,
None => Au::from(border_spacing.horizontal),
};
if reverse_column_order {
*inline_end_margin_edge += column_inline_size + border_inline_size;
@ -882,9 +882,9 @@ fn set_inline_position_of_child_flow(
None => {
// Take spacing into account.
if reverse_column_order {
*inline_end_margin_edge += border_spacing.horizontal.0;
*inline_end_margin_edge += Au::from(border_spacing.horizontal);
} else {
*inline_start_margin_edge += border_spacing.horizontal.0;
*inline_start_margin_edge += Au::from(border_spacing.horizontal);
}
}
}