| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The main change here is that collapsed and `text-transform`'d text is
computed as it's processed by DOM traversal. This single transformed
text is stored in the root of the `InlineFormattingContext`.
This will eventually allow performing linebreaking and shaping of the
entire inline formatting context at once. Allowing for intelligent
processing of linebreaking and also shaping across elements. This
matches more closely what LayoutNG does.
This shouldn't have any (or negligable) behavioral changes, but will
allow us to prevent linebreaking inside of clusters in a followup
change.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change adds support for `white-space-collapse: break-spaces` and
adds initial parsing support for `overflow-wrap` and `word-break`. The
later two properties are not fully supported, only in their interaction
with `break-spaces`. This is a preliminary change preparing to implement
them.
In addition, `break_and_shape` is now forked and added to Layout 2020.
This function is going to change a lot soon and forking is preparation
for this. More code that is only used by Layout 2013 is moved from `gfx`
to that crate.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
| |
fallback (#32165)
This fixes an issue revealed by more consistent font fallback.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows sharing font templates, fonts, and platform fonts across
layout threads. It's the first step toward storing web fonts in the
layout versus the shared `FontCacheThread`. Now fonts and font groups
have some locking (especially on FreeType), which will probably affect
performance. On the other hand, we measured memory usage and this saves
roughly 40 megabytes of memory when loading servo.org based on data from
the memory profiler.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bumps Stylo to servo/stylo#37
`white-space` is split into `white-space-collapse` and `text-wrap-mode`:
| white-space | white-space-collapse | text-wrap-mode |
| ----------- | -------------------- | -------------- |
| normal | collapse | wrap |
| nowrap | collapse | nowrap |
| pre-wrap | preserve | wrap |
| pre | preserve | nowrap |
| pre-line | preserve-breaks | wrap |
| - | preserve-breaks | nowrap |
Note this introduces a combination that wasn't previously possible,
but I think the existing logic can handle it well enough.
The old `allow_wrap()` is replaced by checking whether `text-wrap-mode`
is set to `wrap`.
The old `preserve_newlines()` is replaced by checking whether
`white-space-collapse` is *not* set to `collapse`.
The old `preserve_spaces()` is replaced by checking whether
`white-space-collapse` is set to `preserve`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`TextRunSegment` offset (#32119)
A `TextRun` is composed of `TextRunSegment`s that are composed of
`GlyphRun`s.
`TextRun::glyph_run_is_preserved_newline` is indexing into the `TextRun`
text, but the `GlyphRun` indexes that it uses are relative to the
`TextRunSegment`
offset. Before the code was using the offset without incorporating the
`TextRunSegment` offset. This led to miscalculation of preserved newline
location while processing text content.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->
<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
|
| |
|
|
|
|
|
|
|
|
| |
`<br>` elements are a bit "special" in the sense that they defer a
linebreak, but can also have `clear` applied to them. The `clear` that
they supply should be applie *after* the linebreak is processed. This
change adds special processing for this situation.
Fixes #15402.
|
|
|
|
|
|
|
|
| |
The logic was to remove any collapsible white space preceded by other
white space. However, this should only happen if the preceding space
is also collapsible.
Also fixing the logic in ContentSizesComputation, which was wrong
but previously it didn't matter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Upgrade Stylo to 2023-12-01
* Fixup for https://phabricator.services.mozilla.com/D191362
* Fixup for https://phabricator.services.mozilla.com/D191522
* Fixup for https://phabricator.services.mozilla.com/D191613
* Fixup for https://phabricator.services.mozilla.com/D191161
* Fixup for https://phabricator.services.mozilla.com/D191615
* Fixup for https://phabricator.services.mozilla.com/D193048
* Fixup for https://phabricator.services.mozilla.com/D193547
* Update test expectations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The only font relative unit that Servo knows how to resolve currently is
`rem` (relative to the root font size). This is because Stylo cannot do
any font queries. This adds a mechanism to allow this, exposing the
ability to properly render `ex` units in Servo.
This change only allows resolving some font size relative units thoug,
as Servo doesn't collect all the FontMetrics it needs to resolve them
all. This capability will be added in followup changes.
Some new tests fail:
- ex-unit-001.html: This test fails because Servo does not yet have
support for setting the weight using @font-face rules on web fonts.
- ex-unit-004.html: This test fails because Servo does not yet have
support for setting the Unicode range of a web font using @font-face
rules.
- first-available-font-001.html: This test fails because the above
two feature are missing.
|
|
|
| |
Updating Stylo and test expectations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update Stylo to 2023-10-16
* Fixup for https://phabricator.services.mozilla.com/D185154
* Fixup for https://phabricator.services.mozilla.com/D188216
* Fixup for https://phabricator.services.mozilla.com/D185677
* Fixup for https://phabricator.services.mozilla.com/D188566
* Fixup for https://phabricator.services.mozilla.com/D188727
* Fixup for https://phabricator.services.mozilla.com/D189475
* Fixup for https://phabricator.services.mozilla.com/D189521
* Fixup for https://phabricator.services.mozilla.com/D188812
* Fixup for https://phabricator.services.mozilla.com/D189484
* Update test expectations
|
|
|
| |
It was being treated like `pre`, but it allows wrapping lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Ignore spaces before atomic inline for the min-content size
For the min-content size we should wrap lines wherever is possible,
so wrappable spaces shouldn't increase the length of the line,
they will just be removed or hang at the end of the line.
* Add a clarifying comment
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
---------
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
|
|
|
|
|
|
|
| |
The old logic was always picking the last baseline, but this should only
happen for inline-blocks.
Since replaced elements and flex containers aren't currently setting
their baselines, this is only an improvement for inline-tables.
|
|
|
|
|
| |
* use au in BoxFragement
* review fix
|
|
|
|
|
|
| |
This change makes it so that when calculating the space added between
words for justification, text-indent is taken into account.
Fixes #31775.
|
|
|
| |
Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
|
|
|
|
|
| |
* Allow pre-wrap whitespace to hang at the end of the line
* Use bitflags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The old logic was assuming that all whitespace was a break opportunity,
and that no newlines would be preserved.
Note that text shaping considers the advance of a newline to be the same
as a space. This was problematic because if we have a segment with a
preserved space and newline, only the advance of the space should
contrinute to the size of the block container. Therefore, I'm changing
the breaker logic in other to have newline characters in their own
segment.
Then glyph_run_is_whitespace_ending_with_preserved_newline can just be
renamed to glyph_run_is_preserved_newline.
This patch is still not perfect because it doesn't check allow_wrap(),
so `nowrap` is treated like `normal`, and `pre-wrap` like `pre`.
|
|
|
|
|
|
|
| |
Marking all IFCs as containing floats shouldn't change layout results,
but does prevent parallel layout in some cases. This change fixes an
issue where we were marking all IFCs as containing floats.
Fixes #31540.
|
|
|
|
|
| |
* Changed LineItems to LineItem to make it a clickable link
* No variant named Anonymous is present in Fragment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
At the root of an inline formatting context, we used its vertical-align
in order to compute the strut. That was wrong, since vertical-align
on a block container shouldn't affect the contents, it should only
affect the alignment of the block container (if it's inline-level)
within the parent IFC.
This was only working well if the block container was block-level, since
effective_vertical_align_for_inline_layout returned `baseline` for
block-level boxes.
Instead of the outer display type, this patch changes the logic to check
whether we are at the root of the IFC.
|
|
|
|
|
|
|
|
|
|
|
| |
* make margin in pbm use app unit
* Simplification
* Consistently resolve inline margins as Au, like block margins
---------
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
|
|
|
|
|
| |
* clippy: fix warnings in components/layout_2020
* fix: review comments
|
|
|
|
|
|
| |
They were only considered in min-content sizes.
Also avoid some pointless conversions from Au to Length.
Fixes #31605.
|
|
|
| |
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Synthetic small caps is supported by the font subsystem, but this is
disabled in Layout 2020. We can turn this on to bring support to parity
with the old layout system.
In addition to turning on synthetic small-caps this change also improves
the way that they work. Before, synthetic small caps meant that every
character was a small version of capitalized character. After this
change, capital letters are larger than small caps versions of small
letters -- matching other browsers and the common expectation of how
small caps works.
|
|
|
|
|
|
|
|
|
|
| |
In quirks mode, preserved segment breaks should add line height to
lines. This matches the behavior of WebKit and Blink, but not Gecko.
This also handles the special-case of `<br>` elements, which are
implemented with preserved segment breaks via `white-space: pre-line`.
This is an implementation detail though because `<br>` has a special
behavior if the line isn't empty -- it doesn't add any line height in
this case.
|
|
|
|
|
|
|
|
|
|
| |
As per HTML [1], <div align="..."> and <center> should behave as if they
had the text-align property set to the corresponding value.
Servo implements that as internal text-align values because there should
the extra effect of aligning block descendants, but that part has not
been implemented yet. This patch only adds support for inline layout.
[1]: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds basic support for `text-transform` in a way that is more
complete than legacy layout. There are still many missing elements of
proper `text-transform` support such as:
1. Support for `full-width` and `full-size-kana`
2. Support for grapheme based uppercasing, lowercasing, and
capitalization. These are all done per-code point right now.
3. Support for the language-specific `SpecialCasing.txt` cases for case
mapping such as the ones for Irish and Turkish.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This moves white space collapse to right before breaking and shaping
happens, which is more similar to what happens in legacy layout. This is
the first step toward making this procedure more efficient (avoiding
string copies) and also implementing support for `text-transform`.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
| |
* use au for padding and border in pbm
* review fix
|
|
|
|
|
|
|
| |
This adds an initial implementation of font fallback, on part with the
one used in legacy layout. There are still issues. For instance, font
matching is done per unicode character rather than based on graphemes or
the shape first approach of Chrome. The idea is that these changes can
be made later.
|
|
|
|
|
|
|
|
|
|
| |
Instead of tracking justification opportunities during line layout, wait
until the line is about to be laid out and justification is about
happen. This makes the logic for tracking justification opportunities
simpler. In particular, we no longer have to carefully adjust them when
trimming whitespace. Additionally, this avoids a bit of work unless
justification is turned on.
This also includes a small cleanup of the justification code.
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* use app unit in replaced elements
* more app unit usage
* Avoid unnecessary into()
* Run ./mach fmt
* use scaleby
* update
---------
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Shape text during InlineFormattingContext construction rather than doing
it twice during fragment tree construction. This is a step on the way
toward proper font fallback.
This also moves all `TextRun` related code into `text_run.rs` to try to
trim down the size of `inline.rs`.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because this should only have
performance impacts.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->
<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
|
|
|
| |
cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
whitespace (#31161)
Before counting whitepsace-only `GlyphStore`s where counted as a single
justification opportunity when trimming whitespace from the front and
back of lines. This isn't correct, instead count the actual number of
word seperators of the trimmed `GlyphStore`s.
These two counts can be different in the case where whitespace collapse
isn't happening yet (flexbox). In addition, using word seperators means
the code is making less assumptions about the contents of the line and
is more robust.
This fixes some crashes in flexbox tests on debug builds.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* use app_units
* resolve errors in table layout
* fmt
* add back current_line.min_content
* update expectation
* review fix
|
|
|
|
| |
This fixes many rustdoc errors that occur due to raw URLs in rustdoc
comments as well as unescaped Rust code that should be in backticks.
|
|
|
|
|
| |
* cleanup helper functions in flexbox
* fmt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of a tricky stack of enum iterators expose a `foreach()`
function on InlineFormattingContext, which takes a `FnMut`. This
prevents callers wanting to iterate from keeping a stack of iterators
and will potentially allow a future version of this function to avoid
borrowing the ArcRefCell<...> of inline boxes for every iteration
(presumably using something like OwnedRef).
Convert `inline_content_sizes` to use this new `foreach()` function and
move the `Computation` out of the function body to
`ContentSizesComputation`. This reduces the stack depth of inline size
computation, because `foreach()` is iterative and not recursive.
This is a preliminary change to removing the second round of text shaping
during layout, because shaping will use this new iterator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* use app_unit in flow layout
* fmt
* Avoid crash
* Drop assert that doesn't hold anymore
* update expectation
---------
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
|