Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CSS3 Calc #7185

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Add ch support

  • Loading branch information
dzbarsky committed Sep 2, 2015
commit 86249bdfd27dda33a589093e0b4ff0cbb454d4b9
@@ -424,6 +424,7 @@ pub mod specified {
pub vmax: Option<ViewportPercentageLength>,
pub em: Option<FontRelativeLength>,
pub ex: Option<FontRelativeLength>,
pub ch: Option<FontRelativeLength>,
pub rem: Option<FontRelativeLength>,
pub percentage: Option<Percentage>,
}
@@ -584,6 +585,7 @@ pub mod specified {
let mut vmin = None;
let mut em = None;
let mut ex = None;
let mut ch = None;
let mut rem = None;
let mut percentage = None;
let mut number = None;
@@ -611,6 +613,8 @@ pub mod specified {
em = Some(em.unwrap_or(0.) + val),
FontRelativeLength::Ex(val) =>
ex = Some(ex.unwrap_or(0.) + val),
FontRelativeLength::Ch(val) =>
ch = Some(ch.unwrap_or(0.) + val),
FontRelativeLength::Rem(val) =>
rem = Some(rem.unwrap_or(0.) + val),
},
@@ -626,6 +630,7 @@ pub mod specified {
vmax: vmax.map(ViewportPercentageLength::Vmax),
vmin: vmin.map(ViewportPercentageLength::Vmin),
em: em.map(FontRelativeLength::Em),
ch: ch.map(FontRelativeLength::Ch),
ex: ex.map(FontRelativeLength::Ex),
rem: rem.map(FontRelativeLength::Rem),
percentage: percentage.map(Percentage),
@@ -668,14 +673,14 @@ pub mod specified {
};
}

let count = count!(em, ex, absolute, rem, vh, vmax, vmin, vw, percentage);
let count = count!(ch, em, ex, absolute, rem, vh, vmax, vmin, vw, percentage);
assert!(count > 0);

if count > 1 {
try!(write!(dest, "calc("));
}

serialize!(em, ex, absolute, rem, vh, vmax, vmin, vw, percentage);
serialize!(ch, em, ex, absolute, rem, vh, vmax, vmin, vw, percentage);

if count > 1 {
try!(write!(dest, ")"));
@@ -1329,7 +1334,7 @@ pub mod computed {
val.to_computed_value(context.viewport_size));
}
}
for val in &[self.em, self.ex, self.rem] {
for val in &[self.em, self.ch, self.ex, self.rem] {
if let Some(val) = *val {
length = Some(length.unwrap_or(Au(0)) +
val.to_computed_value(context.font_size, context.root_font_size));
@@ -377,3 +377,4 @@

[Window replaceable attribute: devicePixelRatio]
expected: FAIL

@@ -126,3 +126,6 @@
[calc for transition-duration]
expected: FAIL

[calc(0px + 0ch + 0pt + 0pc + 0in + 0cm + 0mm + 0rem + 0em + 0ex + 0% + 0vw + 0vh + 0vmin + 0vmax)]
expected: FAIL

@@ -39,8 +39,8 @@
['calc(1px + 1pt + 1pc + 1in + 1cm + 1mm)', '155.88333333333333px', '155.88333333333333px'],

// Alphabetical order
['calc(0px + 0pt + 0pc + 0in + 0cm + 0mm + 0rem + 0em + 0ex + 0% + 0vw + 0vh + 0vmin + 0vmax)',
'calc(0em + 0ex + 0px + 0rem + 0vh + 0vmax + 0vmin + 0vw + 0%)',
['calc(0px + 0ch + 0pt + 0pc + 0in + 0cm + 0mm + 0rem + 0em + 0ex + 0% + 0vw + 0vh + 0vmin + 0vmax)',
'calc(0ch + 0em + 0ex + 0px + 0rem + 0vh + 0vmax + 0vmin + 0vw + 0%)',
'0px'],

// Simplification
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.