50 Commits
Author SHA1 Message Date
Eugeniusz Lewandowski fc8097fcc3 Bug 1650944 - Remove ReflowInput.h include from nsIFrame.h r=firefox-style-system-reviewers,layout-reviewers,emilio
Removed the Reflow Input in nsIFrame. Added includes for ReflowInput as
necessary in cpp files. Also Forward Declared nsLineLayout in 3 header
files.

Differential Revision: https://phabricator.services.mozilla.com/D298203
2026-05-04 12:06:23 +00:00
serge-sans-paille eccc9787f4 Bug 2029001 - Remove or guard inclusion of fmt/format.h when possible r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D291866
2026-04-04 10:59:59 +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 077d88e977 Bug 2011213 - Remove FMT_STRING() usage. r=padenot
Should not be needed now that we build with C++20.

Differential Revision: https://phabricator.services.mozilla.com/D279521
2026-01-19 15:12:33 +00:00
Ting-Yu Lin 37912600c5 Bug 2007058 Part 1 - Generalize NS_FRAME_IS_PUSHED_FLOAT bit to NS_FRAME_IS_PUSHED_OUT_OF_FLOW. r=layout-reviewers,emilio
We need a similar concept to mark an abspos frame that is pushed to a later
absolute-containing-block continuation. A frame is either a float or an abspos
and thus lives in a different frame child list, so the same bit can be used in
both scenarios without conflicts.

Differential Revision: https://phabricator.services.mozilla.com/D277137
2025-12-19 21:05:34 +00:00
Emilio Cobos Álvarez 4bbf8598d1 Bug 1998125 - Remove a lot of now unused view code. r=layout-reviewers,firefox-style-system-reviewers,dshin
No need to reposition views during layout and so on, now that we don't
use views for either popups nor subdocuments.

No need for nsView to have parent / sibling / children either.

Differential Revision: https://phabricator.services.mozilla.com/D271205
2025-11-12 01:53:45 +00:00
Ting-Yu Lin 2e9b491a3c Bug 1998869 - Improve noisy reflow log. r=layout-reviewers,dholbert
* At the beginning of `ReflowAbsoluteFrame()`, instead of printing the
  delegating frame's computed size, it now prints the original containing block
  rect, which is a more important information in abspos reflow.
* Use `MOZ_DEFINE_ENUM_TOSTRING_FUNC` to implement `LineReflowStatus` to string
  helper.
* Add an indent when printing `LineReflowStatus`.

Differential Revision: https://phabricator.services.mozilla.com/D271734
2025-11-10 21:29:29 +00:00
serge-sans-paille 2680f1aa2a Bug 1995938 - Remove unused inclusion of DebugOnly.h r=emilio,necko-reviewers,application-update-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,toolkit-telemetry-reviewers,firefox-svg-reviewers,layout-reviewers,dom-worker-reviewers,bytesized,gstoll,mstange,TYLin,chunmin,jesup,asuth
Differential Revision: https://phabricator.services.mozilla.com/D269780
2025-10-27 10:48:42 +00:00
Cristian Tuns 6f66cdf3c7 Revert "Bug 1995938 - Remove unused inclusion of DebugOnly.h r=emilio,necko-reviewers,application-update-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,toolkit-telemetry-reviewers,firefox-svg-reviewers,layout-reviewers,dom-worker-reviewers,bytesized,gstoll,mstange,TYLin,chunmin,jesup,asuth" for causing build bustages in TargetFunction.h
This reverts commit 10e5184168.
2025-10-27 08:58:03 +00:00
serge-sans-paille 10e5184168 Bug 1995938 - Remove unused inclusion of DebugOnly.h r=emilio,necko-reviewers,application-update-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,toolkit-telemetry-reviewers,firefox-svg-reviewers,layout-reviewers,dom-worker-reviewers,bytesized,gstoll,mstange,TYLin,chunmin,jesup,asuth
Differential Revision: https://phabricator.services.mozilla.com/D269780
2025-10-27 08:00:43 +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
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
Ting-Yu Lin d52e3dc178 Bug 1903141 Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert
On optimized builds for all desktop platforms, `nsBlockFrame` is 192 bytes, and
`mFloats` is 16 bytes. With this patch, we can reduce the size of `nsBlockFrame`
to 176 bytes, saving 8.33% memory on every `nsBlockFrame` and its derived
subclasses allocated.

On a real webpage like https://en.wikipedia.org/wiki/Firefox, `about:memory`
shows that we allocate 0.36 MB of `nsBlockFrame` consistently. After this patch,
we allocate 0.33 MB, saving approximately 30 KB (0.36 MB * 8.33%) of the memory.

Differential Revision: https://phabricator.services.mozilla.com/D214046
2024-06-19 21:50:41 +00:00
pstanciu f3651823b9 Backed out 3 changesets (bug 1903141) for causing crashtest failures on nsSplittableFrame.cpp CLOSED TREE
Backed out changeset ccd18b9b52fc (bug 1903141)
Backed out changeset fbd60d2007b0 (bug 1903141)
Backed out changeset ce65f1574c68 (bug 1903141)
2024-06-19 03:15:25 +03:00
Ting-Yu Lin 94a9ed2943 Bug 1903141 Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert
On optimized builds for all desktop platforms, `nsBlockFrame` is 192 bytes, and
`mFloats` is 16 bytes. With this patch, we can reduce the size of `nsBlockFrame`
to 176 bytes, saving 8.33% memory on every `nsBlockFrame` and its derived
subclasses allocated.

On a real webpage like https://en.wikipedia.org/wiki/Firefox, `about:memory`
shows that we allocate 0.36 MB of `nsBlockFrame` consistently. After this patch,
we allocate 0.33 MB, saving approximately 30 KB (0.36 MB * 8.33%) of the memory.

Differential Revision: https://phabricator.services.mozilla.com/D214046
2024-06-18 20:13:55 +00:00
Ting-Yu Lin 1062f4a4ef Bug 1902542 Part 4 - Remove BlockReflowState::mPushedFloats and related APIs. r=layout-reviewers,emilio
`BlockReflowState::mPushedFloats` is a pointer to `mBlock`'s pushed floats
list. However, it is only used in `AppendPushedFloatChain()`. We can just get
the pushed floats list directly.

This is a preparation for the next part that removes a possible scenario where
`mPushedFloats` can point to a removed pushed floats list.

Differential Revision: https://phabricator.services.mozilla.com/D213701
2024-06-14 17:13:04 +00:00
fantasaiandEmilio Cobos Álvarez 5879e8247d Bug 1684236 - Implement 'align-content' on block containers. r=layout-reviewers,jfkthame
This is Fantasai's original patch, massively simplified:

 * We now can switch whether we're a BFC dynamically (bug 1765615), which
   simplifies the patch quite a lot.

 * I removed some changes that were specific to pagination but were untested.
   I left them as D202814, just in case we need some of those in the future.

All in all this makes the patch much more manageable.

Co-authored-by: Emilio Cobos Álvarez <[email protected]>

Differential Revision: https://phabricator.services.mozilla.com/D181858
2024-02-27 16:32:02 +00:00
Ting-Yu Lin 5cec51111c Bug 1877850 Part 2 - Rewrite ComputedSizeAsContainerIfConstrained() using logical coordinates, and use it in BlockReflowState. r=dholbert
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D200238
2024-02-01 22:02:01 +00:00
Sylvestre Ledru b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan 7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru 4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Jonathan Kew 2f9632a6a3 Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r=emilio
A simple form of balance for short blocks, implemented by incrementally reducing
the effective inline-size used during line-breaking, up to the point where an
extra line would be created.

This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me
if that test is correct (see https://github.com/w3c/csswg-drafts/issues/9310).
If we do want the behavior expected by that test, an additional patch to handle
the interaction with line-clamp will be required.

Depends on D187543

Differential Revision: https://phabricator.services.mozilla.com/D187544
2023-09-30 15:53:12 +00:00
Sandor Molnar 53fea6e6ed Backed out 5 changesets (bug 1731541) for causing multiple wpt failures. CLOSED TREE
Backed out changeset c185a38fb335 (bug 1731541)
Backed out changeset 16a3de29e4e6 (bug 1731541)
Backed out changeset 225642ff1de8 (bug 1731541)
Backed out changeset eb0b125d3214 (bug 1731541)
Backed out changeset af42a433722a (bug 1731541)
2023-09-28 23:49:24 +03:00
Jonathan Kew fa67514884 Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r=emilio
A simple form of balance for short blocks, implemented by incrementally reducing
the effective inline-size used during line-breaking, up to the point where an
extra line would be created.

This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me
if that test is correct (see https://github.com/w3c/csswg-drafts/issues/9310).
If we do want the behavior expected by that test, an additional patch to handle
the interaction with line-clamp will be required.

Depends on D187543

Differential Revision: https://phabricator.services.mozilla.com/D187544
2023-09-28 17:28:19 +00:00
Natalia Csoregi 4a88c0e9b1 Backed out 4 changesets (bug 1731541) for causing bustage on nsBlockFrame.cpp. CLOSED TREE
Backed out changeset 7ce2b41bb730 (bug 1731541)
Backed out changeset 71d889de8d97 (bug 1731541)
Backed out changeset 0fd4431f5279 (bug 1731541)
Backed out changeset 5926241957b4 (bug 1731541)
2023-09-28 12:09:30 +03:00
Jonathan Kew 807cb41315 Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r=emilio
A simple form of balance for short blocks, implemented by incrementally reducing
the effective inline-size used during line-breaking, up to the point where an
extra line would be created.

This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me
if that test is correct (see https://github.com/w3c/csswg-drafts/issues/9310).
If we do want the behavior expected by that test, an additional patch to handle
the interaction with line-clamp will be required.

Depends on D187543

Differential Revision: https://phabricator.services.mozilla.com/D187544
2023-09-28 08:31:20 +00:00
Ting-Yu Lin 116b6dfd4f Bug 1805597 - Place a float with insufficient available inline-size below current line regarless of its clearance value. r=jfkthame,layout-reviewers
This bug is a regression of Bug 1323517. This patch fixes the bug by restoring
the behavior to what it was prior to Bug 1323517 Part 7 [1], i.e. a float
element with insufficient available inline-size will be placed below the current
line, regardless of its clearance value. The old logic is here [2] .

`floats-placement-008.html` already passes with current Nightly, but it triggers
this assertion [3] while exploring a solution for this bug. I feel it is worth
to include it as a test.

[1] https://hg.mozilla.org/mozilla-central/rev/d08bab0259f7
[2] https://searchfox.org/mozilla-central/rev/b9cb8817f510057021874627487c6c14f69287c3/layout/generic/BlockReflowState.cpp#588-589
[3] https://searchfox.org/mozilla-central/rev/b25ff1fab82c2d3a91531ad3735e50422407b163/layout/generic/BlockReflowState.cpp#1026-1027

Differential Revision: https://phabricator.services.mozilla.com/D169588
2023-02-13 19:12:10 +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
Ting-Yu Lin f76b468723 Bug 1792134 Part 1 - Clean up around BR clearance handling. r=emilio
This patch shouldn't change the behavior.

* Rename BlockReflowState's `mFloatBreakType` to `mTrailingClearFromPIF` since
  it's the cached result of `FindTrailingClear()` from the block's prev-in-flow.
  Note that `mTrailingClearFromPIF` can have `StyleClear::Line`, which is
  not a float clear value. We'll remove `StyleClear::Line` in a later part to
  make this 100% correct.
* Rename `nsLayoutUtils::CombineBreakType` to `CombineClearType` as well as its
  arguments.
* Simplify FindTrailingClear()'s implementation.

Differential Revision: https://phabricator.services.mozilla.com/D158221
2022-09-29 03:40:54 +00:00
Ting-Yu Lin 602a614514 Bug 498986 Part 1 - Use nsTArray<nsIFrame*> to store float list in nsLineBox and BlockReflowState. r=emilio
Nowadays, nsFloatCache stores no extra information but `nsIFrame*`, which makes
nsFloatCacheList and nsFloatCacheFreeList are just singly and doubly linked
list of frames, respectively.

Most of this patch is a plain rewrite to use nsTArray APIs. There are two
rewrite that need more explanation.

1. `BlockReflowState::mFloatCacheFreeList` is served as a temporarily list to
   avoid extra allocations of nsFloatCache. It takes the ownership of floats
   from a line via FreeFloats(), and later reuses the cache in AddFloat().
   We don't need this anymore, so we remove it.

2. In `PlaceBelowCurrentLineFloats()`, the old code removes a float which
   needs to be pushed to next continuation from `mBelowCurrentLineFloats`.
   After looking through all of the floats, the remaining of
   `mBelowCurrentLineFloats` are moved to the line because they belong to the
   line. In this patch, rather than removing the pushed floats one by one from
   `mBelowCurrentLineFloats`, I use a new list to collect the floats that need
   to be added to the line, and just clear `mBelowCurrentLineFloats` at the
   end of the method.

Differential Revision: https://phabricator.services.mozilla.com/D157976
2022-09-23 06:42:09 +00:00
Emilio Cobos Álvarez 777e2aa014 Bug 1786147 - Make -webkit-line-clamp create a block container in the appropriate situations. r=dholbert
This is a hack, sorta, similar to Chromium's:

  https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/layout/layout_object.cc;l=356;drc=312b74e385e6aba98ab31fd911238c0dc16b396c

except at computed-value rather than used-value time, because it's both
simpler to reason about and prevents lying in the computed style.

This fixes the relevant test-case, and matches closer what Chromium does,
by not creating anonymous flex items for all elements inside the
line-clamp context.

The behavior change is covered by the test changes. I had to also fix a
couple pre-existing bugs that were caught by tests, now that the
line-clamped block is the -webkit-box-styled element rather than an anonymous
flex item (and thus now had padding).

Depends on D155180

Differential Revision: https://phabricator.services.mozilla.com/D155181
2022-09-07 23:57:18 +00:00
Ting-Yu Lin c3f7f8a812 Bug 1464761 Part 1 - Remove IsTruncated() in FlowAndPlaceFloat(). r=dholbert
Add a wpt print test that catches an accidental behavior change for a previous
version of this patch.

Differential Revision: https://phabricator.services.mozilla.com/D151458
2022-07-27 21:55:17 +00:00
Ting-Yu Lin 7c8f078be7 Bug 1778931 Part 3 - Tweak floatRI's mIsTopOfPage bit in FlowAndPlaceFloat(). r=dholbert
The old code tweaks mIsTopOfPage in ReflowFloat(). However
`aAvailableSize.ISize()` (in containing block's writing-mode) always equals to
ContentISize() because it is computed via ComputeAvailableSizeForFloat().
Therefore, the only reason the floatRI's mIsTopOfPage can be `false` is when
some floats are already being placed, and we only check this in the
`!earlyFloatReflow` branch.

By tweaking mIsTopOfPage bit in FlowAndPlaceFloat(), we can also remove two
unused parameters in ReflowFloat().

This patch shouldn't change the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D151457
2022-07-26 04:54:37 +00:00
Ting-Yu Lin 86b181ef13 Bug 1778931 Part 1 - Create a float's ReflowInput in FlowAndPlaceFloat() and pass it into ReflowFloat(). r=dholbert
There is some advantage to creating the float's ReflowInput in
FlowAndPlaceFloat().

1. ReflowFloat() doesn't need to output the float's margin and offset via the
   output arguments. FlowAndPlaceFloat() can get them from the local ReflowInput
   directly.

2. Since we are going to reflow the float, we have to create a ReflowInput
   anyway. FloatMarginISize() can take the ReflowInput and be simplified. No need
   to waste time to create a separate SizeComputationInput.

Also, delete the comment "Pass floatRS so the frame hierarchy can be
used (redoFloatRS has the same hierarchy)" because I believe it is obsolete.

This patch also lays the foundation for other improvements in the later patches.

Differential Revision: https://phabricator.services.mozilla.com/D151455
2022-07-26 04:54:36 +00:00
Ting-Yu Lin 9b273b89f7 Bug 1323517 Part 7 - Fix the placement of an orthogonal float with an auto block-size. r=jfkthame
The old code in AddFloat() used to call nsBlockFrame::ComputeFloatISize() to
compute a float's inline-size, compare it with current line's available
inline-size, and determine whether FlowAndPlaceFloat() should be called.
However, it doesn't handle an orthogonal float with an auto block-size.

Luckily, FlowAndPlaceFloat() already has logic dealing with orthogonal
floats (bug 1141867), so this patch defers the decision to place a float below
the current line until the float's margin inline-size is computed in
FlowAndPlaceFloat().

Differential Revision: https://phabricator.services.mozilla.com/D151209
2022-07-07 19:01:56 +00:00
Ting-Yu Lin ca47f69ffd Bug 1323517 Part 6 - Change FlowAndPlaceFloat()'s return value to a tri-state enum. r=jfkthame
This patch is a preparation for the next part, and doesn't change the behavior
yet.

FlowAndPlaceFloat() is used to return true and false. This patch changes its
return value `true` to `PlaceFloatResult::Placed` and `false` to
`PlaceFloatResult::ShouldPlaceInNextContinuation`.

In the next part, we'll move the logic dealing with "below the current line
floats" into FlowAndPlaceFloat(), and make it return
`PlaceFloatResult::ShouldPlaceBelowCurrentLine`.

Differential Revision: https://phabricator.services.mozilla.com/D151208
2022-07-07 19:01:56 +00:00
Ting-Yu Lin 2dbfe793c8 Bug 1323517 Part 5 - Improve the available size computation for reflowing a float. r=jfkthame
First of all, `nsBlockFrame::AdjustFloatAvailableSpace()` is misleading. It
doesn't adjust the argument `aFloatAvailableSpace` at all, nor does it use any
fields in nsBlockFrame. It simply returns the available space in the parent
block's content area. Thus, I move it into BlockReflowState, and have it return
the available size rather than a rect because a size is sufficient for reflowing
a float.

Also, nsBlockFrame::ReflowFloat() only cares about the available size, but not
the position of the available space, so it is sufficient to pass a LogicalSize
computed by the new method ComputeAvailableSizeForFloat().

In FlowAndPlaceFloat(), there is a loop searching for a wide enough band to
place the float. We don't need to adjust availSize every time mBCoord is changed
in the loop. We can just call ComputeAvailableSizeForFloat() to get a new
available size before reflowing the float in the `!earlyFloatReflow` branch.

This patch shouldn't change the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D151207
2022-07-07 19:01:56 +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 943ce7a0a9 Bug 1323517 Part 2 - Remove float debug log that requires manual #define. r=jfkthame
These are small printf statements that are not build by CI, which increase
maintenance burden.

Differential Revision: https://phabricator.services.mozilla.com/D151204
2022-07-07 19:01:54 +00:00
Ting-Yu Lin 1616732643 Bug 1323517 Part 1 - Remove a duplicate assertion, and assert a fresh reflow status in ReflowFloat(). r=jfkthame
In FlowAndPlaceFloat(), condense two identical assertions about float frame
parent into one.

FlowAndPlaceFloat() calls ReflowFloat() only once, either an early reflow (when
`earlyFloatReflow` is `true`) or a late reflow (when `earlyFloatReflow` is
`false`), so the reflow status is always fresh.

Differential Revision: https://phabricator.services.mozilla.com/D151203
2022-07-07 19:01:54 +00:00
Ting-Yu Lin 1bf987f785 Bug 1777627 Part 1 - Improve BlockReflowState::IsAdjacentWithTop(). r=emilio
I rename and add a comment to the helper, and rewrite it to make it closer to
what the comment describes. The behavior is the same because `mBCoord` and
`mContentArea.BStart(wm)` are both initialized as `mBorderPadding.BStart(wm)`
[1].

Note `isAdjacentWithTop` local variable in ReflowFloat() is not changed because
it's going to be removed in the next patch.

[1] https://searchfox.org/mozilla-central/rev/2005e8d87ee045f19dac58e5bff32eff7d01bc9b/layout/generic/BlockReflowState.cpp#142

Differential Revision: https://phabricator.services.mozilla.com/D150831
2022-07-05 23:43:51 +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
Daniel Holbert 5062d4eb15 Bug 1767069 part 3: Modernize naming for some SizeComputationInput variables in float layout code. r=emilio
This patch does not impact behavior.

Before this patch, these variables' names are abbreviations of their original
type-name, "nsCSSOffsetState".  We renamed that type to SizeComputationInput in
bug 1277129, and this patch just updates the variable-names to reflect that
renaming, so that now they're abbreviations of the new type-name, rather than
the old one.

This patch also takes this opportunity to move these variables declarations
closer to their usage, and in one case we convert a variable to be a temporary
anonymous value in the middle of another assignment.

Differential Revision: https://phabricator.services.mozilla.com/D145137
2022-05-02 18:49:17 +00:00
Daniel Holbert cbd03f52d2 Bug 1767069 part 1: Standardize on "float-avoiding block" in var/function names to refer to block-level elements that cannot intersect floats. r=emilio
This patch does not impact behavior; it's just a handful of renamings and
documentation-updates.

Before this patch, our float-handling code has a bunch of variables and
functions with "replaced" in the name. But in fact these aren't necessarily
replaced; they're just block-level frames that elicit a "false" return-value
from "BlockCanIntersectFloats".  This category *includes* replaced boxes, and
it also includes frames that establish a formatting context, e.g.:
scrollframes, flex/grid containers, flow-root, table.

This patch seeks to clarify things by renaming these to refer to the fact that
they "avoid" floats, e.g. s/replacedBlock/floatAvoidingBlock/.

I've included a comment to reference this term in the BlockCanIntersectFloats()
documentation (note that the "can intersect" concept is the opposite of
"avoids").  I've also renamed a few "aFrame" variables to
"aFloatAvoidingBlock", for a few functions that are explicitly dealing with
this scenario and only expect to be passed frames that are in this category.

Differential Revision: https://phabricator.services.mozilla.com/D145131
2022-05-02 18:49:16 +00:00
Ting-Yu Lin d5aa579d88 Bug 1756008 Part 4 - Replace "BlockReflowInput" with "BlockReflowState". r=layout-reviewers,emilio
This patch is generated via:

```
rg -l 'BlockReflowInput' layout/ | xargs sed -i 's/BlockReflowInput/BlockReflowState/g'
```

Manual fixes are in the next part.

Differential Revision: https://phabricator.services.mozilla.com/D139439
2022-02-23 21:22:43 +00:00
Ting-Yu Lin 9db4ab3b6a Bug 1756008 Part 1 - Rename BlockReflowInput.{h,cpp} to BlockReflowState.{h,cpp}, and fix #includes. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D139436
2022-02-23 21:22:42 +00:00