Commit Graph
202 Commits
Author SHA1 Message Date
Frédéric Wang Nélar b1a1dcc0b1 Bug 2026637 - Determine RTL direction from nsIFrame::mWritingMode. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D290141
2026-03-26 20:02:07 +00:00
Sylvestre Ledru 55481ac4b5 Bug 2023419 - Remove Emacs/Vim modelines from layout/ r=emilio,firefox-style-system-reviewers,layout-reviewers
replaced by .editorconfig

Differential Revision: https://phabricator.services.mozilla.com/D287852
2026-03-17 12:05:43 +00:00
Frédéric Wang c9bc3dd5f7 Bug 2018114 - Part 2: Use lspace/rspace of the core operator during mrow layout. r=layout-reviewers,dshin
For math/mtd, we still include lspace/rspace when we adjust the size of
children in `AddInterFrameSpacingToSize` until bug 2018403 is fixed.

Differential Revision: https://phabricator.services.mozilla.com/D284282
2026-02-25 17:17:36 +00:00
Frédéric Wang 4f2f84ec20 Bug 2018114 - Part 1: Don't take into account lspace/rspace for inline size of embellished operators. r=layout-reviewers,dshin
This is controlled by a new lspace_rspace_for_child_spacing_during_mrow_layout
preference (currently only enabled in nightly), which will also account for
lspace/rspace values in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D284281
2026-02-25 17:17:33 +00:00
Serban Stanca 73daa84cf5 Revert "Bug 2018114 - Part 3: Add more tests for lspace/rspace and update expectations. r=emilio" for causing bp-nu bustages in nsMathMLContainerFrame.cpp.
This reverts commit b8a5fb1b58.

This reverts commit def02242e1.

This reverts commit d87631000a.
2026-02-25 12:18:55 +00:00
Frédéric Wang def02242e1 Bug 2018114 - Part 2: Use lspace/rspace of the core operator during mrow layout. r=layout-reviewers,dshin
For math/mtd, we still include lspace/rspace when we adjust the size of
children in `AddInterFrameSpacingToSize` until bug 2018403 is fixed.

Differential Revision: https://phabricator.services.mozilla.com/D284282
2026-02-25 11:17:03 +00:00
Frédéric Wang d87631000a Bug 2018114 - Part 1: Don't take into account lspace/rspace for inline size of embellished operators. r=layout-reviewers,dshin
This is controlled by a new lspace_rspace_for_child_spacing_during_mrow_layout
preference (currently only enabled in nightly), which will also account for
lspace/rspace values in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D284281
2026-02-25 11:17:01 +00:00
Frédéric Wang 0b95936309 Bug 2018406 Remove tuning of default operator lspace/rspace when math-depth > 0. r=emilio,layout-reviewers
Intent to ship: https://groups.google.com/a/mozilla.org/g/dev-platform/c/4jCrlRGxIIM

Differential Revision: https://phabricator.services.mozilla.com/D284374
2026-02-22 08:07:12 +00:00
Frédéric Wang 9714004803 Bug 2014885 - Convert dom::MathMLElement's length parsing flags to an EnumSet. r=layout-reviewers,dshin
Also make the aFlags argument optional with an empty EnumSet as the default.

Differential Revision: https://phabricator.services.mozilla.com/D282042
2026-02-06 09:12:34 +00:00
Frédéric Wang 050e287bd7 Bug 2013528 - Convert NS_MATHML_OPERATOR_SIZE_INFINITY C macro to constexpr. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D281197
2026-02-04 06:31:00 +00:00
Frédéric Wang 4453f4557f Bug 2013273 - Modernize implementation of nsOperatorFlags. r=layout-reviewers,dshin
Currently, this is a uint32_t with 16 bits used for boolean properties,
2 bits used for operator form and 2 bits used for stretch direction.
Getting and setting all these operator properties is done via C
macros. This patch refactors it so that it holds on a 24bits class
that exposes:

* reference to an `mozilla::EnumSet` called `OperatorBooleans`.
* getter/setter for an enum class called `OperatorForm`.
* getter/setter for an enum class called `OperatorDirection`.

Differential Revision: https://phabricator.services.mozilla.com/D281055
2026-02-03 16:00:57 +00:00
Frédéric Wang 88aaf03123 Bug 2013273 - Convert MathML stretch flags to mozilla::EnumSet. r=layout-reviewers,dshin
Differential Revision: https://phabricator.services.mozilla.com/D280949
2026-02-03 16:00:51 +00:00
Frédéric Wang f0727f2777 Bug 2013273 - Make nsStretchDirection an enum class. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D280935
2026-02-03 16:00:41 +00:00
agoloman cdb00cbee7 Revert "Bug 2013273 - Make GetPreferredStretchSize calculation mode an enum class. r=layout-reviewers,dshin" for causing build bustages @nsMathMLOperators.h.
This reverts commit 9c8eddd444.

Revert "Bug 2013273 - Modernize implementation of nsOperatorFlags. r=layout-reviewers,dshin"

This reverts commit 6cbde817db.

Revert "Bug 2013273 - Ensure underlying types for MathMLFrameType and DrawingMethod are uint8_t. r=layout-reviewers,dshin"

This reverts commit bb3d80f482.

Revert "Bug 2013273 - Convert MathML stretch flags to mozilla::EnumSet. r=layout-reviewers,dshin"

This reverts commit 0abd326292.

Revert "Bug 2013273 - Make mtable eAlign an enum class. r=layout-reviewers,dshin"

This reverts commit da72abe4b4.

Revert "Bug 2013273 - Make nsMencloseNotation an enum class. r=layout-reviewers,dshin"

This reverts commit 1051d05264.

Revert "Bug 2013273 - Make nsStretchDirection an enum class. r=emilio,layout-reviewers"

This reverts commit a98c372331.
2026-02-03 09:57:20 +00:00
Frédéric Wang 6cbde817db Bug 2013273 - Modernize implementation of nsOperatorFlags. r=layout-reviewers,dshin
Currently, this is a uint32_t with 16 bits used for boolean properties,
2 bits used for operator form and 2 bits used for stretch direction.
Getting and setting all these operator properties is done via C
macros. This patch refactors it so that it holds on a 24bits class
that exposes:

* reference to an `mozilla::EnumSet` called `OperatorBooleans`.
* getter/setter for an enum class called `OperatorForm`.
* getter/setter for an enum class called `OperatorDirection`.

Differential Revision: https://phabricator.services.mozilla.com/D281055
2026-02-03 09:06:25 +00:00
Frédéric Wang 0abd326292 Bug 2013273 - Convert MathML stretch flags to mozilla::EnumSet. r=layout-reviewers,dshin
Differential Revision: https://phabricator.services.mozilla.com/D280949
2026-02-03 09:06:19 +00:00
Frédéric Wang a98c372331 Bug 2013273 - Make nsStretchDirection an enum class. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D280935
2026-02-03 09:06:10 +00:00
Frédéric Wang 12f92743d1 Bug 2008690 - Make nsMathMLmmultiscriptsFrame handle italic correction of largeop base. r=emilio,layout-reviewers
Currently, when a size variant is used for large variants of stretchy
operators, we modify the bounding box of the glyph by substracting any
specified italic correction from the calculated width. This is to mimic
legacy behavior of old math fonts that were handling subscript of
slanted integrals by specifying a width smaller than the actual glyph
extent.

This causes rendering issues when one draws the background of the
corresponding `<mo>` element, or when a slanted integral is rendered in
right-to-left mode. This bug is also detected by WPT test
mathml/presentation-markup/scripts/subsup-parameters-2.html since
one case assumes subscript is placed at the right of the base minus
the italic correction. We strengthen it a bit by actually checking the
base's width is properly set.

MathML Core describes italic correction of all MathML boxes (
measurement of how slanted they are), how it can be calculated
recursively from the box's children and how it applies to sub/sup
script positioning. In this patch, we implement a simplified version
addressing above issues and covering simple cases currently supported
by browsers and actually useful in practice.

Differential Revision: https://phabricator.services.mozilla.com/D277987
2026-01-26 15:08:37 +00:00
Frédéric Wang ad2f25ae65 Bug 2008902 - Make eMathMLFrameType an enum class. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D278101
2026-01-08 15:26:36 +00:00
Frédéric Wang 291e676b1d Bug 2008902 - Convert MathML embellish flags to mozilla::EnumSet. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D278100
2026-01-08 15:26:33 +00:00
Frédéric Wang eb94b292ae Bug 2008902 - Convert MathML presentation flags to mozilla::EnumSet. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D278091
2026-01-08 15:26:30 +00:00
Masayuki Nakano 6ef3d44ec6 Bug 2003127 - Make the layout module paint normal selection when selection is styled as "attention" r=emilio,layout-reviewers
The "Find in Page" result appears as a normal selection range and the
selection's display is "attention".  And that may select characters in
unselectable elements including `::before`/`::after` pseudo elements.

At least while the selection's display is "attention", we should paint
the normal selection in any nodes.

Note that once the selection's display is set to "on", the selection
becomes invisible since the user not selectable and won't appear as
visible text when you copy the selection to the clipboard. If this is
a bad UI, we should change the behavior in a follow up bug.

Differential Revision: https://phabricator.services.mozilla.com/D274550
2025-12-03 05:00:56 +00:00
Masayuki Nakano 82a139a8f0 Bug 1998858 - part 2: Make Selection stop splitting user selected range to exclude non-selectable nodes r=smaug,emilio,edgar,TYLin,layout-reviewers
The other browsers do not support multiple selection ranges.  Therefore,
they never split selection ranges to exclude non-selectable nodes.
To align the behavior, we should do so.  However, to keep current
look of `Selection` which is similar to Chrome's behavior, we should
make the selection painters ignore normal selections if their content
is not selectable.

Note that this patch allows painting selected text when there are some
IME selections even if `user-select` is `none` because the normal
selection is also a part of IME selections.  Although our widget
currently do not use non-collapsed normal selection during a
composition, it may be changed to support new IME in the future.

Differential Revision: https://phabricator.services.mozilla.com/D272187
2025-11-21 00:16:55 +00:00
eri 374e8d529b Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod
Add counters and warnings for deprecated uses of the accent property
from the operator dictionary.
Add a new mathml.operator_dictionary_accent.disabled property to control
whether the accent property should be parsed from the dictionary. It is
off by default so there are no behaviour changes.

Differential Revision: https://phabricator.services.mozilla.com/D269049
2025-11-11 10:42:51 +00:00
Cristina Horotan b27997d294 Revert "Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod" for causing mathml-console-messages.html
This reverts commit 2c11ffaf47.
2025-11-05 18:15:21 +00:00
eri 2c11ffaf47 Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod
Add counters and warnings for deprecated uses of the accent property
from the operator dictionary.
Add a new mathml.operator_dictionary_accent.disabled property to control
whether the accent property should be parsed from the dictionary. It is
off by default so there are no behaviour changes.

Differential Revision: https://phabricator.services.mozilla.com/D269049
2025-11-05 15:16:38 +00:00
Alexandru Marc 56668479f2 Revert "Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod" for causing bc failures @ browser_misused_characters_in_strings.js
This reverts commit e6abf8f3d9.
2025-10-31 14:25:42 +00:00
eri e6abf8f3d9 Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod
Add counters and warnings for deprecated uses of the accent property
from the operator dictionary.
Add a new mathml.operator_dictionary_accent.disabled property to control
whether the accent property should be parsed from the dictionary. It is
off by default so there are no behaviour changes.

Differential Revision: https://phabricator.services.mozilla.com/D269049
2025-10-31 13:12:13 +00:00
Alexandru Marc f3e23b9c45 Revert "Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod" for causing multiple failures
This reverts commit e5e1af5784.
2025-10-31 10:09:50 +00:00
eri e5e1af5784 Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod
Add counters and warnings for deprecated uses of the accent property
from the operator dictionary.
Add a new mathml.operator_dictionary_accent.disabled property to control
whether the accent property should be parsed from the dictionary. It is
off by default so there are no behaviour changes.

Differential Revision: https://phabricator.services.mozilla.com/D269049
2025-10-31 08:57:00 +00:00
Frédéric Wang e34c7c802d Bug 1993884 - Remove MathML top_bottom_spacing_for_stretchy_operators preference. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D268341
2025-10-13 09:08:03 +00:00
Frédéric Wang 2a7cdc4e8e Bug 1993884 - Remove MathML centered_operators preference. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D268340
2025-10-13 09:08:00 +00:00
Eri Pazos Pérez 5a7ec7cbb1 Bug 1925478 - Remove unused paths from nsMathMLContainerFrame::Place r=emilio,fredw,layout-reviewers
Preliminary patch to removing the return value of Place, as it is always
NS_OK. The logic associated with it being false has also been removed,
along with DidReflowChildren, which was only called in these paths.

Differential Revision: https://phabricator.services.mozilla.com/D265801
2025-09-23 14:41:03 +00:00
Masayuki Nakano 784537b41e Bug 769207 - part 2: Make nsIFrame use new enum class to receive the type of attribute change r=smaug,dom-core,dshin
`MutationEvent_Bindings::MODIFICATION`,
`MutationEvent_Bindings::ADDITION` and `MutationEvent_Bindings::REMOVAL`
will be removed.  Therefore, we need alternative `enum class` for that.
This patch makes `nsIFrame` and subclasses use the new one.

Differential Revision: https://phabricator.services.mozilla.com/D263053
2025-09-08 00:27:36 +00:00
Emilio Cobos Álvarez a8a2311474 Bug 1976457 - Sort includes in layout/. r=janv,dshin
Interesting bit is layout/.clang-format, the rest is all automated.

Differential Revision: https://phabricator.services.mozilla.com/D256616
2025-07-09 13:24:00 +00:00
Harry Chen e09ba05f08 Bug 1924672 - Add WPT tests and support for more CSS units in MathML. r=fredw,emilio
This reuses the SVG machinery for calculating unit lengths and leaves vi and vb unimplemented. These units need special handling since they depend on the writing mode, but MathML does not support non-horizontal writing modes yet.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1935717.

Differential Revision: https://phabricator.services.mozilla.com/D230738
2025-05-01 15:22:31 +00:00
Alexandru Marc 875344009d Backed out changeset 4a74b1fc4b79 (bug 1924672) for causing build bustages @ nsMathMLmfracFrame.cpp CLOSED TREE 2025-04-30 08:30:30 +03:00
Harry Chen e6ab2a57aa Bug 1924672 - Add WPT tests and support for more CSS units in MathML. r=fredw,emilio
This reuses the SVG machinery for calculating unit lengths and leaves vi and vb unimplemented. These units need special handling since they depend on the writing mode, but MathML does not support non-horizontal writing modes yet.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1935717.

Differential Revision: https://phabricator.services.mozilla.com/D230738
2025-04-30 05:11:08 +00:00
Tom Schuster b8d11d463f Bug 1951893 - Remove unneeded StaticAtom suffixes. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D240598
2025-03-11 11:36:09 +00:00
Jonathan Watt 3eab38263b Bug 1931736. Add missing braces around if/loop statements in layout/mathml/. r=layout-reviewers,emilio
Depends on D229249

Differential Revision: https://phabricator.services.mozilla.com/D229250
2024-11-17 05:03:59 +00:00
Frédéric Wang 9c073c74f4 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 a5c1ebec25 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 fd971f48a2 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 0ab98c54bc 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 0d2636a2e8 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 97e3ad469d 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 4380bb8c18 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 0032366415 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
Frédéric Wang fe0998d618 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 edeffd455d Backed out changeset a6394916d0fd (bug 1904220) for causing bustages at nsMathMLmoFrame.cpp. CLOSED TREE 2024-09-02 13:13:35 +03:00