WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
271627
shorthand value for CSS gap is not kept as-is in serialized and computed values.
https://bugs.webkit.org/show_bug.cgi?id=271627
Summary
shorthand value for CSS gap is not kept as-is in serialized and computed values.
Karl Dubost
Reported
2024-03-24 22:28:17 PDT
see
http://wpt.live/css/css-align/parsing/gap-computed.html
https://wpt.fyi/results/css/css-align/parsing/gap-computed.html
with const target = document.getElementById('target'); target.style['gap'] = 'normal'; Then doing: target.style.cssText; target.style.getPropertyValue('gap'); window.getComputedStyle(target).gap; Safari: cssText: "row-gap: normal; column-gap: normal;" getPropertyValue: "normal" getComputedStyle: "normal normal" Firefox: cssText: "gap: normal;" getPropertyValue: "normal" getComputedStyle: "normal" Chrome: cssText: "gap: normal;" getPropertyValue: "normal" getComputedStyle: "normal" In
https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/parser/CSSPropertyParser.cpp#2911-2921
case CSSPropertyGap: { RefPtr rowGap = CSSPropertyParsing::consumeRowGap(m_range, m_context); RefPtr columnGap = CSSPropertyParsing::consumeColumnGap(m_range, m_context); if (!rowGap || !m_range.atEnd()) return false; if (!columnGap) columnGap = rowGap; addProperty(CSSPropertyRowGap, CSSPropertyGap, rowGap.releaseNonNull(), important); addProperty(CSSPropertyColumnGap, CSSPropertyGap, columnGap.releaseNonNull(), important); return true; } In
https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/ComputedStyleExtractor.cpp#3695-3696
case CSSPropertyGap: return getCSSPropertyValuesForShorthandProperties(gapShorthand()); In
https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/ComputedStyleExtractor.cpp#4788-4794
Ref<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const { CSSValueListBuilder list; for (auto longhand : shorthand) list.append(propertyValue(longhand, UpdateLayout::No).releaseNonNull()); return CSSValueList::createSpaceSeparated(WTFMove(list)); } And [StylePropertyShorthandFunctions.cpp](
https://searchfox.org/wubkat/source/__GENERATED__/WebCore/DerivedSources/StylePropertyShorthandFunctions.cpp#839-846
) StylePropertyShorthand gapShorthand() { static const CSSPropertyID gapProperties[] = { CSSPropertyID::CSSPropertyRowGap, CSSPropertyID::CSSPropertyColumnGap, }; return StylePropertyShorthand(CSSPropertyID::CSSPropertyGap, gapProperties); }
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-03-24 22:28:29 PDT
<
rdar://problem/125335787
>
Tim Nguyen (:ntim)
Comment 2
2024-03-24 23:44:56 PDT
Fixing the cssText bit is just a matter of removing this line:
https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/StyleProperties.cpp#253
There are many ways to fix getComputedStyle, the easiest one being using ShorthandSerializer for the computed style by adding CSSPropertyGap here:
https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/CSSComputedStyleDeclaration.cpp#131-136
Karl Dubost
Comment 3
2024-03-25 00:35:27 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/26398
EWS
Comment 4
2024-03-28 12:23:59 PDT
Committed
276794@main
(ab28ade5ffd5): <
https://commits.webkit.org/276794@main
> Reviewed commits have been landed. Closing PR #26398 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug