Rename MinLength to MozLength.

So that we can reuse this for non-min-prefixed properties (e.g. width).
This commit is contained in:
Hiroyuki Ikezoe 2017-05-20 11:58:58 +09:00
parent 95bda2dff9
commit 57c27e5d35
8 changed files with 59 additions and 58 deletions

View file

@ -675,7 +675,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
"LengthOrNone": impl_style_coord,
"LengthOrNormal": impl_style_coord,
"MaxLength": impl_style_coord,
"MinLength": impl_style_coord,
"MozLength": impl_style_coord,
"Number": impl_simple,
"Integer": impl_simple,
"Opacity": impl_simple,

View file

@ -41,7 +41,7 @@ use values::{Auto, Either, generics};
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{BorderRadiusSize, ClipRect};
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
use values::computed::{MaxLength, MinLength};
use values::computed::{MaxLength, MozLength};
use values::computed::ToComputedValue;
use values::generics::position as generic_position;
@ -1237,14 +1237,14 @@ impl Animatable for LengthOrPercentageOrNone {
}
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Animatable for MinLength {
impl Animatable for MozLength {
#[inline]
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
match (*self, *other) {
(MinLength::LengthOrPercentageOrAuto(ref this),
MinLength::LengthOrPercentageOrAuto(ref other)) => {
(MozLength::LengthOrPercentageOrAuto(ref this),
MozLength::LengthOrPercentageOrAuto(ref other)) => {
this.add_weighted(other, self_portion, other_portion)
.map(MinLength::LengthOrPercentageOrAuto)
.map(MozLength::LengthOrPercentageOrAuto)
}
_ => Err(()),
}
@ -1253,8 +1253,8 @@ impl Animatable for MinLength {
#[inline]
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
match (*self, *other) {
(MinLength::LengthOrPercentageOrAuto(ref this),
MinLength::LengthOrPercentageOrAuto(ref other)) => {
(MozLength::LengthOrPercentageOrAuto(ref this),
MozLength::LengthOrPercentageOrAuto(ref other)) => {
this.compute_distance(other)
},
_ => Err(()),

View file

@ -163,7 +163,7 @@ ${helpers.predefined_type("flex-basis",
% if product == "gecko":
% for min_max in ["min", "max"]:
<%
MinMax = min_max.title()
LengthType = "MaxLength" if "max" == min_max else "MozLength"
initial = "none()" if "max" == min_max else "auto()"
%>
@ -174,37 +174,38 @@ ${helpers.predefined_type("flex-basis",
// be replaced with auto/none in block.
<%helpers:longhand name="${min_max}-${size}" spec="${spec % ('%s-%s' % (min_max, size))}"
animation_value_type="ComputedValue"
logical="${logical}" predefined_type="${MinMax}Length">
logical="${logical}" predefined_type="${LengthType}">
use std::fmt;
use style_traits::ToCss;
% if not logical:
use values::specified::AllowQuirks;
% endif
use values::specified::${MinMax}Length;
use values::specified::${LengthType};
pub mod computed_value {
pub type T = ::values::computed::${MinMax}Length;
pub type T = ::values::computed::${LengthType};
}
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(${MinMax}Length);
pub struct SpecifiedValue(${LengthType});
#[inline]
pub fn get_initial_value() -> computed_value::T {
use values::computed::${MinMax}Length;
${MinMax}Length::${initial}
use values::computed::${LengthType};
${LengthType}::${initial}
}
fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
% if logical:
let ret = ${MinMax}Length::parse(context, input);
let ret = ${LengthType}::parse(context, input);
% else:
let ret = ${MinMax}Length::parse_quirky(context, input, AllowQuirks::Yes);
let ret = ${LengthType}::parse_quirky(context, input, AllowQuirks::Yes);
% endif
// Keyword values don't make sense in the block direction; don't parse them
% if "block" in size:
if let Ok(${MinMax}Length::ExtremumLength(..)) = ret {
if let Ok(${LengthType}::ExtremumLength(..)) = ret {
return Err(())
}
% endif
@ -222,19 +223,19 @@ ${helpers.predefined_type("flex-basis",
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
% if not logical or "block" in size:
use values::computed::${MinMax}Length;
use values::computed::${LengthType};
% endif
let computed = self.0.to_computed_value(context);
// filter out keyword values in the block direction
% if logical:
% if "block" in size:
if let ${MinMax}Length::ExtremumLength(..) = computed {
if let ${LengthType}::ExtremumLength(..) = computed {
return get_initial_value()
}
% endif
% else:
if let ${MinMax}Length::ExtremumLength(..) = computed {
if let ${LengthType}::ExtremumLength(..) = computed {
<% is_height = "true" if "height" in size else "false" %>
if ${is_height} != context.style().writing_mode.is_vertical() {
return get_initial_value()