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

Make the SVG parser interpret form feed as whitespace #23059

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Jan 22, 2024

15c6cea

Make the SVG parser interpret `form feed` as whitespace

https://bugs.webkit.org/show_bug.cgi?id=77755
rdar://problem/95488677

Reviewed by Anne van Kesteren.

This patch is to align WebKit with Chromium / Blink, Gecko / Firefox and Web Specification [1]:

[1] https://lists.w3.org/Archives/Public/public-svg-wg/2014AprJun/0068.html

This patch uses 'isASCIIWhite' across SVG Parser and code base to enable it to handle 'form feed'.

It is inspired by following change in Blink, which enables 'leading' and 'trailing' whitespace
in SVG Attributes [2]:

[2] https://src.chromium.org/viewvc/blink?view=revision&;revision=175785

Credits to Jacob Goldstein  <jacobg@adobe.com> for 'test case'.

* Source/WebCore/svg/SVGParserUtilities.cpp:
(parseGlyphName):
* Source/WebCore/svg/SVGParserUtilities.h:
(isSVGSpace): Deleted
(isSVGSpaceOrComma): Updated
(skipOptionalSVGSpaces):
(skipOptionalSVGSpacesOrDelimiter): Both templates
* Source/WebCore/svg/SVGStringList.cpp:
(SVGStringList::parse):
* LayoutTests/svg/transforms/svg-formFeed-as-whitespace.html: Add Test Case
* LayoutTests/svg/transforms/svg-formFeed-as-whitespace-expected.html: Add Test Case Expectation
* LayoutTests/svg/transforms/svg-line-tabulation-as-not-whitespace.html: Add Test Case
* LayoutTests/svg/transforms/svg-line-tabulation-as-not-whitespace-expected.html: Add Test Case Expectation

Canonical link: https://commits.webkit.org/273353@main

384b9bf

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@Ahmad-S792 Ahmad-S792 added the SVG For bugs in the SVG implementation. label Jan 22, 2024
@Ahmad-S792 Ahmad-S792 self-assigned this Jan 22, 2024
@Ahmad-S792
Copy link
Contributor Author

As per GitHub issue - the tests are still missing but it is just preparatory patch and not do all changes, which were done in Blink patch, I think we can do other changes one by one to align with other browsers. It was just the quick one which I could carve-out. So I did it.

@Ahmad-S792
Copy link
Contributor Author

@Ahmad-S792 Ahmad-S792 force-pushed the fix-svg-parser-to-use-isASCIIWhitespace branch from 1a812a2 to 70e0d27 Compare January 22, 2024 22:49
@Ahmad-S792 Ahmad-S792 changed the title Use 'isASCIIWhitespace' in SVGParserUtilities.cpp|h and SVGStringList.cpp SVG parser does not interpret "form feed" as white space Jan 22, 2024
@Ahmad-S792 Ahmad-S792 changed the title SVG parser does not interpret "form feed" as white space Make the SVG parser interpret form feed as whitespace Jan 22, 2024
@Ahmad-S792 Ahmad-S792 force-pushed the fix-svg-parser-to-use-isASCIIWhitespace branch from 70e0d27 to f8a22d0 Compare January 22, 2024 23:39
@Ahmad-S792 Ahmad-S792 marked this pull request as ready for review January 22, 2024 23:54
Copy link
Contributor

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Ideally there would be web platform tests coverage for this as well. And maybe include coverage that U+000B is not whitespace.

Overall though this seems like a good change and helps with cleaning up our whitespace handling: https://bugs.webkit.org/show_bug.cgi?id=255467.

Thanks!

@Ahmad-S792
Copy link
Contributor Author

Ideally there would be web platform tests coverage for this as well. And maybe include coverage that U+000B is not whitespace.

Overall though this seems like a good change and helps with cleaning up our whitespace handling: https://bugs.webkit.org/show_bug.cgi?id=255467.

Thanks!

I tried this - https://jsfiddle.net/74j5pftn/3/, all browsers are same in dealing with 'U+000B' and confirms that it is not whitespace. As for WPT test coverage, I think based on GitHub link posted above, it mentions that the tests are yet there.

@Ahmad-S792 Ahmad-S792 force-pushed the fix-svg-parser-to-use-isASCIIWhitespace branch from f8a22d0 to 384b9bf Compare January 23, 2024 11:18
@Ahmad-S792
Copy link
Contributor Author

@annevk - I added another test. Is it good to go now?

Copy link
Contributor

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Yeah, sorry, I should have been clearer. "Ideal" wasn't meant to be a merge blocker. Thanks for adding the additional coverage.

@Ahmad-S792 Ahmad-S792 added the merge-queue Applied to send a pull request to merge-queue label Jan 23, 2024
https://bugs.webkit.org/show_bug.cgi?id=77755
rdar://problem/95488677

Reviewed by Anne van Kesteren.

This patch is to align WebKit with Chromium / Blink, Gecko / Firefox and Web Specification [1]:

[1] https://lists.w3.org/Archives/Public/public-svg-wg/2014AprJun/0068.html

This patch uses 'isASCIIWhite' across SVG Parser and code base to enable it to handle 'form feed'.

It is inspired by following change in Blink, which enables 'leading' and 'trailing' whitespace
in SVG Attributes [2]:

[2] https://src.chromium.org/viewvc/blink?view=revision&revision=175785

Credits to Jacob Goldstein  <jacobg@adobe.com> for 'test case'.

* Source/WebCore/svg/SVGParserUtilities.cpp:
(parseGlyphName):
* Source/WebCore/svg/SVGParserUtilities.h:
(isSVGSpace): Deleted
(isSVGSpaceOrComma): Updated
(skipOptionalSVGSpaces):
(skipOptionalSVGSpacesOrDelimiter): Both templates
* Source/WebCore/svg/SVGStringList.cpp:
(SVGStringList::parse):
* LayoutTests/svg/transforms/svg-formFeed-as-whitespace.html: Add Test Case
* LayoutTests/svg/transforms/svg-formFeed-as-whitespace-expected.html: Add Test Case Expectation
* LayoutTests/svg/transforms/svg-line-tabulation-as-not-whitespace.html: Add Test Case
* LayoutTests/svg/transforms/svg-line-tabulation-as-not-whitespace-expected.html: Add Test Case Expectation

Canonical link: https://commits.webkit.org/273353@main
@webkit-commit-queue webkit-commit-queue force-pushed the fix-svg-parser-to-use-isASCIIWhitespace branch from 384b9bf to 15c6cea Compare January 23, 2024 13:35
@webkit-commit-queue
Copy link
Collaborator

Committed 273353@main (15c6cea): https://commits.webkit.org/273353@main

Reviewed commits have been landed. Closing PR #23059 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 15c6cea into WebKit:main Jan 23, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jan 23, 2024
@Ahmad-S792 Ahmad-S792 deleted the fix-svg-parser-to-use-isASCIIWhitespace branch January 24, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SVG For bugs in the SVG implementation.
Projects
None yet
4 participants