Adds support for min-content, max-content, fit-content and stretch,
for atomic inlines.
There are some new test failures because we don't support vertical
writing modes nor `transition-behavior:allow-discrete`.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
CAPMIN is the largest min-content contribution of the table captions.
In Servo, the standard way to compute min/max-content contributions is
`outer_inline_content_sizes()`, so just use that instead of reinventing
the wheel.
This also fixes cyclic percentages to resolve consistently with normal
block boxes.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This will allow callers to start obeying `min-content`, `max-content`,
`fit-content` and `stretch` in follow-up patches.
The old functionality is kept as deprecated methods that we should
eventually remove.
This patch has very little impact on the existing behavior, just some
very minimal implementation of the keywords for css tables.
This also overhauls fixed-layout-2.html since:
- It had code that wasn't doing anything
- It had wrong expecations in prose
- The logic seemed broken in general
- All browsers were failing one testcase
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This change adds support for `position: relative` to table `<caption>`.
In addition to adjusting their position according to inset values, table
captions must also establish containing blocks for descendants that are
absolutely positioned.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
If we encountered a preserved line break after some whitespace, we were
including the space in the max-content size of the following line.
So just like `line_break_opportunity()` was already clearing
`self.pending_whitespace.min_content`, `forced_line_break()` needs to
clear `self.pending_whitespace.max_content` too.
Also some cosmetic refactoring.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Mostly formatting improvements, but also recovering a pair of parenthesis
that was accidentally removed, changing the logic.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
There were various cases like `text-wrap-mode: nowrap` and
`white-space-collapse: break-spaces` that weren't handled well.
Fixes#33335
flexbox_flex-formatting-interop.html fails now because we don't support
`table-layout: fixed`.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
`white-space: break-spaces` should allow a soft wrap opportunity *after*
every preserved white space. Then, to avoid breaking before the first
white space, `TextRunSegment::shape_text()` has some logic to separate
it from the following spaces and put it with the preceding text instead.
The problem was that, when combined with `word-break: keep-all`, we were
then only checking whether there were more white spaces afterwards,
ignoring the soft wrap opportunity after the first one.
Also removing a duplicated `can_break_anywhere` variable.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
We weren't moving a table-header-group to the front if it was the first
row group. However, there might still be preceding rows that don't
belong to any row group.
And similarly, we weren't moving a table-footer-group to the end if it
was the last row group. However, there might still be following rows
that don't belong to any row group.
This patch fixes the logic, and enables existing tests from Microsoft
that were missing a reference.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
When a baseline is orthogonal to the main flexbox axis, it should not
take part in baseline alignment. This change does that for column flex.
While there is no support for vertical writing modes, this change is
made to be as writing mode-agnostic as possible.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
When computing the automatic minimum size, flex layout was using the
natural aspect ratio, ignoring the `aspect-ratio` property.
`ReplacedContent::inline_size_over_block_size_intrinsic_ratio()` is now
made private to avoid more accidental uses.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
When computing the min-content or max-content size of an element we
need to ignore `inline-size`, `min-inline-size` and `max-inline-size`.
However, we should take the block-axis sizing properties into account.
That's because the contents could have percentages depending on them,
which can then affect their inline size via an aspect ratio.
Therefore, this patch adds `IndefiniteContainingBlock`, which is similar
to `ContainingBlock`, but it allows an indefinite inline-size. This
struct is then passed arround during intrinsic sizing.
More refinement will be needed in follow-up patches in order to fully
address the problem.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
When laying out the contents of a flex item, we used to resolve their
cross-axis percentages against the preferred cross size of the item.
Now we will take the min and max cross sizes into account.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
According to HTML, the `width` and `height` attributes should only set
the natural sizes and the aspect ratio.
The `width` and `height` properties should stay as `initial` by default.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Consider a block container that establishes an inline formatting context
and has a definite `block-size` which is clamped by `min-block-size` or
`max-block-size`.
We were already sizing such container correctly, however, its contents
were resolving their percentages against the unclamped `block-size`
value.
This patch fixes the `ContainingBlock` that we pass to the contents so
that they resolve percentages correctly.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
The current working directory when running on WPT runners is not the
folder with the servo binary, but a parent folder into which the servo
nightly tar is extracted. This means the binary is `$PWD/servo/servo`
and resources directory in in `$PWD/servo/resources`, so the current
hardcoded relative path `resources/wpt-prefs.json` will not work on WPT
runners.
This is causing crashes in WPT runner:
2928440716https://community-tc.services.mozilla.com/tasks/J7MqNwJGQRSkIWlvB5ktPQ/runs/0/logs/live/public/logs/live.log
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Allow prefs to be passed in from a separate file
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Add wpt-prefs.json for setting WPT-specific prefs
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* fix argument to read_prefs_file
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update test_parse_pref test
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Add line in executorservo.py to read from wpt-prefs.json
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update MANIFEST.json
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update expectations
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Disable dom.webxr.test for interfaces test
Signed-off-by: Daniel Adams <msub2official@gmail.com>
---------
Signed-off-by: Daniel Adams <msub2official@gmail.com>
In particular, `main_content_sizes()` now works with columns.
`layout_for_block_content_size()` is now used for both intrinsic sizes
and intrinsic contributions, a IntrinsicSizingMode parameter is added
to choose the behavior.
Also, we consider the main size of a flex item as indefinite if its flex
basis is indefinite and the flex container has an indefinite main size.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Ensure xr_promise_test only runs after DOMContentLoaded
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update meta expectations
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update meta-legacy-layout expectations
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Update manifest
Signed-off-by: Daniel Adams <msub2official@gmail.com>
---------
Signed-off-by: Daniel Adams <msub2official@gmail.com>
These are similar to `flex-start` and `flex-end`, but in `wrap-reverse`
situations, they are the opposite.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This change removes restrictions on using the column layout mode of
flexbox and adds an initial implementation of sizing for that flex
direction. There's a lot of missing pieces still, but in some cases this
does render column flexbox.
In particular, there are now two code paths for preferred widths
(intrinsic size) calcuation: one in the main axis (row) and one in
the cross axis (column) corresponding to the flex direciton with
horizontal writing modes.
In addition, `FlexItemBox::inline_content_sizes` is removed in favor of
making `sizing::outer_inline` /
`IndependentFormattingContext::outer_inline_content_sizes` generic
enough to handle using a different value for auto minimum sizes, which
flexbox needs.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This changes updates to the new version of the `cookie` crate in Servo
which no longer uses the old `time@0.1` data types. This requires using
a new version of `time` while we transition off of the old one. This is
the first step in that process.
In addition, the overloading of the `cookie::Cookie` name was causing a
great deal of confusion, so I've renamed the Servo wrapper to
`ServoCookie` like we do with `ServoUrl`.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* 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>