Commit graph

61 commits

Author SHA1 Message Date
Oriol Brufau
50eb69a7e0
Allow creating a ContentSizes from Au (#33208)
No change in behavior, it just simplies some code a little bit.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-08-27 15:22:47 +00:00
Simon Wülker
3b8c638a84
Fix floating point errors in table layout (#33098)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-08-21 10:41:43 +00:00
Martin Robinson
0d94a8acd2
layout: Prepare for bidi by guarding all access to writing-mode (#33082)
We want to selectively enable right-to-left writing modes per layout
context. This change makes that possible by allowing access to
`writing-mode` though an interface that always returns the default
horizontal top-to-bottom (implicitly left-to-right) writing mode.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-08-16 11:38:04 +00:00
Martin Robinson
d941d2fd67
layout: Convert the FragmentTree to physical geometry (#33030)
This converts all geometry in the FragmentTree into physical geometry,
doing conversions ahead of time instead of when traversing the fragment
tree. This is necessary to properly implement BiDi in Servo as we need
to know what side borders are on in mixed RTL and LTR contexts.

In addition, fragments are laid out in a particular context and only
that context knows its writing mode. There were issues where were using
one writing mode to lay out and another to convert to phyisical
coordinates. This isn't an issue now since we only use the default
writing mode, but starts to be an issue with BiDi text.

Closes #25564.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-08-14 12:22:06 +00:00
Martin Robinson
77e9e3deba
fonts: Add support for generic font families and font size configuration (#32673)
This adds support for generic font families in Servo and allows for
configuration of them as well as their default font sizes. One
interesting fix here is that now monospace default to 13px, like it does
in other browsers.

In addition to that, this exposes a new interface in Stylo which allows
setting a default style. This is quite useful for fonts, but also for
other kinds of default style settings -- like text zoom.

Fixes #8371.
Fixes #14773.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-07-08 17:17:48 +00:00
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
6f414df867
Fix and unify 'span' attribute for table columns (#32467)
The attribute was only taken into account on columns that are immediate
children of tables, and on column groups. It was ignored on columns
within column groups.

This patch moves the logic into a helper function that is then called
from the three consumers.
2024-06-10 09:26:46 +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
Oriol Brufau
ecabdc2583
Don't trim leading whitespace of anonymous table cells (#31803)
A sequence of whitespace shouldn't generate an anonymous table row/cell,
but we can't just throw away the leading whitespace, because afterwards
we may encounter some other content, and then the leading whitespace
should appear in the cell (noticeable with e.g. `white-space: pre`).
2024-03-21 11:48:39 +00:00
Azhar Ismagulova
d0fcbb0898
rustdoc: fix warnings in components/layout_2020/table (#31738)
* fix: fixed rustdoc warnings caused by private intra-doc links

* fix: fixed private link warning by allowing private intra doc links
2024-03-19 14:51:28 +00:00
Aarya Khandelwal
2a02f94d76
rustdoc: Correct unresolved link to `handle_cell. (#31708) 2024-03-19 08:41:18 +00:00
Ekta Siwach
03c11f7907
rustdoc: Fix some typos in components/layout_2020/table/mod.rs (#31644)
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-03-19 08:23:14 +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
1f23ec2b27
layout: Do not inherit node and fragment flags in anonymous boxes (#31586)
This doesn't really have observable behavior right now, as much as I
tried to trigger some kind of bug. On the other hand, it's just wrong
and is very obvious when you dump the Fragment tree. If you create a
`display: table-cell` that is a child of the `<body>` all parts of the
anonymous table are flagged as if they are the `<body>` element.
2024-03-09 09:13:19 +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
Martin Robinson
49ae9bb442
layout: Fix the pseudo for anonymous tables (#31578)
Anonymous tables should not use legacy pseudos, as the legacy layout
engine had them inherit lots of random properites that lead to bad
layout in the new layout engine.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-03-08 10:32:51 +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
Martin Robinson
f7f8c24072
layout: Properly propagate text decoration values in tables (#31487)
Instead of just taking the value from the ancestor outside the table,
combine the values when constructing the table.
2024-03-04 15:10:36 +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