Skip to content

[css-shapes] Comprehensive tests for clip-path: shape()#33107

Merged
noamr merged 2 commits intomasterfrom
shape
Mar 10, 2022
Merged

[css-shapes] Comprehensive tests for clip-path: shape()#33107
noamr merged 2 commits intomasterfrom
shape

Conversation

@noamr
Copy link
Copy Markdown
Contributor

@noamr noamr commented Mar 8, 2022

No description provided.

@noamr noamr changed the title [css-shapes] Comprehensive tests for shape() [css-shapes] Comprehensive tests for clip-path: shape() Mar 8, 2022
@birtles birtles requested a review from BorisChiou March 9, 2022 02:32
@birtles
Copy link
Copy Markdown
Contributor

birtles commented Mar 9, 2022

Hi @BorisChiou -- sorry to throw so many tasks your way at the same time. I added you as a reviewer of this because I think you did the shape interpolation in Gecko. Is that right?

@BorisChiou
Copy link
Copy Markdown
Member

I did the CSS path() interpolation and updated some code for other basic-shape functions in Gecko. Looks like this is a new function, shape() from https://drafts.csswg.org/css-shapes-2/#funcdef-shape. Sure, I can take a look at these tests. :)

@noamr
Copy link
Copy Markdown
Contributor Author

noamr commented Mar 9, 2022

I did the CSS path() interpolation and updated some code for other basic-shape functions in Gecko. Looks like this is a new function, shape() from https://drafts.csswg.org/css-shapes-2/#funcdef-shape. Sure, I can take a look at these tests. :)

I contributed the shape() definition and working on some draft (webkit) implementation which allowed me to write tests that work :)
Wanted to contribute the tests before working on upstreaming the implementation

Copy link
Copy Markdown
Member

@BorisChiou BorisChiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but have some typos and nits. Would you mind updating them before merging? I request changes for now and will approve them after you update these nits. Thanks.

Basically, clip-path-shape-interpolation-*.html should be in the animation folder because these two files test the css animations. However, this is my bad because I added clip-path-path-interpolation-*.html in the same places. This patch looks good, and perhaps we should move them into animation folder in the future.

Comment on lines +32 to +33
test_valid_value("clip-path", "shape(from 10px 10px, arc to 50px 1pt of 10px 10px)", "shape(from 10px 10px, arc to 50px 1pt of 10px ccw small)");
test_valid_value("clip-path", "shape(from 10px 10px, arc to 50px 1pt of 10px 10px small rotate 0deg)", "shape(from 10px 10px, arc to 50px 1pt of 10px ccw small)");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitting rotate 0deg makes sense to me, but ccw and small are also default values, so I guess we don't have to serialize them, either?
So this should be something like:
test_valid_value("clip-path", "shape(from 10px 10px, arc to 50px 1pt of 10px 10px small rotate 0deg)", "shape(from 10px 10px, arc to 50px 1pt of 10px)");?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

test_valid_value("clip-path", "shape(from 10px 10px, smooth to 50px 1pt)");
test_valid_value("clip-path", "shape(from 10px 10px, arc to 50px 1pt of 10px 10px)", "shape(from 10px 10px, arc to 50px 1pt of 10px ccw small)");
test_valid_value("clip-path", "shape(from 10px 10px, arc to 50px 1pt of 10px 10px small rotate 0deg)", "shape(from 10px 10px, arc to 50px 1pt of 10px ccw small)");
test_valid_value("clip-path", "shape(from 10% 1rem, arc to 50px 1pt of 20% cw large rotate 25deg)", "shape(from 10% 1rem, arc to 50px 1pt of 20% rotate 25deg cw large)");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should follow the order when serializing these: [[<arc-sweep>] || [<arc-size>] || rotate [<angle>]]?
so this should be something like:
test_valid_value("clip-path", "shape(from 10% 1rem, arc to 50px 1pt of 20% rotate 25deg cw large)", "shape(from 10% 1rem, arc to 50px 1pt of 20% cw large rotate 25deg)");?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<!DOCTYPE html>
<html>
<head>
<title>CSS Masking: Test clip-path property and shape function with nonzero fill</title>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nonzero/evenodd/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">
<link rel="match" href="reference/clip-path-path-002-ref.html">
<meta name="assert" content="The clip-path property takes the basic shape
'shape()' for clipping. Test nonzero path function. On pass you should
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nonzero/evenodd/

Comment on lines +6 to +7
<meta name="assert" content="The clip-path property takes the basic shape
'shape()' for clipping. Test curves.">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't need to add meta "assert" for reference file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<link rel="match" href="reference/clip-path-path-002-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<meta name="assert" content="The clip-path property takes the basic shape
'shape()' for clipping. Test nonzero path function. On pass you should
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nonzero/evenodd/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>CSS Masking: Test clip-path nonzero path interpolation</title>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nonzero/evenodd/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">
<link rel="match" href="reference/clip-path-path-interpolation-002-ref.html">
<meta name="assert" content="The clip-path property takes the basic shape
'shape()' for clipping. Test the interpolation of nonzero
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nonzero/evenodd/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +133 to +142
test_interpolation({
property: 'clip-path',
from: 'shape(from 5% 5px, smooth by 10% 10px via 0% 80px, smooth by 30% 20px)',
to: 'shape(from 15% 15px, smooth by 20% 0px via 10% 60px, smooth by 20% 30px)',
}, [
{at: -0.3, expect: 'shape(from 2% 2px, smooth by 7% 13px via -3% 86px, smooth by 33% 17px)'},
{at: 0, expect: 'shape(from 5% 5px, smooth by 10% 10px via 0% 80px, smooth by 30% 20px)'},
{at: 0.5, expect: 'shape(from 10% 10px, smooth by 15% 5px via 5% 70px, smooth by 25% 25px)'},
{at: 1.5, expect: 'shape(from 20% 20px, smooth by 25% -5px via 15% 50px, smooth by 15% 35px)'},
]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this duplicated? Looks like this is the same as the previous one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by instead of to

Comment on lines +111 to +120
test_interpolation({
property: 'clip-path',
from: 'shape(from 5% 5px, curve by 10% 10px via 0% 80px, curve by 30% 20px via 20% 50px 25% 70px)',
to: 'shape(from 15% 15px, curve by 20% 0px via 10% 60px, curve by 20% 30px via 30% 40px -5% 100px)',
}, [
{at: -0.3, expect: 'shape(from 2% 2px, curve by 7% 13px via -3% 86px, curve by 33% 17px via 17% 53px 34% 61px)'},
{at: 0, expect: 'shape(from 5% 5px, curve by 10% 10px via 0% 80px, curve by 30% 20px via 20% 50px 25% 70px)'},
{at: 0.5, expect: 'shape(from 10% 10px, curve by 15% 5px via 5% 70px, curve by 25% 25px via 25% 45px 10% 85px)'},
{at: 1.5, expect: 'shape(from 20% 20px, curve by 25% -5px via 15% 50px, curve by 15% 35px via 35% 35px -20% 115px)'},
]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this duplicated? Looks like this is the same as the previous one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses by instead of to

Copy link
Copy Markdown
Member

@BorisChiou BorisChiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants