Refactor and modify stuff to make use of NoCalcLength

This commit is contained in:
Ravi Shankar 2017-01-16 01:34:54 +05:30
parent 4035bbd738
commit 377a23df50
14 changed files with 83 additions and 67 deletions

View file

@ -4,7 +4,6 @@
//! Element nodes.
use app_units::Au;
use cssparser::Color;
use devtools_traits::AttrInfo;
use dom::activation::Activatable;
@ -476,7 +475,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
};
if let Some(cellspacing) = cellspacing {
let width_value = specified::Length::Absolute(Au::from_px(cellspacing as i32));
let width_value = specified::Length::from_px(cellspacing as f32);
hints.push(from_declaration(
PropertyDeclaration::BorderSpacing(DeclaredValue::Value(
border_spacing::SpecifiedValue {
@ -509,7 +508,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
};
if let Some(size) = size {
let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(size));
let value = specified::Length::NoCalc(
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size)));
hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
@ -541,7 +541,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
}
LengthOrPercentageOrAuto::Length(length) => {
let width_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length));
specified::Length::NoCalc(specified::NoCalcLength::Absolute(length)));
hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value(width_value))));
}
@ -566,7 +566,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
}
LengthOrPercentageOrAuto::Length(length) => {
let height_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length));
specified::Length::NoCalc(specified::NoCalcLength::Absolute(length)));
hints.push(from_declaration(
PropertyDeclaration::Height(DeclaredValue::Value(height_value))));
}
@ -588,7 +588,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// scrollbar size into consideration (but we don't have a scrollbar yet!)
//
// https://html.spec.whatwg.org/multipage/#textarea-effective-width
let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(cols));
let value = specified::Length::NoCalc(
specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols)));
hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
@ -608,7 +609,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// TODO(mttr) This should take scrollbar size into consideration.
//
// https://html.spec.whatwg.org/multipage/#textarea-effective-height
let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat));
let value = specified::Length::NoCalc(
specified::NoCalcLength::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)));
hints.push(from_declaration(
PropertyDeclaration::Height(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
@ -622,8 +624,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
};
if let Some(border) = border {
let width_value = specified::BorderWidth::from_length(
specified::Length::Absolute(Au::from_px(border as i32)));
let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32));
hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(width_value.clone()))));
hints.push(from_declaration(