Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[math] math style (minimizing logical height of an equation) #5387

Closed
bkardell opened this issue Aug 3, 2020 · 2 comments
Closed

[math] math style (minimizing logical height of an equation) #5387

bkardell opened this issue Aug 3, 2020 · 2 comments
Labels

Comments

@bkardell
Copy link
Contributor

bkardell commented Aug 3, 2020

(Part of #5384 - MathML Core related CSS)

In some cases in mathematical rendering it is desirable to minimize the logical height of an equation. This is generally done by common norms about font-sizing adjustments to parts of the equation, how some operators are drawn, how/where scripts are measured, and how vertical gaps and shifts are applied. Below is an example of the same equation rendered in two common ways, the one on the left applying the common rules to minimize the logical height, the one on the left, not.

math with normal and compact math-styles

For this purpose, we introduce the math-style property with values normal (default) and compact.

MathML supported this via an attribute called displaystyle which was either the string 'true' or the string 'false' ()the rules and the term were derived from The TeXbook). MathML-Core introduces the math-style CSS property and defines how it works for rendering and layout. It maps this attribute's values as a presentational hint to the CSS property for reasons of compatibility with widely deployed content and the existing ecosystem of tools, but strongly recommends authors use CSS.

Tests in https://github.com/web-platform-tests/wpt/tree/master/css/css-fonts/math-script-level-and-math-style

@css-meeting-bot
Copy link
Member

css-meeting-bot commented Sep 10, 2020

The CSS Working Group just discussed math style, and agreed to the following:

  • RESOLVED: Add math-style: normal | compact
The full IRC log of that discussion <fantasai> Topic: math style
<fantasai> github: https://github.com//issues/5387
<fantasai> NeilS: 2 ways of displaying math, one tries to minimize height to fit in lines better
<fantasai> NeilS: one is taller one
<fantasai> NeilS: shifts positions / sizing rules, etc.
<fantasai> NeilS: Designed so you don't have as much gap in lines if you have math in it
<fantasai> NeilS: rules defined in TeXBook
<fantasai> astearns: the switch is true or false for displaystyle?
<fantasai> astearns: I like normal and compact much better
<fantasai> iank_: Makes sense, but seems to also be able to affect the font size?
<fantasai> iank_: that will need to be carefully defined
<fantasai> NeilS: That effect is through the scriptlevel feature
<fantasai> fantasai: Affects the font size, indirectly through another property
<fantasai> iank_: Happy to add, pending scriptlevel discussion
<fantasai> astearns: ok, any concerns to add?
<fantasai> astearns: would it go into display module?
<fantasai> iank_: Goes into MathML Core
<fantasai> RESOLVED: Add math-style: normal | compact

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421110
Commit-Queue: Frédéric Wang <[email protected]>
Reviewed-by: Rob Buis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#808847}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421110
Commit-Queue: Frédéric Wang <[email protected]>
Reviewed-by: Rob Buis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#808847}
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this issue Sep 21, 2020
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421110
Commit-Queue: Frédéric Wang <[email protected]>
Reviewed-by: Rob Buis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#808847}
fred-wang added a commit to fred-wang/csswg-drafts that referenced this issue Sep 22, 2020
This imports the proposal from MathML Core to manage font scaling in math
formulas using a new 'math-level' property. This mechanism involves a new
'math-style' property that describes compactness of formulas as well as
a new 'math' keyword to specify relative font-size change using the a
scale factor calculated from the 'math-level' changes.

w3c#5389
w3c#5387
ryanhaddad pushed a commit to WebKit/WebKit that referenced this issue Dec 22, 2020
https://bugs.webkit.org/show_bug.cgi?id=216702

Patch by Frederic Wang <[email protected]> on 2020-09-25
Reviewed by Rob Buis.

LayoutTests/imported/w3c:

Rebaseline tests to take into account new PASS results.

* web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt:
* web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
* web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt:
* web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt:
* web-platform-tests/mathml/relations/css-styling/displaystyle-1-expected.txt:
* web-platform-tests/mathml/relations/css-styling/displaystyle-2-expected.txt:
* web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Added.

Source/WebCore:

This patch implements the math-style property [1][2] and uses it to map MathML's displaystyle
attribute to style, instead of using an internal inheritance mechanism. In addition, four
changes are made to improve the MathML implementation:
- Support for the displaystyle attribute on all the MathML elements.
- Better handling of dynamic update of displaystyle.
- RenderMathMLUnderOver uses its own displaystyle (rather than the one of the core operator
at its base in order) to determine whether to move its under/over scripts.
- display/displaystyle are made case-insensitive.

[1] https://mathml-refresh.github.io/mathml-core/#the-math-style-property
[2] w3c/csswg-drafts#5387

No new tests, already covered by existing tests.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator MathStyle const):
* css/CSSProperties.json:
* css/CSSValueKeywords.in:
* css/mathml.css: Implement displaystyle rules using math-style.
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::CSSParserFastPaths::isKeywordPropertyID):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::isPresentationAttribute const):
(WebCore::MathMLElement::collectStyleForPresentationAttribute):
* mathml/MathMLElement.h:
* mathml/MathMLMathElement.cpp:
(WebCore::MathMLMathElement::parseAttribute):
* mathml/MathMLMathElement.h:
* mathml/MathMLPresentationElement.cpp:
(WebCore::MathMLPresentationElement::parseAttribute):
* mathml/MathMLPresentationElement.h:
* mathml/MathMLRowElement.cpp:
* mathml/MathMLRowElement.h:
* mathml/MathMLSpaceElement.h:
* mathml/MathMLTokenElement.h:
* rendering/mathml/MathMLStyle.cpp:
(WebCore::MathMLStyle::updateStyleIfNeeded):
(WebCore::MathMLStyle::resolveMathMLStyle):
* rendering/mathml/MathMLStyle.h:
* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::styleDidChange):
* rendering/mathml/RenderMathMLBlock.h:
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::fractionParameters const):
(WebCore::RenderMathMLFraction::stackParameters const):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::styleDidChange):
* rendering/mathml/RenderMathMLOperator.h:
(WebCore::RenderMathMLOperator::isLargeOperatorInDisplayStyle const):
(WebCore::RenderMathMLOperator::shouldMoveLimits const):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::verticalParameters):
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::shouldMoveLimits):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::mathStyle const):
(WebCore::RenderStyle::setMathStyle):
(WebCore::RenderStyle::initialMathStyle):
* rendering/style/RenderStyleConstants.cpp:
(WebCore::operator<<):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
* rendering/style/StyleRareInheritedData.h:

LayoutTests:

Rebaseline tests to take into account new PASS results.

* TestExpectations:
* mathml/opentype/large-operators-displaystyle-dynamic.html: Do the dynamic change directly
after page load but do a requestAnimationFrame before completing the test.
* platform/glib/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed.
* platform/glib/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed.
* platform/glib/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed.
* platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed.
* platform/gtk/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
* platform/gtk/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Copied from LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt.
* platform/gtk/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt: Copied from LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt.
* platform/ios-13/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* platform/ios-wk2/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed.
* platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:
* platform/ios-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed.
* platform/ios-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed.
* platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt:
* platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt:
* platform/ios/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* platform/mac-wk1/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed.
* platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-stretchy-006-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-symmetric-001-expected.txt: Added.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed.
* platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt:

Canonical link: https://commits.webkit.org/229757@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267578 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@fred-wang
Copy link

@bkardell @fantasai Given #5536 (comment) and that the definition is already present in https://w3c.github.io/mathml-core/#the-math-style-property I guess we can close this, as that was done for #5388 and #5389 ?

@bkardell bkardell closed this as completed Sep 6, 2022
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
math-style was originally implemented in [1] but it was decided with the
CSSWG to perform the following changes [2]:
- 'display' is renamed 'normal'
- 'inline' is renamed 'compact'
- the default value becomes 'normal' (instead of 'inline')

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2100787
[2] w3c/csswg-drafts#5387

Bug: 6606
Change-Id: I5eb4aa423f434c068ccb02517b086830291fcf55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421110
Commit-Queue: Frédéric Wang <[email protected]>
Reviewed-by: Rob Buis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#808847}
GitOrigin-RevId: f5abb9c0f60bf970942b80c1b29838a3052ec2a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants