Commit graph

310 commits

Author SHA1 Message Date
Ting-Yu Lin
261c24ebe5 Bug 1795196 Part 1 - Remove ComputedISize() and ComputedBSize() that return writable references. r=emilio
Users of these two getters should use setters such as SetComputedISize() instead.

Differential Revision: https://phabricator.services.mozilla.com/D159352
2022-10-18 00:26:19 +00:00
Emilio Cobos Álvarez
d5836162f2 Bug 1793700 - Improve widget-imposed min size handling. r=TYLin,layout-reviewers,dshin
Make it work as a min-size everywhere rather than only handling it in
nsIFrame::ComputeSize.

This is more similar to what XUL code does. In particular, it makes
makes it work for elements that don't have a definite size in
ComputeSize (like flex containers).

For web-exposed widgets this only matters for <input type=color> and
<input type=range>, which are the only exposed widgets that return a
minimum size that return a minimum size. This patch makes the minimum
size honored for `<input type="color" style="height: auto">`. Add a test
for that (though we might want to change it to match other browsers).

Without this fix, min/max/close buttons on Linux are zero-height with
flex emulation, because we fail to account for their minimum
widget-imposed size.

This allows us to remove the special case in nsFlexContainerFrame too,
since that should be handled by ReflowInput correctly now.

Differential Revision: https://phabricator.services.mozilla.com/D158612
2022-10-05 19:34:03 +00:00
Martin Robinson
3b0ff9fae9 Bug 1791760 - Move GetContainSizeAxes to nsIFrame r=emilio
This will allow this function to eventually return an appropriate value
depending on whether or not content is skipped via `content-visibility:
auto`. This change also starts looking directly at whether
content-visibility is skipping content or not, which should make it
compatible with a future `content-visibility: auto` implementation.

Differential Revision: https://phabricator.services.mozilla.com/D157831
2022-09-22 12:11:09 +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
Emilio Cobos Álvarez
352d47e585 Bug 1786214 - Remove UseAutoBSize flag. r=TYLin
Use a more precise, grid-specific flag to avoid applying grid stretching
etc, and pass an unconstrained block size instead for baseline alignment
measuring, which will cause us to interpret relative sizes as auto.

This shouldn't cause any behavior change, but is a prerequisite
necessary for bug 1609403 (where we don't always want definite sizes
being ignored in measuring reflows for baseline alignment). It's also a
bit clearer, IMO.

Differential Revision: https://phabricator.services.mozilla.com/D155178
2022-08-23 09:17:38 +00:00
Ting-Yu Lin
8839aff8b8 Bug 1463977 Part 3 - Ensure {I|B}Size set in SetComputed{I|B}Size is non-negative, and downgrade the assertion. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D155322
2022-08-23 05:12:00 +00:00
Ting-Yu Lin
95fdc2379b Bug 1463977 Part 2 - Call SetComputedBSizeWithoutResettingResizeFlags() in SetComputedBSize(). r=dholbert
This is a preparation for the next part.

Differential Revision: https://phabricator.services.mozilla.com/D155321
2022-08-23 05:11:59 +00:00
Ting-Yu Lin
611db0b345 Bug 1463977 Part 1 - Mark SizeComputationInput::mFrame const, and assert its validity. r=dholbert
mFrame is public and used throughout the layout, but it shouldn't be modified
post constructor.

Differential Revision: https://phabricator.services.mozilla.com/D155320
2022-08-23 05:11:59 +00:00
Ting-Yu Lin
e4b537b53a Bug 1780264 Part 3 - Remove ReflowInput::mStyleText. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D152204
2022-07-20 00:48:22 +00:00
Ting-Yu Lin
efdf31a619 Bug 1780264 Part 2 - Remove ReflowInput::mStylePadding. r=emilio
While I'm here, rename the local variable `styleMargin` to `margin` to make the
naming consistent with the `padding` naming in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D152203
2022-07-20 00:48:22 +00:00
Ting-Yu Lin
991f16122f Bug 1780264 Part 1 - Remove ReflowInput::mStyleVisibility. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D152202
2022-07-20 00:48:21 +00:00
Ting-Yu Lin
291489917d Bug 1778178 - Convert ReflowInput's available size write-accessors to setters. r=layout-reviewers,jfkthame
This patch rewrites some callers, but they shouldn't change the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D151042
2022-07-06 17:39:57 +00:00
Emilio Cobos Álvarez
9c190fff4b Bug 1771564 - Constify ComputedStyle usage in nsComputedDOMStyle. r=dholbert
None of the consumer need to mutate styles, and this saves some ugly
const_casting on the next patch.

Doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D147555
2022-05-28 01:04:24 +00:00
David Shin
d1cd6ae125 Bug 1765668: Fix border offset when the writing-mode of an abspos element's containing block differs from its absolute containing block. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D146095
2022-05-18 18:09:33 +00:00
Boris Chiou
035220bf4c Bug 1760658 - Part 1: Apply automatic content-based minimum on flex container. r=emilio
Basides, factor out the utility function to AspectRatio so everyone can
use it.

Differential Revision: https://phabricator.services.mozilla.com/D144891
2022-05-02 20:06:32 +00:00
Daniel Holbert
e0100e2b76 Bug 1765632: Coalesce two variables into one Maybe<> variable, in ReflowInput::CalculateHypotheticalPosition. r=dshin
This patch shouldn't change behavior; it's just refactoring/simplifying
existing code, without changing the logic.

Differential Revision: https://phabricator.services.mozilla.com/D144221
2022-04-20 22:35:20 +00:00
David Shin
ec93876623 Bug 1755565 - Implement contain: inline-size. r=emilio,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D143501
2022-04-19 17:44:16 +00:00
Ting-Yu Lin
b48196dcda Bug 1758018 Part 2 - Add helpers testing only "position:relative", and adapt them at some callsites. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D140274
2022-03-04 03:02:01 +00:00
Ting-Yu Lin
7e0c39f9b1 Bug 1758018 Part 1 - Rename the helpers testing "position:relative" or "position:sticky". r=emilio
`nsIFrame::IsRelativelyPositioned()` tests "position:relative" or
"position:sticky", but its naming is misleading until you've dug into the
underlying helper `nsStyleDisplay::IsRelativelyPositionedStyle()`.

Differential Revision: https://phabricator.services.mozilla.com/D140273
2022-03-04 03:02:00 +00:00
Ting-Yu Lin
017c34b54e Bug 1756008 Part 5 - Manual fix for comments and variables regarding BlockReflowState. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D139440
2022-02-23 21:22:44 +00:00
Ting-Yu Lin
7ec49f975f Bug 1735251 - Set ReflowInput::mComputeSize in one operation. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D128150
2021-10-12 17:51:11 +00:00
Ting-Yu Lin
8492d801e8 Bug 1731653 - Record padding change in a frame bit, and use it to detect inline resize. r=dholbert
We store this new bit in nsIFrame instead of in ReflowInput to record a
change to padding (inspired by the mHasBSizeChange bit). That is because
we may construct a ReflowInput more than one time before reflowing the
frame. The first construction of ReflowInput (in
SizeComputationInput::InitOffsets) will update
nsIFrame::UsedPaddingProperty() using the latest style data, so
we *cannot* determine the padding change in any of the subsequent
construction of ReflowInput.

dynamic-change-inline-size-001.html is the scenario fixed by
bug 1307853. We've already passed this test without this patch.

dynamic-change-inline-size-002.html is equivalent to 001.html except
it's written with "box-sizing:content".
dynamic-change-inline-size-003.html is adapted from testcase 2 in bug
1729122 comment 4. Both tests pass after this patch.

Differential Revision: https://phabricator.services.mozilla.com/D126422
2021-09-28 20:59:38 +00:00
Daniel Holbert
b7cb22a3af Bug 1731359 part 1: Change the "NormalPositionProperty" frame property to use the "small value" method of storage. r=emilio
This frame property's type is small enough to fit directly in the property
table's 64-byte slot; so, this patch makes us store the data directly there
(rather than allocating it externally and storing a pointer in the table).

This patch shouldn't impact behavior at all.

Differential Revision: https://phabricator.services.mozilla.com/D126031
2021-09-20 22:26:14 +00:00
Ting-Yu Lin
736fbaef17 Bug 1725973 Part 2 - Mark flex items with percentage flex-basis in column flex container as depending on CB's block-size. r=dholbert
If so, `dependsOnCBBSize` will be set to true, and later in
`ReflowInput::InitResizeFlags()` we will add
`NS_FRAME_CONTAINS_RELATIVE_BSIZE` to the appropriate ancestor.

Sorted the #include statements in ReflowInput.cpp because I added
nsFlexContainerFrame.h.

Differential Revision: https://phabricator.services.mozilla.com/D123703
2021-08-26 22:43:10 +00:00
Emilio Cobos Álvarez
a4e7c9e510 Bug 1722945 - Support break-inside: avoid-{page,column}. r=TYLin
break-before/after: page|column seem harder because you need to deal
with nested breaks, I think, but this should be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D121206
2021-08-03 17:56:58 +00:00
Noemi Erli
89a565ea85 Backed out changeset 67c33ba5566e (bug 1722945) for causing bustage in nsContainerFrame.cpp 2021-08-03 20:35:10 +03:00
Emilio Cobos Álvarez
3d1b4f252f Bug 1722945 - Support break-inside: avoid-{page,column}. r=TYLin
break-before/after: page|column seem harder because you need to deal
with nested breaks, I think, but this should be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D121206
2021-08-03 13:59:47 +00:00
Ting-Yu Lin
8b74ff00e0 Bug 1716212 Part 2 - Carry nsComboboxControlFrame's line-height to nsComboboxDisplayFrame when it has auto block-size. r=emilio
The issue is that combobox display may contain some non-Latin characters
that need extra block-size to display than the one line-height
calculate by using a Latin font spec in combobox control's style.

Before this patch, when a combobox control has unconstrained block-size,
we set combobox display's block-size to combobox control's one
line-height in Reflow(), which is intended to properly initialize
`BlockReflowInput::mMinLineHeight` since combobox display has
`line-height:-moz-block-height`. However, this simply prevents the
combobox display from choosing a larger block-size after the reflow. See
bug 1716212 comment 11 for an analysis.

This patch fixes the issue by carrying combox control's computed line
height to combobox display so that its computed block-size is still
unconstrained so that it can accommodate taller characters in the
display text.

After this patch, <select><option> containing non-Latin characters
should have the same block-size as <button>, and no characters should be
clipped. Modified test_unstyled_control_height.html to test this.

Differential Revision: https://phabricator.services.mozilla.com/D120877
2021-07-28 18:41:19 +00:00
Ting-Yu Lin
97b5489509 Bug 1716212 Part 1 - Rename CalcLineHeight to GetLineHeight, and cache used line height in ReflowInput. r=emilio
This patch introduces `mLineHeight`, and it opens the possibility to
override it in Part 2.

Differential Revision: https://phabricator.services.mozilla.com/D120876
2021-07-28 18:41:18 +00:00
Boris Chiou
df3e4e4f9e Bug 1679794 - Downgrade MOZ_ASSERT to NS_WARNING_ASSERTION for the resolved non-auto-insets block size on abs-positioned elements. r=dholbert
This is an known issue for nscoord because we don't have a better way to
distinguish between the unresolved size and the resolved super large size.
Using NS_WARNING_ASSERTION is the current acceptable way.

Differential Revision: https://phabricator.services.mozilla.com/D119470
2021-07-21 00:07:27 +00:00
Xidorn Quan
bda78e780f Bug 1714457 - Make predefined symbolic counter styles not overridable. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D116938
2021-06-07 11:39:31 +00:00
Butkovits Atila
9a67025305 Backed out changeset 1a6ee358d131 (bug 1714457) for causing failures at redefine-attr-mapping.html. CLOSED TREE 2021-06-07 00:31:38 +03:00
Xidorn Quan
ecf0830a40 Bug 1714457 - Make predefined symbolic counter styles not overridable. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D116938
2021-06-06 12:55:07 +00:00
Ting-Yu Lin
91b3a53395 Bug 1709491 Part 1 - Add SizeComputationInput::ComputedLogicalBorder(), and adapt callers. r=dholbert
The helper is going to be used in a later part.

I don't add the physical version ComputedPhysicalBorder() deliberately
because I don't want to promote the usage of physical coordinate.

Differential Revision: https://phabricator.services.mozilla.com/D114544
2021-05-12 06:32:40 +00:00
Boris Chiou
6c1d6cb52f Bug 1699263 - Fix the issue that we unconditionally use autoBSize when we specify the block size and aspect-ratio. r=TYLin
Also, rewrite CalculateAbsoluteSizeWithResolvedAutoBlockSize(). Move
all the aspect-ratio checks into this function, so make the caller simplier.

Differential Revision: https://phabricator.services.mozilla.com/D109568
2021-04-05 19:33:05 +00:00
Mats Palmgren
55bc8b2992 Bug 1699605 - Add missing !GetPrevInFlow() check. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D109220
2021-03-20 22:40:45 +00:00
Sean Feng
4150fa8a93 Bug 1669734 - For abspos frames, resolve intrinsic BSize keywords to the actual intrinsic BSize, instead of stretching to fill the available space r=emilio,dholbert
This patch creates a new behavior for absolute positioned frames such
that if they have intrinsic size keywords (-moz-fit-content, min-content,
max-content) for their BSize and the margins are auto, instead of taking
as much space as possible, use the actual intrinsic BSize as the BSize.

Users can still use `auto` keyword to make it to fill the available
space.

This change is to align with the spec text for these intrinsic sizing
keywords at https://drafts.csswg.org/css-sizing/#valdef-width-min-content,
per the changes resolved on in https://github.com/w3c/csswg-drafts/issues/3973

This patch modifies the centering.html WPT, to expand the test
cases to test the centering functionalities for not only explicitly specified
height and width, but also the default size and width, in this case the
intrinsic sizing keywords.

Differential Revision: https://phabricator.services.mozilla.com/D106497
2021-03-15 15:45:18 +00:00
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
Boris Chiou
f448377232 Bug 1682032 - aspect-ratio should be applied for auto block-size by default. r=emilio
Based on the discussion in
https://github.com/w3c/csswg-drafts/issues/5721#issuecomment-781702159,
the default ratio-dependent axis is block axis (though the spec issue is
for replaced elements, but I think the behavior should be consistent).
So we should apply aspect-ratio not matter what the inline size is (e.g.
nscoord_MAX, auto or other values).

In the test case, the min-block-size is 1073741823, and its transferred
min-inline-size is also 1073741823, so we get a 1073741823 (i.e. nscoord_MAX)
preferred inline size (i.e. result.ISize(aWM) == NS_UNCONSTRAINEDSIZE).
However, we still have to apply aspect-ratio because the style of block-size is
auto, and so mFlags.mBSizeIsSetByAspectRatio should be set unconditionally here.

I still keep this assertion because it helps me catch this potential
issue. (Just reword it anyway.)

Differential Revision: https://phabricator.services.mozilla.com/D107764
2021-03-10 23:20:49 +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
Mats Palmgren
f01d9a4402 Bug 1694729 - Fix sizing issues for display:table-* on <fieldset> and replaced elements. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D106656
2021-03-01 15:37:00 +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
Tim Nguyen
159428759d Bug 1590884 - Move XUL accesskey handling to DOM and remove nsXULLabelFrame. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D106233
2021-02-24 14:46:28 +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
Emilio Cobos Álvarez
bebec20c7a Bug 1690706 - Move caption-side outside of mako. r=TYLin
Make it an enum class, etc.

Differential Revision: https://phabricator.services.mozilla.com/D103978
2021-02-07 12:33:45 +00:00
Mats Palmgren
f6ef0ea044 Bug 1683748 - Support Grid/Flex/Table/Column layout for the rendered legend of a fieldset. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101555
2021-01-30 13:47:10 +00:00
Dorel Luca
689a7c82d0 Backed out changeset 2d16e9e90401 (bug 1683748) for WPT failures in html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/legend-grid-flex-multicol.html. CLOSED TREE 2021-01-29 22:07:09 +02:00
Mats Palmgren
ca5460eda2 Bug 1683748 - Support Grid/Flex/Table/Column layout for the rendered legend of a fieldset. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D101555
2021-01-29 15:45:42 +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