Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8c142edd53ed1b7ddef9dd6846e5915603d98f1e
https://github.com/WebKit/WebKit/commit/8c142edd53ed1b7ddef9dd6846e5915603d98f1e
Author: Nipun Shukla <[email protected]>
Date: 2026-02-18 (Wed, 18 Feb 2026)
Changed paths:
A LayoutTests/fast/css/lang-document-element-flag-expected.txt
A LayoutTests/fast/css/lang-document-element-flag.html
M LayoutTests/fast/css/lang-matching-document-invalidation-expected.txt
M LayoutTests/fast/css/lang-matching-document-invalidation.html
A
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/lang-attribute-document-element-replacement-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/lang-attribute-document-element-replacement.html
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/Element.h
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
Log Message:
-----------
Reduce number of ElementRareData allocations due to lang
https://bugs.webkit.org/show_bug.cgi?id=307706
rdar://170261859
Reviewed by Ryosuke Niwa.
This patch fixes an issue where the document element's
effectiveLangKnownToMatchDocumentElement flag was not being set correctly,
which had the effect of propagating a lang attribute from that document
element unconditionally. There was also an existing issue where
descendants of an disconnected root with a lang would instead take the new
document element's lang instead of walking their own ancestor chain.
This fix is implemented by having effectiveLang() check isConnected()
prior to using the cached document element language, and walks the
ancestor chain for disconnected elements.
Additionally, this fixes setEffectiveLangStateOnOldDocumentElement()
to clear the flag and changes clearEffectiveLangStateOnNewDocumentElement()
to unconditionally set effectiveLangKnownToMatchDocumentElement to true
as the document element must by definition match itself.
* LayoutTests/fast/css/lang-document-element-flag-expected.txt: Added.
* LayoutTests/fast/css/lang-document-element-flag.html: Added.
* LayoutTests/fast/css/lang-matching-document-invalidation-expected.txt:
* LayoutTests/fast/css/lang-matching-document-invalidation.html:
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/lang-attribute-document-element-replacement-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/lang-attribute-document-element-replacement.html:
Added.
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::clearEffectiveLangStateOnNewDocumentElement):
(WebCore::Element::setEffectiveLangStateOnOldDocumentElement):
(WebCore::Element::removedFromAncestor):
(WebCore::Element::effectiveLang const):
* Source/WebCore/dom/Element.h:
(WebCore::Element::effectiveLangKnownToMatchDocumentElement const):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::effectiveLangKnownToMatchDocumentElement):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
Canonical link: https://commits.webkit.org/307769@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications