Implement CSS attr() substitution with type() syntax, number, and unit types#60660
Conversation
|
EWS run on previous version of this PR (hash 0d6fa52) Details |
iOS Safer C++ Build #4538 (0d6fa52)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
macOS Safer C++ Build #86182 (0d6fa52)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
0d6fa52 to
def5a0a
Compare
|
EWS run on previous version of this PR (hash def5a0a) Details |
…t types https://bugs.webkit.org/show_bug.cgi?id=203322 https://bugs.webkit.org/show_bug.cgi?id=203323 https://bugs.webkit.org/show_bug.cgi?id=203324 https://bugs.webkit.org/show_bug.cgi?id=203326 https://bugs.webkit.org/show_bug.cgi?id=203327 https://bugs.webkit.org/show_bug.cgi?id=203328 https://bugs.webkit.org/show_bug.cgi?id=203329 Reviewed by NOBODY (OOPS!). Extend the CSS variable reference substitution pipeline to handle attr() as a substitution function per CSS Values 5 specification. This allows attr() with type(<syntax>), raw-string, number, and <attr-unit> to work in any CSS property, not just the content property. When an attr() is encountered during parsing, it is detected as a variable reference via classifyBlock() and stored as a CSSVariableReferenceValue. During style resolution, resolveAttrReference() reads the element attribute, validates it against the specified type, and substitutes the resolved tokens (or the fallback value). Key behaviors implemented: - type(<syntax>): validates attribute value against CSS syntax - raw-string / omitted type: substitutes as CSS string token - number: parses attribute as a number token - <attr-unit> (px, em, %, etc.): parses as number then converts to dimension - Fallback defaults per spec (empty string when type omitted, guaranteed-invalid otherwise) - Cycle detection for nested attr() references FIXME: Substitution of var()/attr()/env() within attribute values (spec step 6) is not yet implemented to avoid crashes from recursive custom property resolution. FIXME: attr()-taint security is not yet implemented. * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/css/css-content/parsing/content-invalid-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-content/parsing/content-invalid.html: update it the latest WPT one * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-IACVT-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-all-types-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-container-style-query-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-cycle-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-invalidation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-length-specified-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-null-namespace-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-pseudo-elem-invalidation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-revert-rule-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/attr-security-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/if-conditionals-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-values/if-cycle-expected.txt: * Source/WebCore/css/CSSVariableReferenceValue.cpp: (WebCore::parseAttrTypeSyntax): (WebCore::isValidAttrUnit): (WebCore::parseAttrValueAsNumber): (WebCore::CSSVariableReferenceValue::resolveAttrReference const): (WebCore::CSSVariableReferenceValue::resolveTokenRange const): * Source/WebCore/css/CSSVariableReferenceValue.h: * Source/WebCore/css/parser/CSSVariableParser.cpp: (WebCore::classifyBlock): (WebCore::isValidAttrUnit): (WebCore::isValidAttrReference):
def5a0a to
d47bc4a
Compare
|
EWS run on current version of this PR (hash d47bc4a) Details |
macOS Safer C++ Build #86189 (def5a0a)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
iOS Safer C++ Build #4545 (def5a0a)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
|
This needs to be behind a new preference flag. |
|
Can you also add a bit more (either here in the PR comments or in the commit message) about the overall plan for this feature? e.g. how does it interact with the existing It's not a huge problem for this to be in classes called CSSVariableParser/CSSVariableReferenceValue. This is an existing problem, as they don't just support |
I'm just poking around to see what's happening. But I guess I need to split the PR when things are sorted out.
If I understand it correctly, the new, modern behavior should eventually completely override the old one? |
d47bc4a
d47bc4a
🛠 playstation