Commit graph

138 commits

Author SHA1 Message Date
Sean Feng
8545559775 Bug 1669734 - Factor out the logic of computing auto margins for abspos frames to its own method r=dholbert,emilio
Differential Revision: https://phabricator.services.mozilla.com/D107872
2021-03-15 15:45:17 +00:00
Ting-Yu Lin
ea9685fb41 Bug 1690701 Part 4 - Replace rarely used ReflowInput::IsFloating() with nsStyleDisplay::IsFloating(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D106583
2021-03-04 00:34:04 +00:00
Ting-Yu Lin
7a72791226 Bug 799725 Part 1 - Support AspectRatio in StyleSizeOverrides. r=dholbert
This is a preparation patch for Part 2 -- We need a way to ignore
aspect-ratio when measuring a flex item's content block-size, because we
don't want the stretched inline-size transferring through aspect-ratio
to set block-size.

This patch hasn't changed the behavior yet. Part 2 is going to utilize
mAspectRatio.

Differential Revision: https://phabricator.services.mozilla.com/D106383
2021-02-25 20:06:11 +00:00
Ting-Yu Lin
ed3ef63263 Bug 1692116 Part 3 - Fix table flex item's content block-size measurement by removing mIsFlexContainerMeasuringBSize flag. r=dholbert
The mIsFlexContainerMeasuringBSize flag serves two purposes:

(1) Tell ReflowInput::ComputeMinMaxValues() to treat min-block-size and
max-block-size like the initial value.

We can just set both sizes after creating the ReflowInput, like this
patch does.

(2) Add `ComputeSizeFlag::UseAutoBSize` to mComputeSizeFlags.

Similar to the reasoning in Bug 1674302 Part 2
https://hg.mozilla.org/mozilla-central/rev/23aff0f21a1d, the
UseAutoBSize flag is buggy when used on table flex items because it
never propagates to inner table frame. We can fix it by providing an
'auto' mStyleBSize in StyleSizeOverrides.

This fixed table flex item's content block-size measurement. As
described in table-as-item-specified-height.html, the specified height
on <table> now won't count as another min-height anymore.

Differential Revision: https://phabricator.services.mozilla.com/D106157
2021-02-25 20:06:11 +00:00
Ting-Yu Lin
60b5c8e185 Bug 1693409 Part 2 - Don't enforce table's min-content inline-size when resolving flex base size. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D105685
2021-02-19 22:12:19 +00:00
Ting-Yu Lin
1e1db8c9d9 Bug 1674302 Part 3 - Fix flex base size resolution and main/cross size override for table flex items. r=dholbert
This is the main patch of this bug.

When a flex container provides size overrides for a table flex item,
there are two use cases.

(1) When resolving flex base size, we want to use `flex-basis` to
replace the preferred main size on the *inner table frame* directly.
This is how `height` works on a table element. That is, it sets the
height of the inner table frame, not the table wrapper. This patch
invents `mApplyOverridesVerbatim` flag to tell table wrapper frame don't
do any modification.

(2) When overriding main-size/cross-size for a table flex item, the size
is for *table wrapper frame*. To apply the size to inner table frame,
the table wrapper frame needs adjust the size by subtracting the area
occupied by caption, border, and padding (depending on the box-sizing).

This patch fixes the flex base resolution, and implements the logic for
(2).

We use nsLayoutUtils::GetStyleFrame() to dig into inner table's sizing
properties when resolving flex base size, so we can stop inheriting flex
properties to table wrapper frame in ua.css.

We also need to check style frame's StylePosition() in IsCrossSizeAuto()
so that non-'auto' sizes can prevent tables from being stretched in the
cross axis, just as happens with other flex items. Otherwise with this
patch, the table flex item with fixed height in
dom/flex/test/chrome/test_flex_item_rect.html will be wrongly stretched.

Differential Revision: https://phabricator.services.mozilla.com/D103437
2021-02-18 05:45:25 +00:00
Ting-Yu Lin
838ff0af9f Bug 1689504 Part 4 - Set zero margins for table frame in ComputeMargin(). r=emilio
The old code used to compute margins for table frame, and nuke it
afterwards. We can save time by moving the code that sets zero margins
into ComputeMargin() before looking into margin property.

Differential Revision: https://phabricator.services.mozilla.com/D104351
2021-02-08 10:28:19 +00:00
Ting-Yu Lin
5f5bebcbde Bug 1689504 Part 3 - Remove the specialized code to set a collapsed table's border & padding in SizeComputationInput. r=emilio
When creating a ReflowInput for inner table frame in
CreateReflowInputForInnerTable(), we pass the customize border & padding
if the table frame is border-collapsed.

Similarly, when creating a SizeComputationInput for inner table frame,
we should be able to pass border & padding rather than having a
specialized logic in SizeComputationInput::InitOffsets(). This patch
makes this a reality.

Differential Revision: https://phabricator.services.mozilla.com/D104350
2021-02-08 10:26:41 +00:00
Ting-Yu Lin
60ba2b527c Bug 1688690 Part 2 - Ensure nsTableFrame's computed margins are all zero. r=emilio
This patch makes the following changes:

1. Don't call ReflowInput::CalculateBlockSideMargins() for nsTableFrame
so that setting nsTableFrame's computed margins to zero in
SizeComputationInput::InitOffsets() remains true. Also, add an assertion
in nsTableFrame::Reflow() to ensure that.

2. Remove useless nsTableFrameWrapper::GetChildMargin() because the
method is used to get nsTableFrame's margins, which are now all zero.
Also, the old code that subtracts the block-axis margin from available
block-size doesn't really make sense.

3. Pass all-zero innerMargins to nsTableWrapperFrame::SetDesiredSize(),
and use table wrapper's content-box inline-size as the final desired
border-box inline-size rather than reconstructing it from caption and
inner table's inline-size & margin like the old code.

This inline-size already takes inner table's intrinsic size and
caption's inline-size into consideration in
nsTableWrapperFrame::ComputeAutoSize(), and is the final inline-size we
want to use.

In the next part, we are going to simplify all nsTableWrapperFrame's
methods that take inner frame's margin.

Differential Revision: https://phabricator.services.mozilla.com/D103065
2021-01-27 01:53:36 +00:00
Ting-Yu Lin
a43cae175a Bug 1686603 Part 2 - Add StyleSizeOverrides parameter to ReflowInput's constructor & co. to override data from style system data. r=dholbert
This patch adds the struct as a parameter to various functions.

The struct is cached in ReflowInput so that we don't need to pass it
down to the internal method where nsIFrame::ComputeSize() is called.

In the subsequent patches, we'll use it to revise the implementation of
flex container's flex base size resolution, and size overrides.

Differential Revision: https://phabricator.services.mozilla.com/D101793
2021-01-26 02:47:40 +00:00
Ting-Yu Lin
6e74b37f10 Bug 1686603 Part 1 - Remove unused ReflowInput::GetContainingBlockContentISize(). r=emilio
The last consumer was removed in
https://hg.mozilla.org/mozilla-central/rev/2775681c72a3

Differential Revision: https://phabricator.services.mozilla.com/D101791
2021-01-26 02:47:26 +00:00
Csoregi Natalia
0492d8333a Backed out 8 changesets (bug 1686603) for causing crashtest failures. CLOSED TREE
Backed out changeset 94b5d0986d27 (bug 1686603)
Backed out changeset e7edf6fcc41d (bug 1686603)
Backed out changeset 4c9271f07178 (bug 1686603)
Backed out changeset 7013b95266ae (bug 1686603)
Backed out changeset cf7a55638aef (bug 1686603)
Backed out changeset 7717a0f2a37b (bug 1686603)
Backed out changeset c82593b13a61 (bug 1686603)
Backed out changeset fd1d95a1e706 (bug 1686603)
2021-01-26 04:32:13 +02:00
Ting-Yu Lin
ffce5ed7d6 Bug 1686603 Part 2 - Add StyleSizeOverrides parameter to ReflowInput's constructor & co. to override data from style system data. r=dholbert
This patch adds the struct as a parameter to various functions.

The struct is cached in ReflowInput so that we don't need to pass it
down to the internal method where nsIFrame::ComputeSize() is called.

In the subsequent patches, we'll use it to revise the implementation of
flex container's flex base size resolution, and size overrides.

Differential Revision: https://phabricator.services.mozilla.com/D101793
2021-01-25 22:29:31 +00:00
Ting-Yu Lin
d980c9bbf8 Bug 1686603 Part 1 - Remove unused ReflowInput::GetContainingBlockContentISize(). r=emilio
The last consumer was removed in
https://hg.mozilla.org/mozilla-central/rev/2775681c72a3

Differential Revision: https://phabricator.services.mozilla.com/D101791
2021-01-25 22:03:11 +00:00
Ting-Yu Lin
e64aef319f Bug 1687795 - Rename the flag tracking whether block-size is set by aspect-ratio and inline-size, and improve comments. r=boris
* Follow other flags' naming by putting "Is" at the beginning.
* Delete the accessor because we just access other flags directly.

Differential Revision: https://phabricator.services.mozilla.com/D102480
2021-01-22 04:41:37 +00:00
Mihai Alexandru Michis
b6b2f1e5f4 Backed out 7 changesets (bug 1686603) for causing crashtest assertion failures.
CLOSED TREE

Backed out changeset 19cba7d34a7f (bug 1686603)
Backed out changeset 3a0d0155ea5e (bug 1686603)
Backed out changeset f1f672cdd0c6 (bug 1686603)
Backed out changeset 63020922e2fd (bug 1686603)
Backed out changeset 8766ce79ba5e (bug 1686603)
Backed out changeset 965dbe8de1e1 (bug 1686603)
Backed out changeset b1328ee45f43 (bug 1686603)
2021-01-21 09:21:12 +02:00
Ting-Yu Lin
d0c462cb81 Bug 1686603 Part 2 - Add StyleSizeOverrides parameter to ReflowInput's constructor & co. to override data from style system data. r=dholbert
This patch adds the struct as a parameter to various functions.

The struct is cached in ReflowInput so that we don't need to pass it
down to the internal method where nsIFrame::ComputeSize() is called.

In the subsequent patches, we'll use it to revise the implementation of
flex container's flex base size resolution, and size overrides.

Differential Revision: https://phabricator.services.mozilla.com/D101793
2021-01-21 04:17:59 +00:00
Ting-Yu Lin
35b078ace3 Bug 1686603 Part 1 - Remove unused ReflowInput::GetContainingBlockContentISize(). r=emilio
The last consumer was removed in
https://hg.mozilla.org/mozilla-central/rev/2775681c72a3

Differential Revision: https://phabricator.services.mozilla.com/D101791
2021-01-21 03:56:21 +00:00
Boris Chiou
8d1403f488 Bug 1646100 - Take LogicalSize type for containing block and boxing size adjustment for ComputeISizeValue. r=TYLin
We may use the block size to compute the inline size if there is a
non-auto finite aspect-ratio and definite block size, so we need more
information on the block axis. Therefore, we have to pass LogicalSize
for containing block and boxing size adjustment.

Differential Revision: https://phabricator.services.mozilla.com/D99289
2021-01-19 21:51:04 +00:00
Mats Palmgren
51ff79f7fa Bug 1686310 part 7 - Remove ReflowInput::mFrameType and associated code, which is now dead code. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101554
2021-01-14 03:23:40 +00:00
Mats Palmgren
50c2dfd847 Bug 1686310 part 6 - Remove NS_CSS_FRAME_TYPE_INLINE. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101553
2021-01-14 03:17:46 +00:00
Mats Palmgren
c1cb73505a Bug 1686310 part 5 - Remove NS_CSS_FRAME_TYPE_BLOCK. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101552
2021-01-14 03:46:03 +00:00
Mats Palmgren
f6311eea98 Bug 1686310 part 4 - Remove NS_CSS_FRAME_TYPE_ABSOLUTE. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101551
2021-01-14 03:23:58 +00:00
Mats Palmgren
e4563f969a Bug 1686310 part 3 - Replace NS_CSS_FRAME_TYPE_INTERNAL_TABLE with checks of the actual frame class, which is more correct. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101550
2021-01-14 03:47:42 +00:00
Mats Palmgren
cd4d90de10 Bug 1686310 part 2 - Replace NS_FRAME_IS_REPLACED* with a bit that caches the corresponding IsFrameOfType result. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101549
2021-01-14 03:15:31 +00:00
Mats Palmgren
c4f40b5e7a Bug 1686310 part 1 - Remove NS_CSS_FRAME_TYPE_FLOATING. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101548
2021-01-13 07:10:39 +00:00
Ting-Yu Lin
232fe1b5e5 Bug 1681849 Part 5 - Revise comments in ReflowInput.h. r=emilio
s/aContainingBlockSize/aCBSize/ for ComputeMinMaxValues() because that's
the parameter name used in definition.

Differential Revision: https://phabricator.services.mozilla.com/D99503
2020-12-12 22:13:43 +00:00
Ting-Yu Lin
fda5763ce6 Bug 1681849 Part 4 - Change computed min-size and max-size to store in LogicalSize. r=emilio
Remove unused ComputedMinWidth(), ComputedMaxWidth(),
ComputedMinHeight(), and ComputedMaxHeight() that return
writable-references.

Differential Revision: https://phabricator.services.mozilla.com/D99502
2020-12-12 22:12:49 +00:00
Ting-Yu Lin
74fb0b818e Bug 1681849 Part 3 - Change the computed inline-size and block-size to store in LogicalSize. r=emilio
Delete the comment describing that replaced frames should use their
intrinsic size if they have NS_UNCONSTRAINEDSIZE in mComputedWidth and
mComputedHeight, because we always have a definite size computed by
ComputeSizeWithIntrinsicDimensions().

Differential Revision: https://phabricator.services.mozilla.com/D99501
2020-12-14 19:28:21 +00:00
Ting-Yu Lin
d40b9823cd Bug 1681849 Part 2 - Reimplement SetComputedISize() and SetComputedBSize(). r=emilio
We can use them to implement SetComputedWidth() and SetComputedHeight()
rather than the other way around.

The logic involving whether to call InitResizeFlags() for viewport frame
can be simplified. That is, we don't want to call InitResizeFlags() for
viewport frame in SetComputedISize().

Remove unused ComputedWidth() and ComputedHeight() that return
writable-references.

Differential Revision: https://phabricator.services.mozilla.com/D99500
2020-12-12 22:09:54 +00:00
Ting-Yu Lin
5f0b63620e Bug 1681849 Part 1 - Change available block and inline size to store in LogicalSize. r=layout-reviewers,emilio
I put the private member section at the end of ReflowInput's
declarations. In later patches, other members are going to live there
when they're converted to logical coordinates.

Remove unused AvailableWidth() and AvailableHeight() that return
writable-references.

I didn't port the comment section verbatim, but revise them according to
the best of my knowledge.

Differential Revision: https://phabricator.services.mozilla.com/D99499
2020-12-12 14:56:47 +00:00
Boris Chiou
04d9986bd4 Bug 1651776 - aspect-ratio should be used for abspos when insets on the block axis are specified. r=TYLin
Based on https://github.com/w3c/csswg-drafts/issues/5151,
if the block size is auto, we still can use the insets to resolve the auto
block size on absoluate position elements, so we still can use this resolved
block size to calculate the inline size through aspect-ratio.

Differential Revision: https://phabricator.services.mozilla.com/D96277
2020-11-20 22:46:05 +00:00
Boris Chiou
d1895eafaa Bug 1651776 - Refine the terminology of writing modes when handling unconstrained block-size on out-of-flow boxes. r=TYLin
I'd like to handle aspect-ratio in those code block, so it'd be better
to always handle unconstrained block-size on the writing mode of the current
block. Besides, we move it as a method of ReflowInput.

Differential Revision: https://phabricator.services.mozilla.com/D97515
2020-11-20 22:38:38 +00:00
Ting-Yu Lin
bfa631581a Bug 1675128 Part 5 - Store ReflowInput::mComputedOffsets in LogicalMargin. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96129
2020-11-07 00:03:40 +00:00
Ting-Yu Lin
43e060b82e Bug 1675128 Part 4 - Remove ReflowInput::ComputedPhysicalOffsets() that returns a writable-reference. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96128
2020-11-07 00:03:38 +00:00
Ting-Yu Lin
1fb3ba8f3e Bug 1675128 Part 3 - Make ReflowInput::ComputeRelativeOffsets() return the offset in LogicalMargin. r=emilio
Also, convert its implementation to use more logical APIs.

Differential Revision: https://phabricator.services.mozilla.com/D96127
2020-11-06 22:20:00 +00:00
Ting-Yu Lin
98cfb55831 Bug 1675128 Part 2 - Add WritingMode argument to ReflowInput::ComputedLogicalOffsets(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96126
2020-11-06 09:12:00 +00:00
Ting-Yu Lin
7ffe5c7565 Bug 1675128 Part 1 - Add WritingMode argument to ReflowInput::SetComputedLogicalOffsets(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96125
2020-11-06 09:11:49 +00:00
Ting-Yu Lin
22b412b14b Bug 1674931 Part 7 - Remove WritingMode and LogicalMargin alias in SizeComputationInput. r=jfkthame
When referring to WritingMode and LogicalMargin, most of the existing
users in SizeComputationInput are using `mozilla::` prefix, so let's
remove the alias.

Differential Revision: https://phabricator.services.mozilla.com/D95667
2020-11-03 20:14:32 +00:00
Ting-Yu Lin
83bb7a6d59 Bug 1674931 Part 6 - Remove zero-argument ReflowInput::ComputedSizeWithMarginBorderPadding(). r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D95666
2020-11-03 20:02:50 +00:00
Ting-Yu Lin
a9354a2aef Bug 1674931 Part 5 - Remove zero-argument ReflowInput::ComputedSizeWithBorderPadding(). r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D95665
2020-11-03 20:07:18 +00:00
Ting-Yu Lin
655fc5b719 Bug 1674931 Part 4 - Remove zero-argument ReflowInput::ComputedSizeWithPadding(). r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D95664
2020-11-03 20:04:40 +00:00
Ting-Yu Lin
15775521ac Bug 1674931 Part 3 - Add WritingMode argument to SizeComputationInput::ComputedLogicalPadding(), and adapt callers. r=jfkthame
This patch is similar to Part 1, but for ComputedLogicalPadding().

Differential Revision: https://phabricator.services.mozilla.com/D95663
2020-11-03 19:56:03 +00:00
Ting-Yu Lin
1c052b9ff3 Bug 1674931 Part 2 - Add WritingMode argument to SizeComputationInput::ComputedLogicalBorderPadding(), and adapt callers. r=jfkthame
This patch is similar to Part 1, but for ComputedLogicalBorderPadding().

Differential Revision: https://phabricator.services.mozilla.com/D95662
2020-11-03 19:57:40 +00:00
Ting-Yu Lin
9910d9e651 Bug 1674931 Part 1 - Add WritingMode argument to SizeComputationInput::ComputedLogicalMargin(), and adapt callers. r=jfkthame
It's straightforward to determine which writing mode is required to pass
to ComputedLogicalMargin() by looking at any subsequent method called on
the margin.

For example, if we see

```
ComputedLogicalMargin().BStartEnd(wm);
```

the writing mode needed to pass to `ComputedLogicalMargin()` is `wm`.

Differential Revision: https://phabricator.services.mozilla.com/D95661
2020-11-03 19:44:58 +00:00
Ting-Yu Lin
06aecc5c9f Bug 1674450 Part 8 - Remove SizeComputationInput's one-argument methods to set margin, border/padding, and padding. r=layout-reviewers,jfkthame
The two-argument versions are clearer and easier to use because they
work for any pair of writing mode and logical margin.

Differential Revision: https://phabricator.services.mozilla.com/D95371
2020-10-31 14:45:02 +00:00
Ting-Yu Lin
1531f4b093 Bug 1674450 Part 7 - Store SizeComputationInput's computed margin, border/padding, and padding in logical coordinates. r=layout-reviewers,jfkthame
The one-argument SetComputedLogicalMargin(),
SetComputedLogicalBorderPadding(), and SetComputedLogicalPadding() are
not changed because the next part are going to delete them.

Note that I'm deliberately not making ComputedLogicalMargin() and others
to return `const LogicalMargin&` because the compilers can use RVO to
eliminate unnecessary copy. If we'd like to convert them to accept all
writing mode like `nsIFrame::GetLogicalUsedMargin(WritingMode)` so that
the caller don't need to call `ConvertTo`, they can't return a const
reference anyway.

Differential Revision: https://phabricator.services.mozilla.com/D95370
2020-10-31 14:42:04 +00:00
Ting-Yu Lin
8c17380539 Bug 1674450 Part 6 - Convert ReflowInput::Init()'s optional border and padding parameters to Maybe<LogicalMargin>. r=layout-reviewers,jfkthame
Similar to the optional aContainingBlockSize parameter, both border and
padding should use logical coordinates in ReflowInput::mFrame's writing
mode.

Table frames that need to override border and padding can be simplified a bit.
However, DR_init_constraints_cookie and DR_init_offsets_cookie become more
complex, but they're only for debugging. I'm not planning to update their
internal APIs.

Differential Revision: https://phabricator.services.mozilla.com/D95369
2020-10-31 14:39:23 +00:00
Ting-Yu Lin
acabe0a427 Bug 1674450 Part 5 - Remove SizeComputationInput::ComputedPhysicalBorderPadding() that returns a writable-reference. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D95368
2020-10-31 14:30:11 +00:00
Ting-Yu Lin
d151cd5349 Bug 1674450 Part 4 - Remove SizeComputationInput::ComputedPhysicalPadding() that returns a writable-reference. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D95367
2020-10-31 14:29:50 +00:00