Skip to content

Make text-decoration CSS property a shorthand - #6466

Closed
nt1m wants to merge 1 commit into
WebKit:mainfrom
nt1m:unprefix-text-decoration
Closed

nt1m wants to merge 1 commit into
WebKit:mainfrom
nt1m:unprefix-text-decoration

Conversation

@nt1m

@nt1m nt1m commented Nov 14, 2022 •

Copy link
Copy Markdown
Member

a6e46ae

Make text-decoration CSS property a shorthand
https://bugs.webkit.org/show_bug.cgi?id=230083
rdar://83182835

Reviewed by NOBODY (OOPS!).

- text-decoration should be a shorthand for text-decoration-line/thickness/color/style
- Make -webkit-text-decoration an alias of text-decoration
- Adapt editing code for new behavior

* LayoutTests/TestExpectations:
* LayoutTests/fast/css/getComputedStyle/getComputedStyle-text-decoration-expected.txt:
* LayoutTests/fast/css/getComputedStyle/getComputedStyle-text-decoration.html:
* LayoutTests/fast/css/style-enumerate-properties-expected.txt:
* LayoutTests/fast/css/style-enumerate-properties.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dashed.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dotted-dashed.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dotted.html:
* LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-shorthand-expected.txt:
* LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-shorthand.html:
* LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-letter-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-line-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/text-decoration-serialization.tentative-expected.txt:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
(WebCore::ComputedStyleExtractor::textDecorationShorthandValue):
* Source/WebCore/css/ComputedStyleExtractor.h:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serialize):
* Source/WebCore/css/StyleProperties.cpp:
(WebCore::canUseShorthandForLonghand):
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseShorthand):
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent):
(WebCore::EditingStyle::init):
(WebCore::EditingStyle::styleWithResolvedTextDecorations const):
(WebCore::EditingStyle::collapseTextDecorationProperties):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
(WebCore::EditingStyle::removeEquivalentProperties):
(WebCore::reconcileTextDecorationProperties):
(WebCore::StyleChange::StyleChange):
(WebCore::setTextDecorationProperty):
(WebCore::StyleChange::extractTextStyles):
(WebCore::diffTextDecorations):
(WebCore::extractPropertiesNotIn):
* Source/WebCore/editing/markup.cpp:
(WebCore::serializePreservingVisualAppearanceInternal):

a6e46ae

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ❌ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🛠 gtk
❌ 🧪 ios-wk2-wpt ❌ 🧪 gtk-wk2
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ❌ 🧪 mac-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 tv ❌ 🧪 mac-AS-debug-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch ✅ 🛠 jsc-mips
✅ 🛠 watch-sim ✅ 🧪 jsc-mips-tests

@nt1m
nt1m requested review from graouts and rniwa as code owners November 14, 2022 10:47
@nt1m nt1m self-assigned this Nov 14, 2022
@nt1m nt1m added CSS Cascading Style Sheets implementation WebKit Nightly Build labels Nov 14, 2022
@nt1m
nt1m force-pushed the unprefix-text-decoration branch from 2862607 to bf13e33 Compare November 14, 2022 10:47
@nt1m
nt1m marked this pull request as draft November 14, 2022 10:59
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Nov 14, 2022
Comment thread Source/WebCore/css/StyleProperties.cpp Resolved
@nt1m nt1m removed the merging-blocked Applied to prevent a change from being merged label Feb 24, 2023
@nt1m nt1m changed the title Make text-decoration CSS property spec-compliant Make text-decoration CSS property a shorthand Feb 24, 2023
@nt1m
nt1m force-pushed the unprefix-text-decoration branch from bf13e33 to f56aa8e Compare February 24, 2023 23:39
@nt1m
nt1m force-pushed the unprefix-text-decoration branch from f56aa8e to d36cd6a Compare February 24, 2023 23:41
@nt1m
nt1m force-pushed the unprefix-text-decoration branch from d36cd6a to 0c414d8 Compare February 25, 2023 01:17
https://bugs.webkit.org/show_bug.cgi?id=230083
rdar://83182835

Reviewed by NOBODY (OOPS!).

- text-decoration should be a shorthand for text-decoration-line/thickness/color/style
- Make -webkit-text-decoration an alias of text-decoration
- Adapt editing code for new behavior

* LayoutTests/TestExpectations:
* LayoutTests/fast/css/getComputedStyle/getComputedStyle-text-decoration-expected.txt:
* LayoutTests/fast/css/getComputedStyle/getComputedStyle-text-decoration.html:
* LayoutTests/fast/css/style-enumerate-properties-expected.txt:
* LayoutTests/fast/css/style-enumerate-properties.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dashed.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dotted-dashed.html:
* LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-dotted.html:
* LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-shorthand-expected.txt:
* LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-decoration-shorthand.html:
* LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-letter-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-line-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/text-decoration-serialization.tentative-expected.txt:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
(WebCore::ComputedStyleExtractor::textDecorationShorthandValue):
* Source/WebCore/css/ComputedStyleExtractor.h:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serialize):
* Source/WebCore/css/StyleProperties.cpp:
(WebCore::canUseShorthandForLonghand):
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseShorthand):
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent):
(WebCore::EditingStyle::init):
(WebCore::EditingStyle::styleWithResolvedTextDecorations const):
(WebCore::EditingStyle::collapseTextDecorationProperties):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
(WebCore::EditingStyle::removeEquivalentProperties):
(WebCore::reconcileTextDecorationProperties):
(WebCore::StyleChange::StyleChange):
(WebCore::setTextDecorationProperty):
(WebCore::StyleChange::extractTextStyles):
(WebCore::diffTextDecorations):
(WebCore::extractPropertiesNotIn):
* Source/WebCore/editing/markup.cpp:
(WebCore::serializePreservingVisualAppearanceInternal):
@nt1m
nt1m force-pushed the unprefix-text-decoration branch from 0c414d8 to a6e46ae Compare June 13, 2023 05:51
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 13, 2023
@nt1m nt1m closed this Aug 1, 2024
webkit-commit-queue pushed a commit to vitorroriz/WebKit that referenced this pull request Aug 9, 2025
rdar://156011594
https://bugs.webkit.org/show_bug.cgi?id=296097

Reviewed by Ryosuke Niwa and Tim Nguyen.

Currently, text-decoration can only handle text-decoration-line
values, effectively making it a "alias" for it, while
-webkit-text-decoration can handle only 3 of text-decoration longhands.

We are consolidating behavior here, making -webkit-text-decoration an alias
for text-decoration. The property will be the shorthand for all 4 longhands:
- text-decoration-line
- text-decoration-thickness
- text-decoration-style
- text-decoration-color

We need to rebase a bunch of editing-related tests. Since text-decoration was
effectively working as an alias to text-decoration-line, this behavior was assumed
in EditingStyle. The changes here won't really change how things look from a user's
point of view, but in some cases we will serialize, for example, inline style,
"text-decoration: underline" as "text-decoration-line: underline", which actually
make us more aligned with other engine implementations.

While implementing this, I've realized there is a bug when propagating isCurrentColor
for the animation style. This also affect other shorthands, like text-emphasis.
So we are rebasing the animation tests here and aiming to intestigate it at:
https://bugs.webkit.org/show_bug.cgi?id=296914

This is based on the previous attempts from:

* Oriol Brufau (@Loirooriol):
-  https://commits.webkit.org/248000@main (reverted)
* Tim Nguyen (@nt1m):
- WebKit#6466
* Matthieu Dubet (@mdubet)
- WebKit#23121

* LayoutTests/TestExpectations:
* LayoutTests/editing/deleting/delete-line-break-before-underlined-content-expected.txt:
* LayoutTests/editing/deleting/delete-line-break-before-underlined-content-live-range-expected.txt:
* LayoutTests/editing/deleting/deleting-line-break-preserves-underline-color-expected.txt:
* LayoutTests/editing/deleting/deleting-line-break-preserves-underline-color-live-range-expected.txt:
* LayoutTests/editing/deleting/merge-div-from-span-with-style-expected.txt:
* LayoutTests/editing/deleting/merge-div-from-span-with-style-live-range-expected.txt:
* LayoutTests/editing/deleting/merge-paragraph-from-span-with-multiple-text-decoration-expected.txt:
* LayoutTests/editing/deleting/merge-paragraph-from-span-with-multiple-text-decoration-live-range-expected.txt:
* LayoutTests/editing/deleting/merge-paragraph-from-span-with-style-expected.txt:
* LayoutTests/editing/deleting/merge-paragraph-from-span-with-style-live-range-expected.txt:
* LayoutTests/editing/execCommand/inline-style-after-indentoutdent-expected.txt:
* LayoutTests/editing/execCommand/inline-style-after-indentoutdent.html:
* LayoutTests/editing/execCommand/toggle-mixed-text-decorations-expected.txt:
* LayoutTests/editing/execCommand/toggle-mixed-text-decorations.html:
* LayoutTests/editing/pasteboard/insert-text-decoration-expected.txt:
* LayoutTests/editing/pasteboard/insert-u-with-text-decoration-none-expected.txt:
* LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt:
* LayoutTests/editing/style/push-down-implicit-styles-mac-expected.txt:
* LayoutTests/editing/style/push-down-implicit-styles-mac.html:
* LayoutTests/editing/style/push-down-inline-styles-expected.txt:
* LayoutTests/editing/style/push-down-inline-styles.html:
* LayoutTests/fast/css/style-enumerate-properties-expected.txt:
* LayoutTests/fast/css/style-enumerate-properties.html:
* LayoutTests/fast/events/input-events-paste-rich-datatransfer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-letter-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/first-line-allowed-properties-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-decoration-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/delete_3001-4000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/forwarddelete_3001-4000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/multitest_8001-9000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/strikethrough_1-1000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/strikethrough_1001-2000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/strikethrough_2001-last-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/underline_1-1000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/underline_1001-2000-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/underline_2001-last-expected.txt:
* LayoutTests/platform/glib/fast/events/input-events-paste-rich-datatransfer-expected.txt:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serialize):
* Source/WebCore/css/StyleProperties.cpp:
(WebCore::canUseShorthandForLonghand):
* Source/WebCore/css/html.css:
(abbr[title], acronym[title]):
* Source/WebCore/css/parser/CSSPropertyParserCustom.h:
(WebCore::CSS::PropertyParserCustom::consumeSingleShorthand): Deleted.
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::EditingStyle::init):
(WebCore::EditingStyle::styleWithResolvedTextDecorations const):
(WebCore::EditingStyle::collapseTextDecorationProperties):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
(WebCore::EditingStyle::mergeStyle):
(WebCore::EditingStyle::removeStyleFromRulesAndContext):
(WebCore::EditingStyle::removeEquivalentProperties):
(WebCore::reconcileTextDecorationProperties):
(WebCore::StyleChange::StyleChange):
(WebCore::setTextDecorationProperty):
(WebCore::StyleChange::extractTextStyles):
* Source/WebCore/editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
* Source/WebCore/editing/markup.cpp:
(WebCore::serializePreservingVisualAppearanceInternal):
* Source/WebCore/style/StyleExtractorCustom.h:
(WebCore::Style::isDefaultOrIgnorableTextDecorationLine):
(WebCore::Style::ExtractorCustom::extractTextDecorationShorthand):
(WebCore::Style::ExtractorCustom::extractTextDecorationShorthandSerialization):

Canonical link: https://commits.webkit.org/298456@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation 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