Commit Graph

2034 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
c1dda0bb6e Bug 1925478 - Simplify nsMathMLContainerFrame::DidReflowChildren. r=fredw
No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D226144
2024-10-18 19:19:48 +00:00
Emilio Cobos Álvarez
d75426f579 Bug 1925478 - Remove redundant virtual keywords in layout/mathml. r=jwatt
Just drive-by cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D226119
2024-10-18 12:08:48 +00:00
Frédéric Wang
daa65b5598 Bug 1909417 - Position mprescripts at per MathML Core. r=emilio
From [1]:

> Place the mmultiscripts base and <mprescripts> boxes at inline offsets
  inline-offset and with their alphabetic baselines aligned with the
  alphabetic baseline.

Also tweak subsup-6.html to compute bounding box of the <mprescripts>
element at the time a test is run. Otherwise reflow due to resize of the
`<div id="log">` element can make the test fail.

[1] https://w3c.github.io/mathml-core/#base-with-prescripts-and-postscripts

Differential Revision: https://phabricator.services.mozilla.com/D222614
2024-09-30 12:18:39 +00:00
Frédéric Wang
656a36187f Bug 1916988 - Support CSS width/height properties on MathML elements. r=emilio
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 Chromium does, 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
GetBorderPaddingForPlace and InflateReflowAndBoundingMetrics.

[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

Below is more information about test coverage:

- width-height-001: Verify that width, height, inline-size and block-size
  properties sets the size of the content box. This test used to verify
  they are ignored, this patch fixes the `<meta name="assert">` tag.
  It also adds a test for the case the specified size is smaller than the
  content (we force non empty descendants to make sure this content is
  large enough) and to verify the width is used for the preferred width.

- width-height-002, width-height-003: These are reftests visually checking
  offsets of the math content box within a larger content box (specified
  by width/height) for the mtext, mrow, mpadded, mfrac, msqrt, mroot,
  in LTR/RTL modes. In particular they allow to verify some painted
  elements like fraction bar and radical symbols.

- width-height-004: This test more directly checks that the math content
  box is horizontally centered within a larger content box for munder,
  mover, munderover and mfrac. This patch extends the test to cover the
  case when the math content box is wider (i.e. overflowing outside the
  content box) and removes unnecessary specified height.

- width-height-005: New test for other layout algorithm that don't
  center the math content box, checking inline-start edges of children
  when a width is specified. We check both LTR/RTL modes and
  wider/narrower content boxes.

- width-height-006: Same but checking the top edges for larger/smaller
  height and verifying that baseline is perserved.

Differential Revision: https://phabricator.services.mozilla.com/D221436
2024-09-30 12:18:39 +00:00
Frédéric Wang
859cd83095 Bug 1916988 - Set vertical offset of mfrac denominator from the baseline. r=emilio
Currently, we have

```
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() +
  sizeDen.Height() + denMargin.bottom - sizeDen.BlockStartAscent() +
  denShift;
```

Then a call to `InflateReflowAndBoundingMetrics` respectively increments
`aDesiredSize.BlockStartAscent()` and `aDesiredSize.Height()` by
`borderPadding.top` and `borderPadding.top + borderPadding.bottom`.

Finally, we set

```
dy = aDesiredSize.Height() - sizeDen.Height() - denMargin.bottom -
     borderPadding.bottom;
```

which is equivalent to

```
aDesiredSize.BlockStartAscent() + denShift - sizeDen.BlockStartAscent()
```

Differential Revision: https://phabricator.services.mozilla.com/D222456
2024-09-30 12:18:38 +00:00
Frédéric Wang
139bce88f8 Bug 1918310 - Remove class nsMathMLmsqrtFrame. r=emilio
This class is currently only used to override InheritAutomaticData() and
IsMrowLike(). This patch moves that directly in nsMathMLrootFrame.
Probably we should have the same behavior when ShouldUseRowFallback()
returns true, but this patch does not try and change anything.

Differential Revision: https://phabricator.services.mozilla.com/D222258
2024-09-17 18:25:45 +00:00
Frédéric Wang
43fda17309 Bug 1918310 - Make mroot and msqrt should share their implementation. r=emilio
The msqrt and mroot elements are used to draw radical symbols [1]. That
used to be the case for menclose (until notation="radical" was removed
in [2]) and that's the only reason why nsMathMLmsqrtFrame is deriving
from nsMathMLmencloseFrame. This patch makes it derive from
nsMathMLmrootFrame instead to remove unnecessary code duplication.

[1] https://w3c.github.io/mathml-core/#radicals-msqrt-mroot
[21 https://bugzilla.mozilla.org/show_bug.cgi?id=1783995]

Differential Revision: https://phabricator.services.mozilla.com/D222123
2024-09-17 18:25:45 +00:00
Frédéric Wang
0e828932f8 Bug 1918989 - Remove disabled SHOW_BOUNDING_BOX MathML code. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D222260
2024-09-16 13:27:10 +00:00
Frédéric Wang
4827451a48 Bug 1918308 - Don't always force a reflow in nsMathMLContainerFrame::AttributeChanged. r=emilio
Currently, nsMathMLContainerFrame::AttributeChanged always force a
reflow. This patch removes that behavior tweaks the following derived
classes:

- menclose: Don't mark intrinsic size of descendants dirty, since the
  notation is added around the children, only affecting the element's
  metrics.

- mfrac: Don't mark intrinsic size dirty for the linethickness
  attribute, since it only affects vertical metrics.

- mo: Rebuild 'automatic' data and relayout the entire embellished
  operator hierarchy for all operator properties. I haven't checked the
  details of the MathML 'automatic' data, so it may be a bit too
  aggressive. But at least a reflow is necessary.

- mspace/mpadded: Only mark intrinsic size dirty for the element and
  ancestors, and only for attributes affecting vertical metrics. Also
  remove `InvalidateFrame()` call since we don't have any display item.

- mtable: Don't force reflow or data rebuild when displaystyle changes.
  This was probably needed before displaystyle was re-implemented as
  an attribute mapped to the math-style CSS property.

There is at least one dynamic test for each of the MathML
attributes affecting layout and they don't regress after this patch:
https://bugzilla.mozilla.org/show_bug.cgi?id=1918308#c0

Differential Revision: https://phabricator.services.mozilla.com/D221925
2024-09-13 14:19:45 +00:00
Frédéric Wang
d9d8886f2d Bug 1917763 - Remove nsMathMLContainerFrame::MeasureForWidth(). r=emilio
This method is now only used at one place (more precisely, inside the
nsMathMLContainerFrame::GetIntrinsicISizeMetrics() method) and only
calls the Place() method with the IntrinsicSize + MeasureOnly flags.
This patch removes it and instead ensure we call Place() directly from
GetIntrinsicISizeMetrics(). There is no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221630
2024-09-13 08:03:57 +00:00
Frédéric Wang
fac124e3b1 Bug 1917763 - Do not override MeasureForWidth/Reflow for mroot. r=emilio
This patch reimplements layout of the mroot element by overridding the
Place() method, which is used by nsMathMLContainerFrame for the
implementation of Reflow and MeasureForWidth. These two latter methods
then don't need to be overridden anymore in nsMathMLmrootFrame.

Differential Revision: https://phabricator.services.mozilla.com/D221629
2024-09-13 08:03:56 +00:00
Frédéric Wang
dfac21ba40 Bug 1917763 - Do not override MeasureForWidth/Reflow for mspace. r=emilio
The only reasons why we override MeasureForWidth and Reflow in
nsMathMLmspaceFrame is to make sure attribute parsing is performed.
This patch just uses the implementation of nsMathMLContainerFrame
instead, by moving attribute processing into a new
nsMathMLmspaceFrame::Place method instead, adding proper caching &
invalidation to make it optimal.

Differential Revision: https://phabricator.services.mozilla.com/D221623
2024-09-13 08:03:56 +00:00
Frédéric Wang
6e088229a8 Bug 1917763 - Remove eCSSUnit_Number handling from nsMathMLFrame::ParseNumericValue. r=emilio
This case was used to handle non-zero unitless values, but support was
removed in D89920.

Differential Revision: https://phabricator.services.mozilla.com/D221789
2024-09-13 08:03:56 +00:00
Frédéric Wang
ab34270cba Bug 1917763 - Do not override MeasureForWidth/Reflow for mpadded. r=emilio
The only reasons why we override MeasureForWidth and Reflow in
nsMathMLmpaddedFrame is to make sure attribute parsing is performed.
This patch just uses the implementation of nsMathMLContainerFrame
instead, by lazily parsing the attributes in nsMathMLmpaddedFrame::Place
and adding proper caching & invalidation to make it optimal.

Differential Revision: https://phabricator.services.mozilla.com/D221613
2024-09-13 08:03:55 +00:00
Frédéric Wang
844e39c60a Bug 1917763 - Refactor parsing of mpadded attributes. r=emilio
nsMathMLmpaddedFrame parses each of its width, height, depth, lspace and
voffset attribute into three members: a nsCSSValue and int32_t values
representing enumerated values for optional signs and pseudo-units. This
commit rewrites them as a struct containing a nsCSSValue and two uint8_t
enum classes. One value for the sign that was used to indicate that
the attribute is absent or invalid is moved into a separate mIsValid
boolean. There are no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221612
2024-09-13 08:03:55 +00:00
Frédéric Wang
5930f15160 Bug 1917763 - More consistent handling of MathML's AttributeChanged(). r=emilio
This patch tweaks implementation of AttributeChanged() in MathML layout
classes to be more consistent:

1. Only handle MathML-specific attributes in the default namespace.
2. Return immediately for class attributes, or forward the call to
   the parent class (or grandparent class).

Currently, nsMathMLContainerFrame::AttributeChanged() always forces a
reflow but this change does not cause new calls to it, except for the
edge case of accent/accentunder attributes in the non-default namespace
(nsMathMLmunderoverFrame). Not doing more for
nsMathMLmencloseFrame/nsMathMLmfracFrame breaks some tests, but we can
probably do a weaker invalidation. See bug 1918308 for a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D221921
2024-09-13 08:03:54 +00:00
Frédéric Wang
d498e4b883 Bug 1917763 - Remove PlaceInternal methods from MathML layout classes. r=emilio
These are private methods so that are called by the overridden methods
Place() (without flags) and by MeasureForWidth() (with IntrinsicSize +
MeasureOnly flags). But the former can just be implemented directly and
then the latter does not need to override what nsMathMLContainerFrame
does already. There are no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221611
2024-09-13 08:03:54 +00:00
Butkovits Atila
3b13c53176 Backed out 8 changesets (bug 1917763) for causing bustages at nsMathMLmspaceFrame.h. CLOSED TREE
Backed out changeset 7c7c002d7db2 (bug 1917763)
Backed out changeset 10eb2ccfa645 (bug 1917763)
Backed out changeset 9ba90d161930 (bug 1917763)
Backed out changeset ab7ce0058852 (bug 1917763)
Backed out changeset 19766c906c98 (bug 1917763)
Backed out changeset d1b87bb6e8d4 (bug 1917763)
Backed out changeset 043cf853e2cf (bug 1917763)
Backed out changeset a869862a66ec (bug 1917763)
2024-09-12 18:35:55 +03:00
Frédéric Wang
98ccd16018 Bug 1917763 - Remove nsMathMLContainerFrame::MeasureForWidth(). r=emilio
This method is now only used at one place (more precisely, inside the
nsMathMLContainerFrame::GetIntrinsicISizeMetrics() method) and only
calls the Place() method with the IntrinsicSize + MeasureOnly flags.
This patch removes it and instead ensure we call Place() directly from
GetIntrinsicISizeMetrics(). There is no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221630
2024-09-12 14:26:28 +00:00
Frédéric Wang
2e39449972 Bug 1917763 - Do not override MeasureForWidth/Reflow for mroot. r=emilio
This patch reimplements layout of the mroot element by overridding the
Place() method, which is used by nsMathMLContainerFrame for the
implementation of Reflow and MeasureForWidth. These two latter methods
then don't need to be overridden anymore in nsMathMLmrootFrame.

Differential Revision: https://phabricator.services.mozilla.com/D221629
2024-09-12 14:26:28 +00:00
Frédéric Wang
0787198d38 Bug 1917763 - Do not override MeasureForWidth/Reflow for mspace. r=emilio
The only reasons why we override MeasureForWidth and Reflow in
nsMathMLmspaceFrame is to make sure attribute parsing is performed.
This patch just uses the implementation of nsMathMLContainerFrame
instead, by moving attribute processing into a new
nsMathMLmspaceFrame::Place method instead, adding proper caching &
invalidation to make it optimal.

Differential Revision: https://phabricator.services.mozilla.com/D221623
2024-09-12 14:26:27 +00:00
Frédéric Wang
a27c6154ec Bug 1917763 - Remove eCSSUnit_Number handling from nsMathMLFrame::ParseNumericValue. r=emilio
This case was used to handle non-zero unitless values, but support was
removed in D89920.

Differential Revision: https://phabricator.services.mozilla.com/D221789
2024-09-12 14:26:27 +00:00
Frédéric Wang
83bbfaa75d Bug 1917763 - Do not override MeasureForWidth/Reflow for mpadded. r=emilio
The only reasons why we override MeasureForWidth and Reflow in
nsMathMLmpaddedFrame is to make sure attribute parsing is performed.
This patch just uses the implementation of nsMathMLContainerFrame
instead, by lazily parsing the attributes in nsMathMLmpaddedFrame::Place
and adding proper caching & invalidation to make it optimal.

Differential Revision: https://phabricator.services.mozilla.com/D221613
2024-09-12 14:26:27 +00:00
Frédéric Wang
982ded89fc Bug 1917763 - Refactor parsing of mpadded attributes. r=emilio
nsMathMLmpaddedFrame parses each of its width, height, depth, lspace and
voffset attribute into three members: a nsCSSValue and int32_t values
representing enumerated values for optional signs and pseudo-units. This
commit rewrites them as a struct containing a nsCSSValue and two uint8_t
enum classes. One value for the sign that was used to indicate that
the attribute is absent or invalid is moved into a separate mIsValid
boolean. There are no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221612
2024-09-12 14:26:26 +00:00
Frédéric Wang
21d5db8d44 Bug 1917763 - More consistent handling of MathML's AttributeChanged(). r=emilio
This patch tweaks implementation of AttributeChanged() in MathML layout
classes to be more consistent:

1. Only handle MathML-specific attributes in the default namespace.
2. Return immediately for class attributes, or forward the call to
   the parent class (or grandparent class).

Currently, nsMathMLContainerFrame::AttributeChanged() always forces a
reflow but this change does not cause new calls to it, except for the
edge case of accent/accentunder attributes in the non-default namespace
(nsMathMLmunderoverFrame). Not doing more for
nsMathMLmencloseFrame/nsMathMLmfracFrame breaks some tests, but we can
probably do a weaker invalidation. See bug 1918308 for a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D221921
2024-09-12 14:26:26 +00:00
Frédéric Wang
c0056121f4 Bug 1917763 - Remove PlaceInternal methods from MathML layout classes. r=emilio
These are private methods so that are called by the overridden methods
Place() (without flags) and by MeasureForWidth() (with IntrinsicSize +
MeasureOnly flags). But the former can just be implemented directly and
then the latter does not need to override what nsMathMLContainerFrame
does already. There are no behavior changes.

Differential Revision: https://phabricator.services.mozilla.com/D221611
2024-09-12 14:26:25 +00:00
Frédéric Wang
da354de8ce Bug 1904220 - Fix MathML regression with HYPHEN-MINUS not rendered as MINUS SIGN. r=emilio
After bug 1890531, mathml.centered_operator is disabled and
U+002D HYPHEN-MINUS in <mo> no longer renders as  U+2212 MINUS SIGN.
This patches restore this behavior as the change was unintentional, even
though this is not specified in MathML Core.

Differential Revision: https://phabricator.services.mozilla.com/D219085
2024-09-06 07:20:54 +00:00
Tamas Szentpeteri
cbd6476f0c Backed out changeset 68cc51e9fccd (bug 1904220) for causing build bustages on nsMathMLmoFrame.cpp. CLOSED TREE 2024-09-05 16:34:48 +03:00
Frédéric Wang
9df5d57aca Bug 1904220 - Fix MathML regression with HYPHEN-MINUS not rendered as MINUS SIGN. r=emilio
After bug 1890531, mathml.centered_operator is disabled and
U+002D HYPHEN-MINUS in <mo> no longer renders as  U+2212 MINUS SIGN.
This patches restore this behavior as the change was unintentional, even
though this is not specified in MathML Core.

Differential Revision: https://phabricator.services.mozilla.com/D219085
2024-09-05 13:04:16 +00:00
Tamas Szentpeteri
47c471dc90 Backed out changeset fab98364af1c (bug 1904220) for causing build bustages on nsMathMLmoFrame.cpp. CLOSED TREE 2024-09-05 12:17:20 +03:00
Frédéric Wang
6bc2a2e9d9 Bug 1904220 - Fix MathML regression with HYPHEN-MINUS not rendered as MINUS SIGN. r=emilio
After bug 1890531, mathml.centered_operator is disabled and
U+002D HYPHEN-MINUS in <mo> no longer renders as  U+2212 MINUS SIGN.
This patches restore this behavior as the change was unintentional, even
though this is not specified in MathML Core.

Differential Revision: https://phabricator.services.mozilla.com/D219085
2024-09-05 08:41:41 +00:00
Ting-Yu Lin
26a6db6fb1 Bug 1909761 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert
This patch changes the signature to `GetMinISize()`, `GetPrefISize()`,
`IntrinsicISize` by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing `IntrinsicSizeInput` struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
`IntrinsicSizeInput` for our children.

Differential Revision: https://phabricator.services.mozilla.com/D219521
2024-09-03 04:25:41 +00:00
Frédéric Wang
16e6d72fc1 Bug 1912435 - Make MathML boolean attributes ASCII case-insensitive. r=emilio
This commit ensures MathML boolean attributes (namely displaystyle,
mo@stretchy, mo@symmetric, mo@largeop, mo@movablelimits,
munder@accentunder, mover@accent, munderover@accent,
munderover@accentunder) are ASCII case-insensitive [1]. For
displaystyle that was handled in [2]. For mover/munder/munderover
attributes, this is covered by a test case from scriptlevel-001.html
checking both case-insensitivity and dynamic changes at the same time ;
the latter still seems broken, so these checks are moved into separate
test cases. For mo attributes, a new WPT test is added. Note that
mo@accent, mo@fence, mo@separator are not part of MathML Core (with the
two last without visual effect), we make them case-insensitive for
consistency but don't bother adding tests for them.

[1] https://w3c.github.io/mathml-core/#dfn-boolean used here:
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1574087

Differential Revision: https://phabricator.services.mozilla.com/D218944
2024-09-02 13:59:59 +00:00
Butkovits Atila
4dd538627f Backed out changeset a6394916d0fd (bug 1904220) for causing bustages at nsMathMLmoFrame.cpp. CLOSED TREE 2024-09-02 13:13:35 +03:00
Frédéric Wang
381fa378fb Bug 1904220 - Fix MathML regression with HYPHEN-MINUS not rendered as MINUS SIGN. r=emilio
After bug 1890531, mathml.centered_operator is disabled and
U+002D HYPHEN-MINUS in <mo> no longer renders as  U+2212 MINUS SIGN.
This patches restore this behavior as the change was unintentional, even
though this is not specified in MathML Core.

Differential Revision: https://phabricator.services.mozilla.com/D219085
2024-09-02 09:43:52 +00:00
Butkovits Atila
710069d82f Backed out 6 changesets (bug 1909761) for causing failures at test_contextmenu_rtl.xhtml. CLOSED TREE
Backed out changeset 1e9f47784a54 (bug 1909761)
Backed out changeset d2dcf159185b (bug 1909761)
Backed out changeset 3f48c106bff9 (bug 1909761)
Backed out changeset 38d1e5eda09d (bug 1909761)
Backed out changeset 8de556490289 (bug 1909761)
Backed out changeset 4e7f22f43bb4 (bug 1909761)
2024-08-28 10:44:09 +03:00
Ting-Yu Lin
5548e07e75 Bug 1909761 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert
This patch changes the signature to `GetMinISize()`, `GetPrefISize()`,
`IntrinsicISize` by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing `IntrinsicSizeInput` struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
`IntrinsicSizeInput` for our children.

Differential Revision: https://phabricator.services.mozilla.com/D219521
2024-08-28 06:18:44 +00:00
Frédéric Wang
8ca8f43fc4 Bug 1908069 - Add border/padding/margin support to msqrt, mroot and menclose. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216980
2024-08-07 06:00:45 +00:00
Frédéric Wang
0483682329 Bug 1908069 - Add border/padding/margin support to scripted elements. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216924
2024-08-07 06:00:45 +00:00
Frédéric Wang
8956b160de Bug 1908069 - Add border/padding/margin support to MathML token elements. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216855
2024-08-07 06:00:44 +00:00
Frédéric Wang
f508d43e1d Bug 1908069 - Add border/padding/margin support to mrow-like elements. r=emilio
See D216670 for the general approach taken.

This also fixes nsMathMLContainerFrame::UpdateIntrinsicISize which is
in particular used by nsMathMLmathBlockFrame and
nsMathMLmathInlineFrame when calculating intrinsic size of the <math>
tag and aligns merror's UA style on MathML Core at
https://w3c.github.io/mathml-core/#user-agent-stylesheet.

Differential Revision: https://phabricator.services.mozilla.com/D216686
2024-08-07 06:00:44 +00:00
Frédéric Wang
44c741bd28 Bug 1908069 - Add border/padding/margin support to <mfrac>. r=emilio
This is the first patch of the series that actually take
border/padding/margin into account for MathML layout. One subtility is
that Gecko distinguishes the ink nsBoundingMetrics box and the
ReflowOutput box for accurate positioning of math components contrary
to the current version of MathML Core [1].

For MathML Core and the WPT tests, it is assumed that border/padding are
used to inflate the content box [2] [3] and it does not really matter
whether we inflate the ink bounding box, or simply adjust its offsets
inside the normal bounding box. We choose the former and introduce a
helper function InflateReflowAndBoundingMetrics for that purpose, which
will be reused in follow-up patches. After inflating these boxes, the
offsets of children and painted items must also be adjusted by the
left/top border+padding.

Regarding margins, MathML Core says that we should use "margin boxes"
and WPT tests simply check that the layout of MathML constructions
containing mspace elements with margins is not changed if we move
these margins inside the mspace's width/height/depth attributes. To
pass these tests, we similarly need to inflate both the ink and
non-ink bounding boxes by the margin.

However, the margins can be negative possibly leading to negative
dimensions of "margin boxes". To make the code more generic, we
simplify adjust all usages of the children's nsBoundingMetrics and
ReflowOutput to include these margins. When calling FinishReflowChild
at the end, the offsets of children must be adjusted by these margins.

This patch also reimplements the extra one-pixel padding around a
fraction using rules from MathML Core's UA stylesheet at
https://w3c.github.io/mathml-core/#user-agent-stylesheet

[1] https://github.com/w3c/mathml-core/issues/78
[2] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/border-002.html (L25)
[4] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/padding-002.html (L26)
[3] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/margin-003.html (L50)

Differential Revision: https://phabricator.services.mozilla.com/D216670
2024-08-07 06:00:44 +00:00
Frédéric Wang
bcc3be9085 Bug 1908069 - Introduce PlaceFlags parameter to MathML layout methods. r=emilio
MathML classes has a few Place*() methods  used for layout and intrinsic
size calculation. These methods have a parameter "aPlaceOrigin"
indicating whether the children and other painted objects should have
their final positions set, or if the method is only called for measuring.
This parameter is typically set to false when doing intrinsic size
calculation or when performing some non-final measurement for operator
stretching.

For intrinsic size calculation, it is generally enough to perform
placement with aPlaceOrigin=false and ignoring the vertical metrics.
Some Place*() methods also have a parameter "aWidthOnly" for special
handling. For example, msqrt stretches a radical symbol vertically to
match the height of the content but when doing intrinsic size
calculation this is approximated to nsMathMLChar::GetMaxWidth() instead.
When we implement border/padding/margin we should also be able to
choose between using IntrinsicISizeOffsets() or GetUsed*() methods.

Finally, some Place*() methods initially call a place routing of a
parent class before further tweaking the layout. For example, msqrt
uses mrow layout on children and adds some radical symbol on top of
them. When we implement border/padding, we should make sure we don't
add the border/padding before the final result.

In order to handle all these placement behaviors, a new EnumSet is
introduced. This commit does not change behavior. Handling of padding,
border and margin will be handled in follow-up patches.

Differential Revision: https://phabricator.services.mozilla.com/D216669
2024-08-07 06:00:43 +00:00
Iulian Moraru
7279a1df13 Backed out 7 changesets (bug 1908069) for causing wr failures on mo-lspace-rspace-4.html. CLOSED TREE
Backed out changeset d497ae104185 (bug 1908069)
Backed out changeset c87b8ca300dc (bug 1908069)
Backed out changeset 3e76c02843a7 (bug 1908069)
Backed out changeset f4c5983c700b (bug 1908069)
Backed out changeset 5468da212605 (bug 1908069)
Backed out changeset ab5ab71ddfc4 (bug 1908069)
Backed out changeset 21269d373fff (bug 1908069)
2024-08-01 19:45:36 +03:00
Frédéric Wang
5f1924bd24 Bug 1908069 - Add border/padding/margin support to msqrt, mroot and menclose. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216980
2024-08-01 12:58:09 +00:00
Frédéric Wang
0db59bb809 Bug 1908069 - Add border/padding/margin support to scripted elements. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216924
2024-08-01 12:58:08 +00:00
Frédéric Wang
50e29b7ba1 Bug 1908069 - Add border/padding/margin support to MathML token elements. r=emilio
See D216670 for the general approach taken.

Differential Revision: https://phabricator.services.mozilla.com/D216855
2024-08-01 12:58:08 +00:00
Frédéric Wang
03b5018545 Bug 1908069 - Add border/padding/margin support to mrow-like elements. r=emilio
See D216670 for the general approach taken.

This also fixes nsMathMLContainerFrame::UpdateIntrinsicISize which is
in particular used by nsMathMLmathBlockFrame and
nsMathMLmathInlineFrame when calculating intrinsic size of the <math>
tag and aligns merror's UA style on MathML Core at
https://w3c.github.io/mathml-core/#user-agent-stylesheet.

Differential Revision: https://phabricator.services.mozilla.com/D216686
2024-08-01 12:58:07 +00:00
Frédéric Wang
f2bcfe3b85 Bug 1908069 - Add border/padding/margin support to <mfrac>. r=emilio
This is the first patch of the series that actually take
border/padding/margin into account for MathML layout. One subtility is
that Gecko distinguishes the ink nsBoundingMetrics box and the
ReflowOutput box for accurate positioning of math components contrary
to the current version of MathML Core [1].

For MathML Core and the WPT tests, it is assumed that border/padding are
used to inflate the content box [2] [3] and it does not really matter
whether we inflate the ink bounding box, or simply adjust its offsets
inside the normal bounding box. We choose the former and introduce a
helper function InflateReflowAndBoundingMetrics for that purpose, which
will be reused in follow-up patches. After inflating these boxes, the
offsets of children and painted items must also be adjusted by the
left/top border+padding.

Regarding margins, MathML Core says that we should use "margin boxes"
and WPT tests simply check that the layout of MathML constructions
containing mspace elements with margins is not changed if we move
these margins inside the mspace's width/height/depth attributes. To
pass these tests, we similarly need to inflate both the ink and
non-ink bounding boxes by the margin.

However, the margins can be negative possibly leading to negative
dimensions of "margin boxes". To make the code more generic, we
simplify adjust all usages of the children's nsBoundingMetrics and
ReflowOutput to include these margins. When calling FinishReflowChild
at the end, the offsets of children must be adjusted by these margins.

This patch also reimplements the extra one-pixel padding around a
fraction using rules from MathML Core's UA stylesheet at
https://w3c.github.io/mathml-core/#user-agent-stylesheet

[1] https://github.com/w3c/mathml-core/issues/78
[2] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/border-002.html (L25)
[4] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/padding-002.html (L26)
[3] 27c8d234ee/mathml/relations/css-styling/padding-border-margin/margin-003.html (L50)

Differential Revision: https://phabricator.services.mozilla.com/D216670
2024-08-01 12:58:06 +00:00
Frédéric Wang
ad96ea995b Bug 1908069 - Introduce PlaceFlags parameter to MathML layout methods. r=emilio
MathML classes has a few Place*() methods  used for layout and intrinsic
size calculation. These methods have a parameter "aPlaceOrigin"
indicating whether the children and other painted objects should have
their final positions set, or if the method is only called for measuring.
This parameter is typically set to false when doing intrinsic size
calculation or when performing some non-final measurement for operator
stretching.

For intrinsic size calculation, it is generally enough to perform
placement with aPlaceOrigin=false and ignoring the vertical metrics.
Some Place*() methods also have a parameter "aWidthOnly" for special
handling. For example, msqrt stretches a radical symbol vertically to
match the height of the content but when doing intrinsic size
calculation this is approximated to nsMathMLChar::GetMaxWidth() instead.
When we implement border/padding/margin we should also be able to
choose between using IntrinsicISizeOffsets() or GetUsed*() methods.

Finally, some Place*() methods initially call a place routing of a
parent class before further tweaking the layout. For example, msqrt
uses mrow layout on children and adds some radical symbol on top of
them. When we implement border/padding, we should make sure we don't
add the border/padding before the final result.

In order to handle all these placement behaviors, a new EnumSet is
introduced. This commit does not change behavior. Handling of padding,
border and margin will be handled in follow-up patches.

Differential Revision: https://phabricator.services.mozilla.com/D216669
2024-08-01 12:58:05 +00:00