This change reworks the layout DOM wrappers so that they are simpler and
easier to reason about. The main changes here:
**Combine layout wrappers into one interface:**
- `LayoutNode`/`ThreadSafeLayoutNode` is combined into `LayoutNode`:
The idea here is that `LayoutNode` is always thread-safe when used in
layout as long as no `unsafe` calls are used. These interfaces
only expose what is necessary for layout.
- `LayoutElement`/`ThreadSafeLayoutElement` is combined into
`LayoutElement`: See above.
**Expose two new interfaces to be used *only* with `stylo` and
`selectors`:**
`DangerousStyleNode` and `DangerousStyleElement`. `stylo`
and `selectors` have a different way of ensuring safety that is
incompatible with Servo's layout (access all of the DOM tree anywhere,
but ensure that writing only happens from a single-thread). These types
only implement things like `TElement`, `TNode` and are not intended to
be used by layout at all.
All traits and implementations are moved to files that are named after
the struct or trait inside them, in order to better understand what one
is looking at.
The main goals here are:
- Make it easier to reason about the safe use of the DOM APIs.
- Remove the interdependencies between the `stylo` and `selectors`
interface implementations and the layout interface. This helps
with the first point as well and makes it simpler to know where
a method is implemented.
- Reduce the amount of code.
- Make it possible to eliminate `TrustedNodeAddress` in the future.
- Document and bring the method naming up to modern Rust conventions.
This is a lot of code changes, but is very well tested by the WPT tests.
Unfortunately, it is difficult to make a change like this iteratively.
In addition, this new design comes with new documentation at
servo/book#225.
Testing: This should not change behavior so should be covered by
existing
WPT tests.
Signed-off-by: Martin Robinson <mrobinson@fastmail.fm>
Enable `CJK-aware` line breaking in inline layout so Chinese/Japanese
text gets proper wrap opportunities instead of overflowing containers.
Testing: some WPT are now passing
---------
Signed-off-by: SharanRP <z8903830@gmail.com>
This starts splitting out commonly shared data into a new data structure
that will make it easier to compare old shaping results to new ones in
the future. This eliminates some memory usage during inline layout, but
adds 8 bytes per segment (usually one per inline box). We hope to
recover this memory by storing one `GlyphStore` per `TextRunSegment`,
which
should recover 16 bytes.
Testing: This should not change behavior so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
We were resolving `justify-self: auto` according to the `justify-items`
of the containing block. However, the CSSWG resolved to instead use the
parent box; and if the parent is an inline box, then `justify-items`
doesn't apply, so `justify-self: auto` behaves as `normal`.
Testing: Adding WPT test
Fixes: #43624
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
When encountering a block-level inside an inline box, we would wrap it
(together with other block-level siblings, if any) inside an anonymous
block box.
That was complicating the logic for no real benefit, so just get rid of
these anonymous wrappers, and allow block-levels as direct children of
inlines.
This aligns Servo with WebKit, which did the same refactoring:
https://commits.webkit.org/304357@main
Blink still generates these wrappers, but its design doc acknowledges
that "the anonymous box is not strictly required".
Testing: No existing test fails. But note that, while minimal, this may
have some observable implications. For example, as an accidental
side-effect of #41492, Servo aligned with the CSSWG resolution in
https://github.com/w3c/csswg-drafts/issues/11462, but now we will revert
to the previous behavior. I will address it in a follow-up, and add a
test.
Fixes: #41636
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Fixes incorrect static positioning of absolutely positioned elements
nested within a block that has `margin-top` inside an inline element.
Added two lines of code to `AnonymousBlockBox::layout_into_line_items`
in components/layout/flow/inline/mod.rs:
- We snapshot the current positioning_context_length before laying out
the block.
- We call `adjust_static_position_of_hoisted_fragments` on the
positioning_context after the block fragment is placed by the state.
Testing:
Tested the fix using the manual reproduction HTML provided in the issue,
Also ran the existing WPT tests in `tests/wpt/tests/css/css-position/`
to ensure there are no regressions.
Fixes: #42890
---------
Signed-off-by: vinayak sharma <vinayaks0111@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This and the accompanying stylo PR
(https://github.com/servo/stylo/pull/320) is a partial implementation of
the `first-letter` pseudo element.
Testing: Existing WPT tests. There is one WPT test
(fcp-typographic-pseudo.html) that servo currently fails would timeout
with this PR because opacity of `TextFragment` is taken from the
`InlineFormattingContext` instead of the pseudo element.
Fixes: #43008
Part of: #15413
---------
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This PR modifies the text layout in such a way that text carets can
render on empty lines (other than the first if the textarea is empty).
Zero-length segments are added to support caret rendering. The last
line, if it is without content, does not currently render a caret
correctly
This corresponds to cases 0, 1, and 3 in #41338
Testing: WPT subset `tests/wpt/tests/css/css-text/` ran as expected, one
internal WPT test was added
Fixes: Partially addresses https://github.com/servo/servo/issues/41338
---------
Signed-off-by: Freya Arbjerg <git@arbjerg.dev>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This change includes two related fixes for flakiness revealed by #42847.
1. When caching fonts, try harder to not re-cache a font. This could
happen due to a race condition with the read-write lock on the font
cache. This change improves memory usage in some cases as it prevents
a font from being loaded twice.
2. Incorporate both the strut size and the block size contribution of a
previously unused font in an inline container. Before the code was
incorporating one or the other. In addition, *only* incorporate the
block contribution of a previously unused font if its metrics
meaningfully differ from the container's default font. This was the
case triggered by failing to have the fix in part one of the change.
Testing: This fixes flakiness in an internal WPT-style test.
Fixes: #42908.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
The static position of an abspos is the hypothetical position that it
would have had in the normal flow. If the abspos is inside inline layout
and it had a block-level original display, then the static position is
computed as if the abspos was a block-level that breaks the inline.
Usually this places the static position after the current line. However,
if the abspos is not preceded by any text, padding, border, margin,
preserved newline or atomic inline, then the static position should be
as if the abspos was preceded by a 0px tall phantom line. Previously we
weren't taking that into account.
Note that browsers aren't completely interoperable in corner cases.
Testing: Adding 3 new tests. Blink fails the 2nd one and Gecko fails the
3rd one. WebKit and Servo pass them all.
Fixes: #41990
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
`OutsideMarker::repair_style()` was setting `list_item_style` to the
style of the marker, not the style of the list item.
This patch sets it to `node.parent_style(context)` instead, and it fixes
`ServoThreadSafeLayoutNode::parent_style()` to take the pseudo-element
chain into account. This requires modifying a bunch of logic to pass the
`SharedStyleContext` around.
Testing: Adding a new test
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This continues #41916
Changelog:
- Upstream:
360787fff5...7cd2a178d3
- Servo fixups:
e4d50e905e...d9831d464b
Stylo tracking issue: https://github.com/servo/stylo/issues/305
In particular, this adds support for `alignment-baseline` and
`baseline-shift`, and turns `vertical-align` into a shorthand of them.
This also introduces `vertical-align: center`.
Testing: Various tests improve. Some internal tests are updated because
they were wrong. And some fail because we don't support presentation
attributes on SVG elements.
---------
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This change modifies `LineBreaker` to properly handle `word-break:
keep-all` by adjusting the arguments passed to
`icu_segmenter::LineSegmenter`.
- [CSS
specification](https://drafts.csswg.org/css-text/#valdef-word-break-keep-all)
- Stylo PR : servo/stylo#289
Testing: Created a WPT test for this change, specifically:
`tests/wpt/tests/css/css-text/word-break/word-break-keep-all-011.html`.
Fixes: #42047
---------
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
This change is a reworking of the shaping code and simplification of the
`GlyphRun` data structure.
The shaper was written between 2012 and 2014 against an early version of
Rust. It was originally written to have a single glyph entry per UTF-8
code point. This is useful when you always need to iterate through
glyphs based on UTF-8 code points. Unfortunately, this required a
tri-level data structure to hold detailed glyphs and meant that CJK
characters took over 3x the memory usage of ASCII characters. In
addition, iterating through glyphs (the most common and basic operation
on shaped text) required doing a lookup involving a binary search for
detailed glyphs (ones that had large advances or mapped to more or less
than a single UTF-8 code point).
The new design of the `GlyphStore` is instead based on `chars` in the
input string. These are tracked during layout so that the resulting
glyph output can be interpreted relatively to its original character
offset in the containing IFC. We are already dealing with IFC text on a
per-character basis for a variety of reasons (such as text
transformation and whitespace collapse). In addition, we will now able
to
implement mapping between the character offsets before and after layout
transformations of the original DOM string.
Now the penalty of more complex glyph iteration is only paid when
transforming glyph offsets to character offsets. Currently this is only
done for selections and clicking in text boxes, both of which are much
less common than layout.
This change does not properly handle selections in RTL text, though
rendering and basic selection and visual movement works (though buggy).
It does not seem like this affects the performance of shaping based on
measurement using the text shaping performance counters. This likely
means that the performance of shaping is dominated on our machines by
HarfBuzz. We noticed no performance degradation in Speedometer when run
on a M3 Mac.
Followup work:
- Properly handle selection in RTL text.
- Support mapping from original DOM character offsets to offsets in
layout after text transformation and whitespace collapse. This is now
possible.
Testing: This causes some tests to pass and a few to fail. This is
likely
due to the fact that we are handling glyphs more consistently while
shaping. Of the new failures:
- `letter-spacing-bengali-yaphala-001.html`,
`letter-spacing-cursive-001.html`, `font-feature-settings-tibetan.html`
where passing before probably because we were not applying letter
spacing to detailed glyphs. These scripts should not have letter spacing
applied to them, because they are cursive -- which we never implemented
properly. It will be handled in a a followup.
- `shaping-arabic-diacritics-001.html`: This was a false pass. The tests
verifies that Arabic diacritics are applied to NBSP. This wasn't
happening before nor after this change, but the results matched anyway.
Now they don't, but before and after are equally broken.
-
Fixes: #216
Part of #35540.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
In DOM traversal, `display:contents `elements don't generate boxes, but
their styles still need to apply to children.
`ModernContainerBuilder` now keeps track of `display:contents` ancestors
during traversal then apply their style to text runs.
In `InlineFormattingContextBuilder::push_text` only use same style
parent if both selected and current inline style are identical.
Testing:
> PASS [expected FAIL]
/css/css-display/display-contents-dynamic-before-after-001.html
> PASS [expected FAIL]
/css/css-display/display-contents-dynamic-inline-flex-001-inline.html
> PASS [expected FAIL]
/css/css-display/display-contents-dynamic-inline-flex-001-none.html
> FAIL [expected PASS] /css/css-display/display-contents-fieldset.html
> PASS [expected FAIL]
/css/css-display/display-contents-first-line-002.html
> PASS [expected FAIL] /css/css-display/display-contents-inline-001.html
> PASS [expected FAIL]
/css/css-display/display-contents-inline-flex-001.html
> PASS [expected FAIL]
/css/css-display/display-contents-line-height.html
Fixes: https://github.com/servo/servo/issues/41797
cc: @xiaochengh
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Instead of handling selection in text input during box tree / fragment
tree construction, fully handle it during display list construction.
This means that when the selection changes in script, it updates
automatically in the `FragmentTree` and only a new display list is
necessary. This avoids a layout while changing the selection in text
fields.
Testing: This fixes a few rendering issues, but these are very hard
to isolate and test for. It causes one test to start failing, but this
is
because a cursor that wasn't rendered properly now starts showing
up.
Fixes: #41920.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Various methods, structs and fields were unnecessarily public. Make them
private.
Testing: Not needed, no behavior change.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Some of its logic can just be replaced with a call to the method
`unbreakable_segment_fits_on_line()`.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This patch adds a weak reference to the parent box in `LayoutBoxBase`,
so that boxes can refer to their parent. This will help during future
changes for incremental layout.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This change updates and implements the old `query_text_index` layout
query to properly look for the glyph index of a point within a node's
`Fragment`s. This should work properly with the shadow DOM of both
`<input>` and `<textarea>` elements. In particular, multiple lines are
supported.
Caveats:
- `<input>` and `<textarea>` that are transformed are currently not
supported. This will happen in a followup.
- For multi-line inputs, we should be finding the text offset of the
nearest line that is within the block range of the click. This will
happen in a followup.
Testing: This change adds two Servo-specific WPT-style tests. These are
Servo-specific because the behavior of clicking in text fields isn't
fully specified.
Fixes: #35432Fixes: #10083
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Phantom line boxes allow margins to collapse through them. But in the
sequential layout state we were assuming that was not the case, so we
were placing floats incorrectly.
Testing: Adding 2 tests
Fixes: #41794Fixes: #41734
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Changes `LayoutBox::InlineLevel()` to have a raw `InlineItem` instead of
an `ArcRefCell<InlineItem>`. `InlineItem` is an enum where all the
options already use `ArcRefCell`, so the outer `ArcRefCell` wasn't
really necessary.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Servo `Range` type probably predates the `Range` type in the standard
library. The fact that there are two `Range` types in Servo is often
very confusing. The internal type is only used for byte indices in glyph
runs. This change removes the internal generic `Range` in favor of a
small wrapper around a native Rust `Range`.
It's likely that there are more improvements that could be done here,
such as reusing `Utf8CodePointIndex`, but this code is going to change a
lot soon and these ranges might soon be replaced with actual glyph
ranges. We are going to be looking to remove `TextByteRange` entirely.
This is just an intermediate step.
Testing: This should not change behavior and is thus covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This decreases the size of `TextFragment` by 66 bits and also allows
sharing empty metrics for text runs without fonts. Many `TextFragments`
should share the same font so these 66 bits should reflect reality even
though the `FontMetrics` is now stored on the heap.
Testing: This should not change behavior so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
When a block-level that depends on block constraints is inside an inline
formatting context, then the intrinsic size of the entire IFC needs to
be marked as depending on block constraints too.
Testing: Adding new test
Fixes: #41630
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
When a block-level that depends on block constraints is inside an inline
formatting context, then the entire layout of the IFC needs to be marked
as depending on block constraints too.
Testing: Adding new test
Fixes: #41623
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
We now follow the same approach as Blink: sequences of block-levels in
an inline formatting context get wrapped in an anonymous block, which is
treated as a line item. Inline ancestors are no longer split.
This means that inline elements will now generate a single inline box,
and the box tree makes more sense in general. This will help for
incremental layout.
This also means that block-level elements will now be properly affected
by effects like opacity of filters set on inline ancestors.
Recently, WebKit has done some similar work, but without the anonymous
blocks. We might also consider removing them in the future.
Google's explainer:
https://docs.google.com/document/d/15kgdIHhb9EVNup6Ir5NWwJxpzY5GH0ED7Ld3iMW3HlA/
Testing: Several tests are now passing
Fixes: #39813
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The computation of the min-content and max-content sizes of an inline
formatting context was ignoring floated contents.
Now we will take them into account.
Testing: One test is now passing. Note there isn't much test coverage
because there is no spec, and browsers aren't fully interoperable. More
tests should be added as part of
https://github.com/w3c/csswg-drafts/issues/9120Fixes: #3923
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Fixes caret rendering when the caret is placed a the start of a line
```
Hello,
{here}World!
```
Also adds a utility function to the `range` crate.
Note that the rendering of the caret on many non-empty lines is still
broken due to the presence of several other bugs
Testing: I ran unit tests. Add a new reftest
Fixes: Part of #40839
---------
Signed-off-by: Freya Arbjerg <git@arbjerg.dev>
As previously described in #41150 ,
`InlineFormattingContext::font_metrics` contains info that are easily
accessible via `FontRef`, and the `FontInstanceKey` is already cached in
the `FontContext`. Instead of keeping an index and obtaining these info
using the index, one should be able to obtain the same info via a
`FontRef`.
Testing: This should not change the expected behavior and the current
unit tests and WPT testcases should be sufficient.
Fixes: #41150
---------
Signed-off-by: minghuaw <michael.wu1107@gmail.com>
This reverts commit f5ecb34577 and also
merges more shared properties into `BaseFragment`. The goal here is to
eventually also store a reference to the parent fragment in this
`BaseFragment` as well.
Testing: This should not change behavior in an observable way, so is
covered by WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
And let the Compositor create the `PainterId` when it creates a new
`Painter`. Also make inline formatting code take `LayoutContext` rather
than threading it via the `InlineFormattingContextBuilder`.
Testing: Should preserve existing behavior, so covered by existing
tests.
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
`LayoutBox::clear_fragment_layout_cache()` was just redirecting to the
`clear_fragment_layout_cache()` method of inner structures, until
reaching `LayoutBoxBase` where the work is actually done.
So this patch gets the `LayoutBoxBase` first, and then calls the method
on it. To do so, `LayoutBox::with_base_fold()` is added as a non-mutable
version of the existing `LayoutBox::with_base_mut_fold()`. But since we
the return value doesn't matter, `LayoutBox::with_each_base()` is also
added as a tiny helper around `LayoutBox::with_base_fold()`.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
We were only allowing a soft wrap opportunity before the first run in a
`TextRunSegment`, but not before the other runs. For example, this meant
that the min-content size of `中文中文` would be 4ic instead of just 1ic.
The change brings the logic in `ContentSizesComputation::process_item()`
closer to `TextRunSegment::layout_into_line_items()`.
Testing: Adding new tests. There is also a new failure because we don't
support `word-break: auto-phrase`.
Fixes: #39728
---------
Signed-off-by: Richard Tjokroutomo <richard.tjokro2@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
The height of an inline box is typically decided by font metrics, but if
it's on a phantom line box, then it should be zero.
This is hard to observe, because the contents of a phantom line box are
typically invisible, but it's noticeable on these cases:
- If the inline has a box shadow or an outline (not on all browsers).
- If the inline establishes a containing block for abspos descendants.
- When getting the size using JS APIs.
Testing: Some existing tests pass, also adding a new one
Fixes: #39648
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Both `flow/inline/line.rs` and `flow/inline/mod.rs` had a function to
resolve the `line-height` value. They were pretty much the same, except
that the former wasn't handling single-line text inputs. But I don't
think it matters, since the text inside such input can't be styled with
`vertical-align: top` or `bottom`.
Thus this patch unifies the logic. And to simplify the callers, now this
function accepts a `&InlineContainerStateFlags` instead of a bool for
identifying single-line text inputs.
Testing: There shouldn't be any behavior change.
This is part of #39664
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Motivation: The font cache currently has to store a cache of Keys which
need to be given by the webrender instance.
Having a cache for every WebViewId in the future when we have every
webview have the different webrender::DocumentId might be too wasteful
to store this key cache per DocumentId. This proposes to include in the
WebViewId another id, the RenderingGroupId. This id can be easily
changed
to be equivalent to the DocumentId when we support multiple DocumentIds
for a unique Webrender instance.
Additionally this will keep it easier to integrate the currently out of
tree patches for multiple rendering contexts with different webrenders.
Change:
We introduce the RenderingGroupId in the WebViewId and allow a method to
extract it. The font key cache uses this cache
and forwards it to the Compositor when requesting new changes. The
compositor currently ignores this id.
Additionally, the WebView can return the RenderingGroupId. The WebViewId
also has an appropiate constructor for specifying a RenderingGroupId.
Because there currently will be only one RenderingGroupId the
performance will be minimal.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This should be covered by WPT tests and normal browsing
behavior works fine.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
According to https://drafts.csswg.org/css-inline/#invisible-line-boxes,
if a line box contains non-zero inline-axis margins, padding or borders,
then it can't be phantom.
Therefore, this patch makes adds a `has_inline_pbm` flag to the line.
Note that we can't use the `has_content` flag, because that would add a
soft wrap opportunity between the padding/border/margin and the first
content of the line.
The patch also renames `InlineFormattingContext::had_inflow_content` to
`has_line_boxes`, which is what we care about for collapsing margins
through.
Testing: Adding new tests
Fixes: #39057
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This patch refactors the logic for propagating overflow to the viewport,
fixing various issues:
- Now we won't propagate from the root element if it has no box. Note
the fix isn't observable in Servo because we lack scrollbars.
- If the first `<body>` element has no box, we won't keep searching for
other `<body>` elements. This deviates from the spec, but aligns us with
other browsers.
- We won't propagate from the `<body>` if it has no box. We were already
handling `display: none` but not `display: contents`. This deviates from
the spec, but aligns us with other browsers.
Also, when we flag the root or `<body>` as having propagated `overflow`
to the viewport, we retrieve the `LayoutBoxBase`. Therefore, now we get
the computed style from the `LayoutBoxBase` in a single operation,
instead of first retrieving the style from the DOM element and then
getting the `LayoutBoxBase` from the box.
Testing: Adding more tests. We were only failing one of them, but it's
hard to test the fixes given that we don't show scrollbars. The tests
that were already passing are useful too, e.g. Firefox fails one of
them.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The min-content and max-content inline sizes of an inline formatting
contentext need to take `text-indent` into account. Note it can be set
to a negative amount, so the `ContentSizesComputation` logic needs some
tweaks to handle it well.
Testing: Fixes various WPT tests
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
They only had the writing mode, now they will have the entire computed
style.
This is needed for #39230.
Testing: Not needed, no behavior change
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
`InlineFormattingContextLayout::finish_current_line_and_reset()` has an
early return in case the line has no fragment. However, if the line only
has a forced line break, then we still need to set the baseline.
Testing: Adding new test.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
A LayoutBox typically has one LayoutBoxBase, or none in the case of
`LayoutBox::DisplayContents`. However, `LayoutBox::InlineLevel` can
contain multiple inline items, each one with its base. But since things
like the style or the fragment flags should be the same for all of them,
getting the first base is sometimes enough.
Testing: not needed, no change in behavior.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Phantom line boxes should be treated as non-existing for most purposes,
so don't let them affect the baseline of their block container.
Testing: An existing test passes, and also adding a new one which
doesn't rely on `<button>`
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The `overflow-*` values of either the root element or the `<body>` get
propagated to the viewport. However, we were missing this part:
> The element from which the value is propagated must then have a used
`overflow` value of `visible`.
See https://drafts.csswg.org/css-overflow/#overflow-propagation
Testing:
- `css/cssom-view/scrolling-quirks-vs-nonquirks.html`
- `css/css-overflow/overflow-body-propagation-007.html`
- `css/css-overflow/overflow-body-propagation-008.html`
- `css/css-overflow/overflow-body-propagation-009.html`
- `css/css-overflow/scrollable-overflow-with-nested-elements-001.html`
- `css/css-overflow/scrollable-overflow-with-nested-elements-002.html`
- `css/css-overflow/scrollable-overflow-with-nested-elements-003.html`
- `css/css-overflow/scrollable-overflow-with-nested-elements-004.html`
- `css/css-overflow/scrollbar-gutter-scroll-into-view.html`
Failures:
- `css/css-overflow/overflow-body-propagation-010.html`
Failing because of missing support for `contain: paint`.
- `css/css-overflow/scrollable-overflow-with-nested-elements-005.html`
Failing because of wrong `data-expected-height`, but correct
`data-expected-scroll-height` which is core of this PR.
`data-expected-height` can be dealt separately.
Fixes: #38248
---------
Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Use `ServoThreadSafeLayoutNode` in more places in layout rather than
`ServoLayoutNode`. The former is meant to be used during layout, but
layout 2020 was written against the latter. In general, this reduces the
amount of conversion to the thread-safe version in many places in
layout.
In addition, an unused iterator from the `script` crate
`ServoThreadSafeLayoutNodeChildrenIterator` is replaced with the child
iterator from `layout`. The `layout` version must be directly in
`script` now as it uses the dangerous variants of `next_sibling` and
`first_child`, which allow encapsulating the unsafe bits into one
module.
This will ultimately be useful for storing the layout data of
pseudo-element children of pseudo-elements properly.
Testing: This should not change any behavior and thus is covered by
existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>