Skip to content

Conversation

@eerii
Copy link
Member

@eerii eerii commented Oct 9, 2025

11f6206

Implement math-depth.
https://bugs.webkit.org/show_bug.cgi?id=300967

Reviewed by Antti Koivisto and Sam Weinig.

Parse and implement the `math-depth` property defined on MathML Core:
https://w3c.github.io/mathml-core/#propdef-math-depth.
This is gated behind the `CSSMathDepth` preference.
At the moment the property doesn't do anything, a followup patch for
`font-size: math` is required.

* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/parsing/math-depth-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/parsing/math-depth-valid-expected.txt:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Removed.
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Removed.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/mathml.css:
(math):
(mfrac > *):
(mroot > :not(:first-child)):
(msub > :not(:first-child),):
(mroot > *:last-child): Deleted.
(msub > * + *, msup > * + *, msubsup > * + *, mmultiscripts > * + *, munder > * + *, mover > * + *, munderover > * + *): Deleted.
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::applyUASheetBehaviorsToContext):
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::initialMathDepth):
(WebCore::RenderStyle::mathDepth const):
* Source/WebCore/rendering/style/RenderStyleSetters.h:
(WebCore::RenderStyle::setMathDepth):
* Source/WebCore/rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
(WebCore::StyleRareInheritedData::dumpDifferences const):
* Source/WebCore/rendering/style/StyleRareInheritedData.h:
* Source/WebCore/style/values/math/StyleMathDepth.cpp: Added.
(WebCore::Style::CSSValueConversion<MathDepth>::operator):
* Source/WebCore/style/values/math/StyleMathDepth.h: Added.

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

7cf5016

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 tv 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 9, 2025
@eerii eerii requested a review from weinig October 16, 2025 08:28
Copy link
Contributor

@weinig weinig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, but I like to hear @anttijk's thoughts on the top-priority part.

"animation-wrapper": "StyleTypeWrapper",
"settings-flag": "cssMathDepthEnabled",
"style-converter": "StyleType<MathDepth>",
"top-priority": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like @anttijk to weigh in on what the costs of adding a new top-priority property might be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks. For what is worth, Chromium does this too, since this property needs to resolve before the font-size one: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/css_properties.json5;l=1747?q=%22math-depth%22%20file:properties.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have to do that, Stylo (used by Firefox/Servo) does that too: https://searchfox.org/firefox-main/rev/8e5d58cfed616cb90586c614e53d8ab1ffc8af27/servo/components/style/properties/data.py#55

In practice math-depth is only used for MathML subtrees, so that shouldn't impact the performance when MathML is not used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is really much cost.

@eerii eerii closed this Oct 17, 2025
@eerii eerii reopened this Oct 17, 2025
@eerii eerii requested a review from anttijk October 17, 2025 14:45
@aperezdc aperezdc added safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks and removed merging-blocked Applied to prevent a change from being merged labels Oct 24, 2025
@Ahmad-S792 Ahmad-S792 added merge-queue Applied to send a pull request to merge-queue and removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Oct 24, 2025
https://bugs.webkit.org/show_bug.cgi?id=300967

Reviewed by Antti Koivisto and Sam Weinig.

Parse and implement the `math-depth` property defined on MathML Core:
https://w3c.github.io/mathml-core/#propdef-math-depth.
This is gated behind the `CSSMathDepth` preference.
At the moment the property doesn't do anything, a followup patch for
`font-size: math` is required.

* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/parsing/math-depth-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/parsing/math-depth-valid-expected.txt:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Removed.
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-script-level-001.tentative-expected.txt: Removed.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Removed.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/mathml.css:
(math):
(mfrac > *):
(mroot > :not(:first-child)):
(msub > :not(:first-child),):
(mroot > *:last-child): Deleted.
(msub > * + *, msup > * + *, msubsup > * + *, mmultiscripts > * + *, munder > * + *, mover > * + *, munderover > * + *): Deleted.
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::applyUASheetBehaviorsToContext):
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::initialMathDepth):
(WebCore::RenderStyle::mathDepth const):
* Source/WebCore/rendering/style/RenderStyleSetters.h:
(WebCore::RenderStyle::setMathDepth):
* Source/WebCore/rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
(WebCore::StyleRareInheritedData::dumpDifferences const):
* Source/WebCore/rendering/style/StyleRareInheritedData.h:
* Source/WebCore/style/values/math/StyleMathDepth.cpp: Added.
(WebCore::Style::CSSValueConversion<MathDepth>::operator):
* Source/WebCore/style/values/math/StyleMathDepth.h: Added.

Canonical link: https://commits.webkit.org/302116@main
@webkit-commit-queue
Copy link
Collaborator

Committed 302116@main (11f6206): https://commits.webkit.org/302116@main

Reviewed commits have been landed. Closing PR #52063 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 11f6206 into WebKit:main Oct 24, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 24, 2025
@eerii eerii deleted the math-depth-pr branch October 25, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants