241 Commits
Author SHA1 Message Date
Daniel Holbert 09af591d4d Bug 2038767: Use GetOrCreateDeletableProperty in a few more places. r=layout-reviewers,firefox-svg-reviewers,longsonr,emilio
And while we're at it, clean up some unnecessary void* usage in
nsFloatManager::GetRegionFor (which predated our introduction of type-safe
frame-property accessors in bug 1230034).

Differential Revision: https://phabricator.services.mozilla.com/D299829
2026-05-11 21:56:17 +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
Emilio Cobos Álvarez 08d8a894db Bug 1984859 - Use a common type for layout rounded corners and graphics rounded corners. r=layout-reviewers,gfx-reviewers,jfkthame,jnicol
Differential Revision: https://phabricator.services.mozilla.com/D262041
2025-08-23 22:55:18 +00:00
Atila Butkovits 533eabba32 Revert "Bug 1984859: apply code formatting via Lando" for causing failures at element-paint-native-widget.html.
This reverts commit c7950c03d7.

Revert "Bug 1984859 - Use a common type for layout rounded corners and graphics rounded corners. r=layout-reviewers,gfx-reviewers,jfkthame,jnicol"

This reverts commit 2991156989.

Revert "Bug 1984859 - Use Margin to represent border widths in nsCSSRendering. r=layout-reviewers,gfx-reviewers,jfkthame,jnicol"

This reverts commit 446150abe6.
2025-08-23 19:10:23 +00:00
Emilio Cobos Álvarez 2991156989 Bug 1984859 - Use a common type for layout rounded corners and graphics rounded corners. r=layout-reviewers,gfx-reviewers,jfkthame,jnicol
Differential Revision: https://phabricator.services.mozilla.com/D262041
2025-08-23 17:57:50 +00:00
Jonathan Kew 55066c9ce0 Bug 1887465 - Introduce UsedFloat and UsedClear types in layout, for the used values of CSS float and clear properties after resolving logical values. r=layout-reviewers,emilio
No change in behavior, just makes it clearer when we're working with used values
where the inline-* logical values have been resolved.

Differential Revision: https://phabricator.services.mozilla.com/D230029
2024-11-25 22:58:47 +00:00
Jonathan Kew 0813b3e111 Bug 1887465 - Use the containing block's writing mode to resolve logical values for CSS float and clear properties. r=layout-reviewers,emilio
And don't resolve them prematurely; the computed value should remain
logical, and only be mapped to physical sides at use time.

Differential Revision: https://phabricator.services.mozilla.com/D229998
2024-11-25 22:58:46 +00:00
Alexandru Marc ed1511635d Backed out 2 changesets (bug 1887465) for causing build bustages @ WritingModes.h . CLOSED TREE
Backed out changeset 5203c09eceb4 (bug 1887465)
Backed out changeset 0507fcccf575 (bug 1887465)
2024-11-25 18:47:23 +02:00
Jonathan Kew 4d1ec66bf7 Bug 1887465 - Introduce UsedFloat and UsedClear types in layout, for the used values of CSS float and clear properties after resolving logical values. r=layout-reviewers,emilio
No change in behavior, just makes it clearer when we're working with used values
where the inline-* logical values have been resolved.

Differential Revision: https://phabricator.services.mozilla.com/D230029
2024-11-25 14:02:27 +00:00
Jonathan Kew 64fa9b6bb6 Bug 1887465 - Use the containing block's writing mode to resolve logical values for CSS float and clear properties. r=layout-reviewers,emilio
And don't resolve them prematurely; the computed value should remain
logical, and only be mapped to physical sides at use time.

Differential Revision: https://phabricator.services.mozilla.com/D229998
2024-11-25 14:02:26 +00:00
Jonathan Watt 7532be254f Bug 1931736. Add missing braces around if/loop statements in layout/generic/. r=layout-reviewers,emilio
Depends on D229247

Differential Revision: https://phabricator.services.mozilla.com/D229248
2024-11-17 05:03:58 +00:00
Ting-Yu Lin 42e43e5387 Bug 1892307 Part 1 - Convert LineRelativeDir to an enum class. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D207905
2024-04-19 22:16:03 +00:00
Boris Chiou 2206399c45 Bug 1884425 - Introduce PathOrShapeFunciton for path() and shape(). r=firefox-style-system-reviewers,zrhoffman
Use this as a wrapper for `path()` and `shape()`, so it'd be easier to
specialize its `Animate` trait.

Differential Revision: https://phabricator.services.mozilla.com/D205490
2024-03-28 19:42:13 +00:00
Boris Chiou 5621be82f7 Bug 1823463 - Support shape() for clip-path property in style. r=emilio
Implement the style part for shape(). Besides, update some issues in the
test file, e.g. avoid using viewport height so we get the fixed result
on different devices.

I will refactor `PathCommand` to let it be a specialization of
`GenericShapeCommand` in the following path.

Differential Revision: https://phabricator.services.mozilla.com/D202882
2024-03-18 21:20:28 +00:00
Boris Chiou 43bb1fa8a2 Bug 1842277 - Compute <basic-shape-rect> to the equivalent inset() function. r=devtools-reviewers,emilio
Per spec
https://drafts.csswg.org/css-shapes-1/#basic-shape-computed-values, and
the spec issue, https://github.com/w3c/csswg-drafts/issues/9053,
all <basic-shape-rect> functions compute to the equivalent inset() function.
i.e.
`xywh(x y w h)` computes to
`inset(y calc(100% - x - w) calc(100% - y - h) x)`

The basic concept is to use `BasicShapeRect` as the specified value of
`<basic-shape-rect>`, i.e. inset()/xywh()/rect(), and its computed value is
the equivalent `InsetRect`, and so it becomes possible to interpolate among
these three functions.

Also, we can drop BuildXywhPath() and ComputeRect() because now there is
only inset() function when building gfx::Path.

Besides, tweak the test, offset-path-shape-xywh-003.html, because the original
test, `xywh(10% 10% 80% 80%)`, has to calculate `calc(100% - 10% - 80%)`.
Its result is `Percentage(0.099999964)` in Rust code, and then it makes us
compute an imprecision inset rect when building the gfx::path, which results in
a transform with the sub-pixel translation. So change it to
`xywh(10% 10% 90% 90%)` to avoid adding fuzzy tolerance.

Differential Revision: https://phabricator.services.mozilla.com/D183221
2023-07-12 20:16:47 +00:00
Boris Chiou 1b1742d1d8 Bug 1786160 - Support xywh() for clip-path. r=emilio
The fuzzy in the test happens on the round because we use the different way
to draw the round of clip-path (compared to border-radius property) in
the render backend, so there are some tiny differences.

Differential Revision: https://phabricator.services.mozilla.com/D182421
2023-07-07 18:12:41 +00:00
Boris Chiou 0bde3ad169 Bug 1786160 - Rename inset as rect in ShapeUtils. r=emilio
We would like to use these function for all rectangular shape, i.e.
inset()/xywh()/rect(). So rename them to avoid confusion.

No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D182422
2023-07-07 18:12:41 +00:00
Boris Chiou 12bd1f78e9 Bug 1786160 - Support xywh() in style. r=emilio
Also, add layout.css.basic-shape-xywh.enabled and enable it on Nightly

Differential Revision: https://phabricator.services.mozilla.com/D182419
2023-07-07 18:12:40 +00:00
Boris Chiou 79181ce7c7 Bug 1837305 - Part 1: Rework GenericBasicShape. r=devtools-reviewers,emilio
The definition of `<basic-shape>` includes other types of basic shapes,
e.g. path(), xywh(), rect(). So we put them together to match the spec.
However, some properties only use the subset of basic shapes, so we use
the bitflags to choose the supported basic shape at the parse time.

Also, remove StyleBasicShapeType because no one uses it.

Only refactoring in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D179624
2023-06-15 00:03:59 +00:00
Jonathan Kew e2c069db1f Bug 1815404 - Replace most uses of gfxContext::CreateOrNull with stack-allocated contexts. r=gfx-reviewers,lsalzman
Depends on D170370

Differential Revision: https://phabricator.services.mozilla.com/D170371
2023-02-21 07:28:25 +00:00
Jonathan Kew e998377ebb Bug 1815404 - Remove refcounting from gfxContext. r=gfx-reviewers,lsalzman
Depends on D170367

Differential Revision: https://phabricator.services.mozilla.com/D170369
2023-02-21 07:28:24 +00:00
Razvan Cojocaru 363946e17f Bug 1060421 - Change the type of [Int]PointTyped::[x|y] back to [Int]CoordTyped. r=botond
[Int]CoordTyped no longer inherits Units because otherwise
instances of [Int]IntPointTyped may get one Base subobject because
it inherits Units, and others because of BasePoint's Coord members,
which end up increasing the [Int]CoordTyped's objects size (since
according to the ISO C++ standard, different Base subobject are
required to have different addresses).

Differential Revision: https://phabricator.services.mozilla.com/D160713
2022-11-04 18:29:35 +00:00
Ting-Yu Lin 78c77ab5fa Bug 1792134 Part 6 - More rename and clean up related to StyleClear. r=emilio
* Rename `mBreakType` to `mFloatClearType` in nsLineBox and nsReflowStatus and
  the methods around it.
* Rename `mBreakType` to `mClear` in nsStyleDisplay.
* Many other method parameters or local variables rename such as from
  `aBreakType` to `aClearType`.

Differential Revision: https://phabricator.services.mozilla.com/D158276
2022-09-29 03:40:56 +00:00
Andrew McCreight 291afe14f4 Bug 1792574, part 3 - Don't include nsMemory where it isn't needed. r=xpcom-reviewers,necko-reviewers,valentin,nika
There are only 3 places where nsMemory.h is still needed (image/RasterImage.cpp,
gfx/thebes/gfxFT2FontList.cpp, and nsMemory.cpp). Remove the rest.

Differential Revision: https://phabricator.services.mozilla.com/D158213
2022-09-28 15:17:46 +00:00
Emilio Cobos Álvarez c43e65587f Bug 1785903 - Use inset rect as the border area to compute shape radii. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D155072
2022-08-22 22:15:24 +00:00
Ting-Yu Lin 1e182ca819 Bug 1323517 Part 3 - Rename GetLowestFloatTop to LowestFloatBStart. r=jfkthame
Both the method's documentation and implementation already use logical
coordinate.

Differential Revision: https://phabricator.services.mozilla.com/D151205
2022-07-07 19:01:55 +00:00
Ting-Yu Lin e8fc547345 Bug 1758824 - Prevent integer overflow in nsFloatManager::ShapeInfo::XInterceptAtY(). r=emilio
`aY * aY` or `aRadiusY * aRadiusY` can lead to 32-bit integer overflow,
resulting a negative number. Then `sqrt()` will produce a `nan` on a negative
number.

We should compute the `y/radiusY` division, and then square the result.

Differential Revision: https://phabricator.services.mozilla.com/D149951
2022-06-24 04:59:29 +00:00
Boris Chiou 4733d757e6 Bug 1739260 - Force to advance next band if we cannot get a suitable float available space. r=dholbert
Without this patch, the test case, floats-aspect-ratio-001.html, hangs because:

1. The initial float available space is correct, and its size is 100px x 50px.
   And the bfc element is "width: auto; height: auto; aspect-ratio: 1/1;".
   So its width and height depend on the available space.

2. And then, we try to get a new available area based on the height of
   the bfc element (note: its size is 100px x 100px). However, we get an
   invalid zero-width float available area which is occupied by the element
   with float:right (i.e. the pink one), in the first band, and the size of
   float available space is 0px x 100px. This makes the size of bfc element
   become 0px x 0px when checking `FloatAvoidingBlockFitsInAvailSpace()`.
   So it always fits in this float available area. And because we get two
   different available areas in the first band (i.e. same `aBCoord`), so we
   don't go into the break condition, and contine to get a new
   `childReflowInput`, and then go to the next iteration.

3. In the 2nd loop, we try to get a new float available space by the
   height of the bfc element (note: its size is 0px x 0px now because
   the width of current float available space is 0px), so the
   new float available space is 100px x 0px, and the bfc element fits in
   this available area, but again, we have two different available
   areas, so we still don't go into the break condition. Instead, we use
   the new available area to compute the childReflowInput for the next
   iteration, and now the size of the bfc element becomes 100px x 100px.
   And then we go back to the state of (2).

4. So the bfc element enters a resize oscillation due to the invalid
   float available space together with the aspect-ratio and auto sizes
   (i.e. "widht: auto; height: auto;") I think. And the invalid float
   available space also let |AvailableSpaceShrunk()| be unexpected because
   we hit an assertion: "ASSERTION: available space should not grow on the
   start side and shrink on the end side".

A possible way is to make sure we get a suitable float available area for
`floatAvoidingBlock`, so this can avoid the bfc element from entering
a resize oscillation.

Note:
1. bfc means block-formatting-context, and its variable name is
   `floatAvoidingBlock` in nsBlockFrame.cpp.
2. We don't need to check zere or positive inline size for the float
   available space because `AvailableSpaceShrunk()` should make sure we
   leave the loop properly.
   See https://phabricator.services.mozilla.com/D145524#4766290 for the
   the example when the inline size is exactly zero.

Besides, we also fix contain-inline-size-bfc-floats-001.html with this
patch.

Differential Revision: https://phabricator.services.mozilla.com/D145524
2022-05-19 20:48:42 +00:00
Emilio Cobos Álvarez cb66a015b3 Bug 1704742 - Fix percent basis of shape radii. r=TYLin
Matches other browsers, and the spec, as per
https://drafts.csswg.org/css-shapes/#basic-shape:

    All the lengths expressed in percentages are resolved from the used
    dimensions of the reference box.

Differential Revision: https://phabricator.services.mozilla.com/D111790
2021-04-14 09:29:37 +00:00
Simon Giesecke 32d04cdc11 Bug 708901 - Migrate to nsTHashSet in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D108597
2021-03-24 17:56:46 +00:00
Csoregi Natalia 37fe7677dd Backed out 13 changesets (bug 708901, bug 1184468) for causing build bustage on GeckoViewHistory.cpp. CLOSED TREE
Backed out changeset b1e4c01e63b8 (bug 708901)
Backed out changeset 37b52cce83c0 (bug 708901)
Backed out changeset eee75f33f060 (bug 708901)
Backed out changeset 479bf64c7986 (bug 708901)
Backed out changeset 15a8fb94d15d (bug 708901)
Backed out changeset be31ccd9a61d (bug 708901)
Backed out changeset fc54f4eaedd5 (bug 708901)
Backed out changeset 03c3a56c3d13 (bug 708901)
Backed out changeset 73f11d3c1298 (bug 708901)
Backed out changeset aed22fd80893 (bug 708901)
Backed out changeset 74d8249fbe7e (bug 708901)
Backed out changeset acb725eb3c1d (bug 1184468)
Backed out changeset 70f3ea6efec4 (bug 1184468)
2021-03-24 19:26:20 +02:00
Simon Giesecke cbe4b9ff3a Bug 708901 - Migrate to nsTHashSet in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D108597
2021-03-24 16:58:58 +00:00
Ting-Yu Lin 33775fc8e4 Bug 1574046 Part 2 - Move calling nsFloatManager::ClearContinues to BlockReflowInput::ClearFloats(). r=dbaron
All the callers in nsBlockFrame call BlockReflowInput::ClearFloats(), I
don't feel we need to pass the DONT_CLEAR_PUSHED_FLOATS down to
nsFloatManager. Besides, I'll remove the flag in a later patch.

Differential Revision: https://phabricator.services.mozilla.com/D74537
2020-05-27 04:44:42 +00:00
Simon Giesecke e589800b47 Bug 1626570 - Improve handling of copying arrays in layout/generic/. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D72353
2020-05-05 10:11:01 +00:00
Simon Giesecke e613597e90 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in layout. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D66016
2020-03-17 09:38:32 +00:00
Emilio Cobos Álvarez cd8bf52d3e Bug 1614510 - Split clip-path and shape-outside values. r=boris
We don't actually share _that_ much code across them. This makes callers clearer
and code less confusing, IMHO.

This also has the benefit of not autocompleting path from devtools for
shape-outside.

Differential Revision: https://phabricator.services.mozilla.com/D62373
2020-02-11 23:34:53 +00:00
Emilio Cobos Álvarez 08cc931df3 Bug 1614510 - Use cbindgen for shape-outside and clip-path. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D62372
2020-02-11 22:03:53 +00:00
Emilio Cobos Álvarez 1071708870 Bug 1614198 - Use cbindgen instead of nsStyleImage. r=aosmond
The trickier part is that we represent -moz-image-rect as a Rect() type instead
of image with non-null clip-rect. So we need to add a bit of code to
distinguish "image request types" from other types of images.

But it's not too annoying, and we need to do the same for fancier images like
image-set and such whenever we implement it, so seems nice to get rid of
most explicit usages of nsStyleImage::GetType().

Differential Revision: https://phabricator.services.mozilla.com/D62164
2020-02-11 20:56:20 +00:00
Emilio Cobos Álvarez c7c1186c47 Bug 1613349 - Rename nsIFrame::DeleteProperty to RemoveProperty. r=dholbert
As it doesn't necessarily call delete and that may be confusing.

Differential Revision: https://phabricator.services.mozilla.com/D61764
2020-02-06 16:06:49 +00:00
Daniel Holbert 86280b8f73 Bug 1613198: Move inline impls for nsIFrame::GetNormalPosition and GetLogicalNormalPosition into nsIFrameInlines.h. r=jfkthame
Also, add an nsIFrameInlines.h include to all .cpp files who call these APIs
and who don't yet have an include for this header.

Differential Revision: https://phabricator.services.mozilla.com/D61615
2020-02-05 09:52:35 +00:00
Chris Peterson 0a9155f83b Bug 1570499 - Part 1: Replace MOZ_FALLTHROUGH macro with C++17's [[fallthrough]] attribute. r=froydnj
This changeset is a simple find and replace of `MOZ_FALLTHROUGH` and `[[fallthrough]]`.

Unfortunately, the MOZ_FALLTHROUGH_ASSERT macro (to assert on case fallthrough in debug builds) is still necessary after switching from [[clang::fallthrough]] to [[fallthrough]] because:

* MOZ_ASSERT(false) followed by [[fallthrough]] triggers a -Wunreachable-code warning in DEBUG builds
* but MOZ_ASSERT(false) without [[fallthrough]] triggers a -Wimplicit-fallthrough warning in NDEBUG builds.

Differential Revision: https://phabricator.services.mozilla.com/D56440
2019-12-20 07:16:43 +00:00
Mats Palmgren 786def0d4c Bug 1574046 - Wallpaper the effect of this bug in nsBlockFrame::ComputeFinalSize. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D56738
2019-12-17 23:03:21 +00:00
Ting-Yu Lin 9c95d87b5b Bug 1582224 - Split SIDEWAYS bit in WritingMode. r=jfkthame,emilio
Currently, there's no way to tell whether the SIDEWAYS bit is set from
`writing-mode:sideways-*` or `writing-mode:vertical-*; text-orientation:sideways;`.
To be able to tell them apart, split SIDEWAYS bits into VERTICAL_SIDEWAYS
and TEXT_SIDEWAYS. This is needed by my proposed solution in bug 1102175.

Also, provide convenience methods related to sideways writing-mode, and replace
obscure checks in the codebase.

Note that we don't have the use cases to distinguish vertical-rl from
sideways-rl in layout, but for the completeness, IsSidewaysLR() is still
defined.

Differential Revision: https://phabricator.services.mozilla.com/D46321
2019-09-19 02:37:14 +00:00
Nathan Froyd 85bbd65354 Bug 1570982 - remove CPP_THROW_NEW; r=glandium
We always define it to the same thing, and we're inconsistent in whether
we use `CPP_THROW_NEW` or `throw()`, so we might as well just use the
standard C++ thing and get rid of some baggage.

Differential Revision: https://phabricator.services.mozilla.com/D40425
2019-08-14 01:32:41 +00:00
Emilio Cobos Álvarez 44042b61d7 Bug 1552636 - Remove eStyleImageType_URL. r=TYLin
It was introduced in bug 1352096 to reduce complexity with Stylo (apparently).

Right now it doesn't look like it reduces any complexity, and it's a bit
annoying with some of the patches that I'm writing at the moment.

So unless there's any objection I think it should go away.

Differential Revision: https://phabricator.services.mozilla.com/D31708
2019-05-22 11:34:23 +00:00
Emilio Cobos Álvarez 95464eaeb7 Bug 1548691 - Use the owned slice type for basic shape polygon coordinates. r=TYLin,heycam
This enables destructors for tagged unions in cbindgen, implemented in:

 * https://github.com/eqrion/cbindgen/pull/333

Which allow us to properly generate a destructor for the cbindgen-generated
StyleBasicShape (which now contains an OwnedSlice).

For now, we still use the glue code to go from Box<BasicShape> to
UniquePtr<BasicShape>. But that will change in the future when we generate even
more stuff and remove all the glue.

I could add support for copy-constructor generation to cbindgen for tagged
enums, but I'm not sure if it'll end up being needed, and copy-constructing
unions in C++ is always very tricky.

Differential Revision: https://phabricator.services.mozilla.com/D29769
2019-05-09 11:24:57 +00:00
Emilio Cobos Álvarez 8ba05939c2 Bug 1546697 - Use a consistent style for enum classes in layout. r=dholbert
Per the discussion in:

  https://groups.google.com/d/msg/mozilla.dev.platform/P79pwa9z5m8/iPYPAWPHCAAJ

They should be CamelCase, and that's what most of them already do. This converts
the rest, which are a few.

For the ones that already used `e` or `k` prefixes, I've mostly done:

 for file in $(rg Type::e layout | cut -d : -f 1 | sort | uniq); do sed -i 's#Type::e#Type::#g' $file; done

For the ones that used uppercase, I've removed the prefix if it was already in
the type name, and turn them into CamelCase.

Depends on D28680

Differential Revision: https://phabricator.services.mozilla.com/D28681
2019-04-25 23:03:04 +00:00
Masayuki Nakano 394fc8aa9f Bug 1544343 - part 3: Make layout use mozilla::PresShell instead of nsIPresShell as far as possible r=emilio
This patch changes remaining things under `layout/`.  However, there are some
places which still need to use `nsIPresShell`.  That will be fixed in a
follow up bug.

Differential Revision: https://phabricator.services.mozilla.com/D27477
2019-04-16 07:25:10 +00:00
Cameron McCormack 25a8bde841 Bug 1534240 - Boost loading priority of CSS images similarly to how we do for HTML images. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D24814
2019-03-28 02:54:16 +00:00
Ryan Hunt a96492f0f6 Bug 1523969 part 14 - Move method definition inline comments to new line in 'layout/'. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D21115
2019-02-25 16:09:24 -06:00