in each layout logic, in order to correctly resolve sizing keywords.
This patch adds a new `Sizes` struct which holds the preferred, min and
max sizing values for one axis, and unifies the logic to resolve the
final size into there.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Include unimplemented console methods in idl file
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Fix console.assert signature
The condition is optional and there can be multiple messages.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Implement console.trace
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* ./mach fmt
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Log stack trace when calling console.trace
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Update wpt expectations
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Include line/column info in console.trace logs
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Move option out of constant
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Update mozjs
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Don't unnecessarily clone responses twice when sending them to devtools
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Store http response reason instead of inferring it later
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Update wpt expectations
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Consider:
```html
<div style="position: relative; width: 50px; height: 50px; border: solid; margin: 5px">
<div style="position: absolute; top: 0; bottom: 0; height: max-content">
<canvas width="25" height="25" style="background: cyan; height: 100%"></canvas>
</div>
</div>
```
In order to determine the inline min/max-content sizes, we need a
tentative block size as the input, which only takes extrinsic values
into account.
In this case `height: max-content` is intrinsic, so we were treating it
as `height: initial`, which would behave as a definite `height: stretch`.
Therefore, the canvas was able to resolve its percentage.
However, it seems weird to treat an explicitly intrinsic keyword in an
extrinsic way, and Blink doesn't do it. So now we treat the tentative
block size as indefinite, therefore the percentage behaves as auto.
This adds a new test, we were previously failing 6 subtests, now only 3.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Expose a new constructor on `HTMLCollection`, `new_with_filter_fn`, that
filters elements using a simple static function -- a common pattern.
This allows more easily creating this `HTMLCollection` without having to
create a new data structure. Since the constructor takes a static
function, no data should be captured preventing garbage collection
issues.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Post layout, when a `Window` has all of the new `<iframe>` sizes, size
any `Window`s for `Pipeline`s in the same `ScriptThread` synchronously.
This ensures that when laying out from the outermost frame to the
innermost frames, the frames sizes are set properly.
There is still an issue where a non-same-`ScriptThread` `<iframe>` sits
in between two `<iframe>`s of the same origin. According to the
specification these frames should all be synchrnously laid out --
something quite difficult in Servo. This is issue #34655.
This is the first change in a series of changes to improve the
consistency of `<iframe>` loading and sizing.
Fixes#14719.
Fixes#24569.
Fixes#24571.
Fixes#25269.
Fixes#25275.
Fixes#25285.
Fixes#30571.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
When servo is run in multiprocess mode, the content process receives
the preferences via IPC from the main process. However, currently
these preferences are only used to update Servo's own preferences by
explictly calling Preference::set_all(). This doesn't ensure that
stylo's copy of preferences is also updated.
This change replaces the call to `Preference::set_all()` with
call to `add_user_prefs` which does ensure both Servo's and Stylos'
preferences are updated.
Fixes#34660.
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
A reflow might still be necessary if it's necessary for display and the
reflow itself wasn't for display. After this happens a display becomes
necessary and the page is still dirty for layout purposes.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Adds support for min-content, max-content, fit-content and stretch,
for the case that was missing from #34568: block-level elements that
establish an independent formatting context, when there are floats.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Manage `<iframe>` size updates in `Window`. In addition to removing
duplicated code, this will allow setting `<iframe>` sizes synchronously
on child `Pipeline`s of the same origin in the script process in a
followup change. The goal is remove flakiness from `<iframe>` sizing.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Adds support for min-content, max-content, fit-content and stretch,
for block-level elements that don't establish an independent formatting
context, and for block-level elements when there is no float.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This eliminates the way that crossbeam channels are used to send layout
results back to script, which should increase the efficiency of layout.
If asynchronous layout is re-established it can be written as a layer on
top of the layout interface, that way layout doesn't have to know so
many details of how the asynchronocity works.
Renames:
- `ScriptReflow` to `ReflowRequest`: Script is the only thing that
requests reflow.
- `ReflowComplete` to `ReflowResult`
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
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>
These all happen now in *update the rendering*, typically after the
message that triggered this code is processed, though in two cases
reflow needs to be triggered explicitly. This makes `ReflowReason`
redundant though perhaps `ReflowCondition` can be expanded later to give
more insight into why the page is dirty.
- Handling of the "reflow timer" concept has been explained a bit more via
data structures and rustdoc comments.
- Theme changes are cleaned up a little to simplify what happens during
reflow and to avoid unecessary reflows when the theme doesn't change.
Notably, layout queries and scrolling still trigger normal reflows and
don't update the rendering. This needs more investigation as it's
unclear to me currently whether or not they should update the rendering
and simply delay event dispatch or only reflow.
In general, this is a simplfication of the code.
Fixes#31871.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
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>
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>
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>
* Fix deprecated PanicInfo alias
Fixes:
```rust
use of deprecated type alias `std::panic::PanicInfo`: use `PanicHookInfo` instead
```
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
* build: upgrade rustc to 1.82.0
Tracking issue for the silenced lints:
https://github.com/servo/servo/issues/34591
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
A rendering opportunity is now unconditionally triggered by handling IPC
messages in the `ScriptThread`, unless animations are running in which
case it's driven by the compositor. We can now remove calls to
`note_rendering_opportunity` and `rendering_opportunity`.
There is one tricky case, which is when a promise completion during a
microtask checkpoint dirties the page again. In this case we need to
trigger a new rendering opportunity, unless animations are running. In
a followup change, when not driven by the compositor, rendering
opportunities will be driven by a timed task, meaning we can remove this
workaround.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* respond to winit platform theme changed event and send it to the layout thread
Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
* refactoring viewport and theme change handling functions based on feedback
Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
* fixing issues reported by test-tidy
Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
* update stylo in order to use color_scheme function on Device
Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
---------
Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
Co-authored-by: lazypassion <25536767+lazypassion@users.noreply.github.com>
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>
* Make servodriver a thin wrapper over the base webdriver browser/executor classes.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Make ServoWebDriverRefTestExecutor a thin shell over the webdriver reftest executor.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Wait for the initial load to complete when opening a new tab via webdriver.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Remove assumption of a single tab from the webdriver server.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Serialize all keys of JS objects when converting to webdriver values.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Cleanup, docs, etc.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Use webview terminology more consistently.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix flake8 errors.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This removes two explicit calls to reflow to detect rAFs that do not
modify the DOM and to trigger reflows when the page isn't dirty. This
can cause extra reflows, especially when animations are running. This
change removes them, relying on *update the rendering* to properly
trigger reflows, shortly after running rAF callbacks and after
animations are updated.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
- 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>
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>
The `pending reflow` concept isn't necessary now that *update the
rendering* is taking care of triggering reflows at the correct time.
`Window::reflow` already avoids reflows if the page is not dirty, so
pending reflows is now just an extraneous check as long as *update the
rendering* runs properly.
This change also removes some explicit reflows, which now wait until the
appropriate moment during *update the rendering*. This should remove
some extra reflows that are not necessary.
Servo needs some way to track that resizing the web view needs to
re-layout due to the initial containing block changing. Move handling
of `Document::needs_paint` to the script thread and use this, expanding
the rustdoc to explain what it is for a bit more clearly.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Add traits to allow converting between types that are not defined in the script crate.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Rewrite all From/TryFrom implementations on generated WebIDL types to use new Convert/TryConvert traits.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
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>