[webkit-changes] [WebKit/WebKit] 83c5b7: Support CSS width/height properties on MathML elem...

Frédéric Wang noreply at github.com
Wed Oct 30 02:47:01 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 83c5b73b334b37e076e2209a2427583b6cc1a153
      https://github.com/WebKit/WebKit/commit/83c5b73b334b37e076e2209a2427583b6cc1a153
  Author: Frédéric Wang <fwang at igalia.com>
  Date:   2024-10-30 (Wed, 30 Oct 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/spaces/mspace-width-height-001-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-001-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-004-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt
    M LayoutTests/mathml/presentation/mspace-prefered-width-expected.html
    M LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt
    R LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-001-expected.txt
    R LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt
    R LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt
    M LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt
    M LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt
    R LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt
    R LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt
    M Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLBlock.h
    M Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLFraction.h
    M Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLRow.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h

  Log Message:
  -----------
  Support CSS width/height properties on MathML elements
https://bugs.webkit.org/show_bug.cgi?id=281292

Reviewed by Rob Buis.

This patch implements support for the width/height properties on
MathML elements [1]. The general algorithm from the spec is as
follows:

(1) The outcome of the math layout is a "math content box".
(2) The content box sets its size from computed width/height values. If
auto, it's the one of the "math content box". This patch ignores
percentage values for now [2] [3].
(3) math content box is shifted so that its inline-start and top edges
aligns with the ones of the content box. There are exceptions
elements like mfrac and munder/mover/munderover which instead
horizontally center the math content box within the content box.
For baseline adjustment, we follow what other browsers do, see [4].
(4) Padding+border are added around the content box. Note that we
ignore the box-sizing property for now [5].

The patch essentially tweaks the various MathML layout algorithms to
perform steps (3) and (4) before the calls to
adjustPreferredLogicalWidthsForBorderAndPadding() and
adjustLayoutForBorderAndPadding(). In particular this might slightly
change current behavior for mrow-like layout. More tweaks might be
needed would be handled in follow-up patches.

[1] https://w3c.github.io/mathml-core/#layout-algorithms
[2] https://github.com/w3c/mathml-core/issues/76
[3] https://github.com/w3c/mathml-core/issues/77
[4] https://github.com/w3c/mathml-core/issues/259
[5] https://github.com/w3c/mathml-core/issues/257
[6] https://github.com/web-platform-tests/wpt/pull/48569

* LayoutTests/TestExpectations: width-height-003.html PASS. msqrt case for width-height-003.html still has small diff.
* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/spaces/mspace-width-height-001-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-001-expected.txt: We pass everything except preferred mo size because of how we handle lspace/rspace, see [6].
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-004-expected.txt: Remove new lines in txt expectation.
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt: Use a platform-independent "everything PASS" expectation.
* LayoutTests/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt: Use a platform-independent "everything PASS" expectation.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-001-expected.txt: Removed.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt: Removed.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt: Removed.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-005-expected.txt: Removed.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/width-height-006-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/spaces/mspace-width-height-001-expected.txt: Added. Use a platform-independent "everything PASS" expectation.
* LayoutTests/mathml/presentation/mspace-prefered-width-expected.html: This was initially added in 136708 at main, tweak expectation now that we support width on mspace.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt: Update now that we support width/height on MathML elements.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt: Ditto.
* LayoutTests/platform/mac/imported/w3c/web-platform-tests/mathml/relations/css-styling/display-2-expected.txt: Ditto.
* Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::sizeAppliedToMathContent): New helper to retrieve the specified CSS width/height, if any.
(WebCore::RenderMathMLBlock::applySizeToMathContent): New helper to apply the specified CSS width/height to the math content box and return inline shift for further adjustments.
* Source/WebCore/rendering/mathml/RenderMathMLBlock.h:
(WebCore::RenderMathMLBlock::isMathContentCentered const): New helper to indicate whether math content should be centered on the inline axis if a different size is specified by the user.
* Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLFraction::layoutBlock): Apply specified sizes, adjust children position.
(WebCore::RenderMathMLFraction::paint): Comment about fraction bar painting.
* Source/WebCore/rendering/mathml/RenderMathMLFraction.h: MathML Core says fraction content is centered.
* Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLMenclose::layoutBlock): Apply specified sizes, adjust children position.
* Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp:
(WebCore::RenderMathMLPadded::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLPadded::layoutBlock): Apply specified sizes, adjust children position.
* Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLRoot::layoutBlock): Apply specified sizes, adjust children position.
* Source/WebCore/rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLRow::layoutBlock): Apply specified sizes, adjust children position. This also removes previous setLogicalHeight() and updateLogicalHeight() calls.
* Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLScripts::layoutBlock): Apply specified sizes, adjust children position.
* Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp:
(WebCore::RenderMathMLSpace::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLSpace::layoutBlock): Apply specified sizes. Minor refactoring to make sure border/padding are handled after.
* Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths): Account for specified sizes.
(WebCore::RenderMathMLUnderOver::layoutBlock): Apply specified sizes, adjust children position.
* Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h: MathML Core says munder/mover/munderover content is centered.

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



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


More information about the webkit-changes mailing list