-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add CSSComponentValueDelimiter::CommaOrWhitespace #48769
Closed
Closed
+224
−69
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Jan 17, 2025
This pull request was exported from Phabricator. Differential Revision: D68349385 |
NickGerleman
force-pushed
the
export-D68349385
branch
from
January 17, 2025 21:28
a7d679d
to
acd0722
Compare
This pull request was exported from Phabricator. Differential Revision: D68349385 |
…g to block scope (facebook#48768) Summary: Right now, if something like `CSSColor` accepted a function notation block (e.g. for `rgb()` syntax), it is given a syntax parser which may extend beyond the scope of the current function block. This is confusing, but also problematic for the `CSSSyntaxParser` block visiting logic to validate a correct scope exit. This change makes it so that the `CSSSyntaxParser` passsed to `CSSDataTypeParser` for function and simple blocks is limited to the syntax within the given block. This prevents extra visiblity beyond the block we are trying to parse, and allows the function/simple block visitor to reliably fail parsing if the block is not correctly terminated, or there are unconsumed component values within the block not handled by the data type parser. Changelog: [Internal] Differential Revision: D68340127
Summary: Must function notations do not require delimiting commas, with color function "legacy" syntax being an exception. E.g. ``` rgb() = [ <legacy-rgb-syntax> | <modern-rgb-syntax> ] rgba() = [ <legacy-rgba-syntax> | <modern-rgba-syntax> ] <legacy-rgb-syntax> = rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? ) <legacy-rgba-syntax> = rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? ) <modern-rgb-syntax> = rgb( [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? ) <modern-rgba-syntax> = rgba( [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? ) ``` Theoretically, this should mean an expression like `rgb(1, 2 0)`, which mixes both comma and whitespace delimeters would be malformed, but both Chrome, and RN's existing `normalize-color` package support this, so to make this pattern easier, we add the ability to scan based on using either whitespace or comma as component value delimiter. Interestingly, the current spec revision also allows `rgb` function with alpha, or `rgba` function without alpha, which Chrome correctly supports, but `normalize-color` does not. Changelog: [Internal] Differential Revision: D68349385
NickGerleman
added a commit
to NickGerleman/react-native
that referenced
this pull request
Jan 17, 2025
Summary: Must function notations do not require delimiting commas, with color function "legacy" syntax being an exception. E.g. ``` rgb() = [ <legacy-rgb-syntax> | <modern-rgb-syntax> ] rgba() = [ <legacy-rgba-syntax> | <modern-rgba-syntax> ] <legacy-rgb-syntax> = rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? ) <legacy-rgba-syntax> = rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? ) <modern-rgb-syntax> = rgb( [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? ) <modern-rgba-syntax> = rgba( [ <number> | <percentage> | none]{3} [ / [<alpha-value> | none] ]? ) ``` Theoretically, this should mean an expression like `rgb(1, 2 0)`, which mixes both comma and whitespace delimeters would be malformed, but both Chrome, and RN's existing `normalize-color` package support this, so to make this pattern easier, we add the ability to scan based on using either whitespace or comma as component value delimiter. Interestingly, the current spec revision also allows `rgb` function with alpha, or `rgba` function without alpha, which Chrome correctly supports, but `normalize-color` does not. Changelog: [Internal] Differential Revision: D68349385
NickGerleman
force-pushed
the
export-D68349385
branch
from
January 17, 2025 21:32
acd0722
to
cdc6ce6
Compare
This pull request was exported from Phabricator. Differential Revision: D68349385 |
NickGerleman
force-pushed
the
export-D68349385
branch
from
January 17, 2025 21:33
cdc6ce6
to
1cb3769
Compare
This pull request was exported from Phabricator. Differential Revision: D68349385 |
This pull request has been merged in 743de70. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Must function notations do not require delimiting commas, with color function "legacy" syntax being an exception.
E.g.
Theoretically, this should mean an expression like
rgb(1, 2 0)
, which mixes both comma and whitespace delimeters would be malformed, but both Chrome, and RN's existingnormalize-color
package support this, so to make this pattern easier, we add the ability to scan based on using either whitespace or comma as component value delimiter.Interestingly, the current spec revision also allows
rgb
function with alpha, orrgba
function without alpha, which Chrome correctly supports, butnormalize-color
does now.Changelog: [Internal]
Differential Revision: D68349385