WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
286290
Add support for the lang attribute in SVG
https://bugs.webkit.org/show_bug.cgi?id=286290
Summary
Add support for the lang attribute in SVG
Deleted User
Reported
2025-01-21 03:44:30 PST
https://searchfox.org/wubkat/source/LayoutTests/imported/w3c/web-platform-tests/svg/text/reftests/lang-attribute.svg
According to
https://searchfox.org/wubkat/rev/d4766b667963256e41db8c72a02613067074d834/LayoutTests/TestExpectations#2345
it fails. The error lies presumably in a missing check in
https://searchfox.org/wubkat/rev/d4766b667963256e41db8c72a02613067074d834/Source/WebCore/dom/Element.cpp#4547
.
Attachments
rendering in safari, firefox, chrome
(149.65 KB, image/png)
2026-04-02 07:46 PDT
,
Karl Dubost
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-01-28 03:45:14 PST
<
rdar://problem/143751056
>
Karl Dubost
Comment 2
2026-04-02 07:46:15 PDT
Created
attachment 478905
[details]
rendering in safari, firefox, chrome The test is failing just because of the font chosen to render the text I guess. Maybe Vitor knows why?
Karl Dubost
Comment 3
2026-04-02 08:11:26 PDT
Code snippet for the console to extract the relevant information for each browser: document.querySelectorAll('text, tspan').forEach(el => { console.log( el.tagName + ' lang=' + el.getAttribute('lang') + ' matches:lang(ja)=' + el.matches(':lang(ja)') + ' matches:lang(zh-CN)=' + el.matches(':lang(zh-CN)') + ' matches:lang(zh-TW)=' + el.matches(':lang(zh-TW)') + ' "' + el.textContent.trim().substring(0, 20) + '"' ); }); Safari: [Log] text lang=null matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直 今骨直 今骨直" [Log] tspan lang=ja matches:lang(ja)=true matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直" [Log] tspan lang=zh-CN matches:lang(ja)=false matches:lang(zh-CN)=true matches:lang(zh-TW)=false "今骨直" [Log] tspan lang=zh-TW matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=true "今骨直" Firefox: text lang=null matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直 今骨直 今骨直" debugger eval code:2:13 tspan lang=ja matches:lang(ja)=true matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直" debugger eval code:2:13 tspan lang=zh-CN matches:lang(ja)=false matches:lang(zh-CN)=true matches:lang(zh-TW)=false "今骨直" debugger eval code:2:13 tspan lang=zh-TW matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=true "今骨直" Chrome: text lang=null matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直 今骨直 今骨直" VM17:2 tspan lang=ja matches:lang(ja)=true matches:lang(zh-CN)=false matches:lang(zh-TW)=false "今骨直" VM17:2 tspan lang=zh-CN matches:lang(ja)=false matches:lang(zh-CN)=true matches:lang(zh-TW)=false "今骨直" VM17:2 tspan lang=zh-TW matches:lang(ja)=false matches:lang(zh-CN)=false matches:lang(zh-TW)=true "今骨直"
Karl Dubost
Comment 4
2026-04-02 08:14:51 PDT
HTMLElement::collectPresentationalHintsForAttribute() (HTMLElement.cpp:259-265) maps lang and xml:lang to -webkit-locale via mapLanguageAttributeToLocale(), which calls addPropertyToPresentationalHintStyle(style, CSSPropertyWebkitLocale, ...). SVGElement::collectPresentationalHintsForAttribute() (SVGElement.cpp:1026-1031) only handles SVG-specific presentation attributes (fill, stroke, etc.) via cssPropertyIdForSVGAttributeName(). It does not handle lang/xml:lang at all. The language never becomes a -webkit-locale presentational hint.
Karl Dubost
Comment 5
2026-04-02 08:17:01 PDT
Add lang/xml:lang → -webkit-locale mapping in SVGElement, mirroring what HTMLElement does. SVGElement.cpp — hasPresentationalHintsForAttribute(): ============ bool SVGElement::hasPresentationalHintsForAttribute(const QualifiedName& name) const { if (cssPropertyIdForSVGAttributeName(name, document().settings()) > 0) return true; if (name.matches(XMLNames::langAttr) || name.matches(HTMLNames::langAttr)) return true; return StyledElement::hasPresentationalHintsForAttribute(name); } ============ SVGElement.cpp — collectPresentationalHintsForAttribute(): ============ void SVGElement::collectPresentationalHintsForAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style) { CSSPropertyID propertyID = cssPropertyIdForSVGAttributeName(name, document().settings()); if (propertyID > 0) addPropertyToPresentationalHintStyle(style, propertyID, value); else if (name.matches(XMLNames::langAttr)) mapLanguageAttributeToLocale(value, style); else if (name.matches(HTMLNames::langAttr) && !hasAttributeWithoutSynchronization(XMLNames::langAttr)) mapLanguageAttributeToLocale(value, style); } ============ Note: mapLanguageAttributeToLocale() is currently a private method on HTMLElement.
Karl Dubost
Comment 6
2026-04-02 09:22:15 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/61919
EWS
Comment 7
2026-04-02 20:41:27 PDT
Committed
310495@main
(f7fa439ccd03): <
https://commits.webkit.org/310495@main
> Reviewed commits have been landed. Closing PR #61919 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