Commit graph

716 commits

Author SHA1 Message Date
Martin Robinson
564ba5969f
layout: Non-auto z-index should always make stacking contexts for flex items (#32961)
Fixes #32756.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-08-12 12:15:20 +00:00
Martin Robinson
1d464a576a
layout: Add support for align-content: stretch (#32906)
This adds support for `align-content: stretch` by splitting flex line
layout into two phases. The first phase takes place before determing how
much extra space to allocate for stretching items. Then line layout
finishes, which might cause two layouts for items with `align-self:
stretch`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-08-06 10:33:37 +00:00
Martin Robinson
f1602005a0
deps: Upgrade to WebRender 0.65 (#32930)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-08-05 14:35:21 +00:00
Martin Robinson
10b06f0129
layout: Improve documentation and code structure in FlexItemBox::automatic_min_size (#32911)
This change add specification text to comments and restructres the code
a bit to better match the specification. In addition, a the
`establishes_scroll_container()` helper is used instead of looking at
overflow directly. It should not change behavior at all.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-08-05 09:24:31 +00:00
Delan Azabani
974c9dc89a
layout: Compute intrinsic sizes for flex items and flex containers (#32854)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-08-02 06:45:11 +00:00
Oriol Brufau
ca6169990e
Implement gaps in flexbox layout (#32891)
As per https://drafts.csswg.org/css-align/#gaps

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-31 07:25:54 +00:00
Martin Robinson
a64f75b62f
layout: Fix display of new text in textarea elements (#32886)
Previously `<textarea>` was just displaying node contents, which is the
original text content, not the one updated by later typing. This change
fixes that issue.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-07-30 14:39:17 +00:00
Martin Robinson
e23dc0bf6f
layout: Port border-image support for legacy layout (#32874)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-07-30 06:41:23 +00:00
Martin Robinson
1906741704
layout: Add support for propagating baselines from flexbox (#32841)
Some tests are still broken due to missing preferred widths calculation
for flexbox and also for missing column layout.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2024-07-24 14:38:03 +00:00
Martin Robinson
569fd5d8b5
Upgrade stylo to 2024-07-16 (#32812)
* Upgrade stylo to 2024-07-16

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

* Use the new `dom` crate from stylo

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-07-24 14:37:08 +00:00
valadaptive
60e65c175d
Implement the aspect-ratio property for replaced elements (#32800)
* Add WPT tests for box-sizing with aspect-ratio

Signed-off-by: valadaptive <valadaptive@protonmail.com>

* Implement `aspect-ratio` for replaced elements

There are two regressions because we don't implement `object-fit`, and
one because we don't properly represent non-available <img>s with `alt`
attributes.

Signed-off-by: valadaptive <valadaptive@protonmail.com>

---------

Signed-off-by: valadaptive <valadaptive@protonmail.com>
2024-07-24 11:40:23 +00:00
Martin Robinson
5eb77592ea
layout: Reduce the complexity of FlexLine::layout (#32810)
Instead of a complex combination of iterators, use a flatter iteration
design when laying out a flex line.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2024-07-19 10:37:29 +00:00
rachaelspooky
8b3c9b744a
Fix 5 clippy warnings (#32808)
Signed-off-by: Rachael Gentry <rachael.l.gentry@gmail.com>
2024-07-19 04:04:42 +00:00
valadaptive
f6c9714286
Fix sizing of replaced elements with min/max sizes (#32777)
If a (min/max)-(height/width) property is set, we still need to respect
the intrinsic ratio of the element if it exists. The previous code was
simply clamping the element size after doing the sizing calculations
once, but this leads to an incorrect aspect ratio.

Signed-off-by: valadaptive <valadaptive@protonmail.com>
2024-07-18 07:07:13 +00:00
Delan Azabani
1b1f79305e
flex: handle ‘align-self: [ first | last ]? && baseline’ (#32787)
* flex: handle ‘align-self: baseline’

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* FIXME: css/css-flexbox/align-items-baseline-overflow-non-visible.html

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Fix baseline selection

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Fix baseline calculation with padding/border/margin

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Fix compile errors and warnings

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Implement ‘align-self: last baseline’

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Fix bug where non-baseline-aligned items affected max baseline

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Update expectations

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Rename method

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-07-18 07:03:29 +00:00
Martin Robinson
882a855b8c
Convert layout to use Gecko's alignment style representation (#32790)
Signed-off-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Nico Burns <nico@nicoburns.com>
2024-07-17 14:18:55 +00:00
Delan Azabani
039631cfa5
layout: Properly handle min/max cross container size (#32785)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-07-16 12:14:02 +00:00
atbrakhi
c6443f74a4
Remove unused implementation (#32754)
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2024-07-10 10:57:49 +00:00
atbrakhi
a3bb8048fc
use au in inline (#32728)
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2024-07-09 19:18:59 +00:00
石蕊 (Pi-Cla)
f29dd64a7b
Fix more clippy (#32740) 2024-07-09 04:47:43 +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
atbrakhi
d9b99723f5
Remove unused ToWebRender implementation (#32729) 2024-07-08 16:10:34 +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
4e79ac5701
layout: Allow rendering LineItems independent of inline box (#32666)
Refactor inline layout to allow rendering line items in the second stage
to be rendered in any order, independent of their parent inline box.
This will allow line items to be reordered, effectively allowing the
splitting of inline boxes, for the purposes of BiDi and any other inline
reordering feature.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-07-03 15:15:31 +00:00
atbrakhi
4357751f28
use au in TextFragment (#32653) 2024-07-03 07:27:08 +00:00
atbrakhi
044ab3eeab
fix clippy warning (#32667) 2024-07-02 14:59:46 +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
atbrakhi
fced0b4940
use au in AtomicLineItem (#32630) 2024-06-27 11:12:32 +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
Oriol Brufau
f055964792
Switch replaced layout to app units (#32625) 2024-06-26 16:19:24 +00:00
Oriol Brufau
7b6aa64aca
Clean up some unused dependencies (#32600) 2024-06-25 13:02:59 +00:00
Oriol Brufau
a972e5c200
Switch flex layout to app units (#32599) 2024-06-25 07:05:16 +00:00
Oriol Brufau
b1fdfb88bb
Upgrade stylo to 2024-05-31 (#32474)
* Upgrade stylo to 2024-05-31

* Fixup for https://phabricator.services.mozilla.com/D211731

* Fixup for https://phabricator.services.mozilla.com/D207779

* Fixup for https://phabricator.services.mozilla.com/D207781

* Update test expectations
2024-06-24 20:03:50 +00:00
atbrakhi
26c585a0c5
use app unit in box_fragement (#32349) 2024-06-21 14:54:21 +00:00
Martin Robinson
66edef8065
layout: Simplify Contents a little (#32487)
Instead of duplicating some of `NonReplacedContents` in `Contents`,
divide it into either replaced and non-replaced content, since this is
how the layout system processes `Contents` always. In addition, stop
using `TryInto` to match replaced or non-replaced contents, as it is
quite confusing to handle an `Err` as a success case.
2024-06-21 10:13:31 +00:00
Martin Robinson
44064b1439
layout: Add very basic support for showing text in input boxes (#32365)
This only paints text in input fields. Selection and cursor are still
not painted.

In addition to adding this feature, the change also updates the
user-agent.css with the latest from the HTML specification. Extra
padding and extraneous settings (such as a bogus line-height and
min-height) are also removed from servo.css. This leads to some new
passes.

There are some new passes, this introduces failures as inserting text
reveals issues that were hidden before. Notably:

- failures in `/html/editing/editing-0/spelling-and-grammar-checking/`:
  We do not support spell-checking.
- Most of the rest of the new failures are missing features of input
  boxes that are also missing in legacy layout.
2024-06-20 10:13:50 +00:00
Martin Robinson
cd2ab36759
Rename gfx to fonts (#32556)
This crate only takes care of fonts now as graphics related things are
split into other crates. In addition, this exposes data structures at
the top of the crate, hiding the implementation details and making it
simpler to import them.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-06-19 20:26:19 +00:00
Martin Robinson
e74075255b
layout: Flatten inline box storage in InlineFormattingContexts (#32539)
This accomplishes two things:

1. Makes it easier to iterate through all inline formatting context
   items.
2. Will make it possible to easily move back and forth through the tree
   of inline boxes, in order to enable reordering and splitting inline
   boxes on lines -- necessary for BiDi.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-06-19 08:51:10 +00:00
Martin Robinson
70982dfa5a
layout: Allocate inline box start space on segment (#32486)
Instead of allocating the inline padding and border space on the line,
allocate it on the segment -- which where the inline box start goes.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-06-18 16:19:00 +00:00
Martin Robinson
4a7f3bac7c
Use workspace definitions for all crates and update to the 2021 edition (#32544) 2024-06-18 09:22:08 +00:00
Martin Robinson
bae9f6d844
layout: Linebreak the entire InlineFormattingContext at once (#32483)
Instead of linebreaking inside each single-font text segment, linebreak
the entire inline formatting context at once. This has several benefits:

1. It allows us to use `icu_segmenter` (already in use from style),
   which is written against a newer version of the Unicode spec --
   preventing breaking emoji clusters.
2. Opens up the possibility of changing the way that linebreaking and
   shaping work -- eventually allowing shaping across inline box
   boundaries and line breaking *after* shaping.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-06-13 20:12:14 +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
Martin Robinson
f4c9b310d5
layout: Take into account display: table etc in offset* queries (#32448)
* layout: Take into account `display: table` etc in offset* queries

The specification says that for deciding whether an element should be
used for offset* queries, a browser should take into account whether the
element is a table cell or table. This change makes that happen.

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

* Only tag HTML elements if they are in the HTML namespace

---------

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-06-10 15:05:57 +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
Martin Robinson
674edb4df0
layout: Properly size absolutely positioned tables (#32447)
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-06-07 16:21:08 +00:00
Martin Robinson
6eaccbc297
layout: Don't default to fallback fonts for spaces (#32442)
Previously, when deciding the font for a space, preference was given to
the previous used font. This could means that the font chosen was a
fallback font instead of the first font that supporting the space
character in the font preference list.

This caused an issue rendering emojis surrounded by spaces with "Noto
Color Emoji" which has a space character the same size as the emoji,
leading to too much spacing between them.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-06-05 15:00:57 +00:00
Oriol Brufau
5f538b89e0
Fix getComputedStyle for width and height (#32437)
It was providing a length whenever the element generates a box.
However, these properties don't apply to non-replaced inlines,
so the computed value should be provided instead.
2024-06-04 18:36:19 +00:00