Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f7fa439ccd0358e373f57d325a8eeef15966aa58
      
https://github.com/WebKit/WebKit/commit/f7fa439ccd0358e373f57d325a8eeef15966aa58
  Author: Karl Dubost <[email protected]>
  Date:   2026-04-02 (Thu, 02 Apr 2026)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/platform/glib/TestExpectations
    M Source/WebCore/dom/StyledElement.cpp
    M Source/WebCore/dom/StyledElement.h
    M Source/WebCore/html/HTMLElement.cpp
    M Source/WebCore/html/HTMLElement.h
    M Source/WebCore/svg/SVGElement.cpp

  Log Message:
  -----------
  Add support for the lang attribute in SVG
https://bugs.webkit.org/show_bug.cgi?id=286290
rdar://143751056

Reviewed by Ryosuke Niwa and Vitor Roriz.

The lang attribute on SVG elements (e.g., <tspan lang="ja">) was not
propagated to the font system's locale, causing all CJK text to render
with default glyphs regardless of language. Characters like 骨 and 直
have language-specific glyph variants (Japanese vs Simplified Chinese
vs Traditional Chinese) that require the correct locale to select.

The root cause: HTMLElement::collectPresentationalHintsForAttribute()
maps lang/xml:lang to the -webkit-locale CSS property via
mapLanguageAttributeToLocale(), which feeds into
FontDescription::specifiedLocale() for font selection. SVGElement had
no equivalent mapping — the lang attribute was parsed and queryable via
:lang() but never reached the font system.

The fix moves mapLanguageAttributeToLocale() from HTMLElement (private)
to StyledElement (protected), which is the shared base class of both
HTMLElement and SVGElement. This is the natural home for the method:
it maps a DOM attribute to a CSS presentational hint using
addPropertyToPresentationalHintStyle(), which is already a StyledElement
method. SVGElement then uses the inherited method in its own
collectPresentationalHintsForAttribute() to handle lang and xml:lang
the same way HTMLElement does.

No behavioral change for HTML elements — they call the same function,
now inherited from StyledElement instead of defined locally.

This should cause no regression but progresses two WPT tests which puts
WebKit on par with Gecko and Blink and will improve internationalization
of SVG.
imported/w3c/web-platform-tests/svg/text/reftests/xml-lang-attribute.svg
imported/w3c/web-platform-tests/svg/text/reftests/lang-attribute.svg

* LayoutTests/TestExpectations:
* LayoutTests/platform/glib/TestExpectations:
  Adding exclusions for glib, because of font issues on the platform.
* Source/WebCore/dom/StyledElement.cpp:
(WebCore::StyledElement::mapLanguageAttributeToLocale):
* Source/WebCore/dom/StyledElement.h:
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::mapLanguageAttributeToLocale): Deleted.
* Source/WebCore/html/HTMLElement.h:
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::hasPresentationalHintsForAttribute const):
(WebCore::SVGElement::collectPresentationalHintsForAttribute):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to