* janitor: Fix clippy error drop_copy
Clippy says cache_entry is Copy, so calling drop on it is useless since
it will drop a copied value.
* janitor: Fix clippy error
... about cloning a double ref.
Co-authored-by: Olivier Goffart <olivier@woboq.com>
This can be reproduced with this example:
```
import { TabWidget } from "std-widgets.slint";
App := Window {
preferred-width: 700px;
preferred-height: 500px;
HorizontalLayout {
side-bar := TouchArea {
property <int> current-item: 1;
clicked => { current-item = current-item == 0 ? 1 : 0 ; }
}
if(side-bar.current-item == 0) : TabWidget { }
}
}
```
With the native style. (click on the window, then resize)
This will result in a stack overflow, because we have a cycle in the
dependency graph and they are marked dirty forever.
The NativeTabWidget will create two way binding internally. And it will
be crated as a result of the layout cache property because that's when
the model will be evaluated and created. This will inatvertently create
a dependency between the layout cache property, and the two way link.
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
Olivier found the following steps that reproduce the crash with Skia:
1. Open the gallery and select the "Text Edit" tab.
2. In the first text edit widget, select the first three letters.
3. Click into the second text edit (while the first one shows the selected text)
4. At the beginning of the text, insert the letter "ù" a few times.
This sequence would result in the cursor_position property get out of
sync. Since it represents a byte offset in the utf-8 text, it would
point straight into a utf-8 sequence, resulting in a panic when the
renderer would try to create a slice of the selected text.
As a remedy, this patch renames the cursor_position and anchor_position
properties and provides wrapper getter accessors for use within the
TextInput to safely bound the stored offset.
Eventually we need to intercept changes to the text property and adjust
the cursor and anchor position properties accordingly, so that they
remain valid. However this requires that the compiler is aware that a
property is not accessible directly but has a setter that needs to be
called instead.
This likely/hopefully also fixes#1707.
We already checked before that we can flick in that direction
(horizontally or vertically), but we did not check that we were not
actually at the end already.
Bump fontdb, foreign-types (used for skia/metal), ttf-parser and winit.
The winit bump is explicit on the patch version to ensure the IME crash
fix is included.
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.
In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.
Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.
- On the web, to return the image size, we need to use the natural size
of the image, and not its dom size, as the later get modified since
commit b727aba4a0
- The target size did not take in account the image fit, that's because
former version of resvg could only render by respecting the aspect
ratio. But since the web don't have this limitation, we now need to
take it into account. And new version of resvg can also scale with
any aspect ratio
SVGs are rendered using HTML image elements, that are converted to textures.
The size of the texture defaults to the SVGs viewbox, which may be small - despite
it being possible to render the SVG at a higher resolution with great quality.
Similar to the native code path, this patch also uses the target image size
and propagates it to the DOM HTML image element to instruct the browser to
render the SVG at a higher resolution.
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
This avoids accidental use of logical pixels, esp. for SVG, elimiates
one call to `to_untyped()` as well as an untyped scale factor in the
femtovg renderer.
Known caveats:
- winit doesn't forward mouse events to the IME, so clicking
with the mouse while composing results in funny effects such
as the pre-edit text following the cursor.
- With FemtoVG there's no text decoration support, thus no underlining
of the preedit area.