Commit Graph
165 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
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 96ed4866fa Bug 2013273 - Make GetPreferredStretchSize calculation mode an enum class. r=layout-reviewers,dshin
STRETCH_CONSIDER_ACTUAL_SIZE is actually not used anymore, so only keep two
calculation modes.

Differential Revision: https://phabricator.services.mozilla.com/D281186
2026-02-03 16:01:00 +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 9c8eddd444 Bug 2013273 - Make GetPreferredStretchSize calculation mode an enum class. r=layout-reviewers,dshin
STRETCH_CONSIDER_ACTUAL_SIZE is actually not used anymore, so only keep two
calculation modes.

Differential Revision: https://phabricator.services.mozilla.com/D281186
2026-02-03 09:06:28 +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
serge-sans-paille 9272ce026e Bug 2009953 - Do not use reserved identifiers for macro guard in layout r=firefox-style-system-reviewers,layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D278787
2026-01-14 23:09:01 +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 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
Emilio Cobos Álvarez 45879990e9 Bug 1725177 - Make ::backdrop a real generated content pseudo-element. r=layout-reviewers,firefox-style-system-reviewers,dshin
This allows animating ::backdrop and addresses long-standing animation
issues.

Differential Revision: https://phabricator.services.mozilla.com/D276755
2025-12-17 22:11:20 +00:00
serge-sans-paille 820e6e5cba Bug 1993127 - Remove unused inclusion of Attributes.h from layout/* r=emilio,firefox-style-system-reviewers,firefox-svg-reviewers,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D269715
2025-10-24 13:07:17 +00:00
Frédéric Wang e8d5fdd3ed Bug 1925478 - Remove nsMathMLContainerFrame::DidReflow. r=layout-reviewers,emilio
nsMathMLContainerFrame (and its derived classes) relies on a
FinishReflow() method that is called at the end of Reflow(). So just
clear the NS_MATHML_STRETCH_DONE bit there instead of DidReflow().

Differential Revision: https://phabricator.services.mozilla.com/D226118
2025-10-11 19:12:53 +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 b38a095a5e Bug 769207 - part 6: Make nsMathMLContainerFrame::ChildListChanged() stop taking the attribute modification type r=layout-reviewers,emilio
It's unused.

Differential Revision: https://phabricator.services.mozilla.com/D263057
2025-09-08 00:27:52 +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
Emilio Cobos Álvarez 1d78b7cf40 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
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 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 148e63a1db 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
Butkovits Atila aeafb698d8 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 3dfc68ed39 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
Ting-Yu Lin 6af05a0977 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
Butkovits Atila 4d06404349 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 f0ff97db90 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 3b8f2d0470 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 ad6375be7c 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] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/border-002.html#L25
[4] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/padding-002.html#L26
[3] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/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 8a08b8f2c0 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 096c9e730e 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 9febf3345f 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 4f718eac8d 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] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/border-002.html#L25
[4] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/padding-002.html#L26
[3] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/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 db0c8952ec 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
Tamas Szentpeteri 5098f477fd Backed out 7 changesets (bug 1908069) for causing mochitest failures related to EnumSet.h. CLOSED TREE
Backed out changeset 7a9063b6e9f1 (bug 1908069)
Backed out changeset 6b8c788b3fb3 (bug 1908069)
Backed out changeset 6775a291fb83 (bug 1908069)
Backed out changeset 526b1ba8c610 (bug 1908069)
Backed out changeset e7797c083647 (bug 1908069)
Backed out changeset 2c4076a423fa (bug 1908069)
Backed out changeset 8fac35770369 (bug 1908069)
2024-07-31 18:45:21 +03:00
Frédéric Wang 51aa69374b 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-07-31 14:14:30 +00:00
Frédéric Wang c127c754f6 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] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/border-002.html#L25
[4] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/padding-002.html#L26
[3] https://github.com/web-platform-tests/wpt/blob/27c8d234ee83a4b15f36ad10cc26c951b1782fb6/mathml/relations/css-styling/padding-border-margin/margin-003.html#L50

Differential Revision: https://phabricator.services.mozilla.com/D216670
2024-07-31 14:14:29 +00:00
Frédéric Wang 8c0cb2de1c 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-07-31 14:14:28 +00:00
Ting-Yu Lin 2969a5e0cb Bug 1909995 Part 2 - Add IntrinsicISize() as a helper to implement GetMinISize() and GetPrefISize(). r=layout-reviewers,emilio
Most frame types have identical or very similar implementation for GetMinISize()
and GetPrefISize(), and many of them already have `IntrinsicISize()` to unify
the implementation. This patch introduces nsIFrame::IntrinsicISize() so that
derived classes only need to override one method.

`nsBlockFrame`, `ColumnSetWrapperFrame`, and `nsColumnSetFrame` are the only
three classes where their `GetMinISize()` and `GetPrefISize()` have significant
differences. Therefore, we rename `GetMinISize()` and `GetPrefISize()` to
`MinISize()` and `PrefISize`, respectively, and use them as helpers to implement
their `IntrinsicISize()`.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D217790
2024-07-26 20:54:56 +00:00
Ting-Yu Lin b665e0070b Bug 1890207 Part 2 - Rename mIntrinsicWidth and UpdateIntrinsicWidth. r=layout-reviewers,tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D206857
2024-04-08 05:05:15 +00:00
Ting-Yu Lin 0278d9fd9a Bug 1890207 Part 1 - Initialize mBlockStartAscent directly in the declaration. r=layout-reviewers,tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D206856
2024-04-08 05:05:15 +00:00
Frédéric Wang f85adc1d81 Bug 1874823 - Make nsBlockFrame::Init set NS_BLOCK_STATIC_BFC by checking classes. r=layout-reviewers,AlaskanEmily
The following classes deriving from nsBlockFrame always set
NS_BLOCK_STATIC_BFC in their constructors or initializers:

- nsComboboxControlFrame
- nsFileControlFrame
- nsSelectsAreaFrame
- ColumnSetWrapperFrame
- nsMathMLmathBlockFrame

Do that in nsBlockFrame::Init instead. Behavior is unchanged.

Differential Revision: https://phabricator.services.mozilla.com/D199097
2024-01-24 12:13:42 +00:00
Sandor Molnar a6c0549a83 Backed out 2 changesets (bug 1874823) for causing assertion failures at builds/worker/checkouts/gecko/layout/generic/nsIFrame.cpp CLOSED TREE
Backed out changeset 4e0e2448d7a5 (bug 1874823)
Backed out changeset 2c0d41730484 (bug 1874823)
2024-01-24 13:39:51 +02:00
Frédéric Wang 6ac01236dc Bug 1874823 - Make nsBlockFrame::Init set NS_BLOCK_STATIC_BFC by checking classes. r=layout-reviewers,AlaskanEmily
The following classes deriving from nsBlockFrame always set
NS_BLOCK_STATIC_BFC in their constructors or initializers:

- nsComboboxControlFrame
- nsFileControlFrame
- nsSelectsAreaFrame
- ColumnSetWrapperFrame
- nsMathMLmathBlockFrame

Do that in nsBlockFrame::Init instead. Behavior is unchanged.

Differential Revision: https://phabricator.services.mozilla.com/D199097
2024-01-24 10:52:29 +00:00
Sandor Molnar 91365e8cd8 Backed out 2 changesets (bug 1874823) for causing assertion failures at builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp CLOSED TREE
Backed out changeset f5d297181393 (bug 1874823)
Backed out changeset a38e1f388fd2 (bug 1874823)
2024-01-24 12:22:11 +02:00
Frédéric Wang 2edf3ee738 Bug 1874823 - Make nsBlockFrame::Init set NS_BLOCK_STATIC_BFC by checking classes. r=layout-reviewers,AlaskanEmily
The following classes deriving from nsBlockFrame always set
NS_BLOCK_STATIC_BFC in their constructors or initializers:

- nsComboboxControlFrame
- nsFileControlFrame
- nsSelectsAreaFrame
- ColumnSetWrapperFrame
- nsMathMLmathBlockFrame

Do that in nsBlockFrame::Init instead. Behavior is unchanged.

Differential Revision: https://phabricator.services.mozilla.com/D199097
2024-01-24 09:50:45 +00:00
Frédéric Wang 8656a4a0a7 Bug 1765615 - Introduce NS_BLOCK_DYNAMIC_BFC state bit. r=layout-reviewers,emilio
After D198523, NS_BLOCK_FLOAT_MGR and NS_BLOCK_MARGIN_ROOT are always
set simultaneously when initiating a frame, so we can merge them into a
single NS_BLOCK_STATIC_BFC flag. The freed bit is used to define a new
NS_BLOCK_DYNAMIC_BFC flag that has the same effect and is now used for
frames with paint/layout containment so that in D197043 they can be
updated later without having to reconstruct the frame tree. Finally
NS_BLOCK_BFC_STATE_BITS is the bitwise union of these BFC flags.

The following changes are made and cause no behavior changes:

- Instead of testing whether NS_BLOCK_FLOAT_MGR or NS_BLOCK_MARGIN_ROOT
  is set, or whether all of the bits from
  NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS are set, we test whether any
  of the NS_BLOCK_BFC_STATE_BITS is set.

- Instead of adding NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS when
  constructing a frame, we add NS_BLOCK_STATIC_BFC. The exception is
  for frame with paint/layout containment, for which we set
  NS_BLOCK_DYNAMIC_BFC instead.

Differential Revision: https://phabricator.services.mozilla.com/D198530
2024-01-16 07:58:47 +00:00
Emilio Cobos Álvarez c27730d3df Bug 1364813 - Remove IsFrameOfType, use non-virtual checks. r=jwatt
Extend the per-frame-class bit we have to devirtualize IsLeaf to also
devirtualize IsFrameOfType. That is, move this data to FrameClasses.py.

This was done by going through all the frame classes, trying to preserve
behavior.

The only quirky thing is that I had to add two more trivial frame
classes, `nsAudioFrame` for audio elements, and
`nsFloatingFirstLetterFrame`. That's because these frame classes were
returning different answers at runtime, but they do this only on
conditions that trigger frame reconstruction (floating, and being an
audio element, respectively).

Differential Revision: https://phabricator.services.mozilla.com/D194703
2023-11-26 22:17:28 +00:00