mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
style: Manually rename some variables.
lop is not an acceptable variable name for LengthPercentage. Differential Revision: https://phabricator.services.mozilla.com/D15813
This commit is contained in:
parent
daf1f02feb
commit
80651fde47
14 changed files with 92 additions and 92 deletions
|
@ -185,7 +185,7 @@ impl GeckoStyleCoordConvertible for LengthPercentageOrAuto {
|
|||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
LengthPercentageOrAuto::Auto => coord.set_value(CoordDataValue::Auto),
|
||||
LengthPercentageOrAuto::LengthPercentage(ref lop) => lop.to_gecko_style_coord(coord),
|
||||
LengthPercentageOrAuto::LengthPercentage(ref lp) => lp.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ impl GeckoStyleCoordConvertible for LengthPercentageOrNone {
|
|||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
LengthPercentageOrNone::None => coord.set_value(CoordDataValue::None),
|
||||
LengthPercentageOrNone::LengthPercentage(ref lop) => lop.to_gecko_style_coord(coord),
|
||||
LengthPercentageOrNone::LengthPercentage(ref lp) => lp.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ impl GeckoStyleCoordConvertible for LengthPercentageOrNone {
|
|||
impl<L: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for TrackBreadth<L> {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
TrackBreadth::Breadth(ref lop) => lop.to_gecko_style_coord(coord),
|
||||
TrackBreadth::Breadth(ref lp) => lp.to_gecko_style_coord(coord),
|
||||
TrackBreadth::Fr(fr) => coord.set_value(CoordDataValue::FlexFraction(fr)),
|
||||
TrackBreadth::Keyword(TrackKeyword::Auto) => coord.set_value(CoordDataValue::Auto),
|
||||
TrackBreadth::Keyword(TrackKeyword::MinContent) => coord.set_value(
|
||||
|
@ -257,7 +257,7 @@ impl GeckoStyleCoordConvertible for ComputedShapeRadius {
|
|||
ShapeRadius::FarthestSide => coord.set_value(CoordDataValue::Enumerated(
|
||||
StyleShapeRadius::FarthestSide as u32,
|
||||
)),
|
||||
ShapeRadius::Length(lop) => lop.to_gecko_style_coord(coord),
|
||||
ShapeRadius::Length(lp) => lp.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ impl GeckoStyleCoordConvertible for ExtremumLength {
|
|||
impl GeckoStyleCoordConvertible for ComputedMozLength {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
MozLength::LengthPercentageOrAuto(ref lopoa) => lopoa.to_gecko_style_coord(coord),
|
||||
MozLength::LengthPercentageOrAuto(ref lpoa) => lpoa.to_gecko_style_coord(coord),
|
||||
MozLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ impl GeckoStyleCoordConvertible for ComputedMozLength {
|
|||
impl GeckoStyleCoordConvertible for ComputedMaxLength {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
MaxLength::LengthPercentageOrNone(ref lopon) => lopon.to_gecko_style_coord(coord),
|
||||
MaxLength::LengthPercentageOrNone(ref lpon) => lpon.to_gecko_style_coord(coord),
|
||||
MaxLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,15 +68,15 @@ impl nsCSSValue {
|
|||
}
|
||||
|
||||
/// Sets LengthPercentage value to this nsCSSValue.
|
||||
pub unsafe fn set_lop(&mut self, lop: LengthPercentage) {
|
||||
if lop.was_calc {
|
||||
return bindings::Gecko_CSSValue_SetCalc(self, lop.into())
|
||||
pub unsafe fn set_length_percentage(&mut self, lp: LengthPercentage) {
|
||||
if lp.was_calc {
|
||||
return bindings::Gecko_CSSValue_SetCalc(self, lp.into())
|
||||
}
|
||||
debug_assert!(lop.percentage.is_none() || lop.unclamped_length() == Length::zero());
|
||||
if let Some(p) = lop.percentage {
|
||||
debug_assert!(lp.percentage.is_none() || lp.unclamped_length() == Length::zero());
|
||||
if let Some(p) = lp.percentage {
|
||||
return self.set_percentage(p.0);
|
||||
}
|
||||
self.set_px(lop.unclamped_length().px());
|
||||
self.set_px(lp.unclamped_length().px());
|
||||
}
|
||||
|
||||
/// Sets a px value to this nsCSSValue.
|
||||
|
@ -90,7 +90,7 @@ impl nsCSSValue {
|
|||
}
|
||||
|
||||
/// Returns LengthPercentage value.
|
||||
pub unsafe fn get_lop(&self) -> LengthPercentage {
|
||||
pub unsafe fn get_length_percentage(&self) -> LengthPercentage {
|
||||
match self.mUnit {
|
||||
nsCSSUnit::eCSSUnit_Pixel => {
|
||||
LengthPercentage::new(
|
||||
|
|
|
@ -526,8 +526,8 @@ def set_gecko_property(ffi_name, expr):
|
|||
}
|
||||
};
|
||||
match length {
|
||||
SvgLengthPercentageOrNumber::LengthPercentage(lop) =>
|
||||
self.gecko.${gecko_ffi_name}.set(lop),
|
||||
SvgLengthPercentageOrNumber::LengthPercentage(lp) =>
|
||||
self.gecko.${gecko_ffi_name}.set(lp),
|
||||
SvgLengthPercentageOrNumber::Number(num) =>
|
||||
self.gecko.${gecko_ffi_name}.set_value(CoordDataValue::Factor(num.into())),
|
||||
}
|
||||
|
@ -939,10 +939,10 @@ def set_gecko_property(ffi_name, expr):
|
|||
transform_functions = [
|
||||
("Matrix3D", "matrix3d", ["number"] * 16),
|
||||
("Matrix", "matrix", ["number"] * 6),
|
||||
("Translate", "translate", ["lop", "optional_lop"]),
|
||||
("Translate3D", "translate3d", ["lop", "lop", "length"]),
|
||||
("TranslateX", "translatex", ["lop"]),
|
||||
("TranslateY", "translatey", ["lop"]),
|
||||
("Translate", "translate", ["lp", "optional_lp"]),
|
||||
("Translate3D", "translate3d", ["lp", "lp", "length"]),
|
||||
("TranslateX", "translatex", ["lp"]),
|
||||
("TranslateY", "translatey", ["lp"]),
|
||||
("TranslateZ", "translatez", ["length"]),
|
||||
("Scale3D", "scale3d", ["number"] * 3),
|
||||
("Scale", "scale", ["number", "optional_number"]),
|
||||
|
@ -993,7 +993,7 @@ transform_functions = [
|
|||
# Note: This is an integer type, but we use it as a percentage value in Gecko, so
|
||||
# need to cast it to f32.
|
||||
"integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)",
|
||||
"lop" : "%s.set_lop(%s)",
|
||||
"lp" : "%s.set_length_percentage(%s)",
|
||||
"angle" : "%s.set_angle(%s)",
|
||||
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
|
||||
# Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap
|
||||
|
@ -1042,8 +1042,8 @@ transform_functions = [
|
|||
# %s is substituted with the call to GetArrayItem.
|
||||
css_value_getters = {
|
||||
"length" : "Length::new(bindings::Gecko_CSSValue_GetNumber(%s))",
|
||||
"lop" : "%s.get_lop()",
|
||||
"lopon" : "Either::Second(%s.get_lop())",
|
||||
"lp" : "%s.get_length_percentage()",
|
||||
"lpon" : "Either::Second(%s.get_length_percentage())",
|
||||
"lon" : "Either::First(%s.get_length())",
|
||||
"angle" : "%s.get_angle()",
|
||||
"number" : "bindings::Gecko_CSSValue_GetNumber(%s)",
|
||||
|
@ -4568,7 +4568,7 @@ fn static_assert() {
|
|||
pub fn set_word_spacing(&mut self, v: longhands::word_spacing::computed_value::T) {
|
||||
use crate::values::generics::text::Spacing;
|
||||
match v {
|
||||
Spacing::Value(lop) => self.gecko.mWordSpacing.set(lop),
|
||||
Spacing::Value(lp) => self.gecko.mWordSpacing.set(lp),
|
||||
// https://drafts.csswg.org/css-text-3/#valdef-word-spacing-normal
|
||||
Spacing::Normal => self.gecko.mWordSpacing.set_value(CoordDataValue::Coord(0)),
|
||||
}
|
||||
|
@ -5027,8 +5027,8 @@ clip-path
|
|||
}
|
||||
for (gecko, servo) in self.gecko.mStrokeDasharray.iter_mut().zip(v) {
|
||||
match servo {
|
||||
SvgLengthPercentageOrNumber::LengthPercentage(lop) =>
|
||||
gecko.set(lop),
|
||||
SvgLengthPercentageOrNumber::LengthPercentage(lp) =>
|
||||
gecko.set(lp),
|
||||
SvgLengthPercentageOrNumber::Number(num) =>
|
||||
gecko.set_value(CoordDataValue::Factor(num.into())),
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ impl ToAnimatedValue for ComputedMaxLength {
|
|||
use crate::values::computed::LengthPercentageOrNone;
|
||||
use crate::values::generics::length::MaxLength as GenericMaxLength;
|
||||
match animated {
|
||||
GenericMaxLength::LengthPercentageOrNone(lopn) => {
|
||||
let result = match lopn {
|
||||
GenericMaxLength::LengthPercentageOrNone(lpn) => {
|
||||
let result = match lpn {
|
||||
LengthPercentageOrNone::LengthPercentage(len) => {
|
||||
LengthPercentageOrNone::LengthPercentage(len.clamp_to_non_negative())
|
||||
},
|
||||
LengthPercentageOrNone::None => lopn,
|
||||
LengthPercentageOrNone::None => lpn,
|
||||
};
|
||||
GenericMaxLength::LengthPercentageOrNone(result)
|
||||
},
|
||||
|
@ -77,8 +77,8 @@ impl ToAnimatedValue for ComputedMozLength {
|
|||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
use crate::values::generics::length::MozLength as GenericMozLength;
|
||||
match animated {
|
||||
GenericMozLength::LengthPercentageOrAuto(lopa) => {
|
||||
GenericMozLength::LengthPercentageOrAuto(lopa.clamp_to_non_negative())
|
||||
GenericMozLength::LengthPercentageOrAuto(lpa) => {
|
||||
GenericMozLength::LengthPercentageOrAuto(lpa.clamp_to_non_negative())
|
||||
},
|
||||
_ => animated,
|
||||
}
|
||||
|
|
|
@ -556,8 +556,8 @@ impl LengthPercentageOrNone {
|
|||
pub fn to_used_value(&self, containing_length: Au) -> Option<Au> {
|
||||
match *self {
|
||||
LengthPercentageOrNone::None => None,
|
||||
LengthPercentageOrNone::LengthPercentage(ref lop) => {
|
||||
Some(lop.to_used_value(containing_length))
|
||||
LengthPercentageOrNone::LengthPercentage(ref lp) => {
|
||||
Some(lp.to_used_value(containing_length))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -616,15 +616,15 @@ impl From<NonNegativeLength> for NonNegativeLengthPercentage {
|
|||
|
||||
impl From<LengthPercentage> for NonNegativeLengthPercentage {
|
||||
#[inline]
|
||||
fn from(lop: LengthPercentage) -> Self {
|
||||
NonNegative::<LengthPercentage>(lop)
|
||||
fn from(lp: LengthPercentage) -> Self {
|
||||
NonNegative::<LengthPercentage>(lp)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NonNegativeLengthPercentage> for LengthPercentage {
|
||||
#[inline]
|
||||
fn from(lop: NonNegativeLengthPercentage) -> LengthPercentage {
|
||||
lop.0
|
||||
fn from(lp: NonNegativeLengthPercentage) -> LengthPercentage {
|
||||
lp.0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ impl<L> TrackBreadth<L> {
|
|||
#[inline]
|
||||
pub fn is_fixed(&self) -> bool {
|
||||
match *self {
|
||||
TrackBreadth::Breadth(ref _lop) => true,
|
||||
TrackBreadth::Breadth(ref _lp) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -278,9 +278,9 @@ impl<L: ToCss> ToCss for TrackSize<L> {
|
|||
max.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
TrackSize::FitContent(ref lop) => {
|
||||
TrackSize::FitContent(ref lp) => {
|
||||
dest.write_str("fit-content(")?;
|
||||
lop.to_css(dest)?;
|
||||
lp.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
TrackSize::Minmax(ref b1, ref b2) => {
|
||||
TrackSize::Minmax(b1.to_computed_value(context), b2.to_computed_value(context))
|
||||
},
|
||||
TrackSize::FitContent(ref lop) => TrackSize::FitContent(lop.to_computed_value(context)),
|
||||
TrackSize::FitContent(ref lp) => TrackSize::FitContent(lp.to_computed_value(context)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,8 +322,8 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
ToComputedValue::from_computed_value(b1),
|
||||
ToComputedValue::from_computed_value(b2),
|
||||
),
|
||||
TrackSize::FitContent(ref lop) => {
|
||||
TrackSize::FitContent(ToComputedValue::from_computed_value(lop))
|
||||
TrackSize::FitContent(ref lp) => {
|
||||
TrackSize::FitContent(ToComputedValue::from_computed_value(lp))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,8 +162,8 @@ impl<LengthPercentageType: Parse, NumberType: Parse> Parse
|
|||
return Ok(SvgLengthPercentageOrNumber::Number(num));
|
||||
}
|
||||
|
||||
let lop = LengthPercentageType::parse(context, input)?;
|
||||
Ok(SvgLengthPercentageOrNumber::LengthPercentage(lop))
|
||||
let lp = LengthPercentageType::parse(context, input)?;
|
||||
Ok(SvgLengthPercentageOrNumber::LengthPercentage(lp))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -316,8 +316,8 @@ impl Parse for ShapeRadius {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(lop) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) {
|
||||
return Ok(generic::ShapeRadius::Length(lop));
|
||||
if let Ok(lp) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) {
|
||||
return Ok(generic::ShapeRadius::Length(lp));
|
||||
}
|
||||
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
|
|
|
@ -278,10 +278,10 @@ impl Parse for VerticalAlign {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(lop) =
|
||||
if let Ok(lp) =
|
||||
input.try(|i| LengthPercentage::parse_quirky(context, i, AllowQuirks::Yes))
|
||||
{
|
||||
return Ok(GenericVerticalAlign::Length(lop));
|
||||
return Ok(GenericVerticalAlign::Length(lp));
|
||||
}
|
||||
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
|
|
|
@ -985,10 +985,10 @@ impl FontSize {
|
|||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<FontSize, ParseError<'i>> {
|
||||
if let Ok(lop) =
|
||||
if let Ok(lp) =
|
||||
input.try(|i| LengthPercentage::parse_non_negative_quirky(context, i, allow_quirks))
|
||||
{
|
||||
return Ok(FontSize::Length(lop));
|
||||
return Ok(FontSize::Length(lp));
|
||||
}
|
||||
|
||||
if let Ok(kw) = input.try(KeywordSize::parse) {
|
||||
|
|
|
@ -32,8 +32,8 @@ impl Parse for TrackBreadth<LengthPercentage> {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(lop) = input.try(|i| LengthPercentage::parse_non_negative(context, i)) {
|
||||
return Ok(TrackBreadth::Breadth(lop));
|
||||
if let Ok(lp) = input.try(|i| LengthPercentage::parse_non_negative(context, i)) {
|
||||
return Ok(TrackBreadth::Breadth(lp));
|
||||
}
|
||||
|
||||
if let Ok(f) = input.try(parse_flex) {
|
||||
|
@ -57,7 +57,7 @@ impl Parse for TrackSize<LengthPercentage> {
|
|||
return input.parse_nested_block(|input| {
|
||||
let inflexible_breadth =
|
||||
match input.try(|i| LengthPercentage::parse_non_negative(context, i)) {
|
||||
Ok(lop) => TrackBreadth::Breadth(lop),
|
||||
Ok(lp) => TrackBreadth::Breadth(lp),
|
||||
Err(..) => {
|
||||
let keyword = TrackKeyword::parse(input)?;
|
||||
TrackBreadth::Keyword(keyword)
|
||||
|
@ -73,9 +73,9 @@ impl Parse for TrackSize<LengthPercentage> {
|
|||
}
|
||||
|
||||
input.expect_function_matching("fit-content")?;
|
||||
let lop =
|
||||
let lp =
|
||||
input.parse_nested_block(|i| LengthPercentage::parse_non_negative(context, i))?;
|
||||
Ok(TrackSize::FitContent(lop))
|
||||
Ok(TrackSize::FitContent(lp))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ pub type VerticalPosition = PositionComponent<Y>;
|
|||
pub enum PositionComponent<S> {
|
||||
/// `center`
|
||||
Center,
|
||||
/// `<lop>`
|
||||
/// `<length-percentage>`
|
||||
Length(LengthPercentage),
|
||||
/// `<side> <lop>?`
|
||||
/// `<side> <length-percentage>?`
|
||||
Side(S, Option<LengthPercentage>),
|
||||
}
|
||||
|
||||
|
@ -113,22 +113,22 @@ impl Position {
|
|||
let y_pos = PositionComponent::Center;
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Ok(PositionComponent::Side(x_keyword, lop)) => {
|
||||
Ok(PositionComponent::Side(x_keyword, lp)) => {
|
||||
if input.try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
let x_pos = PositionComponent::Side(x_keyword, lop);
|
||||
let x_pos = PositionComponent::Side(x_keyword, lp);
|
||||
let y_pos = PositionComponent::Center;
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_keyword) = input.try(Y::parse) {
|
||||
let y_lop = input
|
||||
let y_lp = input
|
||||
.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
let x_pos = PositionComponent::Side(x_keyword, lop);
|
||||
let y_pos = PositionComponent::Side(y_keyword, y_lop);
|
||||
let x_pos = PositionComponent::Side(x_keyword, lp);
|
||||
let y_pos = PositionComponent::Side(y_keyword, y_lp);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = PositionComponent::Side(x_keyword, None);
|
||||
let y_pos = lop.map_or(PositionComponent::Center, PositionComponent::Length);
|
||||
let y_pos = lp.map_or(PositionComponent::Center, PositionComponent::Length);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
},
|
||||
Ok(x_pos @ PositionComponent::Length(_)) => {
|
||||
|
@ -136,10 +136,10 @@ impl Position {
|
|||
let y_pos = PositionComponent::Side(y_keyword, None);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_lop) =
|
||||
if let Ok(y_lp) =
|
||||
input.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
let y_pos = PositionComponent::Length(y_lop);
|
||||
let y_pos = PositionComponent::Length(y_lp);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let y_pos = PositionComponent::Center;
|
||||
|
@ -149,23 +149,23 @@ impl Position {
|
|||
Err(_) => {},
|
||||
}
|
||||
let y_keyword = Y::parse(input)?;
|
||||
let lop_and_x_pos: Result<_, ParseError> = input.try(|i| {
|
||||
let y_lop = i
|
||||
let lp_and_x_pos: Result<_, ParseError> = input.try(|i| {
|
||||
let y_lp = i
|
||||
.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
if let Ok(x_keyword) = i.try(X::parse) {
|
||||
let x_lop = i
|
||||
let x_lp = i
|
||||
.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
let x_pos = PositionComponent::Side(x_keyword, x_lop);
|
||||
return Ok((y_lop, x_pos));
|
||||
let x_pos = PositionComponent::Side(x_keyword, x_lp);
|
||||
return Ok((y_lp, x_pos));
|
||||
};
|
||||
i.expect_ident_matching("center")?;
|
||||
let x_pos = PositionComponent::Center;
|
||||
Ok((y_lop, x_pos))
|
||||
Ok((y_lp, x_pos))
|
||||
});
|
||||
if let Ok((y_lop, x_pos)) = lop_and_x_pos {
|
||||
let y_pos = PositionComponent::Side(y_keyword, y_lop);
|
||||
if let Ok((y_lp, x_pos)) = lp_and_x_pos {
|
||||
let y_pos = PositionComponent::Side(y_keyword, y_lp);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = PositionComponent::Center;
|
||||
|
@ -188,18 +188,18 @@ impl ToCss for Position {
|
|||
match (&self.horizontal, &self.vertical) {
|
||||
(
|
||||
x_pos @ &PositionComponent::Side(_, Some(_)),
|
||||
&PositionComponent::Length(ref y_lop),
|
||||
&PositionComponent::Length(ref y_lp),
|
||||
) => {
|
||||
x_pos.to_css(dest)?;
|
||||
dest.write_str(" top ")?;
|
||||
y_lop.to_css(dest)
|
||||
y_lp.to_css(dest)
|
||||
},
|
||||
(
|
||||
&PositionComponent::Length(ref x_lop),
|
||||
&PositionComponent::Length(ref x_lp),
|
||||
y_pos @ &PositionComponent::Side(_, Some(_)),
|
||||
) => {
|
||||
dest.write_str("left ")?;
|
||||
x_lop.to_css(dest)?;
|
||||
x_lp.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
y_pos.to_css(dest)
|
||||
},
|
||||
|
@ -231,14 +231,14 @@ impl<S: Parse> PositionComponent<S> {
|
|||
if input.try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
return Ok(PositionComponent::Center);
|
||||
}
|
||||
if let Ok(lop) = input.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks)) {
|
||||
return Ok(PositionComponent::Length(lop));
|
||||
if let Ok(lp) = input.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks)) {
|
||||
return Ok(PositionComponent::Length(lp));
|
||||
}
|
||||
let keyword = S::parse(context, input)?;
|
||||
let lop = input
|
||||
let lp = input
|
||||
.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
.ok();
|
||||
Ok(PositionComponent::Side(keyword, lop))
|
||||
Ok(PositionComponent::Side(keyword, lp))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,10 +371,10 @@ impl LegacyPosition {
|
|||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let x_pos = OriginComponent::Side(x_keyword);
|
||||
if let Ok(y_lop) =
|
||||
if let Ok(y_lp) =
|
||||
input.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
return Ok(Self::new(x_pos, OriginComponent::Length(y_lop)));
|
||||
return Ok(Self::new(x_pos, OriginComponent::Length(y_lp)));
|
||||
}
|
||||
let _ = input.try(|i| i.expect_ident_matching("center"));
|
||||
return Ok(Self::new(x_pos, OriginComponent::Center));
|
||||
|
@ -384,10 +384,10 @@ impl LegacyPosition {
|
|||
let y_pos = OriginComponent::Side(y_keyword);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
if let Ok(y_lop) =
|
||||
if let Ok(y_lp) =
|
||||
input.try(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
|
||||
{
|
||||
let y_pos = OriginComponent::Length(y_lop);
|
||||
let y_pos = OriginComponent::Length(y_lp);
|
||||
return Ok(Self::new(x_pos, y_pos));
|
||||
}
|
||||
let _ = input.try(|i| i.expect_ident_matching("center"));
|
||||
|
|
|
@ -83,8 +83,8 @@ impl Parse for LineHeight {
|
|||
if let Ok(number) = input.try(|i| NonNegativeNumber::parse(context, i)) {
|
||||
return Ok(GenericLineHeight::Number(number));
|
||||
}
|
||||
if let Ok(nlop) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) {
|
||||
return Ok(GenericLineHeight::Length(nlop));
|
||||
if let Ok(nlp) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) {
|
||||
return Ok(GenericLineHeight::Length(nlp));
|
||||
}
|
||||
let location = input.current_source_location();
|
||||
let ident = input.expect_ident()?;
|
||||
|
@ -116,8 +116,8 @@ impl ToComputedValue for LineHeight {
|
|||
GenericLineHeight::Number(number) => {
|
||||
GenericLineHeight::Number(number.to_computed_value(context))
|
||||
},
|
||||
GenericLineHeight::Length(ref non_negative_lop) => {
|
||||
let result = match non_negative_lop.0 {
|
||||
GenericLineHeight::Length(ref non_negative_lp) => {
|
||||
let result = match non_negative_lp.0 {
|
||||
LengthPercentage::Length(NoCalcLength::Absolute(ref abs)) => {
|
||||
context
|
||||
.maybe_zoom_text(abs.to_computed_value(context).into())
|
||||
|
|
|
@ -235,7 +235,7 @@ impl Parse for Transform {
|
|||
pub enum OriginComponent<S> {
|
||||
/// `center`
|
||||
Center,
|
||||
/// `<lop>`
|
||||
/// `<length-percentage>`
|
||||
Length(LengthPercentage),
|
||||
/// `<side>`
|
||||
Side(S),
|
||||
|
@ -306,8 +306,8 @@ where
|
|||
if input.try(|i| i.expect_ident_matching("center")).is_ok() {
|
||||
return Ok(OriginComponent::Center);
|
||||
}
|
||||
if let Ok(lop) = input.try(|i| LengthPercentage::parse(context, i)) {
|
||||
return Ok(OriginComponent::Length(lop));
|
||||
if let Ok(lp) = input.try(|i| LengthPercentage::parse(context, i)) {
|
||||
return Ok(OriginComponent::Length(lp));
|
||||
}
|
||||
let keyword = S::parse(context, input)?;
|
||||
Ok(OriginComponent::Side(keyword))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue