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

CSS: Support recursive calc definition, improve compatibility for custom properties, support :has pseudo-class #5432

Merged
merged 5 commits into from
Feb 8, 2023

Conversation

matthiasblaesing
Copy link
Contributor

@matthiasblaesing matthiasblaesing commented Feb 4, 2023

Support recursive CSS property definitions (calc function with embedded function calls)

The grammar for calc property values failed to parse embedded var and
calc calls correctly. The issue is the work-around introduces as
function-content, which basicly prevents nesting any expression that
contains braces.

This changes the grammar parsing result from a tree to a directed graph,
which can contain cycles. This needs to taken into account by useers of
the parsed grammar.

An example of such a cycle is:

calc-fn -> calc-sum -> calc-product -> calc-value -> calc-sum
              ^                                        |
              +----------------------------------------+

For example this is now supported:

.header {
  height: calc(28 * var(--spacing-unit));
}

Improve compatibility for custom properties

Custom properties can hold more or less arbitrary content. This was not parsed and is now:

:root {
  --grid-gutter: (var(--margins) * var(--spacing-unit));
  --cell-margin: (var(--grid-gutter) / 2);
}

Support CSS :has pseudo-class

This was not parsed and is now:

body:has(+ #aCheck:checked) {
    background-color:red;
}

Closes: #5025
Closes: #5303

@matthiasblaesing matthiasblaesing added CSS [ci] enable web job ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Feb 4, 2023
@matthiasblaesing matthiasblaesing added this to the NB18 milestone Feb 4, 2023
@matthiasblaesing matthiasblaesing force-pushed the css_improvements branch 2 times, most recently from b1486d3 to b7394ab Compare February 5, 2023 08:39
Copy link
Contributor

@vieiro vieiro left a comment

Choose a reason for hiding this comment

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

Great job! Thanks, @matthiasblaesing

@matthiasblaesing
Copy link
Contributor Author

@vieiro thank you for the review. I pushed updates - could you have another look?

@vieiro
Copy link
Contributor

vieiro commented Feb 5, 2023

@vieiro thank you for the review. I pushed updates - could you have another look?

@matthiasblaesing Great job. Thanks again for this!

The grammar for calc property values failed to parse embedded var and
calc calls correctly. The issue is the work-around introduces as
function-content, which basicly prevents nesting any expression that
contains braces.

This changes the grammar parsing result from a tree to a directed graph,
which can contain cycles. This needs to taken into account by useers of
the parsed grammar.

An example of such a cycle is:

calc-fn -> calc-sum -> calc-product -> calc-value -> calc-sum
              ^                                        |
              +----------------------------------------+

Closes: apache#5025
@matthiasblaesing matthiasblaesing merged commit 795e1d8 into apache:master Feb 8, 2023
@matthiasblaesing matthiasblaesing deleted the css_improvements branch February 10, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) CSS [ci] enable web job
Projects
None yet
2 participants