mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use CSSPixelLength in LengthOrPercentage{*}.
Replace Au with CSSPixelLength in LengthOrPercentage, LengthOrPercentageOrAuto, and LengthOrPercentageOrNone.
This commit is contained in:
parent
535c1e3c6f
commit
b89286e8e7
25 changed files with 109 additions and 118 deletions
|
@ -329,7 +329,7 @@ impl CandidateBSizeIterator {
|
|||
}
|
||||
(LengthOrPercentageOrAuto::Percentage(_), None) |
|
||||
(LengthOrPercentageOrAuto::Auto, _) => MaybeAuto::Auto,
|
||||
(LengthOrPercentageOrAuto::Length(length), _) => MaybeAuto::Specified(length),
|
||||
(LengthOrPercentageOrAuto::Length(length), _) => MaybeAuto::Specified(Au::from(length)),
|
||||
};
|
||||
let max_block_size = match (fragment.style.max_block_size(), block_container_block_size) {
|
||||
(LengthOrPercentageOrNone::Percentage(percent), Some(block_container_block_size)) => {
|
||||
|
@ -340,7 +340,7 @@ impl CandidateBSizeIterator {
|
|||
}
|
||||
(LengthOrPercentageOrNone::Percentage(_), None) |
|
||||
(LengthOrPercentageOrNone::None, _) => None,
|
||||
(LengthOrPercentageOrNone::Length(length), _) => Some(length),
|
||||
(LengthOrPercentageOrNone::Length(length), _) => Some(Au::from(length)),
|
||||
};
|
||||
let min_block_size = match (fragment.style.min_block_size(), block_container_block_size) {
|
||||
(LengthOrPercentage::Percentage(percent), Some(block_container_block_size)) => {
|
||||
|
@ -350,7 +350,7 @@ impl CandidateBSizeIterator {
|
|||
calc.to_used_value(block_container_block_size).unwrap_or(Au(0))
|
||||
}
|
||||
(LengthOrPercentage::Percentage(_), None) => Au(0),
|
||||
(LengthOrPercentage::Length(length), _) => length,
|
||||
(LengthOrPercentage::Length(length), _) => Au::from(length),
|
||||
};
|
||||
|
||||
// If the style includes `box-sizing: border-box`, subtract the border and padding.
|
||||
|
@ -1172,7 +1172,7 @@ impl BlockFlow {
|
|||
(LengthOrPercentageOrAuto::Calc(calc), _) => {
|
||||
calc.to_used_value(containing_block_size)
|
||||
}
|
||||
(LengthOrPercentageOrAuto::Length(length), _) => Some(length),
|
||||
(LengthOrPercentageOrAuto::Length(length), _) => Some(Au::from(length)),
|
||||
(LengthOrPercentageOrAuto::Percentage(percent), Some(container_size)) => {
|
||||
Some(container_size.scale_by(percent.0))
|
||||
}
|
||||
|
|
|
@ -3039,7 +3039,7 @@ struct StopRun {
|
|||
|
||||
fn position_to_offset(position: LengthOrPercentage, total_length: Au) -> f32 {
|
||||
match position {
|
||||
LengthOrPercentage::Length(Au(length)) => length as f32 / total_length.0 as f32,
|
||||
LengthOrPercentage::Length(l) => l.to_i32_au() as f32 / total_length.0 as f32,
|
||||
LengthOrPercentage::Percentage(percentage) => percentage.0 as f32,
|
||||
LengthOrPercentage::Calc(calc) => {
|
||||
calc.to_used_value(Some(total_length)).unwrap().0 as f32 / total_length.0 as f32
|
||||
|
|
|
@ -45,7 +45,7 @@ impl AxisSize {
|
|||
pub fn new(size: LengthOrPercentageOrAuto, content_size: Option<Au>, min: LengthOrPercentage,
|
||||
max: LengthOrPercentageOrNone) -> AxisSize {
|
||||
match size {
|
||||
LengthOrPercentageOrAuto::Length(length) => AxisSize::Definite(length),
|
||||
LengthOrPercentageOrAuto::Length(length) => AxisSize::Definite(Au::from(length)),
|
||||
LengthOrPercentageOrAuto::Percentage(percent) => {
|
||||
match content_size {
|
||||
Some(size) => AxisSize::Definite(size.scale_by(percent.0)),
|
||||
|
@ -76,7 +76,7 @@ fn from_flex_basis(
|
|||
) -> MaybeAuto {
|
||||
match (flex_basis, containing_length) {
|
||||
(GenericFlexBasis::Length(LengthOrPercentage::Length(length)), _) =>
|
||||
MaybeAuto::Specified(length),
|
||||
MaybeAuto::Specified(Au::from(length)),
|
||||
(GenericFlexBasis::Length(LengthOrPercentage::Percentage(percent)), Some(size)) =>
|
||||
MaybeAuto::Specified(size.scale_by(percent.0)),
|
||||
(GenericFlexBasis::Length(LengthOrPercentage::Percentage(_)), None) =>
|
||||
|
@ -89,7 +89,7 @@ fn from_flex_basis(
|
|||
MaybeAuto::from_style(main_length, size),
|
||||
(GenericFlexBasis::Auto, None) => {
|
||||
if let LengthOrPercentageOrAuto::Length(length) = main_length {
|
||||
MaybeAuto::Specified(length)
|
||||
MaybeAuto::Specified(Au::from(length))
|
||||
} else {
|
||||
MaybeAuto::Auto
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ use style::selector_parser::RestyleDamage;
|
|||
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
|
||||
use style::str::char_is_whitespace;
|
||||
use style::values::{self, Either, Auto};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::generics::box_::VerticalAlign;
|
||||
use text;
|
||||
use text::TextRunScanner;
|
||||
|
@ -1516,7 +1516,7 @@ impl Fragment {
|
|||
let (result_inline, _) = self.calculate_replaced_sizes(None, None);
|
||||
result_inline
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => length,
|
||||
LengthOrPercentageOrAuto::Length(length) => Au::from(length),
|
||||
LengthOrPercentageOrAuto::Calc(calc) => {
|
||||
// TODO(nox): This is probably wrong, because it accounts neither for
|
||||
// clamping (not sure if necessary here) nor percentage.
|
||||
|
@ -2261,7 +2261,7 @@ impl Fragment {
|
|||
}
|
||||
}
|
||||
VerticalAlign::Length(LengthOrPercentage::Length(length)) => {
|
||||
offset -= length
|
||||
offset -= Au::from(length)
|
||||
}
|
||||
VerticalAlign::Length(LengthOrPercentage::Percentage(percentage)) => {
|
||||
offset -= minimum_line_metrics.space_needed().scale_by(percentage.0)
|
||||
|
@ -2336,11 +2336,11 @@ impl Fragment {
|
|||
continue
|
||||
}
|
||||
if inline_context_node.style.logical_margin().inline_end !=
|
||||
LengthOrPercentageOrAuto::Length(Au(0)) {
|
||||
LengthOrPercentageOrAuto::Length(Length::new(0.)) {
|
||||
return false
|
||||
}
|
||||
if inline_context_node.style.logical_padding().inline_end !=
|
||||
LengthOrPercentage::Length(Au(0)) {
|
||||
LengthOrPercentage::Length(Length::new(0.)) {
|
||||
return false
|
||||
}
|
||||
if inline_context_node.style.logical_border_width().inline_end != Au(0) {
|
||||
|
@ -2357,11 +2357,11 @@ impl Fragment {
|
|||
continue
|
||||
}
|
||||
if inline_context_node.style.logical_margin().inline_start !=
|
||||
LengthOrPercentageOrAuto::Length(Au(0)) {
|
||||
LengthOrPercentageOrAuto::Length(Length::new(0.)) {
|
||||
return false
|
||||
}
|
||||
if inline_context_node.style.logical_padding().inline_start !=
|
||||
LengthOrPercentage::Length(Au(0)) {
|
||||
LengthOrPercentage::Length(Length::new(0.)) {
|
||||
return false
|
||||
}
|
||||
if inline_context_node.style.logical_border_width().inline_start != Au(0) {
|
||||
|
|
|
@ -141,7 +141,7 @@ impl MarginCollapseInfo {
|
|||
may_collapse_through = may_collapse_through &&
|
||||
match fragment.style().content_block_size() {
|
||||
LengthOrPercentageOrAuto::Auto => true,
|
||||
LengthOrPercentageOrAuto::Length(Au(v)) => v == 0,
|
||||
LengthOrPercentageOrAuto::Length(l) => l.px() == 0.,
|
||||
LengthOrPercentageOrAuto::Percentage(v) => {
|
||||
v.0 == 0. || containing_block_size.is_none()
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ impl MarginCollapseInfo {
|
|||
|
||||
if may_collapse_through {
|
||||
match fragment.style().min_block_size() {
|
||||
LengthOrPercentage::Length(Au(0)) => {
|
||||
LengthOrPercentage::Length(l) if l.px() == 0. => {
|
||||
FinalMarginState::MarginsCollapseThrough
|
||||
},
|
||||
LengthOrPercentage::Percentage(v) if v.0 == 0. => {
|
||||
|
@ -412,7 +412,7 @@ impl MaybeAuto {
|
|||
LengthOrPercentageOrAuto::Calc(calc) => {
|
||||
MaybeAuto::from_option(calc.to_used_value(Some(containing_length)))
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => MaybeAuto::Specified(length)
|
||||
LengthOrPercentageOrAuto::Length(length) => MaybeAuto::Specified(Au::from(length))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ pub fn style_length(style_length: LengthOrPercentageOrAuto,
|
|||
match container_size {
|
||||
Some(length) => MaybeAuto::from_style(style_length, length),
|
||||
None => if let LengthOrPercentageOrAuto::Length(length) = style_length {
|
||||
MaybeAuto::Specified(length)
|
||||
MaybeAuto::Specified(Au::from(length))
|
||||
} else {
|
||||
MaybeAuto::Auto
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ impl SizeConstraint {
|
|||
let mut min_size = match container_size {
|
||||
Some(container_size) => min_size.to_used_value(container_size),
|
||||
None => if let LengthOrPercentage::Length(length) = min_size {
|
||||
length
|
||||
Au::from(length)
|
||||
} else {
|
||||
Au(0)
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ impl SizeConstraint {
|
|||
let mut max_size = match container_size {
|
||||
Some(container_size) => max_size.to_used_value(container_size),
|
||||
None => if let LengthOrPercentageOrNone::Length(length) = max_size {
|
||||
Some(length)
|
||||
Some(Au::from(length))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -136,9 +136,9 @@ impl Flow for MulticolFlow {
|
|||
available_block_size: {
|
||||
let style = &self.block_flow.fragment.style;
|
||||
if let LengthOrPercentageOrAuto::Length(length) = style.content_block_size() {
|
||||
length
|
||||
Au::from(length)
|
||||
} else if let LengthOrPercentageOrNone::Length(length) = style.max_block_size() {
|
||||
length
|
||||
Au::from(length)
|
||||
} else {
|
||||
// FIXME: do column balancing instead
|
||||
// FIXME: (until column balancing) substract margins/borders/padding
|
||||
|
|
|
@ -248,7 +248,7 @@ impl Flow for TableFlow {
|
|||
LengthOrPercentageOrAuto::Auto |
|
||||
LengthOrPercentageOrAuto::Calc(_) |
|
||||
LengthOrPercentageOrAuto::Percentage(_) => Au(0),
|
||||
LengthOrPercentageOrAuto::Length(length) => length,
|
||||
LengthOrPercentageOrAuto::Length(length) => Au::from(length),
|
||||
},
|
||||
percentage: match *specified_inline_size {
|
||||
LengthOrPercentageOrAuto::Auto |
|
||||
|
|
|
@ -305,7 +305,7 @@ impl Flow for TableRowFlow {
|
|||
LengthOrPercentageOrAuto::Percentage(_) => {
|
||||
child_base.intrinsic_inline_sizes.minimum_inline_size
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => length,
|
||||
LengthOrPercentageOrAuto::Length(length) => Au::from(length),
|
||||
},
|
||||
percentage: match child_specified_inline_size {
|
||||
LengthOrPercentageOrAuto::Auto |
|
||||
|
|
|
@ -50,9 +50,9 @@ impl From<nsStyleCoord_CalcValue> for CalcLengthOrPercentage {
|
|||
impl From<LengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: LengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
match other {
|
||||
LengthOrPercentage::Length(au) => {
|
||||
LengthOrPercentage::Length(px) => {
|
||||
nsStyleCoord_CalcValue {
|
||||
mLength: au.0,
|
||||
mLength: px.to_i32_au(),
|
||||
mPercent: 0.0,
|
||||
mHasPercent: false,
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ impl LengthOrPercentageOrAuto {
|
|||
/// Convert this value in an appropriate `nsStyleCoord::CalcValue`.
|
||||
pub fn to_calc_value(&self) -> Option<nsStyleCoord_CalcValue> {
|
||||
match *self {
|
||||
LengthOrPercentageOrAuto::Length(au) => {
|
||||
LengthOrPercentageOrAuto::Length(px) => {
|
||||
Some(nsStyleCoord_CalcValue {
|
||||
mLength: au.0,
|
||||
mLength: px.to_i32_au(),
|
||||
mPercent: 0.0,
|
||||
mHasPercent: false,
|
||||
})
|
||||
|
@ -96,7 +96,7 @@ impl LengthOrPercentageOrAuto {
|
|||
impl From<nsStyleCoord_CalcValue> for LengthOrPercentage {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> LengthOrPercentage {
|
||||
match (other.mHasPercent, other.mLength) {
|
||||
(false, _) => LengthOrPercentage::Length(Au(other.mLength)),
|
||||
(false, _) => LengthOrPercentage::Length(Au(other.mLength).into()),
|
||||
(true, 0) => LengthOrPercentage::Percentage(Percentage(other.mPercent)),
|
||||
_ => LengthOrPercentage::Calc(other.into()),
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl From<nsStyleCoord_CalcValue> for LengthOrPercentage {
|
|||
impl From<nsStyleCoord_CalcValue> for LengthOrPercentageOrAuto {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> LengthOrPercentageOrAuto {
|
||||
match (other.mHasPercent, other.mLength) {
|
||||
(false, _) => LengthOrPercentageOrAuto::Length(Au(other.mLength)),
|
||||
(false, _) => LengthOrPercentageOrAuto::Length(Au(other.mLength).into()),
|
||||
(true, 0) => LengthOrPercentageOrAuto::Percentage(Percentage(other.mPercent)),
|
||||
_ => LengthOrPercentageOrAuto::Calc(other.into()),
|
||||
}
|
||||
|
|
|
@ -1342,10 +1342,6 @@ extern "C" {
|
|||
pub fn Gecko_CSSValue_GetArrayItemConst(css_value: nsCSSValueBorrowed,
|
||||
index: i32) -> nsCSSValueBorrowed;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_GetAbsoluteLength(css_value: nsCSSValueBorrowed)
|
||||
-> nscoord;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_GetKeyword(aCSSValue: nsCSSValueBorrowed)
|
||||
-> nsCSSKeyword;
|
||||
|
@ -1360,10 +1356,6 @@ extern "C" {
|
|||
pub fn Gecko_CSSValue_GetCalc(aCSSValue: nsCSSValueBorrowed)
|
||||
-> nsStyleCoord_CalcValue;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_SetAbsoluteLength(css_value: nsCSSValueBorrowedMut,
|
||||
len: nscoord);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CSSValue_SetNumber(css_value: nsCSSValueBorrowedMut,
|
||||
number: f32);
|
||||
|
|
|
@ -106,7 +106,7 @@ impl GeckoStyleCoordConvertible for NumberOrPercentage {
|
|||
impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
let value = match *self {
|
||||
LengthOrPercentage::Length(au) => CoordDataValue::Coord(au.0),
|
||||
LengthOrPercentage::Length(px) => CoordDataValue::Coord(px.to_i32_au()),
|
||||
LengthOrPercentage::Percentage(p) => CoordDataValue::Percent(p.0),
|
||||
LengthOrPercentage::Calc(calc) => CoordDataValue::Calc(calc.into()),
|
||||
};
|
||||
|
@ -115,7 +115,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
|||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentage::Length(Au(coord))),
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentage::Length(Au(coord).into())),
|
||||
CoordDataValue::Percent(p) => Some(LengthOrPercentage::Percentage(Percentage(p))),
|
||||
CoordDataValue::Calc(calc) => Some(LengthOrPercentage::Calc(calc.into())),
|
||||
_ => None,
|
||||
|
@ -169,7 +169,7 @@ impl GeckoStyleCoordConvertible for NonNegativeNumber {
|
|||
impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
let value = match *self {
|
||||
LengthOrPercentageOrAuto::Length(au) => CoordDataValue::Coord(au.0),
|
||||
LengthOrPercentageOrAuto::Length(px) => CoordDataValue::Coord(px.to_i32_au()),
|
||||
LengthOrPercentageOrAuto::Percentage(p) => CoordDataValue::Percent(p.0),
|
||||
LengthOrPercentageOrAuto::Auto => CoordDataValue::Auto,
|
||||
LengthOrPercentageOrAuto::Calc(calc) => CoordDataValue::Calc(calc.into()),
|
||||
|
@ -179,7 +179,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
|||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentageOrAuto::Length(Au(coord))),
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentageOrAuto::Length(Au(coord).into())),
|
||||
CoordDataValue::Percent(p) => Some(LengthOrPercentageOrAuto::Percentage(Percentage(p))),
|
||||
CoordDataValue::Auto => Some(LengthOrPercentageOrAuto::Auto),
|
||||
CoordDataValue::Calc(calc) => Some(LengthOrPercentageOrAuto::Calc(calc.into())),
|
||||
|
@ -191,7 +191,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
|||
impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
let value = match *self {
|
||||
LengthOrPercentageOrNone::Length(au) => CoordDataValue::Coord(au.0),
|
||||
LengthOrPercentageOrNone::Length(px) => CoordDataValue::Coord(px.to_i32_au()),
|
||||
LengthOrPercentageOrNone::Percentage(p) => CoordDataValue::Percent(p.0),
|
||||
LengthOrPercentageOrNone::None => CoordDataValue::None,
|
||||
LengthOrPercentageOrNone::Calc(calc) => CoordDataValue::Calc(calc.into()),
|
||||
|
@ -201,7 +201,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
|||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentageOrNone::Length(Au(coord))),
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrPercentageOrNone::Length(Au(coord).into())),
|
||||
CoordDataValue::Percent(p) => Some(LengthOrPercentageOrNone::Percentage(Percentage(p))),
|
||||
CoordDataValue::None => Some(LengthOrPercentageOrNone::None),
|
||||
CoordDataValue::Calc(calc) => Some(LengthOrPercentageOrNone::Calc(calc.into())),
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! Little helpers for `nsCSSValue`.
|
||||
|
||||
use app_units::Au;
|
||||
use gecko_bindings::bindings;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::{nsCSSValue, nsCSSUnit};
|
||||
|
@ -75,8 +74,8 @@ impl nsCSSValue {
|
|||
/// Sets LengthOrPercentage value to this nsCSSValue.
|
||||
pub unsafe fn set_lop(&mut self, lop: LengthOrPercentage) {
|
||||
match lop {
|
||||
LengthOrPercentage::Length(au) => {
|
||||
bindings::Gecko_CSSValue_SetAbsoluteLength(self, au.0)
|
||||
LengthOrPercentage::Length(px) => {
|
||||
bindings::Gecko_CSSValue_SetPixelLength(self, px.px())
|
||||
}
|
||||
LengthOrPercentage::Percentage(pc) => {
|
||||
bindings::Gecko_CSSValue_SetPercentage(self, pc.0)
|
||||
|
@ -89,9 +88,10 @@ impl nsCSSValue {
|
|||
|
||||
/// Returns LengthOrPercentage value.
|
||||
pub unsafe fn get_lop(&self) -> LengthOrPercentage {
|
||||
use values::computed::Length;
|
||||
match self.mUnit {
|
||||
nsCSSUnit::eCSSUnit_Pixel => {
|
||||
LengthOrPercentage::Length(Au(bindings::Gecko_CSSValue_GetAbsoluteLength(self)))
|
||||
LengthOrPercentage::Length(Length::new(bindings::Gecko_CSSValue_GetNumber(self)))
|
||||
},
|
||||
nsCSSUnit::eCSSUnit_Percent => {
|
||||
LengthOrPercentage::Percentage(Percentage(bindings::Gecko_CSSValue_GetPercentage(self)))
|
||||
|
|
|
@ -633,7 +633,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
SvgLengthOrPercentageOrNumber::Number(number),
|
||||
CoordDataValue::Coord(coord) =>
|
||||
SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Length(Au(coord))),
|
||||
LengthOrPercentage::Length(Au(coord).into())),
|
||||
CoordDataValue::Percent(p) =>
|
||||
SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Percentage(Percentage(p))),
|
||||
|
@ -5210,7 +5210,7 @@ clip-path
|
|||
vec.push(SvgLengthOrPercentageOrNumber::Number(number.into())),
|
||||
CoordDataValue::Coord(coord) =>
|
||||
vec.push(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Length(Au(coord)).into())),
|
||||
LengthOrPercentage::Length(Au(coord).into()).into())),
|
||||
CoordDataValue::Percent(p) =>
|
||||
vec.push(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Percentage(Percentage(p)).into())),
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<% from data import to_idl_name, SYSTEM_FONT_LONGHANDS %>
|
||||
|
||||
use app_units::Au;
|
||||
use cssparser::Parser;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
|
@ -47,7 +46,7 @@ use values::animated::effects::FilterList as AnimatedFilterList;
|
|||
use values::animated::effects::TextShadowList as AnimatedTextShadowList;
|
||||
use values::computed::{Angle, BorderCornerRadius, CalcLengthOrPercentage};
|
||||
use values::computed::{ClipRect, Context, ComputedUrl};
|
||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{LengthOrPercentageOrNone, MaxLength, NonNegativeLength};
|
||||
use values::computed::{NonNegativeNumber, Number, NumberOrPercentage, Percentage};
|
||||
use values::computed::{PositiveIntegerOrAuto, ToComputedValue};
|
||||
|
@ -813,7 +812,7 @@ impl ToAnimatedZero for LengthOrPercentageOrAuto {
|
|||
LengthOrPercentageOrAuto::Length(_) |
|
||||
LengthOrPercentageOrAuto::Percentage(_) |
|
||||
LengthOrPercentageOrAuto::Calc(_) => {
|
||||
Ok(LengthOrPercentageOrAuto::Length(Au(0)))
|
||||
Ok(LengthOrPercentageOrAuto::Length(Length::new(0.)))
|
||||
},
|
||||
LengthOrPercentageOrAuto::Auto => Err(()),
|
||||
}
|
||||
|
@ -827,7 +826,7 @@ impl ToAnimatedZero for LengthOrPercentageOrNone {
|
|||
LengthOrPercentageOrNone::Length(_) |
|
||||
LengthOrPercentageOrNone::Percentage(_) |
|
||||
LengthOrPercentageOrNone::Calc(_) => {
|
||||
Ok(LengthOrPercentageOrNone::Length(Au(0)))
|
||||
Ok(LengthOrPercentageOrNone::Length(Length::new(0.)))
|
||||
},
|
||||
LengthOrPercentageOrNone::None => Err(()),
|
||||
}
|
||||
|
@ -2314,9 +2313,9 @@ impl ComputeSquaredDistance for TransformOperation {
|
|||
// convert Au into px.
|
||||
let extract_pixel_length = |lop: &LengthOrPercentage| {
|
||||
match *lop {
|
||||
LengthOrPercentage::Length(au) => au.to_f64_px(),
|
||||
LengthOrPercentage::Length(px) => px.px(),
|
||||
LengthOrPercentage::Percentage(_) => 0.,
|
||||
LengthOrPercentage::Calc(calc) => calc.length().px() as f64,
|
||||
LengthOrPercentage::Calc(calc) => calc.length().px(),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2465,7 +2464,7 @@ impl From<NonNegativeNumber> for NumberOrPercentage {
|
|||
impl From<LengthOrPercentage> for NumberOrPercentage {
|
||||
fn from(lop: LengthOrPercentage) -> NumberOrPercentage {
|
||||
match lop {
|
||||
LengthOrPercentage::Length(len) => NumberOrPercentage::Number(len.to_f32_px()),
|
||||
LengthOrPercentage::Length(len) => NumberOrPercentage::Number(len.px()),
|
||||
LengthOrPercentage::Percentage(p) => NumberOrPercentage::Percentage(p),
|
||||
LengthOrPercentage::Calc(_) => {
|
||||
panic!("We dont't expected calc interpolation for SvgLengthOrPercentageOrNumber");
|
||||
|
|
|
@ -1480,11 +1480,10 @@ ${helpers.predefined_type(
|
|||
}
|
||||
|
||||
// Converts computed LengthOrPercentageOrNumber into computed
|
||||
// LengthOrPercentage. Number maps into Length
|
||||
// LengthOrPercentage. Number maps into Length (pixel unit)
|
||||
fn lopon_to_lop(value: &ComputedLoPoNumber) -> ComputedLoP {
|
||||
use app_units::Au;
|
||||
match *value {
|
||||
Either::First(number) => ComputedLoP::Length(Au::from_f32_px(number)),
|
||||
Either::First(number) => ComputedLoP::Length(ComputedLength::new(number)),
|
||||
Either::Second(length_or_percentage) => length_or_percentage,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ ${helpers.single_keyword("-moz-text-size-adjust", "auto none",
|
|||
|
||||
${helpers.predefined_type("text-indent",
|
||||
"LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"computed::LengthOrPercentage::Length(computed::Length::new(0.))",
|
||||
animation_value_type="ComputedValue",
|
||||
spec="https://drafts.csswg.org/css-text/#propdef-text-indent",
|
||||
allow_quirks=True)}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
spec = "https://drafts.csswg.org/css-logical-props/#propdef-margin-%s" % side[1]
|
||||
%>
|
||||
${helpers.predefined_type("margin-%s" % side[0], "LengthOrPercentageOrAuto",
|
||||
"computed::LengthOrPercentageOrAuto::Length(Au(0))",
|
||||
"computed::LengthOrPercentageOrAuto::Length(computed::Length::new(0.))",
|
||||
alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"),
|
||||
allow_quirks=not side[1],
|
||||
animation_value_type="ComputedValue", logical = side[1], spec = spec,
|
||||
|
|
|
@ -209,7 +209,7 @@ ${helpers.predefined_type("order", "Integer", "0",
|
|||
animation_value_type="ComputedValue", logical = logical)}
|
||||
${helpers.predefined_type("min-%s" % size,
|
||||
"LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::Length(Au(0))",
|
||||
"computed::LengthOrPercentage::Length(computed::Length::new(0.))",
|
||||
"parse_non_negative",
|
||||
spec=spec % ("min-%s" % size),
|
||||
animation_value_type="ComputedValue",
|
||||
|
|
|
@ -363,12 +363,12 @@ impl ToAnimatedValue for ComputedMaxLength {
|
|||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
use values::computed::{LengthOrPercentageOrNone, Percentage};
|
||||
use values::computed::{Length, LengthOrPercentageOrNone, Percentage};
|
||||
match animated {
|
||||
ComputedMaxLength::LengthOrPercentageOrNone(lopn) => {
|
||||
let result = match lopn {
|
||||
LengthOrPercentageOrNone::Length(au) => {
|
||||
LengthOrPercentageOrNone::Length(max(au, Au(0)))
|
||||
LengthOrPercentageOrNone::Length(px) => {
|
||||
LengthOrPercentageOrNone::Length(Length::new(px.px().max(0.)))
|
||||
},
|
||||
LengthOrPercentageOrNone::Percentage(percentage) => {
|
||||
LengthOrPercentageOrNone::Percentage(Percentage(percentage.0.max(0.)))
|
||||
|
@ -392,12 +392,12 @@ impl ToAnimatedValue for ComputedMozLength {
|
|||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
use values::computed::{LengthOrPercentageOrAuto, Percentage};
|
||||
use values::computed::{Length, LengthOrPercentageOrAuto, Percentage};
|
||||
match animated {
|
||||
ComputedMozLength::LengthOrPercentageOrAuto(lopa) => {
|
||||
let result = match lopa {
|
||||
LengthOrPercentageOrAuto::Length(au) => {
|
||||
LengthOrPercentageOrAuto::Length(max(au, Au(0)))
|
||||
LengthOrPercentageOrAuto::Length(px) => {
|
||||
LengthOrPercentageOrAuto::Length(Length::new(px.px().max(0.)))
|
||||
},
|
||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(percentage.0.max(0.)))
|
||||
|
|
|
@ -30,12 +30,11 @@ impl ToAnimatedValue for BackgroundSize {
|
|||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
use app_units::Au;
|
||||
use values::computed::Percentage;
|
||||
use values::computed::{Length, Percentage};
|
||||
let clamp_animated_value = |value: LengthOrPercentageOrAuto| -> LengthOrPercentageOrAuto {
|
||||
match value {
|
||||
LengthOrPercentageOrAuto::Length(len) => {
|
||||
LengthOrPercentageOrAuto::Length(Au(::std::cmp::max(len.0, 0)))
|
||||
LengthOrPercentageOrAuto::Length(Length::new(len.px().max(0.)))
|
||||
},
|
||||
LengthOrPercentageOrAuto::Percentage(percent) => {
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(percent.0.max(0.)))
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! `<length>` computed values, and related ones.
|
||||
|
||||
use app_units::{Au, AU_PER_PX};
|
||||
use app_units::Au;
|
||||
use ordered_float::NotNaN;
|
||||
use std::fmt;
|
||||
use std::ops::{Add, Neg};
|
||||
|
@ -155,7 +155,7 @@ impl From<LengthOrPercentage> for CalcLengthOrPercentage {
|
|||
CalcLengthOrPercentage::new(Length::new(0.), Some(this))
|
||||
}
|
||||
LengthOrPercentage::Length(this) => {
|
||||
CalcLengthOrPercentage::new(this.into(), None)
|
||||
CalcLengthOrPercentage::new(this, None)
|
||||
}
|
||||
LengthOrPercentage::Calc(this) => {
|
||||
this
|
||||
|
@ -171,7 +171,7 @@ impl From<LengthOrPercentageOrAuto> for Option<CalcLengthOrPercentage> {
|
|||
Some(CalcLengthOrPercentage::new(Length::new(0.), Some(this)))
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(this) => {
|
||||
Some(CalcLengthOrPercentage::new(this.into(), None))
|
||||
Some(CalcLengthOrPercentage::new(this, None))
|
||||
}
|
||||
LengthOrPercentageOrAuto::Calc(this) => {
|
||||
Some(this)
|
||||
|
@ -190,7 +190,7 @@ impl From<LengthOrPercentageOrNone> for Option<CalcLengthOrPercentage> {
|
|||
Some(CalcLengthOrPercentage::new(Length::new(0.), Some(this)))
|
||||
}
|
||||
LengthOrPercentageOrNone::Length(this) => {
|
||||
Some(CalcLengthOrPercentage::new(this.into(), None))
|
||||
Some(CalcLengthOrPercentage::new(this, None))
|
||||
}
|
||||
LengthOrPercentageOrNone::Calc(this) => {
|
||||
Some(this)
|
||||
|
@ -293,7 +293,7 @@ impl ToComputedValue for specified::CalcLengthOrPercentage {
|
|||
#[derive(ToAnimatedZero, ToCss)]
|
||||
#[distance(fallback = "Self::compute_squared_distance_fallback")]
|
||||
pub enum LengthOrPercentage {
|
||||
Length(Au),
|
||||
Length(Length),
|
||||
Percentage(Percentage),
|
||||
Calc(CalcLengthOrPercentage),
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ impl LengthOrPercentage {
|
|||
impl From<Au> for LengthOrPercentage {
|
||||
#[inline]
|
||||
fn from(length: Au) -> Self {
|
||||
LengthOrPercentage::Length(length)
|
||||
LengthOrPercentage::Length(length.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,13 +341,13 @@ impl LengthOrPercentage {
|
|||
#[inline]
|
||||
#[allow(missing_docs)]
|
||||
pub fn zero() -> LengthOrPercentage {
|
||||
LengthOrPercentage::Length(Au(0))
|
||||
LengthOrPercentage::Length(Length::new(0.))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// 1px length value for SVG defaults
|
||||
pub fn one() -> LengthOrPercentage {
|
||||
LengthOrPercentage::Length(Au(AU_PER_PX))
|
||||
LengthOrPercentage::Length(Length::new(1.))
|
||||
}
|
||||
|
||||
/// Returns true if the computed value is absolute 0 or 0%.
|
||||
|
@ -357,17 +357,19 @@ impl LengthOrPercentage {
|
|||
pub fn is_definitely_zero(&self) -> bool {
|
||||
use self::LengthOrPercentage::*;
|
||||
match *self {
|
||||
Length(Au(0)) => true,
|
||||
Length(l) => l.px() == 0.0,
|
||||
Percentage(p) => p.0 == 0.0,
|
||||
Length(_) | Calc(_) => false
|
||||
Calc(_) => false
|
||||
}
|
||||
}
|
||||
|
||||
// CSSFloat doesn't implement Hash, so does CSSPixelLength. Therefore, we still use Au as the
|
||||
// hash key.
|
||||
#[allow(missing_docs)]
|
||||
pub fn to_hash_key(&self) -> (Au, NotNaN<f32>) {
|
||||
use self::LengthOrPercentage::*;
|
||||
match *self {
|
||||
Length(l) => (l, NotNaN::new(0.0).unwrap()),
|
||||
Length(l) => (Au::from(l), NotNaN::new(0.0).unwrap()),
|
||||
Percentage(p) => (Au(0), NotNaN::new(p.0).unwrap()),
|
||||
Calc(c) => (Au::from(c.unclamped_length()), NotNaN::new(c.percentage()).unwrap()),
|
||||
}
|
||||
|
@ -376,7 +378,7 @@ impl LengthOrPercentage {
|
|||
/// Returns the used value.
|
||||
pub fn to_used_value(&self, containing_length: Au) -> Au {
|
||||
match *self {
|
||||
LengthOrPercentage::Length(length) => length,
|
||||
LengthOrPercentage::Length(length) => Au::from(length),
|
||||
LengthOrPercentage::Percentage(p) => containing_length.scale_by(p.0),
|
||||
LengthOrPercentage::Calc(ref calc) => {
|
||||
calc.to_used_value(Some(containing_length)).unwrap()
|
||||
|
@ -389,7 +391,7 @@ impl LengthOrPercentage {
|
|||
pub fn clamp_to_non_negative(self) -> Self {
|
||||
match self {
|
||||
LengthOrPercentage::Length(length) => {
|
||||
LengthOrPercentage::Length(Au(::std::cmp::max(length.0, 0)))
|
||||
LengthOrPercentage::Length(Length::new(length.px().max(0.)))
|
||||
},
|
||||
LengthOrPercentage::Percentage(percentage) => {
|
||||
LengthOrPercentage::Percentage(Percentage(percentage.0.max(0.)))
|
||||
|
@ -405,7 +407,7 @@ impl ToComputedValue for specified::LengthOrPercentage {
|
|||
fn to_computed_value(&self, context: &Context) -> LengthOrPercentage {
|
||||
match *self {
|
||||
specified::LengthOrPercentage::Length(ref value) => {
|
||||
LengthOrPercentage::Length(Au::from(value.to_computed_value(context)))
|
||||
LengthOrPercentage::Length(value.to_computed_value(context))
|
||||
}
|
||||
specified::LengthOrPercentage::Percentage(value) => {
|
||||
LengthOrPercentage::Percentage(value)
|
||||
|
@ -420,7 +422,7 @@ impl ToComputedValue for specified::LengthOrPercentage {
|
|||
match *computed {
|
||||
LengthOrPercentage::Length(value) => {
|
||||
specified::LengthOrPercentage::Length(
|
||||
ToComputedValue::from_computed_value(&value.into())
|
||||
ToComputedValue::from_computed_value(&value)
|
||||
)
|
||||
}
|
||||
LengthOrPercentage::Percentage(value) => {
|
||||
|
@ -442,7 +444,7 @@ impl ToComputedValue for specified::LengthOrPercentage {
|
|||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq, ToCss)]
|
||||
#[distance(fallback = "Self::compute_squared_distance_fallback")]
|
||||
pub enum LengthOrPercentageOrAuto {
|
||||
Length(Au),
|
||||
Length(Length),
|
||||
Percentage(Percentage),
|
||||
Auto,
|
||||
Calc(CalcLengthOrPercentage),
|
||||
|
@ -482,9 +484,9 @@ impl LengthOrPercentageOrAuto {
|
|||
pub fn is_definitely_zero(&self) -> bool {
|
||||
use self::LengthOrPercentageOrAuto::*;
|
||||
match *self {
|
||||
Length(Au(0)) => true,
|
||||
Length(l) => l.px() == 0.0,
|
||||
Percentage(p) => p.0 == 0.0,
|
||||
Length(_) | Calc(_) | Auto => false
|
||||
Calc(_) | Auto => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +498,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAuto {
|
|||
fn to_computed_value(&self, context: &Context) -> LengthOrPercentageOrAuto {
|
||||
match *self {
|
||||
specified::LengthOrPercentageOrAuto::Length(ref value) => {
|
||||
LengthOrPercentageOrAuto::Length(Au::from(value.to_computed_value(context)))
|
||||
LengthOrPercentageOrAuto::Length(value.to_computed_value(context))
|
||||
}
|
||||
specified::LengthOrPercentageOrAuto::Percentage(value) => {
|
||||
LengthOrPercentageOrAuto::Percentage(value)
|
||||
|
@ -516,7 +518,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAuto {
|
|||
LengthOrPercentageOrAuto::Auto => specified::LengthOrPercentageOrAuto::Auto,
|
||||
LengthOrPercentageOrAuto::Length(value) => {
|
||||
specified::LengthOrPercentageOrAuto::Length(
|
||||
ToComputedValue::from_computed_value(&value.into())
|
||||
ToComputedValue::from_computed_value(&value)
|
||||
)
|
||||
}
|
||||
LengthOrPercentageOrAuto::Percentage(value) => {
|
||||
|
@ -538,7 +540,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAuto {
|
|||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq, ToCss)]
|
||||
#[distance(fallback = "Self::compute_squared_distance_fallback")]
|
||||
pub enum LengthOrPercentageOrNone {
|
||||
Length(Au),
|
||||
Length(Length),
|
||||
Percentage(Percentage),
|
||||
Calc(CalcLengthOrPercentage),
|
||||
None,
|
||||
|
@ -574,7 +576,7 @@ impl LengthOrPercentageOrNone {
|
|||
pub fn to_used_value(&self, containing_length: Au) -> Option<Au> {
|
||||
match *self {
|
||||
LengthOrPercentageOrNone::None => None,
|
||||
LengthOrPercentageOrNone::Length(length) => Some(length),
|
||||
LengthOrPercentageOrNone::Length(length) => Some(Au::from(length)),
|
||||
LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent.0)),
|
||||
LengthOrPercentageOrNone::Calc(ref calc) => calc.to_used_value(Some(containing_length)),
|
||||
}
|
||||
|
@ -588,7 +590,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrNone {
|
|||
fn to_computed_value(&self, context: &Context) -> LengthOrPercentageOrNone {
|
||||
match *self {
|
||||
specified::LengthOrPercentageOrNone::Length(ref value) => {
|
||||
LengthOrPercentageOrNone::Length(Au::from(value.to_computed_value(context)))
|
||||
LengthOrPercentageOrNone::Length(value.to_computed_value(context))
|
||||
}
|
||||
specified::LengthOrPercentageOrNone::Percentage(value) => {
|
||||
LengthOrPercentageOrNone::Percentage(value)
|
||||
|
@ -608,7 +610,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrNone {
|
|||
LengthOrPercentageOrNone::None => specified::LengthOrPercentageOrNone::None,
|
||||
LengthOrPercentageOrNone::Length(value) => {
|
||||
specified::LengthOrPercentageOrNone::Length(
|
||||
ToComputedValue::from_computed_value(&value.into())
|
||||
ToComputedValue::from_computed_value(&value)
|
||||
)
|
||||
}
|
||||
LengthOrPercentageOrNone::Percentage(value) => {
|
||||
|
@ -629,7 +631,7 @@ pub type NonNegativeLengthOrPercentage = NonNegative<LengthOrPercentage>;
|
|||
impl From<NonNegativeLength> for NonNegativeLengthOrPercentage {
|
||||
#[inline]
|
||||
fn from(length: NonNegativeLength) -> Self {
|
||||
LengthOrPercentage::Length(Au::from(length.0)).into()
|
||||
LengthOrPercentage::Length(length.0).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ impl TransformList {
|
|||
|
||||
let extract_pixel_length = |lop: &LengthOrPercentage| {
|
||||
match *lop {
|
||||
LengthOrPercentage::Length(au) => au.to_f32_px(),
|
||||
LengthOrPercentage::Length(px) => px.px(),
|
||||
LengthOrPercentage::Percentage(_) => 0.,
|
||||
LengthOrPercentage::Calc(calc) => calc.length().px(),
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ impl<S: Side> ToComputedValue for PositionComponent<S> {
|
|||
match length.to_computed_value(context) {
|
||||
ComputedLengthOrPercentage::Length(length) => {
|
||||
ComputedLengthOrPercentage::Calc(
|
||||
CalcLengthOrPercentage::new((-length).into(), Some(Percentage::hundred())))
|
||||
CalcLengthOrPercentage::new(-length, Some(Percentage::hundred())))
|
||||
},
|
||||
ComputedLengthOrPercentage::Percentage(p) => {
|
||||
ComputedLengthOrPercentage::Percentage(Percentage(1.0 - p.0))
|
||||
|
|
|
@ -84,7 +84,7 @@ impl ToComputedValue for LineHeight {
|
|||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
use values::computed::NonNegativeLength;
|
||||
use values::computed::Length as ComputedLength;
|
||||
use values::specified::length::FontBaseSize;
|
||||
match *self {
|
||||
GenericLineHeight::Normal => {
|
||||
|
@ -100,20 +100,21 @@ impl ToComputedValue for LineHeight {
|
|||
GenericLineHeight::Length(ref non_negative_lop) => {
|
||||
let result = match non_negative_lop.0 {
|
||||
LengthOrPercentage::Length(NoCalcLength::Absolute(ref abs)) => {
|
||||
context.maybe_zoom_text(abs.to_computed_value(context)).into()
|
||||
context.maybe_zoom_text(abs.to_computed_value(context))
|
||||
}
|
||||
LengthOrPercentage::Length(ref length) => {
|
||||
length.to_computed_value(context).into()
|
||||
length.to_computed_value(context)
|
||||
},
|
||||
LengthOrPercentage::Percentage(ref p) => {
|
||||
FontRelativeLength::Em(p.0)
|
||||
.to_computed_value(
|
||||
context,
|
||||
FontBaseSize::CurrentStyle,
|
||||
).into()
|
||||
)
|
||||
}
|
||||
LengthOrPercentage::Calc(ref calc) => {
|
||||
let computed_calc = calc.to_computed_value_zoomed(context, FontBaseSize::CurrentStyle);
|
||||
let computed_calc =
|
||||
calc.to_computed_value_zoomed(context, FontBaseSize::CurrentStyle);
|
||||
let font_relative_length =
|
||||
FontRelativeLength::Em(computed_calc.percentage())
|
||||
.to_computed_value(
|
||||
|
@ -125,10 +126,10 @@ impl ToComputedValue for LineHeight {
|
|||
let pixel = computed_calc
|
||||
.clamping_mode
|
||||
.clamp(absolute_length + font_relative_length);
|
||||
NonNegativeLength::new(pixel)
|
||||
ComputedLength::new(pixel)
|
||||
}
|
||||
};
|
||||
GenericLineHeight::Length(result)
|
||||
GenericLineHeight::Length(result.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use app_units::Au;
|
||||
use cssparser::RGBA;
|
||||
use style::properties::longhands::transform::computed_value::ComputedOperation as TransformOperation;
|
||||
use style::properties::longhands::transform::computed_value::T as TransformList;
|
||||
|
@ -68,18 +67,18 @@ fn test_transform_interpolation_on_translate() {
|
|||
use style::values::computed::{CalcLengthOrPercentage, Length, LengthOrPercentage};
|
||||
|
||||
let from = TransformList(Some(vec![
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au(0)),
|
||||
LengthOrPercentage::Length(Au(100)),
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Length::new(0.)),
|
||||
LengthOrPercentage::Length(Length::new(100.)),
|
||||
Length::new(25.))]));
|
||||
let to = TransformList(Some(vec![
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
|
||||
LengthOrPercentage::Length(Au(0)),
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(0.)),
|
||||
Length::new(75.))]));
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
|
||||
TransformList(Some(vec![TransformOperation::Translate(
|
||||
LengthOrPercentage::Length(Au(50)),
|
||||
LengthOrPercentage::Length(Au(50)),
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
Length::new(50.),
|
||||
)]))
|
||||
);
|
||||
|
@ -90,8 +89,8 @@ fn test_transform_interpolation_on_translate() {
|
|||
Length::new(25.),
|
||||
)]));
|
||||
let to = TransformList(Some(vec![
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au::from_px(100)),
|
||||
LengthOrPercentage::Length(Au::from_px(50)),
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
Length::new(75.))]));
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
|
||||
|
@ -157,8 +156,8 @@ fn test_transform_interpolation_on_mismatched_lists() {
|
|||
let from = TransformList(Some(vec![TransformOperation::Rotate(0.0, 0.0, 1.0,
|
||||
Angle::from_radians(100.0))]));
|
||||
let to = TransformList(Some(vec![
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
|
||||
LengthOrPercentage::Length(Au(0)),
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(0.)),
|
||||
Length::new(0.))]));
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue