Skip to content

[MathML] Use unstretched size for minsize/maxsize default and percentages#59200

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Ahmad-S792:eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages
Mar 23, 2026
Merged

[MathML] Use unstretched size for minsize/maxsize default and percentages#59200
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Ahmad-S792:eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages

Conversation

@Ahmad-S792
Copy link
Copy Markdown
Contributor

@Ahmad-S792 Ahmad-S792 commented Feb 22, 2026

e142f1f

[MathML] Use unstretched size for minsize/maxsize default and percentages
https://bugs.webkit.org/show_bug.cgi?id=308423
rdar://170908253

Reviewed by Frédéric Wang.

Per MathML Core section 3.2.4.3 "Layout of operators"
(https://w3c.github.io/mathml-core/#layout-of-operators), under the
block (vertical) stretch axis path, the spec says:

"Let minsize and maxsize be the minsize and maxsize properties on the
operator. Percentage values are interpreted relative to the height of g."

This says percentage values for minsize/maxsize are relative to the
height of the base glyph (the unstretched size). Store the unstretched
size in MathOperator during reset() and use it as the reference value
for minsize/maxsize calculations.

Per step 5 of the layout algorithm, the spec also says:

"If minsize < 0 then set minsize to 0. If maxsize < minsize then set
maxsize to minsize."

This clamping is performed in stretchTo() to match the spec's algorithm
structure, where minSize()/maxSize() return unclamped values.

Note that minsize/maxsize only appear in the block (vertical) stretch
axis section of the spec. The inline (horizontal) stretch path has no
minsize/maxsize step, so we only compute the unstretched size for
vertical operators.

* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/mo-minsize-maxsize-001-expected.txt: Progressions
* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/size-and-position-of-stretchy-fences-with-default-font-001-expected.txt: Rebaseline
* LayoutTests/platform/glib/mathml/opentype/vertical-expected.txt: Ditto
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/size-and-position-of-stretchy-fences-with-default-font-001-expected.txt: Platform Specific Expectation
* Source/WebCore/rendering/mathml/MathOperator.cpp:
(WebCore::MathOperator::reset):
* Source/WebCore/rendering/mathml/MathOperator.h:
(WebCore::MathOperator::unstretchedSize const):
* Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::minSize const):
(WebCore::RenderMathMLOperator::maxSize const):
(WebCore::RenderMathMLOperator::stretchTo):

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

495acd9

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

@Ahmad-S792 Ahmad-S792 self-assigned this Feb 22, 2026
@Ahmad-S792 Ahmad-S792 added the MathML For bugs specific to MathML. label Feb 22, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 22, 2026
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Feb 22, 2026
@Ahmad-S792 Ahmad-S792 force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from cc1c8a6 to dd3e4f1 Compare February 22, 2026 08:09
@fred-wang
Copy link
Copy Markdown
Contributor

@Ahmad-S792

  • Does WebKit support minsize/maxsize for horizontal operators? MathML Core only mentions it for vertical operators?
  • Can you please indicate which part of the spec you are using? I see https://w3c.github.io/mathml-core/#layout-of-operators ; but I don't understand your 1em fallback or the clamping of maxsize above 0 (should be minsize?).

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 22, 2026
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Mar 9, 2026
@Ahmad-S792 Ahmad-S792 force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from dd3e4f1 to 39e1a01 Compare March 9, 2026 17:09
@Ahmad-S792 Ahmad-S792 requested a review from fred-wang March 9, 2026 17:09
@Ahmad-S792
Copy link
Copy Markdown
Contributor Author

Ahmad-S792 commented Mar 9, 2026

@Ahmad-S792

  • Does WebKit support minsize/maxsize for horizontal operators? MathML Core only mentions it for vertical operators?
  • Can you please indicate which part of the spec you are using? I see https://w3c.github.io/mathml-core/#layout-of-operators ; but I don't understand your 1em fallback or the clamping of maxsize above 0 (should be minsize?).

You are right about both issues:

  • The 1em fallback was mistake — the unstretched size should always be set when minSize()/maxSize() are called, since reset() returns early if no base glyph is found, and stretching only proceeds with a valid operator. I've replaced it now.
  • The maxsize clamping to 0 was wrong. The spec says: "If minsize < 0 then set minsize to 0. If maxsize < minsize then set maxsize to minsize." So now fixed it as well.
  • In last, updated commit message.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 9, 2026
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Mar 9, 2026
@Ahmad-S792 Ahmad-S792 force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from 39e1a01 to fdcb08a Compare March 9, 2026 20:13
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 10, 2026
Copy link
Copy Markdown
Contributor

@fred-wang fred-wang left a comment

Choose a reason for hiding this comment

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

LGTM, but please see comments.

@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Mar 21, 2026
@Ahmad-S792 Ahmad-S792 force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from fdcb08a to 9755a02 Compare March 21, 2026 10:46
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 21, 2026
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Mar 21, 2026
@Ahmad-S792 Ahmad-S792 force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from 9755a02 to 495acd9 Compare March 21, 2026 23:01
Copy link
Copy Markdown
Contributor

@fred-wang fred-wang left a comment

Choose a reason for hiding this comment

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

Thanks.

@Ahmad-S792 Ahmad-S792 added the merge-queue Applied to send a pull request to merge-queue label Mar 23, 2026
…ages

https://bugs.webkit.org/show_bug.cgi?id=308423
rdar://170908253

Reviewed by Frédéric Wang.

Per MathML Core section 3.2.4.3 "Layout of operators"
(https://w3c.github.io/mathml-core/#layout-of-operators), under the
block (vertical) stretch axis path, the spec says:

"Let minsize and maxsize be the minsize and maxsize properties on the
operator. Percentage values are interpreted relative to the height of g."

This says percentage values for minsize/maxsize are relative to the
height of the base glyph (the unstretched size). Store the unstretched
size in MathOperator during reset() and use it as the reference value
for minsize/maxsize calculations.

Per step 5 of the layout algorithm, the spec also says:

"If minsize < 0 then set minsize to 0. If maxsize < minsize then set
maxsize to minsize."

This clamping is performed in stretchTo() to match the spec's algorithm
structure, where minSize()/maxSize() return unclamped values.

Note that minsize/maxsize only appear in the block (vertical) stretch
axis section of the spec. The inline (horizontal) stretch path has no
minsize/maxsize step, so we only compute the unstretched size for
vertical operators.

* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/mo-minsize-maxsize-001-expected.txt: Progressions
* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/size-and-position-of-stretchy-fences-with-default-font-001-expected.txt: Rebaseline
* LayoutTests/platform/glib/mathml/opentype/vertical-expected.txt: Ditto
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/size-and-position-of-stretchy-fences-with-default-font-001-expected.txt: Platform Specific Expectation
* Source/WebCore/rendering/mathml/MathOperator.cpp:
(WebCore::MathOperator::reset):
* Source/WebCore/rendering/mathml/MathOperator.h:
(WebCore::MathOperator::unstretchedSize const):
* Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::minSize const):
(WebCore::RenderMathMLOperator::maxSize const):
(WebCore::RenderMathMLOperator::stretchTo):

Canonical link: https://commits.webkit.org/309764@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch from 495acd9 to e142f1f Compare March 23, 2026 16:40
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 309764@main (e142f1f): https://commits.webkit.org/309764@main

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

@webkit-commit-queue webkit-commit-queue merged commit e142f1f into WebKit:main Mar 23, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 23, 2026
@Ahmad-S792 Ahmad-S792 deleted the eng/MathML-Use-unstretched-size-for-minsize-maxsize-default-and-percentages branch April 10, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MathML For bugs specific to MathML.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants