Permalink
Browse files

style: Three-value position syntax uses calc() as its computed value …

…representation.

This restores the previous behavior of using calc().

Note that background-position / object-position, which test this, weren't
hitting the assertion because they use another codepath.

I didn't add more extensive tests for this because it's well tested for those
two properties, and because this is legacy anyway, see the comment in the test.

I did add the assertion to the codepath those two properties hit.

Differential Revision: https://phabricator.services.mozilla.com/D16176
  • Loading branch information...
emilio committed Jan 11, 2019
1 parent 119b316 commit 99f6d6f1b88d5f34c3092546626fa239e75d1c69
Showing with 8 additions and 2 deletions.
  1. +6 −1 components/style/gecko/conversions.rs
  2. +2 −1 components/style/values/specified/position.rs
@@ -22,8 +22,8 @@ use crate::values::computed::transform::Matrix3D;
use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::{Angle, Gradient, Image};
use crate::values::computed::{Integer, LengthPercentage};
use crate::values::computed::{Length, Percentage, TextAlign};
use crate::values::computed::{LengthPercentageOrAuto, NonNegativeLengthPercentageOrAuto};
use crate::values::computed::{Percentage, TextAlign};
use crate::values::generics::box_::VerticalAlign;
use crate::values::generics::grid::{TrackListValue, TrackSize};
use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
@@ -35,6 +35,11 @@ use style_traits::values::specified::AllowedNumericType;

impl From<LengthPercentage> for nsStyleCoord_CalcValue {
fn from(other: LengthPercentage) -> nsStyleCoord_CalcValue {
debug_assert!(
other.was_calc ||
other.percentage.is_none() ||
other.unclamped_length() == Length::zero()
);
let has_percentage = other.percentage.is_some();
nsStyleCoord_CalcValue {
mLength: other.unclamped_length().to_i32_au(),
@@ -263,11 +263,12 @@ impl<S: Side> ToComputedValue for PositionComponent<S> {
let length = length.to_computed_value(context);
let p = Percentage(1. - length.percentage());
let l = -length.unclamped_length();
// We represent `<end-side> <length>` as `calc(100% - <length>)`.
ComputedLengthPercentage::with_clamping_mode(
l,
Some(p),
length.clamping_mode,
length.was_calc,
/* was_calc = */ true,
)
},
PositionComponent::Side(_, Some(ref length)) |

0 comments on commit 99f6d6f

Please sign in to comment.