Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Make numbers keep track of whether they were specified as calc(). #16144

Merged
merged 13 commits into from Mar 27, 2017
@@ -200,7 +200,7 @@ impl ToFilterOps for filter::T {
Filter::Brightness(amount) => result.push(webrender_traits::FilterOp::Brightness(amount)),
Filter::Contrast(amount) => result.push(webrender_traits::FilterOp::Contrast(amount)),
Filter::Grayscale(amount) => result.push(webrender_traits::FilterOp::Grayscale(amount)),
Filter::HueRotate(angle) => result.push(webrender_traits::FilterOp::HueRotate(angle.0)),
Filter::HueRotate(angle) => result.push(webrender_traits::FilterOp::HueRotate(angle.radians())),
Filter::Invert(amount) => result.push(webrender_traits::FilterOp::Invert(amount)),
Filter::Opacity(amount) => result.push(webrender_traits::FilterOp::Opacity(amount.into())),
Filter::Saturate(amount) => result.push(webrender_traits::FilterOp::Saturate(amount)),
@@ -496,8 +496,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
shared_lock,
PropertyDeclaration::BorderSpacing(
Box::new(border_spacing::SpecifiedValue {
horizontal: width_value.clone(),
vertical: width_value,
horizontal: width_value,
vertical: None,
}))));
}

@@ -343,7 +343,7 @@ impl PropertyAnimation {

#[inline]
fn does_animate(&self) -> bool {
self.property.does_animate() && self.duration != Time(0.0)
self.property.does_animate() && self.duration.seconds() != 0.0
}

/// Whether this animation has the same end value as another one.
@@ -681,7 +681,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
transition_property, name);
match PropertyAnimation::from_transition_property(*transition_property,
timing_function,
Time(relative_duration as f32),
Time::from_seconds(relative_duration as f32),
&from_style,
&target_style) {
Some(property_animation) => {
@@ -59,13 +59,16 @@ impl From<SpecifiedTimingFunction> for nsTimingFunction {

match function {
SpecifiedTimingFunction::Steps(steps, StartEnd::Start) => {
tf.set_as_step(nsTimingFunction_Type::StepStart, steps);
debug_assert!(steps.value() >= 0);
tf.set_as_step(nsTimingFunction_Type::StepStart, steps.value() as u32);
},
SpecifiedTimingFunction::Steps(steps, StartEnd::End) => {
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps);
debug_assert!(steps.value() >= 0);
tf.set_as_step(nsTimingFunction_Type::StepEnd, steps.value() as u32);
},
SpecifiedTimingFunction::CubicBezier(p1, p2) => {
tf.set_as_cubic_bezier(p1, p2);
tf.set_as_cubic_bezier(Point2D::new(p1.x.value, p1.y.value),
Point2D::new(p2.x.value, p2.y.value));
},
SpecifiedTimingFunction::Keyword(keyword) => {
match keyword {
@@ -1283,7 +1283,7 @@ fn static_assert() {
use properties::longhands::font_size_adjust::computed_value::T;
match v {
T::None => self.gecko.mFont.sizeAdjust = -1.0 as f32,
T::Number(n) => self.gecko.mFont.sizeAdjust = n.0 as f32,
T::Number(n) => self.gecko.mFont.sizeAdjust = n,
}
}

@@ -1293,11 +1293,10 @@ fn static_assert() {

pub fn clone_font_size_adjust(&self) -> longhands::font_size_adjust::computed_value::T {
use properties::longhands::font_size_adjust::computed_value::T;
use values::specified::Number;

match self.gecko.mFont.sizeAdjust {
-1.0 => T::None,
_ => T::Number(Number(self.gecko.mFont.sizeAdjust)),
_ => T::Number(self.gecko.mFont.sizeAdjust),
}
}

@@ -1356,8 +1355,8 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn ${type}_${ident}_at(&self, index: usize)
-> longhands::${type}_${ident}::computed_value::SingleComputedValue {
use values::specified::Time;
Time(self.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name} / 1000.)
use values::computed::Time;
Time::from_seconds(self.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name} / 1000.)
}
${impl_animation_or_transition_count(type, ident, gecko_ffi_name)}
${impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)}
@@ -1665,7 +1664,7 @@ fn static_assert() {
"length" : "bindings::Gecko_CSSValue_SetAbsoluteLength(%s, %s.0)",
"percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s)",
"lop" : "%s.set_lop(%s)",
"angle" : "bindings::Gecko_CSSValue_SetAngle(%s, %s.0)",
"angle" : "bindings::Gecko_CSSValue_SetAngle(%s, %s.radians())",
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
}
%>
@@ -1739,7 +1738,7 @@ fn static_assert() {
css_value_getters = {
"length" : "Au(bindings::Gecko_CSSValue_GetAbsoluteLength(%s))",
"lop" : "%s.get_lop()",
"angle" : "Angle(bindings::Gecko_CSSValue_GetAngle(%s))",
"angle" : "Angle::from_radians(bindings::Gecko_CSSValue_GetAngle(%s))",
"number" : "bindings::Gecko_CSSValue_GetNumber(%s)",
}
%>
@@ -19,8 +19,10 @@
#[inline] pub fn get_initial_specified_value() -> SpecifiedValue { ${initial_specified_value} }
% endif
#[allow(unused_variables)]
#[inline] pub fn parse(context: &ParserContext, input: &mut Parser)
-> Result<SpecifiedValue, ()> {
#[inline]
pub fn parse(context: &ParserContext,
input: &mut Parser)
-> Result<SpecifiedValue, ()> {
% if needs_context:
specified::${type}::${parse_method}(context, input)
% else:
@@ -36,7 +36,6 @@ use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
use values::computed::{MaxLength, MinLength};
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
use values::computed::ToComputedValue;
use values::specified::Angle as SpecifiedAngle;



@@ -455,7 +454,7 @@ impl Interpolate for i32 {
impl Interpolate for Angle {
#[inline]
fn interpolate(&self, other: &Angle, progress: f64) -> Result<Self, ()> {
self.radians().interpolate(&other.radians(), progress).map(Angle)
self.radians().interpolate(&other.radians(), progress).map(Angle::from_radians)
}
}

@@ -952,7 +951,7 @@ fn build_identity_transform_list(list: &[TransformOperation]) -> Vec<TransformOp
result.push(TransformOperation::Matrix(identity));
}
TransformOperation::Skew(..) => {
result.push(TransformOperation::Skew(Angle(0.0), Angle(0.0)));
result.push(TransformOperation::Skew(Angle::zero(), Angle::zero()))
}
TransformOperation::Translate(..) => {
result.push(TransformOperation::Translate(LengthOrPercentage::zero(),
@@ -963,7 +962,7 @@ fn build_identity_transform_list(list: &[TransformOperation]) -> Vec<TransformOp
result.push(TransformOperation::Scale(1.0, 1.0, 1.0));
}
TransformOperation::Rotate(..) => {
result.push(TransformOperation::Rotate(0.0, 0.0, 1.0, Angle(0.0)));
result.push(TransformOperation::Rotate(0.0, 0.0, 1.0, Angle::zero()));
}
TransformOperation::Perspective(..) => {
// http://dev.w3.org/csswg/css-transforms/#identity-transform-function
@@ -1052,7 +1051,7 @@ fn interpolate_transform_list(from_list: &[TransformOperation],
}

/// https://drafts.csswg.org/css-transforms/#Rotate3dDefined
fn rotate_to_matrix(x: f32, y: f32, z: f32, a: SpecifiedAngle) -> ComputedMatrix {
fn rotate_to_matrix(x: f32, y: f32, z: f32, a: Angle) -> ComputedMatrix {
let half_rad = a.radians() / 2.0;
let sc = (half_rad).sin() * (half_rad).cos();
let sq = (half_rad).sin().powi(2);
@@ -223,7 +223,7 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",

#[inline]
pub fn get_initial_specified_value() -> SpecifiedValue {
SpecifiedValue(vec![Either::Second(Number(0.0))])
SpecifiedValue(vec![Either::Second(Number::new(0.0))])
}

impl ToComputedValue for SpecifiedValue {
@@ -486,7 +486,7 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",

#[inline]
pub fn get_initial_specified_value() -> SpecifiedValue {
SpecifiedValue(vec![SingleSpecifiedValue::Number(Number(1.0))])
SpecifiedValue(vec![SingleSpecifiedValue::Number(Number::new(1.0))])
}

impl ToComputedValue for SpecifiedValue {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.