mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
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
This commit is contained in:
parent
119b316885
commit
99f6d6f1b8
2 changed files with 8 additions and 2 deletions
|
@ -22,8 +22,8 @@ use crate::values::computed::transform::Matrix3D;
|
||||||
use crate::values::computed::url::ComputedImageUrl;
|
use crate::values::computed::url::ComputedImageUrl;
|
||||||
use crate::values::computed::{Angle, Gradient, Image};
|
use crate::values::computed::{Angle, Gradient, Image};
|
||||||
use crate::values::computed::{Integer, LengthPercentage};
|
use crate::values::computed::{Integer, LengthPercentage};
|
||||||
|
use crate::values::computed::{Length, Percentage, TextAlign};
|
||||||
use crate::values::computed::{LengthPercentageOrAuto, NonNegativeLengthPercentageOrAuto};
|
use crate::values::computed::{LengthPercentageOrAuto, NonNegativeLengthPercentageOrAuto};
|
||||||
use crate::values::computed::{Percentage, TextAlign};
|
|
||||||
use crate::values::generics::box_::VerticalAlign;
|
use crate::values::generics::box_::VerticalAlign;
|
||||||
use crate::values::generics::grid::{TrackListValue, TrackSize};
|
use crate::values::generics::grid::{TrackListValue, TrackSize};
|
||||||
use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
|
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 {
|
impl From<LengthPercentage> for nsStyleCoord_CalcValue {
|
||||||
fn from(other: LengthPercentage) -> 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();
|
let has_percentage = other.percentage.is_some();
|
||||||
nsStyleCoord_CalcValue {
|
nsStyleCoord_CalcValue {
|
||||||
mLength: other.unclamped_length().to_i32_au(),
|
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 length = length.to_computed_value(context);
|
||||||
let p = Percentage(1. - length.percentage());
|
let p = Percentage(1. - length.percentage());
|
||||||
let l = -length.unclamped_length();
|
let l = -length.unclamped_length();
|
||||||
|
// We represent `<end-side> <length>` as `calc(100% - <length>)`.
|
||||||
ComputedLengthPercentage::with_clamping_mode(
|
ComputedLengthPercentage::with_clamping_mode(
|
||||||
l,
|
l,
|
||||||
Some(p),
|
Some(p),
|
||||||
length.clamping_mode,
|
length.clamping_mode,
|
||||||
length.was_calc,
|
/* was_calc = */ true,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
PositionComponent::Side(_, Some(ref length)) |
|
PositionComponent::Side(_, Some(ref length)) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue