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 #7496

Merged
merged 23 commits into from Sep 2, 2015
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9556141
Implement Calc for LengthOrPercentage
dzbarsky Aug 11, 2015
cb4d878
Implement Calc for LengthOrPercentageOrAuto
dzbarsky Aug 12, 2015
2bb6b45
Implement proper calc parsing
dzbarsky Aug 12, 2015
5df4b82
Implement font relative and viewport relative units for calc
dzbarsky Aug 12, 2015
af4d2e9
Clean up serialization and other hacks
dzbarsky Aug 13, 2015
64dc954
Clean up serialization code a little
dzbarsky Aug 13, 2015
cfa1e46
Clean up AST simplification code
dzbarsky Aug 13, 2015
6573e80
Properly serialize % values in calc expressions
dzbarsky Aug 13, 2015
663e0f6
Simplify like terms in all sum expressions, not just toplevel calc
dzbarsky Aug 13, 2015
63d0429
Simplify the calc AST simplification code
dzbarsky Aug 13, 2015
67db4fb
Remove stray changes
dzbarsky Aug 13, 2015
f8bd7c4
Fix some calc parsing panics
dzbarsky Aug 14, 2015
164af05
Expand out nested products
dzbarsky Aug 15, 2015
dcac654
Use the type system to enforce that product nodes are simplified away
dzbarsky Aug 15, 2015
53e8f7d
Get rid of some cloning
dzbarsky Aug 15, 2015
5ac205b
Clean up some stray lines
dzbarsky Aug 15, 2015
cdae523
Address review comments
dzbarsky Aug 23, 2015
25829bb
Add calc reftest
dzbarsky Aug 26, 2015
2591a89
Add calc parsing tests for the other properties
dzbarsky Aug 26, 2015
80d471d
Merge branch 'master' into calc
SimonSapin Sep 1, 2015
b30c4f7
Add support for the ch unit in calc()
SimonSapin Sep 1, 2015
9f48dcd
Fix font-size keywords parsing.
SimonSapin Sep 2, 2015
b51b7dd
Fix ch/em confusion.
SimonSapin Sep 2, 2015
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add support for the ch unit in calc()

  • Loading branch information
SimonSapin committed Sep 1, 2015
commit b30c4f70f936ed63ae2448a88fb2e66916b111be
@@ -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),
},
@@ -627,6 +631,7 @@ pub mod specified {
vmin: vmin.map(ViewportPercentageLength::Vmin),
em: em.map(FontRelativeLength::Em),
ex: ex.map(FontRelativeLength::Ex),
ch: ex.map(FontRelativeLength::Ch),
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!(em, ex, ch, 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!(em, ex, ch, 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.ex, self.ch, 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));
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.