Commit graph

889 commits

Author SHA1 Message Date
Steven Novaryo
3b3db37f16
layout: Fix CSS attr() function case sensitivity matching (#34574)
Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
2024-12-13 17:29:52 +00:00
Oriol Brufau
681d7dca9b
Use inline-start/inline-end instead of left/right terminology for floats (#34608)
It was a bit confusing that e.g. a float with `FloatSide::InlineStart`
would set `FloatBand::left`, or that `PlacementAmongFloats` would
compute `max_inline_start` from the various `FloatBand::left`.
So now all the float logic will consistently use logical terminoligy.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-13 16:37:35 +00:00
Oriol Brufau
f7e2ec3a0f
Distinguish cached inline_content_sizes() from uncached ones (#34595)
Several structs and enums had a `inline_content_sizes()` method, but it
wasn't clear which ones would try to cache the result, and which ones
would always compute it.

Therefore, this performs some clarifying renaming:
 - Cached ones stay as `inline_content_sizes()`
 - Uncached ones become `compute_inline_content_sizes()`

Also, to simplify calls to `LayoutBoxBase::inline_content_sizes()`,
`compute_inline_content_sizes()` is moved into a new trait.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-12 15:39:51 +00:00
Oriol Brufau
874e106924
Fix block size of containing block established by table rows (#34596)
Due to a typo, the containing block established by a table row for the
table cells had its block size set to the its inline size. However,
this block size is currently unused, so no change in behavior.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-12 15:13:56 +00:00
Dmitrii Desiatkin
5cb75a84a3
layout: Fix ordering of padding, border, and margin in inline BiDi (#34572)
* [fix](inline flow): Create PBM items in inline context in propper visual order

Signed-off-by: Desiatkin Dmitrii <d.desyatkin@innopolis.university>

* Rename left/right pbm terms in inline layout to logical nomenclature

 - LineItem::LeftInlineBoxPaddingBorderMargin(_) is renamed to
   LineItem::InlineStartBoxPaddingBorderMargin(_)
 - LineItem::RightInlineBoxPaddingBorderMargin(_) is renamed to
   LineItem::InlineEndBoxPaddingBorderMargin(_)
 - LineLayoutInlineContainerFlags::HAD_LEFT_PBM is renamed to
   LineLayoutInlineContainerFlags::HAD_INLINE_START_PBM
 - LineLayoutInlineContainerFlags::HAD_RIGHT_PBM is renamed to
   LineLayoutInlineContainerFlags::HAD_INLINE_END_PBM

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Update test expectations

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Desiatkin Dmitrii <d.desyatkin@innopolis.university>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-12-12 14:39:50 +00:00
Oriol Brufau
acf0074f8a
Share more code for non-replaced float-avoiding blocks (#34585)
Block-level elements that establish an independent formatting context
(or are replaced) need to avoid overlapping floats.

In the non-replaced case, we have two different subcases, depending on
whether the inline size of the element is known. This patch makes them
share more logic.

Then `solve_clearance_and_inline_margins_avoiding_floats()` would only
be used in the replaced case, so it's removed, inlining its logic.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-12 12:53:44 +00:00
Nico Burns
c0703b605d
Remove taffy-specific layout caching (#34589)
Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-12-12 09:35:03 +00:00
Mukilan Thiyagarajan
7fcde1f7a3
build: upgrade rustc to 1.81.0 (#34270)
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-12-12 07:26:16 +00:00
Nico Burns
84c59e09b6
Deduplicate taffy layout pbm computation (#34587)
Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-12-12 01:45:40 +00:00
Oriol Brufau
41e3c321e5
Make sure to cache inline_content_sizes() (#34586)
The refactoring in 264c0f972f stopped
caching the `inline_content_sizes()` calls from:
- `FlexItemBox::layout_for_block_content_size()`
- `IndependentFormattingContext::layout_float_or_atomic_inline()`
- `TaffyContainerContext::compute_child_layout()`

Also, the call from `OutsideMarker::layout()` was never cached.

This patch caches all of them.

It's not clear at all which `inline_content_sizes()` are cached and
which aren't, so I plan to improve the situation in a follow-up.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-12 01:37:05 +00:00
Martin Robinson
9d11d584f6
layout: Clean up inline layout data types a bit (#34563)
- Remove the `LayoutBox::InlineBox` variant that was only used for
  inline level boxes. Now they are stored in `LayoutBox::InlineLevel`
  along with other kinds of out-of-flow and atomic inline items.
- Reduce the size of `InlineItem` by 260 bytes per item by using atomic
  indirection / pointers. This adds a bit of overhead to access items in
  exchange for a lot of memory saved.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-12-11 14:40:34 +00:00
Martin Robinson
f1b8d49e77
layout: Make a new ContainingBlockSize type (#34565)
This might make caching these values a bit easier in the future.
Correcting the visibility of `ContainingBlock` also exposed some new
rustc and clippy warnings that are fixed here.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-12-11 14:40:04 +00:00
Oriol Brufau
e10e989abb
Don't transfer indefinite height: stretch to inline axis (#34557)
Consider this testcase:
```html
<canvas style="aspect-ratio: 1; height: stretch; background: cyan"
        width="200" height="100"></canvas>
```

To compute the intrinsic inline sizes we were treating `height: stretch`
as the natural height (100px) and then transferring that to the inline
axis through the preferred aspect ratio. So the element was 100px wide.

However, an indefinite `stretch` should be treated as an automatic size,
which wouldn't be transferred to the inline axis.

The fix actually makes the code slightly simpler.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-10 11:12:28 +00:00
Martin Robinson
f5fdbd70d0
layout: Have SameFormattingContextBlock be a LayoutBoxBase (#34530)
This allows `SameFormattingContextBlock` to cache inline content sizes
and will eventually allow it to participate in incremental layout.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-12-09 06:57:15 +00:00
Martin Robinson
1b1a4eca55
layout: Add LayoutBox to TableSlotCell (#34513)
This allows cells to cache their inline content size and will eventually
allow them to participate in incremental layout.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-12-08 08:54:40 +00:00
Martin Robinson
264c0f972f
layout: Add LayoutBoxBase and use it for IndependentFormattingContext (#34507)
Add a new struct `LayoutBoxBase`, that will be used throughout the box
tree. The idea of this struct is that we have a place to consistently
store common layout information (style and node information) and also to
cache layout results such as content sizes (inline and maybe later box
sizes) and eventually layout results.

In addition to the addition of this struct,
`IndependentFormattingContext` is flattened slightly so that it directly
holds the contents of both replaced and non-replaced elements.

This is only added to independent formatting contexts, but will later be
added to all block containers as well.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-12-07 19:12:25 +00:00
Oriol Brufau
61ca2dde29
Upgrade Stylo to 2024-12-04 (#34501)
* Upgrade Stylo to 2024-12-04

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

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

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Update test expectations

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-06 01:05:54 +00:00
Oriol Brufau
5201c84fb4
Fix stretch sizes on replaced abspos (#34430)
We were sizing absolutely positioned replaced elements within their
actual containing block instead of the inset-modified containing block.
Then the `stretch` keyword would result in a wrong size.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-05 20:45:20 +00:00
tanishka
bba3bc6ac2
layout: Add missing support for some alignment keywords on absolutely positioned elements (#34365)
* Add missing support for some alignment keywords on absolutely positioned elements

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Check the direction of the alignment container, nits, test expectations

In this case we need to check the direction of the static position
containing block, not the actual containing block:
```html
<!DOCTYPE html>
<div style="position: relative">
  <div style="display: flex; flex-direction: column; width: 100px; height: 100px; border: solid; direction: rtl">
    <div style="position: absolute; width: 20px; height: 20px; background: cyan; top: 20px; align-self: self-start"></div>
    <div style="position: absolute; width: 20px; height: 20px; background: magenta; bottom: 20px; align-self: self-end"></div>
  </div>
</div>
```

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-12-05 11:33:09 +00:00
Oriol Brufau
0be5209003
Improve performance of flex column layouts by caching (#34461)
* Obey min and max properties when computing main size of column flex

When laying out a column flex container with an auto preferred main size,
we were resolving the used main size to the intrinsic max-content size.
However, we weren't clamping this amount between the min and max sizes.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Improve performance of flex column layouts by caching

We were already using a cache for layout_for_block_content_size(), but
we were only storing the intrinsic block size. Thus when laying out the
flex items for real, we would perform new layouts, triggering an
exponential complexity in case of nested flexboxes.

Now we cache the entire layout result so that we can avoid doing the
work again.

This improves the results of flexbox-deeply-nested-column-flow.html
(a Blink perf test) from ~40 runs/second to ~500 runs/second on my PC.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-12-03 12:35:24 +00:00
Oriol Brufau
ad448da7de
Obey min and max properties when computing main size of column flex (#34450)
When laying out a column flex container with an auto preferred main size,
we were resolving the used main size to the intrinsic max-content size.
However, we weren't clamping this amount between the min and max sizes.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-12-02 22:14:54 +00:00
Oriol Brufau
888a93af47
Refactor AbsoluteAxisSolver (#34443)
`AbsoluteAxisSolver::solve()` would compute, among other things, the
position of the absolute positioned element if it had start alignment.
Then, `AbsoluteAxisSolver::origin_for_alignment_or_justification()`
could optionally opt into modifying that alignment if needed.

This was quite convoluted and not easy to follow. It's simpler to not
compute the position in `AbsoluteAxisSolver::solve()`, and instead do it
always in `AbsoluteAxisSolver::origin_for_alignment_or_justification()`,
which I'm renaming to `AbsoluteAxisSolver::origin_for_margin_box()`
because it aligns the margin box of the abspos within its alignment
container.

Then the `Anchor` struct becomes useless and can be removed.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-12-02 12:49:00 +00:00
Oriol Brufau
f2b5f515d7
Fix alignment of abspos child of flexbox with flipped direction (#34426)
The containing block for the static position of an absolutely positioned
element in flex layout is established by the flex container. However, if
the flex container has static position, the actual containing block will
be established by another ancestor.

If the flex container and the containing block have different directions,
the static position needs especial handling when aligning the abspos.
We were already trying to do so with the `flip_anchor` flag, but there
were bugs.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-30 14:25:10 +00:00
Oriol Brufau
19a7e95a6a
Refactor computation of preferred aspect ratios (#34416)
* Refactor computation of preferred aspect ratios

Computing min/max-content sizes required a ContainingBlock in order to
resolve the padding and border when determining the preferred aspect
ratio. However, all callers already knew the padding and border, so they
can compute the ratio themselves, and pass it directly instead of
the ContainingBlock.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Put preferred aspect ratio into ConstraintSpace

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-29 11:40:52 +00:00
tanishka
16da1c2721
Ensure taffy uses margin when calling used_size_as_if_inline_element_from_content_box_sizes() (#34421)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
2024-11-28 19:20:39 +00:00
Oriol Brufau
a37ccc3e64
Use natural ratio for object-fit (#34413)
We were using the preferred aspect ratio provided by the `aspect-ratio`
property instead of the natural aspect ratio. However, the preferred
aspect ratio should only be used to size the replaced element. To paint
the replaced contents into that element we need the natural ratio.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-28 12:57:38 +00:00
Delan Azabani
d65a2e9797
Additional tracing for flex layout, inline layout, and fonts (#34392)
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2024-11-27 02:44:06 +00:00
Oriol Brufau
d034385f76
Use an AtomicRefCell instead of a RwLock for caching intrinsic sizes (#34384)
It panics if the value is mutably borrowed concurrently, but this allows
it to perform better.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-26 13:35:41 +00:00
Nico Burns
63793ccbb7
Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo (#34353)
* Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix OpenHarmony build

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-11-25 23:42:04 +00:00
Nico Burns
97154d9cf8
Avoid laying out grid items and generating fragments if only inline size is requested (#34352)
* Layout: Short-circuit grid item layout if only inline size is requested

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Layout: Avoid creating grid item fragments if only size is requested

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-11-25 21:32:52 +00:00
Oriol Brufau
ba061ec2b0
Refine logic for laying out flex item in column layout after #34346 (#34372)
- Clamp the stretch size to not be negative when the sum of padding,
  borders and margins exceed the available space. This avoids a 2nd
  layout.
- Avoid computing the inline content sizes if the result isn't needed.
- Instead of clamping both the min-content and max-content sizes to be
  between the min and max constraints, just compute the fit-content size
  first, and then clamp. Then `ContentSizes::map()` can be removed.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-25 16:17:54 +00:00
Jonathan Schwender
810a91ecac
Remove some unused dependencies (#34355)
* Remove unused deps

This doesn't seem to remove any deps from the workspace.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* ohos: Remove gaol dependency

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2024-11-25 10:29:58 +00:00
Martin Robinson
c11e0e8e70
layout: Add a hit test item that covers all scroll frame contents (#34347)
When building scroll frames, add a special
`StackingContextContent::Fragment` type for a hit test that covers all
scroll frame contents. This makes it so that you don't have to be
hovering over actual content to scroll the scroll frame.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-11-24 19:04:57 +00:00
Nico Burns
9542466b31
Remove unnecessary clone in layout (#34350)
Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-11-23 01:22:40 +00:00
Oriol Brufau
f943ba023a
Improve performance of column flexboxes (#34346)
If a flex item in a single-line column flex container stretches, then
we can know its final size. So instead of first laying it out using its
intrinsic inline size, and then stretching it later, we can use the
correct size from the very beginning.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-11-22 22:52:47 +00:00
Nico Burns
6cbd89dbb0
Layout: Implement CSS Grid using taffy (#32619)
* Add layout.grid.enabled pref

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Add taffy dependency

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Import taffy <-> stylo conversion code from taffy_stylo crate

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Add `Grid` variant to DisplayInside

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Implement CSS Grid using Taffy

Signed-off-by: Nico Burns <nico@nicoburns.com>

Import full stylo_taffy crate

Signed-off-by: Nico Burns <nico@nicoburns.com>

Squashed PR feedback changes

Deduplicate is_document_only_whitespace

Signed-off-by: Nico Burns <nico@nicoburns.com>

Import taffy::AvailableSpace

Signed-off-by: Nico Burns <nico@nicoburns.com>

Rename FlexContext to TaffyContainerContext

Signed-off-by: Nico Burns <nico@nicoburns.com>

Eliminate references to flexbox in taffy/layout module

Signed-off-by: Nico Burns <nico@nicoburns.com>

Use constructors for geom types

Signed-off-by: Nico Burns <nico@nicoburns.com>

Remove comment about abspos elements splitting contiguous text runs

Signed-off-by: Nico Burns <nico@nicoburns.com>

Remove reference to flexbox in taffy/construct

Signed-off-by: Nico Burns <nico@nicoburns.com>

Deduplicate construction of flexbox/grid containers

Signed-off-by: Nico Burns <nico@nicoburns.com>

Make anonymous text runs InFlow

Signed-off-by: Nico Burns <nico@nicoburns.com>

Remove commented code

Signed-off-by: Nico Burns <nico@nicoburns.com>

Update comments

Signed-off-by: Nico Burns <nico@nicoburns.com>

Inline/vendor the stylo/taffy interop code

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Update test expectations

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix nits from PR review

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-11-21 20:21:01 +00:00
Oriol Brufau
97f53021b1
Upgrade Stylo to 2024-11-01 (#34322)
* Upgrade Stylo to 2024-11-01

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

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

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

* Update test expectations

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-21 15:14:45 +00:00
Oriol Brufau
138ec6d0ec
Remove the containing_block parameter from TableLayout::layout_caption (#34297)
It was only used for the style, but the containing block of the caption
is the table wrapper box, whose style is stored in `self.table.style`.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-20 16:24:00 +00:00
Delan Azabani
caf2467649
Set all tracing spans to trace level for now (#34256)
* Clean up tracing instrumentation

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Set all tracing spans to trace level for now

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
2024-11-19 02:53:43 +00:00
Oriol Brufau
8c689aac67
Fix min/max-content block size of replaced element (#34284)
The min-content and max-content sizes on the block axis depend on the
inline size. But when computing the SizeConstraint corresponding to the
inline axis, we were resolving the preferred inline size ignoring
intrinsic keywords. Now we will only ignore `auto`.

Also, this patch refactors the logic to compute the min-content and
max-content block sizes after fully resolving the inline size.
This avoids having to resolve the inline sizing properties twice.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-18 22:04:57 +00:00
tanishka
11dfbd6f90
layout: Use Size::FitContent when the alignment isn't normal or stretch for absolutely positioned elements (#34264)
* layout: Use Size::FitContent when the alignment isn't normal or stretch

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Use unwrap_or_default()

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Use self.alignment.value()

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Refactor used_size to handle non-definite sizes

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Include AlignFlags::Auto

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Update test expectations

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
2024-11-18 15:06:23 +00:00
Nico Burns
6955950948
Fix offsetLeft/offsetTop to match major browsers (#32761)
* Fix offsetLeft/offsetTop to match major browsers

See: https://github.com/w3c/csswg-drafts/issues/10549
Signed-off-by: Nico Burns <nico@nicoburns.com>

Fix crash when <html> element is absolutely positioned

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Update test expectations

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Update test expectations again

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Use PhysicalRect and PhysicalVec types

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Use is_some_and

Signed-off-by: Nico Burns <nico@nicoburns.com>

* clippy

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Apply comment changes from code review

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-11-16 15:28:38 +00:00
Oriol Brufau
557a0ceb89
Protect against arithmetic underflow in TableBuilder::current_y() (#34247)
It doesn't seem like any web page could trigger the underflow,
but this makes the code more robust.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-14 16:03:39 +00:00
chickenleaf
91f96cc9dd
Support justify-self on absolutely positioned elements (#34235)
* Support justify-self on absolutely positioned elements

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* updating test expectations

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
2024-11-13 14:14:44 +00:00
Oriol Brufau
9102644470
Use a RwLock to cache inline_content_sizes() (#34232)
In order to support size keywords in block layout, we may need to call
`inline_content_sizes()` in order to compute the min/max-content sizes.
But this required a mutable reference in order the update the cache,
and in various places we already had mutable references.

So this switches the cache into a RwLock to avoid needing mutable refs.
Note OnceCell wouldn't work because it's not thread-safe.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-13 09:56:02 +00:00
Oriol Brufau
bf75f17348
Add BoxFragment::is_inline_box() (#34233)
A helper function to check for inline boxes.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-12 15:50:20 +00:00
Oriol Brufau
6a62d52cbb
Use LazyCells instead of callbacks when resolving size keywords (#34211)
In most cases we already had a LazyCell anyways, since we could need the
value for multiple properties. Instead of passing a callback that forces
the evaluation of the LazyCell, it's simpler to just pass the LazyCell
directly.

Also, this way we no longer need mutable references.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-11 16:26:20 +00:00
Oriol Brufau
b28260aa13
Fix inline content sizes of intrinsic element with indefinite block size (#34152)
To compute the min-content and max-content inline sizes of a replaced
element, we were only using the aspect ratio to transfer definite block
sizes resulting from clamping the preferred block size between the min
and max block sizes.

However, if the preferred block size is indefinite, then we weren't
transfering the min and max through the aspect ratio.

This patch adds a `SizeConstraint` enum that can represent these cases,
and a `ConstraintSpace` struct analogous to `IndefiniteContainingBlock`
but with no inline size, and a `SizeConstraint` block size.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2024-11-11 11:38:19 +00:00
Martin Robinson
f4cc20f7ef
layout: Fix caching of streching flex items in row flex (#34162)
When a flex item stretches in the cross axis in a row flex, the flex
container layout should depend on block constraints. In this case the
cross axis is the block axis (assuming horizontal writing modes --
vertical are not yet supported). This changes fixes an issue where the
cached layout was used in this case when stretching should trigger a new
layout.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-11-08 16:59:23 +00:00
atbrakhi
85a9ca7cb6
layout: Add instrumentation for display_list (#34128)
* Add instrumentation for display_list

Signed-off-by: atbrakhi <atbrakhi@igalia.com>

* review update

Signed-off-by: atbrakhi <atbrakhi@igalia.com>

* review fix

Signed-off-by: atbrakhi <atbrakhi@igalia.com>

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2024-11-08 09:05:07 +00:00