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 calc parsing tests for the other properties

  • Loading branch information
dzbarsky committed Aug 26, 2015
commit 2591a89a91945629cee5ea5df8598eff5334f24e
@@ -6,3 +6,123 @@
[calc(0px + 0pt + 0pc + 0in + 0cm + 0mm + 0rem + 0em + 0ex + 0% + 0vw + 0vh + 0vmin + 0vmax)]
expected: FAIL

[calc for border-width]
expected: FAIL

[calc for border-top-width]
expected: FAIL

[calc for border-left-width]
expected: FAIL

[calc for border-right-width]
expected: FAIL

[calc for border-bottom-width]
expected: FAIL

[calc for outline-width]
expected: FAIL

[calc for outline-offset]
expected: FAIL

[calc for letter-spacing]
expected: FAIL

[calc for word-spacing]
expected: FAIL

[calc for border-spacing]
expected: FAIL

[calc for column-width]
expected: FAIL

[calc for column-gap]
expected: FAIL

[calc for perspective]
expected: FAIL

[calc for border-top-left-radius]
expected: FAIL

[calc for border-bottom-left-radius]
expected: FAIL

[calc for border-top-right-radius]
expected: FAIL

[calc for border-bottom-right-radius]
expected: FAIL

[calc for top]
expected: FAIL

[calc for left]
expected: FAIL

[calc for bottom]
expected: FAIL

[calc for right]
expected: FAIL

[calc for width]
expected: FAIL

[calc for height]
expected: FAIL

[calc for min-width]
expected: FAIL

[calc for min-height]
expected: FAIL

[calc for max-width]
expected: FAIL

[calc for max-height]
expected: FAIL

[calc for line-height]
expected: FAIL

[calc for vertical-align]
expected: FAIL

[calc for background-position]
expected: FAIL

[calc for background-size]
expected: FAIL

[calc for font-size]
expected: FAIL

[calc for text-indent]
expected: FAIL

[calc for transform-origin]
expected: FAIL

[calc for perspective-origin]
expected: FAIL

[calc for transition-delay]
expected: FAIL

[calc for z-index]
expected: FAIL

[calc for column-count]
expected: FAIL

[calc for opacity]
expected: FAIL

[calc for transition-duration]
expected: FAIL

@@ -57,6 +57,97 @@
assert_equals(window.getComputedStyle(div).getPropertyValue('width'), item[2]);
}, item[0]);
});

var lengthProperties = [
'border-width',
'border-top-width',
'border-left-width',
'border-right-width',
'border-bottom-width',
'outline-width',
'outline-offset',
'letter-spacing',
'word-spacing',
'border-spacing',
'column-width',
'column-gap',
'perspective',
];

lengthProperties.forEach(function(prop) {
test(function() {
div.style.setProperty(prop, 'calc(1px)');
assert_equals(div.style.getPropertyValue(prop), '1px');
assert_equals(window.getComputedStyle(div).getPropertyValue(prop), '1px');
}, 'calc for ' + prop);
});

var lengthOrPercentageProperties = [
'border-top-left-radius',
'border-bottom-left-radius',
'border-top-right-radius',
'border-bottom-right-radius',
'top',
'left',
'bottom',
'right',
'width',
'height',
'min-width',
'min-height',
'max-width',
'max-height',
'line-height',
'vertical-align',
'background-position',
'background-size',
'font-size',
'text-indent',
'transform-origin',
'perspective-origin',
];

lengthOrPercentageProperties.forEach(function(prop) {
test(function() {
div.style.setProperty(prop, 'calc(1px + 0%)');
assert_equals(div.style.getPropertyValue(prop), 'calc(1px + 0%)');
assert_equals(window.getComputedStyle(div).getPropertyValue(prop), '1px');
}, 'calc for ' + prop);
});

var timeProperties = [
'transition-delay',
];

timeProperties.forEach(function(prop) {
test(function() {
div.style.setProperty(prop, 'calc(1s)');
assert_equals(div.style.getPropertyValue(prop), '1s');
assert_equals(window.getComputedStyle(div).getPropertyValue(prop), '1s');
}, 'calc for ' + prop);
});

var numberProperties = [
'z-index',
'column-count',
'opacity',
'transition-duration',
];

numberProperties.forEach(function(prop) {
test(function() {
div.style.setProperty(prop, 'calc(1)');
assert_equals(div.style.getPropertyValue(prop), '1');
assert_equals(window.getComputedStyle(div).getPropertyValue(prop), '1');
}, 'calc for ' + prop);
});


/* TODO: test these:
counter-increment, counter-reset,
color, box-shadow, clip, text-shadow, transform
transition-timing-function
*/
</script>
</head>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.