Commit graph

2124 commits

Author SHA1 Message Date
Ting-Yu Lin
c99b45fa14 Bug 1798373 Part 6 - Change nsContainerFrame::AppendFrames() to take rvalue reference of nsFrameList. r=emilio
Change nsBlockFrame::AppendFrames() helper, too.

Differential Revision: https://phabricator.services.mozilla.com/D160842
2022-11-01 21:15:54 +00:00
Ting-Yu Lin
4787078c5c Bug 1798373 Part 5 - Change nsContainerFrame::SetInitialChildList() to take rvalue reference of nsFrameList. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D160841
2022-11-01 21:15:54 +00:00
Ting-Yu Lin
fc3719b5aa Bug 1798373 Part 4 - Remove nsFrameList::SetFrames() that takes nsFrameList. r=emilio
SetFrame() is equivalent to `operator=`, so external callers can use `operator=`
instead. For the two callers wanting to set `nsFrameList` to `AbsoluteFrameList`
in `nsCSSFrameConstructor`, removing SetFrame() disallows it. However, we can
easily change the declaration from `nsFrameList` to a `AbsoluteFrameList` to
resolve the problem.

Differential Revision: https://phabricator.services.mozilla.com/D160840
2022-11-01 21:15:53 +00:00
Ting-Yu Lin
adf4fab73c Bug 1798373 Part 2 - Change nsFrameList::AppendFrames to take rvalue reference of nsFrameList. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D160838
2022-11-01 21:15:52 +00:00
Ting-Yu Lin
569c5f244b Bug 1798373 Part 1 - Change nsFrameList::InsertFrames to take rvalue reference of nsFrameList. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D160837
2022-11-01 21:15:52 +00:00
Ting-Yu Lin
babc81bc9c Bug 1797011 Part 3 - Delete nsFrameList's copy assigment operator. r=emilio
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D160015
2022-10-26 04:22:25 +00:00
Ting-Yu Lin
13d40cfd97 Bug 1797011 Part 1 - Delete nsFrameList's copy constructor. r=layout-reviewers,emilio
This patch doesn't change behavior, and eliminates copy construction of
nsFrameList via utilizing const-references to store the return value of
`GetChildList()`.

nsFrameList::Clone() is added in case the caller wants a copy of a list.

This is the first step toward making nsFrameList a move-only class.

Differential Revision: https://phabricator.services.mozilla.com/D160013
2022-10-26 04:22:24 +00:00
Ting-Yu Lin
d0b5d62f69 Bug 1797009 - Use PushTruncatedLine() once more. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D160171
2022-10-25 17:28:28 +00:00
Ting-Yu Lin
e7055d8d51 Bug 1797009 - Extract common operation when reporting line-break-before status, and use PushTruncatedLine() more. r=emilio
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D160012
2022-10-25 02:33:47 +00:00
Butkovits Atila
b704dcf231 Backed out 4 changesets (bug 1797011) for causing high frequency ThreadSanitizer failures. CLOSED TREE
Backed out changeset e55bef9aa488 (bug 1797011)
Backed out changeset 515757be2f7e (bug 1797011)
Backed out changeset 360739dfb6d1 (bug 1797011)
Backed out changeset 9a3f104b78c5 (bug 1797011)
2022-10-25 01:03:29 +03:00
Ting-Yu Lin
aae6173a16 Bug 1797011 Part 3 - Delete nsFrameList's copy assigment operator. r=emilio
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D160015
2022-10-24 19:14:33 +00:00
Ting-Yu Lin
a3eea20a9b Bug 1797011 Part 1 - Delete nsFrameList's copy constructor. r=layout-reviewers,emilio
This patch doesn't change behavior, and eliminates copy construction of
nsFrameList via utilizing const-references to store the return value of
`GetChildList()`. This is the first step toward making nsFrameList a move-only
class.

Differential Revision: https://phabricator.services.mozilla.com/D160013
2022-10-24 19:14:32 +00:00
Ting-Yu Lin
8bbc0dbcf5 Bug 1794456 Part 3 - Support range-based for loop for nsFrameList::Slice. r=emilio
Since Slice::mEnd is the first frame that is NOT in the slice, so we only
support forward iteration, and it's sufficient to replace existing usages of
nsFrameList::Enumerator.

For those for loops iterating TableColFrame and TableColGroupFrame, we need to
explicitly check the validity of the iterator because they modify the frame list
while iterating. nsFrameList::Enumerator::End() has a hack for this.
https://searchfox.org/mozilla-central/rev/ffa4d00965c5281def6d3ddcbcdf6259d38c9b9a/layout/generic/nsFrameList.h#402-407

Differential Revision: https://phabricator.services.mozilla.com/D158986
2022-10-11 21:01:28 +00:00
Ting-Yu Lin
ce9040c985 Bug 1794035 Part 4 - Use range-based for loops to iterate nsFrameList. r=emilio
After this patch, we still need nsFrameList::Enumerator to iterate
nsFrameList::Slice. We might enhance nsFrameList::Iterator to support Slice, but
I'll leave this for another day.

Differential Revision: https://phabricator.services.mozilla.com/D158809
2022-10-07 01:41:41 +00:00
Ting-Yu Lin
d38c1fa035 Bug 1794035 Part 3 - Move nsBlockFrame::HasPushedFloatsFromPrevContinuation() implementation to cpp. r=emilio
It is large enough to live in cpp.

Differential Revision: https://phabricator.services.mozilla.com/D158808
2022-10-07 01:41:41 +00:00
Ting-Yu Lin
baa8c00217 Bug 1794035 Part 2 - Rename RemoveFramesAfter, improve its implementation, and remove ExtractTail. r=emilio
RemoveFramesAfter and ExtractTail have similar purpose, so we really should keep
one of them to avoid confusion.

They have the following minor differences:
1. RemoveFramesAfter() keeps aFrame in the list, while ExtractTail() returns it.
2. If aFrame is empty, RemoveFramesAfter() returns the entire list, while
   ExtractTail returns an empty list.

It's more convenient for the existing callers to use the RemoveFramesAfter(), so
ExtractTail is unneeded.

After this patch, both RemoveFramesAfter() and RemoveFramesBefore() return the
entire list if aFrame is nullptr.

Rename RemoveFramesAfter() to TakeFramesAfter() for symmetry with
TakeFramesBefore().

This change shouldn't change the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D158807
2022-10-07 01:41:40 +00:00
Ting-Yu Lin
171f18c10d Bug 1794035 Part 1 - Rename nsFrameList::ExtractHead to TakeFramesBefore. r=emilio
I feel it's hard to understand the purpose of ExtractHead(), especially where
aFrame is going after the call. Therefore, I rename it to TakeFramesBefore(),
and have it complement the existing RemoveFramesAfter(), which will be rename
later. No behavioral change intended.

Also, slightly reword the method's documentation to reflect the its new
name. (Remove the "sibling" wording from the comment since it's an
implementation details that frames are actually a doubly linked list.)

Differential Revision: https://phabricator.services.mozilla.com/D158806
2022-10-07 01:41:40 +00:00
Ting-Yu Lin
ff8e435a59 Bug 1793826 Part 1 - Change nsFrameList::ExtractHead and ExtractTail to take nsIFrame* argument. r=emilio
This is a preparation to remove nsFrameList::FrameLinkEnumerator in the next
part.

Differential Revision: https://phabricator.services.mozilla.com/D158700
2022-10-06 06:47:25 +00:00
Csoregi Natalia
eb363bd64e Backed out 2 changesets (bug 1793826) for causing build bustages. CLOSED TREE
Backed out changeset 9e398426c46f (bug 1793826)
Backed out changeset 01820845ab62 (bug 1793826)
2022-10-06 03:41:00 +03:00
Ting-Yu Lin
307de24fc3 Bug 1793826 Part 1 - Change nsFrameList::ExtractHead and ExtractTail to take nsIFrame* argument. r=emilio
This is a preparation to remove nsFrameList::FrameLinkEnumerator in the next
part.

FrameLinkEnumerator::Find() can be replaced with std::find/std::find_if.

Differential Revision: https://phabricator.services.mozilla.com/D158700
2022-10-06 00:19:41 +00:00
Emily McDonough
1f2d745a94 Bug 1782597 Part 2 - Use null to indicate page value equal to the auto value for CSS named pages r=dholbert
This applies both to the individual mStartPageValue and mEndPageValue fields
of the nsIFrame::PageValues struct, and for the nsIFrame::PageValuesProperty
being null to indicate both mStartPageValue and mEndPageValue are auto.

Fetching this is handled by nsIFrame::GetStartPageValue and
nsIFrame::GetEndPageValue, which also ensure the use of first-in-flow frames.

Differential Revision: https://phabricator.services.mozilla.com/D157873
2022-10-05 22:07:47 +00:00
Ting-Yu Lin
b798773da4 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
39e9b0eb72 Bug 1792134 Part 3 - Remove StyleClear::Line. r=emilio
Before this patch, StyleClear::Line indicates that the nsLineBox has break-after
but no float clearance (note we don't allow line break-before with clear:none);
StyleClear::None indicates the line has no break-before nor break-after.

In this patch, I added `mHasForcedLineBreak` bit in nsLineBox to indicate the
line has a break so that StyleClear can serve its original meaning -- the float
clearance. In Part 6, I'll rename more existing methods and variables related to
float clearance.

Now, instead of using StyleClear::None to clear the line break status, the
caller should use ClearForcedLineBreak(); Similar to set
SetInlineLineBreakBeforeAndReset() and SetInlineLineBreakAfter on
nsReflowStatus, SetBreakTypeBefore/SetBreakTypeAfter on nsLineBox always sets
break status with an optional float clearance parameter.

This patch shouldn't change the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D158224
2022-09-29 03:40:55 +00:00
Ting-Yu Lin
d467693a88 Bug 1792134 Part 2 - Simplify two callsites with nsLineBox::HasBreakBefore. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D158222
2022-09-29 03:40:55 +00:00
Ting-Yu Lin
8ede95ba5f 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
0bf768dbfc 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
Emily McDonough
673e9552a0 Bug 1764437 - Check for prev/next sibling when propagating start/end page values for frames r=dholbert
This also properly handles placeholder frames, and ensures that when checking
next/prev sibling we ignore placeholder frames.

To properly test this for multiple levels of page value propagation, we also
need to use FirstInFlow to get page values when checking for breaks in block
frames.

Differential Revision: https://phabricator.services.mozilla.com/D157175
2022-09-20 21:42:34 +00:00
Martin Robinson
f943c5f18d Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D157306
2022-09-15 20:32:27 +00:00
Norisz Fay
fd54c095de Backed out changeset c3780baf6f24 (bug 1789255) for causing build bustages CLOSED TREE 2022-09-15 21:14:04 +03:00
Martin Robinson
631f1807ed Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D157306
2022-09-15 17:56:42 +00:00
Emilio Cobos Álvarez
1ac22be3aa Bug 1790882 - Call ApplyLineClamp even with a definite computed block-size. r=dholbert
The previous implementation of line-clamp was relying on the flex
measuring reflow.

Differential Revision: https://phabricator.services.mozilla.com/D157371
2022-09-15 15:06:14 +00:00
Sandor Molnar
4009825526 Backed out changeset 3a5759eabb42 (bug 1789255) for causing wpt failures in netwerk/protocol/http/Http2Session.cpp CLOSED TREE 2022-09-14 02:01:36 +03:00
Emily McDonough
aea863f3d5 Bug 1779645 Part 1 - Switch CSS named page fragmentation to happen at reflow instead of frame construction r=dholbert
This also adds a small post-processing step for frame-construction to ensure
that replaced frames (or more generally frames with content but no children)
have the auto page-name set on them.

When page-name value tracking is switched to be lazy, this post-processing step
will likely be redundant and can be removed.

Differential Revision: https://phabricator.services.mozilla.com/D152701
2022-09-13 21:29:37 +00:00
Martin Robinson
f48a334b7c Bug 1789255: Anonymous children of elements with content-visibility should not be skipped for layout r=emilio
Some anonymous children are important for properly sizing their parents
even when those parents hide content with `content-visibility`. This is
shown by regressions in the proper layout of some form elements with
`content-visibility`.

This change introduces a more conservative approach for avoiding layout
of hidden content. Instead of leaving all children dirty during reflow,
reflow anonymous frames (and nsComboboxDisplayFrame, a specialized kind
of anonymous frame). This change means that frames may only lay out some
of their children, so it must introduce some more changes to assumptions
during line layout.

In addition, this change renames `content-visibility` related methods in
nsIFrame in order to make it more obvious what they do.

Differential Revision: https://phabricator.services.mozilla.com/D156473
2022-09-13 20:01:35 +00:00
criss
a4d6291cea Backed out 3 changesets (bug 1786399, bug 1779645) for causing reftest failures on page-name-zero-height-001.html. CLOSED TREE
Backed out changeset 81c8d6a2d6f9 (bug 1786399)
Backed out changeset 3ee5fb016aa0 (bug 1779645)
Backed out changeset b626e11a262d (bug 1779645)
2022-09-13 04:19:42 +03:00
Emily McDonough
dbbd632586 Bug 1779645 Part 1 - Switch CSS named page fragmentation to happen at reflow instead of frame construction r=dholbert
This also adds a small post-processing step for frame-construction to ensure
that replaced frames (or more generally frames with content but no children)
have the auto page-name set on them.

When page-name value tracking is switched to be lazy, this post-processing step
will likely be redundant and can be removed.

Differential Revision: https://phabricator.services.mozilla.com/D152701
2022-09-12 22:44:48 +00:00
Emilio Cobos Álvarez
a11c622dc7 Bug 1786147 - Remove layout.css.webkit-line-clamp.enabled, and add a new pref to apply line-clamp to all BFCs. r=dholbert
It's always true, so remove it.

Add another pref to allow -webkit-line-clamp to work on all blocks
rather than just legacy -webkit-boxes, which seems something we should
try to look into, eventually.

Depends on D155181

Differential Revision: https://phabricator.services.mozilla.com/D155182
2022-09-07 23:57:18 +00:00
Emilio Cobos Álvarez
3c206e563a 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
Oriol Brufau
2bf0e47e75 Bug 1788068 - Obey contain-intrinsic-size in single-select list boxes. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D155984
2022-08-30 20:23:37 +00:00
Martin Robinson
ff6e1e7e64 Bug 1767262 - Lazily layout content that is hidden via content-visibility: hidden r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D145949
2022-08-29 14:41:36 +00:00
Sandor Molnar
a4f3a0f44b Backed out changeset f67c8298a104 (bug 1767262) for causing wpt assertion failures in layout/base/PresShell.cpp CLOSED TREE 2022-08-24 20:39:45 +03:00
Martin Robinson
9d8878f0d0 Bug 1767262 - Lazily layout content that is hidden via content-visibility: hidden r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D145949
2022-08-24 13:30:55 +00:00
Nathan LaPre
0a26bbd880 Bug 1776928 - avoid backplating text that is entirely whitespace in HCM, r=morgan
Some sites use text content that consists entirely of whitespace, which can
lead to unexpected rendering in High Contrast Mode - namely, backplating of
invisible characters. This commit adds logic that detects text nodes consisting
entirely of whitespace and reports their text area as 0. This commit also adds
a test for the behavior, and modifies an existing test to reflect the new
behavior.

Differential Revision: https://phabricator.services.mozilla.com/D155248
2022-08-23 19:41:59 +00:00
Butkovits Atila
5c5ef28ffa Backed out changeset 5a4a5749f8dc (bug 1767262) for causing wpt failures. 2022-08-23 18:33:04 +03:00
Martin Robinson
4d8325d138 Bug 1767262 - Lazily layout content that is hidden via content-visibility: hidden r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D145949
2022-08-23 14:16:10 +00:00
Ting-Yu Lin
27be7e6ac4 Bug 1441048 Part 2 - Use NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR to detect block-fragmented context when marking a line dirty. r=emilio
We can move a float frame into its block parent's PushedFloatsList during column
balancing when it cannot fit in the available block-size.

Later, when the column balancing algorithm reflows the last column in an
unconstrained block-size (in the very last reflow if needed [1]), we have to
reflow the line which contains the float's placeholder. The old code uses
`GetPrevInFlow() || GetNextInFlow()` to detect this scenario, which is
insufficient because the float's block parent might not have any continuation.
This patch uses `NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR` bit to detect this instead.

[1] https://searchfox.org/mozilla-central/rev/5c04fc7016eb7f52cf835d482f1125c8f139c959/layout/generic/nsColumnSetFrame.cpp#1144-1154

Differential Revision: https://phabricator.services.mozilla.com/D154860
2022-08-17 17:18:00 +00:00
Butkovits Atila
ae6a677e52 Backed out changeset 7538d23ee88e (bug 1767262) for causing failures at content-visibility-081.html. CLOSED TREE 2022-08-15 20:37:49 +03:00
Martin Robinson
1cf715eb0d Bug 1767262 - Lazily layout content that is hidden via content-visibility: hidden r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D145949
2022-08-15 16:18:43 +00:00
Ting-Yu Lin
f101e2077d Bug 1464761 Part 4 - Remove nsReflowStatus::mTruncated bit. r=dholbert
In the description of the mTruncated bit, its purpose is the same as calling
SetInlineLineBreakBeforeAndReset(). We've removed all its usages in previous
patches, so the bit is no longer needed.

Differential Revision: https://phabricator.services.mozilla.com/D151461
2022-07-27 21:55:18 +00:00
Ting-Yu Lin
1a163a2709 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