Commit graph

42 commits

Author SHA1 Message Date
Martin Robinson
89944bd330
layout: Improve layout of table captions (#32695)
- Instead of treating captions as a `BlockFormattingContext`, treat it as
  a `NonReplacedFormattingContext`, which allows reusing flow layout for
  captions -- fixing some issues with sizing.
- Pass in the proper size of the containing block when laying out,
  fixing margin calculation.
- Follow the unspecified rules about how various size properties on
  captions affect their size.
- Improve linebreaking around atomics, which is tested by
  caption-related tests. This fixes intrinsic size calculation regarding
  soft wrap opportunities around atomic and also makes the code making
  these actual soft wrap opportunities a bit better.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-07-08 12:58:38 +00:00
Martin Robinson
4b63043c6a
clippy: Fix warnings in shared and config, fonts, layout, and layout_2020 components (#32674) 2024-07-04 14:18:58 +00:00
Martin Robinson
959ffad99a
layout: Add support for table captions (#32657)
This adds initial support for table captions. To do this, the idea of
the table wrapper becomes a bit more concrete. Even so, the wrapper is
still reponsible for allocating space for the grid's border and padding,
as those properties are specified on the wrapper and not grid in CSS.

In order to account for this weirdness of HTML/CSS captions and grid are
now laid out and placed with a negative offset in the table wrapper
content rect.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-07-03 18:24:19 +00:00
Martin Robinson
adc0fc984d
layout: Make geom.rs logical geoemetry types more ergonomic (#32633)
Make using the logical geometry types more ergonomic by having them all
implement `Copy` (at most 4 64-bit numbers), similar to what `euclid`
does. In addition add an implementation of `Neg` for `LogicalVec` and
`LogicalSides` as it will be used in upcoming table implementation code.
2024-06-28 08:20:50 +00:00
Martin Robinson
e16291f14e
layout: Enable parallel layout for tables (#32477)
This simply wraps row and column-based layout of table sells in a
`par_iter()` unconditionally enabling parallel layout for tables. In the
future we can choose to adjust the conditions under which layout is done
in parallel.
2024-06-26 16:33:48 +00:00
atbrakhi
26c585a0c5
use app unit in box_fragement (#32349) 2024-06-21 14:54:21 +00:00
Oriol Brufau
b4e41d8727
Fix table track offsets when there is visibility: collapse (#32469)
Each non-collapsed track used to increase the offset by the subsequent
border spacing. Now they will take care of their preceding spacing
instead.

This way, if a cell spans two rows, and the second is collapsed, the
cell won't be forced to be at least as tall as the border spacing.
This matches Gecko and Blink (WebKit lacks `visibility: collapse`).

This makes visibility-collapse-border-spacing-001.html fail because we
generate outlines in a different way than Blink. Gecko also fails it
in a similar (but different) way.
2024-06-11 18:59:09 +00:00
Oriol Brufau
d10d01757d
Don't shrink table columns when handling cells with greater spanning (#32458)
For example:
```html
<table border="1">
  <tr>  <td></td>  <td></td>  </tr>
  <tr>  <td colspan="2"></td>  </tr>
</table>
```
We should initially size the columns according to the cells in the first
row since they have a span of 1. Then we handle the cell in the second
row with a span of 2, this should be able to increase the size of the
columns, but never decrease them.
2024-06-07 16:37:12 +00:00
Oriol Brufau
5d5ac4ec64
Implement 'visibility: collapse' on table parts (#32333)
https://drafts.csswg.org/css2/#dynamic-effects

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-05-21 18:02:53 +00:00
Oriol Brufau
5b13604bd8
Implement 'empty-cells' for layout 2020 (#32331)
https://drafts.csswg.org/css-tables/#empty-cell-rendering

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-05-21 11:08:08 +00:00
Martin Robinson
0cd9c3f2c4
tables: Add a naive implementation of border-collapse (#32309)
This change adds a very simple implementation of `border-collapse` for
tables. No harmonization or merging is done at all for borders. Instead,
the largest border for every continuous border sets the size. Instead of
merging different border styles, they are squashed to half size -- which
isn't great, but ensures appropriate positioning.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-05-18 08:24:23 +00:00
komuhangi
0da2508e4d
clippy: Allow too_many_arguments for all functions (#31962)
This is the start of preventing this in the future.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-04-01 14:53:33 +00:00
Martin Robinson
b8c82c1ab0
layout: Allow transforming inline replaced elements (#31833)
This requires passing through information about whether or not the
element in question is replaced when checking to see if it's
transformable and transitively all functions that make decisions about
containing blocks. A new FragmentFlag is added to help track this -- it
will be set on both the replaced items BoxFragment container as well as
the Fragment for the replaced item itself.

Fixes #31806.
2024-03-27 11:57:27 +00:00
Oriol Brufau
d16f259e1d
Fix table with rows but no column (#31862)
* Fix table with rows but no column

We weren't generating any fragment for the rows, which meant that JS
APIs like clientWidth would be 0, and also outlines weren't painted.

This aligns Servo with Blink and WebKit. Gecko is broken, it distributes
twice the table height among the rows.

* Feedback

* Avoid conflict with #31874
2024-03-26 12:36:43 +00:00
Oriol Brufau
dbe3cb8a3c
Don't update row baseline if cell is empty (#31831)
Gecko, Blink and WebKit agree that the if a row only has empty cells,
its baseline should be at the bottom, not at the top.

There isn't interoperability when the cells are just empty-ish, so this
patch takes the simplest approach, aligning with Blink: any out-of-flow
or in-flow content other than collapsed whitespace counts as not empty.
2024-03-25 09:39:02 +00:00
atbrakhi
95e69fe4ff
layout: use Au in BoxFragment (#31794)
* use au in BoxFragement

* review fix
2024-03-22 04:30:39 +00:00
RustAndMetal
f6a975fc58
clippy: Fix several warnings (#31710)
Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
2024-03-18 08:33:43 +00:00
Oriol Brufau
82128d3838
Don't null out the baselines of anonymous tables (#31704) 2024-03-15 20:46:41 +00:00
Martin Robinson
78fe461ff2
layout: Properly parent table-row and table-row-group (#31619)
Put table cell content fragments into a hieararchy of fragments that
include their table row and table row group fragments. This ensures that
things like relative positioning and transforms set on rows and row
groups properly affect cells and cell content.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-03-14 10:33:42 +00:00
eri
b03411f567
clippy: Fix warnings in components/layout_2020 (#31611)
* clippy: fix warnings in components/layout_2020

* fix: review comments
2024-03-11 14:24:33 +00:00
Oriol Brufau
fddc7a1390
Align table cell measures in the block axis to Gecko/Blink/WebKit (#31596) 2024-03-09 12:59:57 +00:00
Martin Robinson
7e8a1503ba
layout: Add documentation about table layout (#31535)
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-03-08 12:57:23 +00:00
Oriol Brufau
6b5a5147f8
Obey table cell's box-sizing (#31536)
Instead of assuming `box-sizing: content-box`.
2024-03-08 12:07:42 +00:00
Oriol Brufau
dea416eec9
Fix the measures of a table cell (#31513)
The spec doesn't make much sense, this seems to match Gecko and Blink.
2024-03-06 12:42:06 +00:00
Oriol Brufau
abda22ed63
Fix intrinsic sizing of tables (#31506)
* Fix intrinsic sizing of tables

* Feedback
2024-03-05 20:38:30 +00:00
Oriol Brufau
e76770202c
Fix column and row measures (#31480)
The min-content size of a table track was >= the max-content size. So
- For the min-content size of a column, now we just use min-inline-size,
  ignoring inline-size and max-inline-size. This matches Gecko, Blink
  and WebKit.
- For the max-content size of a column, we keep matching Gecko.
  Note that Blink and WebKit are different, they ignore max-inline-size.
- For both the min-content and max-content sizes of a row, now we just
  use block-size. This matches Gecko, Blink and WebKit.

Also, if the computed value contains percentages, now we treat it as
the initial value, instead of resolving percentages against zero.
This matches Gecko and Blink, but not WebKit for rows.
2024-03-04 08:10:14 +00:00
Oriol Brufau
50fdb82246
Fix size of tables in flow layout (#31455)
* Fix size of tables in flow layout

The contents of a table can make it bigger than what we would expect
from its 'width', 'min-width', 'height' and ' min-height' properties.
Also, 'width: auto' doesn't stretch it to fill the containing block.

We had to refactor the resolution of margins to happen after layout,
otherwise 'auto' margins wouldn't align correctly.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Feedback

* Consistently use `containing_block_for_table` in table layout

* Update test result

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-03-02 01:39:41 +00:00
Oriol Brufau
5f399139ae
Fix percentages in CSS tables (#31454)
100% is stored as Percent(1.), not as percent(100.)

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-02-29 15:21:14 +00:00
Martin Robinson
127aa657c2
layout: Add initial support for row height distribution (#31421)
This change adds a version of row height distribution that follows the
distribtuion algorithm used for tables in Blink's LayoutNG. This is just
an intermediate step toward implementing a distribution algorithm for
both rows and columns more similar to Layout NG.

The CSS Table 3 specification is often wrong with regard to web
compatability, which is why we have abandoned it in favor of the Layout
NG algorithm for row height distribution.  this work.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-02-29 12:12:54 +00:00
Oriol Brufau
b07505417e
Fix percentages in the padding of a table-cell (#31430) 2024-02-27 13:28:23 +00:00
Martin Robinson
02ae1f448e
layout: Add support for table rows, columns, rowgroups and colgroups (#31341)
This adds support for table rows, columns, rowgroups and colgroups.
There are few additions here:

1. The createion of fragments, which allows script queries and hit
   testing to work properly. These fragments are empty as all cells are
   still direct descendants of the table fragment.
2. Properly handling size information from tracks and track groups as
   well as frustrating rules about reordering rowgroups.
3. Painting a background seemlessly across track groups and groups. This
   is a thing that isn't done in legacy layout (nor WebKit)!

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-02-20 13:22:02 +00:00
atbrakhi
74c07db56c
make ContainingBlock use Au for inline_size and block_size (#31370) 2024-02-20 09:14:44 +00:00
Oriol Brufau
07c7096246
Include border-spacing gutters in compute_inline_content_sizes (#31337)
This way, if the table is inside an intrinsically sized container, like
a float or inline-block, the table won't overflow it (in basic cases).
2024-02-13 09:00:02 +00:00
atbrakhi
8ba251c95f
layout: make padding and border use Au in pbm (#31289)
* use au for padding and border in pbm

* review fix
2024-02-12 22:49:50 +00:00
Martin Robinson
35fb95ca85
layout: Start work on table row height and vertical-align (#31246)
This implements a very naive row height allocation approach. It has just
enough to implement `vertical-align` in table cells. Rowspanned cells
get enough space for their content, with the extra space necessary being
allocated to the last row. There's still a lot missing here, including
proper distribution of row height to rowspanned cells.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-02-10 08:03:01 +00:00
Martin Robinson
7f13316f24
layout: Collect both start and end baselines for fragments (#31230)
This change starts collecting the starting baseline set for fragments,
which is necessary for some layout modes (flex and tables, namely) as
well as being important for the implementation of `align-items`. In
addition, it converts baseline measurement to use `Au` everywhere.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-02-05 18:06:05 +00:00
Oriol Brufau
33127e0e60
Lint layout_2020 with clippy (#31196)
cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
2024-01-26 23:15:03 +00:00
Martin Robinson
1876b49251
layout: Add support for table border-spacing (#31166)
This adds support for table `border-spacing` property. Note that we do
not yet support the collapsed border model.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-01-26 16:07:08 +00:00
Martin Robinson
d68c7e7881
layout: Implement computation of table column widths (#31165)
* layout: Implement computation of table column widths

This change implements the various steps of table column width
computation, ignoring features that don't exist yet (such as separated
borders, column elements, and colgroups).

Co-authored-by: Oriol Brufau <obrufau@igalia.com>

* Fix an issue with the assignment of column percent width

* Respond to review comments

---------

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-01-25 23:13:13 +00:00
Oriol Brufau
50f56affe3
Lint layout_2020 with clippy (#31169)
cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
2024-01-25 09:03:31 +00:00
atbrakhi
45af1198aa
Layout: use Au in ContentSizes (#31135)
* use app_units

* resolve errors in table layout

* fmt

* add back current_line.min_content

* update expectation

* review fix
2024-01-23 10:18:39 +00:00
Martin Robinson
fc31e69f79
layout: Add *very* basic support for table layout (#31121)
* layout: Add *very* basic support for table layout

This is the first step to proper table layout. It implements a naive
layout algorithm, notably only taking into account the preferred widths
of the first table row. Still, it causes some float tests to start
passing, so turn on the `layout.tables.enabled` preference for those
directories.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>

* Address review comments

* Fix a crash with rowspan=0

* Turn on pref and update results for `/css/css-tables` and `/css/CSS2/tables`

---------

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-01-19 13:20:20 +00:00