Skip to content

::first-letter should include preceding punctuation and space separators #42507

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johannesodland
Copy link
Contributor

@johannesodland johannesodland commented Mar 14, 2025

2bceb0e

::first-letter should include preceding punctuation and space separators
https://bugs.webkit.org/show_bug.cgi?id=179815

Reviewed by NOBODY (OOPS!).

Updating the punctuation and whitespace characters that are included preceding and following the first-letter
according to https://www.w3.org/TR/css-pseudo-4/#first-letter-pattern.
This change makes first-letter-punctuation-and-space.html pass.

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::isPrecedingPunctuationForFirstLetter):
(WebCore::isFollowingPunctuationForFirstLetter):
(WebCore::shouldSkipForFirstLetter):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
(WebCore::isPunctuationForFirstLetter): Deleted.

5d194cf

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ❌ 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl ❌ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
❌ 🧪 ios-wk2-wpt ❌ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ❌ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ⏳ 🧪 mac-AS-debug-wk2 ❌ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🧪 vision-wk2 ❌ 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@nt1m nt1m requested review from alanbaradlay and anttijk March 14, 2025 21:41
@Ahmad-S792 Ahmad-S792 added the Layout and Rendering For bugs with layout and rendering of Web pages. label Mar 14, 2025
@johannesodland johannesodland force-pushed the eng/first-letter-should-include-preceding-punctuation-and-space-separators branch from 2bceb0e to 1f36172 Compare March 14, 2025 22:16
Copy link
Contributor

@fantasai fantasai left a comment

Choose a reason for hiding this comment

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

Not all space characters are allowed -- we still have to exclude U+3000 IDEOGRAPHIC SPACE, but also allow the rest of of Zs!

@johannesodland johannesodland force-pushed the eng/first-letter-should-include-preceding-punctuation-and-space-separators branch from 1f36172 to 6a8ffe7 Compare March 25, 2025 19:26
@johannesodland johannesodland force-pushed the eng/first-letter-should-include-preceding-punctuation-and-space-separators branch from 6a8ffe7 to f637b31 Compare March 25, 2025 19:34
@johannesodland johannesodland force-pushed the eng/first-letter-should-include-preceding-punctuation-and-space-separators branch from f637b31 to 56eacd3 Compare March 25, 2025 20:12
https://bugs.webkit.org/show_bug.cgi?id=179815

Reviewed by NOBODY (OOPS!).

Updating the punctuation and whitespace characters that are included preceding and following the first-letter
according to https://www.w3.org/TR/css-pseudo-4/#first-letter-pattern.
This change makes first-letter-punctuation-and-space.html pass.

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::isPrecedingPunctuationForFirstLetter):
(WebCore::isFollowingPunctuationForFirstLetter):
(WebCore::shouldSkipForFirstLetter):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
(WebCore::isPunctuationForFirstLetter): Deleted.
@johannesodland johannesodland force-pushed the eng/first-letter-should-include-preceding-punctuation-and-space-separators branch from 56eacd3 to 5d194cf Compare March 25, 2025 20:14
@johannesodland
Copy link
Contributor Author

Not all space characters are allowed -- we still have to exclude U+3000 IDEOGRAPHIC SPACE, but also allow the rest of of Zs!

I tried to avoid changing the whitespace logic too much, but we might just update it now 😅

I have pushed an update to the PR to align with the updated First Letters and Associated Punctuation chapter in the spec.

It should pass the updated web platform test (yet to be reviewed).

@johannesodland johannesodland requested a review from fantasai March 25, 2025 20:39
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 25, 2025
@johannesodland
Copy link
Contributor Author

I realize that we also have to consume the white-space before the preceding punctuation. Otherwise ::first-letter will not work in cases such as below:

<p>
  The initial T-character should ble included in `::first-letter`.
</p>

@fantasai , I expect the preceding white-spaces also should be included in the ::first-letter as that is how webkit currently works.

Which letters should be allowed to precede the punctuation? Does this need to be specced?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layout and Rendering For bugs with layout and rendering of Web pages. merging-blocked Applied to prevent a change from being merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants