aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020
Commit message (Collapse)AuthorAgeFilesLines
* Use `ContentSizes::shrink_to_fit` when possible (#33527)Oriol Brufau2024-09-252-8/+11
| | | | | And ensure that the minimum wins for malformed ContentSizes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* fonts: Use `IpcSharedMemory` to send font data (#33530)Martin Robinson2024-09-252-6/+6
| | | | | | | | | | | | | | | | | | | | | This changes modifes the way that font data is sent over IPC channels. Instead of serializing the data or sending it via IPC byte senders, font data is copied into shared memory and a copy of the handle is sent over the channel. There is also the idea of sending the file handle of the on disk data of system fonts. This could be implemented as a further followup once there is an abstraction in `ipc-channel` over file handles. To accomplish this, a `FontData` abstraction is added, which also allows caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded by some APIs). This could also be a place for caching font tables in the future. Finally, the `FontCacheThread` is renamed to the `SystemFontService` while the proxy for this is now named `SystemFontServiceProxy`. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Layout: Implement innerText/outerText (#33312)Ben2024-09-241-4/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement outerText on HtmlElement Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fixed some innerText/outerText bugs Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Unified innerText/outerText handling outside of Layout Before these 2 were treated separately and only within Layout would they end up calling the same method, now they are already unified within HTMLElement Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Address a few nits Signed-off-by: Martin Robinson <mrobinson@igalia.com> * Added innerText support for `inline-flex` Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com> Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Shane Handley <shanehandley@fastmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Add `HTMLCanvasDataSource::Empty` that represent transparent black instead ↵Samson2024-09-222-15/+17
| | | | | | | | | | | | | | | of `HTMLCanvasDataSource::Image(None)` (#33519) * `HTMLCanvasDataSource::Empty` that represent transparent black instead of Image(None) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fix warning from 3a0d27b2312c6396e85178615290ac2ec3592ce1 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* fix many clippy warnings (#33510)Gae242024-09-211-1/+1
| | | Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* Enable min-content, max-content, fit-content and stretch (#33492)Oriol Brufau2024-09-203-9/+16
| | | | | | | | | For the sizing properties. We don't actually support them yet, just treating them as the initial value. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Ensure that `<caption>`'s support `position: relative` (#33426)Martin Robinson2024-09-191-3/+13
| | | | | | | | | 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>
* layout: Add support for `object-fit` and `object-position` (#33479)Martin Robinson2024-09-1810-70/+155
| | | | | | | | | | This also makes a couple small improvements: - Rename `IntrinsicSizes` to `NaturalSizes` which reflects more modern spec language. - Move the conversion of Stylo's `ImageRendering` to WebRender's version to a `ToWebRender` trait implementation. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Add `rust-version` to all `Cargo.toml` files (#33483)Martin Robinson2024-09-171-0/+1
| | | | | | | This is another step preparing for building Servo without `mach`. Fixes #33430. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Clear `self.pending_whitespace.max_content` in `forced_line_break()` (#33469)Oriol Brufau2024-09-161-8/+8
| | | | | | | | | | | | 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>
* Replace .map_or(false with Option::is_some_and (#33468)Simon Wülker2024-09-166-19/+23
| | | Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Small improvements for table border collapse (#33452)Oriol Brufau2024-09-162-15/+128
| | | | | | | | We were only collapsing the borders from adjacent cells. This patch also handles the borders from rows, row groups, columns, and column groups. Additionally, it takes the border style into account in order to decide which border wins. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Do not remove extra columns at the end of the table (#33451)Oriol Brufau2024-09-162-23/+15
| | | | | | | | | | | <col> and <colgroup> elements can be used to create extra columns that have no cell. We were removing these columns and column groups, but in general we shouldn't do that. Now we will only remove them if the table has no row nor row group. matching WebKit and the expectations of some tests. But note that Gecko and Blink never remove them. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Let `LengthPercentage::maybe_to_used_value()` accept `Option<Au>` (#33450)Oriol Brufau2024-09-161-17/+11
| | | | | | Bump Stylo to servo/stylo#75 and remove conversions that are no longer necessary. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix rustdoc problems (#33458)Oriol Brufau2024-09-141-2/+2
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Allow table-layout:fixed to shrink cells to less than the border+padding ↵Oriol Brufau2024-09-131-6/+14
| | | | | | | | | | (#33442) A table cell with `width: auto` in fixed layout will now have an outer min-content width of zero, even if it has borders or padding. In a way, this is like allowing the content-box width to become negative. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Fix precision issue with line heights (#33438)Oriol Brufau2024-09-131-1/+5
| | | | | | | | | When computing the ascent and descent in an inline formatting context, we weren't taking into account that app units have precision limitations. Therefore, in some cases we were getting a line height that was slightly taller than the value specified in `line-height`. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* uses app units in display_list (#33420)atbrakhi2024-09-1312-139/+131
| | | | Signed-off-by: atbrakhi <atbrakhi@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Fix inset box-shadow to use the padding box (#33433)Oriol Brufau2024-09-131-5/+4
| | | | | As specified in https://drafts.csswg.org/css-backgrounds-3/#shadow-shape Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Simplify table logic in effective_overflow() (#33431)Oriol Brufau2024-09-131-33/+22
| | | | | | | | | | | | | On tables, we need to treat an overflow value of `scroll` or `auto` as `visible`. Both `scroll` or `auto` are scrollable, which implies that the other axis must also have a scrollable value. Therefore, when we make the value behave as the non-scrollable `visible`, we need to adjust the other axis too. The previous logic was checking `is_scrollable()` but that wasn't necessary, since computed values must have the same scrollability. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Cleanup after #33396 (#33429)Oriol Brufau2024-09-125-19/+15
| | | | | | 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>
* Add support for `table-layout: fixed` (#33384)Oriol Brufau2024-09-121-35/+55
| | | | | | | More details might be needed to fully support the feature, but this covers the basic functionality. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Avoid crash with large table column widths (#33424)Oriol Brufau2024-09-121-12/+15
| | | | | Fixes #33423 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Handle all `white-space` values when intrinsically sizing an IFC (#33343)Oriol Brufau2024-09-112-31/+52
| | | | | | | | | | | 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>
* layout: Reverse space-between alignment properly for absolute children of ↵Martin Robinson2024-09-111-0/+2
| | | | | | | | | flex containers (#33406) When aligning with `space-between` the space should be allocated on the `flex-end` side of the container ie it should be mapped to `flex-start` (`start` and reversing if necssary). Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Let table-related boxes adjust their `overflow` values (#33400)Oriol Brufau2024-09-114-13/+64
| | | | | | | | | | The `overflow` property doesn't apply to table track and track groups, and table elements only accept a few `overflow` values. Therefore, this patch adds an `effective_overflow()` method to get the actual value that needs to be used. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Right-to-left support for other layout modes (#33375)Martin Robinson2024-09-1118-525/+814
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removes the `effective_writing_mode` concept and tries to properly implement right-to-left layout support for all non-inline writing modes. In general, what needs to happen is that rectangles need to be converted to physical rectangles using the containing block. A right-to-left rectangle's inline start is on the right physical side of the containing block. Likewise a positive inline offset in right-to-left text is a negative physical one. The implementation here is pretty good for most layout modes, but floats are still a bit in process. Currently, floats are processed in the logical layout of the block container, but there still might be issues with float interaction with mixed RTL and LTR. While this does move us closer to supporting vertical writing modes, this is still unsupported. New failures: - Vertical writing mode not supported: - `/css/CSS2/floats/floats-placement-vertical-001b.xht` - `/css/CSS2/floats/floats-placement-vertical-001c.xht` - Absolutes inlines should avoid floats (#33323) - `/css/css-position/position-absolute-dynamic-static-position-floats-004.html` - No support for grid - `/css/css-align/self-alignment/self-align-safe-unsafe-grid-003.html` - `/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html` - `/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html` - Cannot reproduce these locally on any platform. Very mysterious: - `/css/css-tables/row-group-margin-border-padding.html` - `/css/css-tables/row-margin-border-padding.html` - Exposes bugs we have related to hanging whitespace in preserved whitespace inlines: - `/css/css-text/white-space/trailing-space-and-text-alignment-rtl-003.html` - `/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-023.html` Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Use `Au` in `ComputedValuesExt` (#33396)atbrakhi2024-09-1013-272/+240
| | | | | | | | | | | | | | | | | | | | * Use app unit in `ComputedValuesExt` Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: atbrakhi <atbrakhi@igalia.com> * Some miscellaneous fixes Signed-off-by: Martin Robinson <mrobinson@igalia.com> * remove redundant defination of `containing_block_inline_size` Signed-off-by: atbrakhi <atbrakhi@igalia.com> --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Allow breaking line after space with `white-space: break-spaces` (#33376)Oriol Brufau2024-09-101-4/+3
| | | | | | | | | | | | | | `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>
* Fix reordering of table-header-group and table-footer-group (#33383)Oriol Brufau2024-09-091-63/+66
| | | | | | | | | | | | | | | 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>
* layout: Implement proper absolute child position for flexbox (#33346)Martin Robinson2024-09-0910-228/+404
| | | | | | | | | | | This implements the requirements outlined in the [flexbox specification] about how to position absolute children of flex containers. We must establish a static position rectangle (to use if all insets are auto) and also align the child into that rectangle. [flebox specification]: https://drafts.csswg.org/css-flexbox/#abspos-items Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Remove unused imports (#33371)Oriol Brufau2024-09-092-3/+3
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* tidy: Fix rustdoc warnings and add a tidy check for a common URL issue (#33366)Martin Robinson2024-09-084-11/+10
| | | | | | | | This change fixes all rustdoc errors and also adds a tidy check for a very common rustdoc URL issue. Eventually rustdoc warnings should likely cause the build to fail, but this catches those issues sooner in order to not waste so much developer time. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Do not use orthogonal baselines in flex layout (#33347)Martin Robinson2024-09-072-28/+43
| | | | | | | | | 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>
* layout: Lay out absolutes in atomic containing blocks (#33336)Martin Robinson2024-09-061-9/+17
| | | | | | | | | | When inline atomics establish containing blocks for absolute descendants, layout should happen with those atomics as the containing block. This ensures that the absolute descendents have the correct containing block and Fragment parent. This wasn't happening before and this change fixes that. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Treat `align-self: normal` as `stretch` on flex items (#33314)Oriol Brufau2024-09-051-1/+2
| | | | | | According to https://drafts.csswg.org/css-align/#align-flex It was being treated as `auto` instead. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix intrinsic sizing of column flex containers (#33299)Oriol Brufau2024-09-041-5/+3
| | | | | | | | | | | From https://drafts.csswg.org/css-flexbox-1/#intrinsic-cross-sizes, > The min-content/max-content cross size of a single-line flex container > is the largest min-content contribution/max-content contribution > (respectively) of its flex items. We were using the min/max-content size instead of the min/max-content contribution. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix various issues with replaced elements in flex layout (#33263)Oriol Brufau2024-08-308-187/+331
| | | | | | | | In particular, this takes into account that flex items may be stretched, and if they have an aspect ratio, we ma6y need to convert the stretched size through the ratio. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Use the proper aspect ratio in flexbox (#33256)Oriol Brufau2024-08-302-28/+20
| | | | | | | | | | 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>
* Fix automatic minimum size for column flexbox (#33248)Oriol Brufau2024-08-291-3/+10
| | | | | | | `main_content_size_info()` was always assigning the main-axis automatic minimum size into the inline axis. But in a column flexbox, the main axis corresponds to the block axis. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Handle aspect ratios in `ReplacedContent::inline_content_sizes` (#33240)Oriol Brufau2024-08-293-24/+39
| | | | | | | We were only handling the aspect ratio of a replaced element when computing its min/max-content contribution, but not when computing the min/max-content size. Now both cases will take it into account. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Stop using `unicode-segmentation` in layout (#33250)Martin Robinson2024-08-292-4/+4
| | | | | | | `layout` already uses `icu_segmentation` so there's no need to pull in another segmenter. This reduces the number of segmenters used in the crate to 2 from 3. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Add an indefinite containing block for intrinsic sizing (#33204)Oriol Brufau2024-08-2912-297/+572
| | | | | | | | | | | | | | | | | | 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>
* Obey min and max cross sizes of flex items (#33242)Oriol Brufau2024-08-291-1/+6
| | | | | | | | 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>
* Obey `min-block-size` and `max-block-size` in floats (#33241)Oriol Brufau2024-08-291-1/+1
| | | | | We were using the unclamped `box_size.block` instead of `block_size`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Bump xi_unicode to latest version (#33246)Jonathan Schwender2024-08-291-1/+1
| | | | | | | | | | | | | | | | | | * Bump xi_unicode to latest version Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> * dep: update XI_LINE_BREAKING_CLASS_ZWJ constant to 42 This matches the value returned by xi-unicode's linebreak_property for `u200D` codepoint in v0.3.0 of the crate. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> --------- Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* layout: Add initial support for `clip-path: [<basic-shape> || <shape-box>]` ↵Chocolate Pie2024-08-284-24/+373
| | | | | | | | | | | | | | | | | | | | | (#33107) * Turn on clip-path tests and add results Signed-off-by: Martin Robinson <mrobinson@igalia.com> * enhance: Add support for `clip-path: [<basic-shape> || <shape-box>]` Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> * Changes from review Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Fix clippy wanings in layout (#33215)atbrakhi2024-08-273-7/+4
| | | Signed-off-by: atbrakhi <atbrakhi@igalia.com>
* Allow creating a `ContentSizes` from `Au` (#33208)Oriol Brufau2024-08-274-36/+21
| | | | | No change in behavior, it just simplies some code a little bit. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Allow caching `IndependentFormattingContext::inline_content_sizes()` (#33207)Oriol Brufau2024-08-271-3/+1
| | | | | | | | | | | | For non-replaced formatting contexts, this method redirected directly to `NonReplacedFormattingContextContents::inline_content_sizes()`, which has the actual logic for the computation. Thus it was bypassing the cache, which is handled in `NonReplacedFormattingContext::inline_content_sizes()`. Therefore, this patch redirects to the latter. Signed-off-by: Oriol Brufau <obrufau@igalia.com>