Commit Graph

624 Commits

Author SHA1 Message Date
Olivier FAURE 6f111233d7
Add comment in accessibility pass (#704) 2024-10-21 12:23:18 +00:00
Olivier FAURE ed5c141701
Reorganize top-level Masonry modules (#703) 2024-10-21 12:18:30 +00:00
Olivier FAURE 7fef215fb0
Update test-related documentation (#698) 2024-10-21 10:05:32 +00:00
Daniel McNab 38415d65ca
Don't use full tracing spans in full-tree passes by default (#687)
This can be toggled using the `MASONRY_TRACE_PASSES` environment
variable.

This is as-discussed in [#xilem > Scrolling is insanely
laggy](https://xi.zulipchat.com/#narrow/channel/354396-xilem/topic/Scrolling.20is.20insanely.20laggy).
There are a few overlapping issues, but this *significantly* improves
performance in debug mode.

The main pass which was problematic was the compose pass, however this
also had a significant impact on the time taken by the
accessibility/paint passes.

This only applies to the passes which traverse the entire tree, so not
the targeted passes. I also chose to exclude update_disabled and
update_stashed, as those will not necessarily happen to all widgets.

This also significantly reduces the size of the created log files - see
[#masonry > Heavy amounts of logs with large
app](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Heavy.20amounts.20of.20logs.20with.20large.20app).
In most cases, if you're using the log file, you will be in development,
which means that you can hopefully recreate the issue with the logging
for the passes you need enabled.
2024-10-21 09:51:34 +00:00
Bruce Mitchener 771eb2f02f
ci: Update Rust stable version and typos-cli (#700) 2024-10-21 00:53:30 +00:00
Olivier FAURE 4d20e0dd19
Merge StatusChange with Update (#697) 2024-10-20 17:15:18 +00:00
Olivier FAURE f403337219
Implement fixpoint loop in run_rewrite_passes (#696)
This implements the last feature from the Pass Specification RFC 🎉
2024-10-20 17:12:18 +00:00
Olivier FAURE 40d1987161
Make passes that affect accesskit nodes request an accessibility pass (#692) 2024-10-20 16:38:14 +00:00
Olivier FAURE d5f28ba2de
Refactor away some redundant methods in RenderRoot (#694) 2024-10-20 16:01:56 +00:00
Philipp Mildenberger 4817f24e86
Clippy pass, cosmetic fixes, and `rust-version.workspace=true` for web examples (#689)
Phew, fixing (future) clippy-lints is grunt-work (I enabled
`unnameable_types` for this), this is by far not complete, mostly
xilem-side, but at least a small step towards enabling more of our lint
set.

There's a few "drive-by fixes" like hiding `View::ViewState` types in
Xilem (I don't think we generally want to expose these), or exposing
event types in xilem_web.

I would suggest disabling the `allow_attributes_without_reason` lint for
now, so that we can update the rust version. I feel like adding comments
next to these is just unnecessary extra-work. I think adding more
reasons should probably be a separate pass, after a rust version update,
so that `#[allow(..., reason="")]` is supported.
2024-10-20 15:57:22 +00:00
Olivier FAURE 9ccc0f9e59
Remove bitrotted comment (#695)
See discussion in #666
2024-10-20 15:11:44 +00:00
Olivier FAURE 7f0ccb8c1f
Tweak comment on anim method (#693) 2024-10-20 15:05:06 +00:00
Olivier FAURE 3d8c7950e4
Reorder imports across project (#690)
Split off from #637.
2024-10-20 14:54:13 +00:00
Olivier FAURE ef5d9afec3
Rename `RenderRoot::state` to `global_state` (#691) 2024-10-20 14:46:46 +00:00
Daniel McNab 2832766eff
Remove the dead `links` field from TextLayout (#686)
cc for awareness @mwcampbell.

That field was dead code left behind when we removed previous links
support. On that struct is probably not the right field for links to
live, since `Label` also uses `TextLayout`, but can't meaningfully
support links as part of a different interactive widget.
2024-10-18 12:41:31 +00:00
Daniel McNab 86604b7a74
Remove potential interactivity from `Label` (#683)
The whole reason the Label widget exists is as a non-interactive text
holder for higher-level widgets. Therefore, it isn't meaningful for it
to have interactivity.
2024-10-18 09:53:54 +00:00
Olivier FAURE d01652ddc7
Create on_anim method (#678)
This marks animation as something that's somewhere between an event
(it's triggered externally, it can't be requested synchronously as part
of rewrite passes) and an update (it takes the same context type, and
isn't tied to a user interaction).
2024-10-17 12:42:46 +00:00
Olivier FAURE dc9a2e2a97
Rename lifecycle to update (#677) 2024-10-17 12:09:14 +00:00
Olivier FAURE cdda9b542d
Only send ImeMoved signal for focused text input (#684) 2024-10-17 12:06:28 +00:00
Olivier FAURE f4848ce937
Add missing_trait_methods lints to test helper widgets (#679) 2024-10-17 12:01:39 +00:00
Philipp Mildenberger bad934b21a
xilem: Change `View::rebuild` to not return the element, and cleanup imports and `Mut` (#681)
It's possible to avoid returning the `ViewElement::Mut` in
`View::rebuild`, while having access to the element *after* a child view
was rebuilt.

This PR removes that again making the signature a little bit cleaner,
and also cleans up a lot of other stuff:
* `Mut<'_, Self::Element>` can be shortened to `Mut<Self::Element>`
* `use xilem::core::*` instead of `use xilem_core::*`, this is
especially useful in the examples, to avoid newcomers giving the
impression, that an additional dependency xilem_core is needed.
* Various cosmetic stuff, like one typo fix, empty line between
doc-comment (as (nightly) clippy currently bleats for me)

For more context see
https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/.E2.9C.94.20.60.26mut.20ViewElement.3A.3AMut.3C'_.3E.60.20in.20.60View.3A.3Arebuild.60.3F
2024-10-17 11:56:31 +00:00
Olivier FAURE 3ba0df6064
Reorder update passes (#674)
Reorder update passes so their code is in the same order as they're run.
Split out anim pass to a separate file (since it's not run with the
other passes).
This is strictly cut-and-paste, no code has been changed.
2024-10-16 16:44:30 +00:00
Olivier FAURE 17f5f24ff3
Remove debug_validate method (#676)
I'm pretty sure this method never caught a single bug.

I think the idea of a "safety net" that checks invariants are upheld by
passes (without trusting pass code) has merit, but it should be based on
a survey of previous bugs in pass code.
2024-10-16 15:21:14 +00:00
Olivier FAURE 1258a258cd
Rename pass functions from root_xxx to run_xxx_pass (#675)
This means all the pass functions now have the same naming convention,
which makes the code more grep-able.
2024-10-16 13:53:39 +00:00
Matt Campbell c73beee706
Accessibility for text (#615)
This adds the necessary AccessKit properties and child nodes to expose
detailed information about text widgets. It also supports the
`SetTextSelection` action.

---------

Co-authored-by: Olivier FAURE <couteaubleu@gmail.com>
2024-10-16 13:03:17 +00:00
Olivier FAURE f4a8b47587
Refactor safety rails for layout pass (#644)
Merge call_widget_method_with_checks, run_layout_inner and
run_layout_on.
Remove needs_visit flag.
Add checks for invalid values in place_child, set_child_translation and
run_layout.

---------

Co-authored-by: jaredoconnell <jared.oc321@gmail.com>
2024-10-15 16:25:46 +00:00
Olivier FAURE 9a6178b3d4
Add request_render context method (#660)
Remove some redundant request_paint calls

Fixes #585.
2024-10-15 16:18:47 +00:00
Olivier FAURE 1aab06ad52
Stop storing text in TextLayout (#666)
Remove type parameter from TextLayout.
Tweak error message in text widgets.

This makes the TextLayout code slightly simpler (though with more
invariants) in anticipation of splitting it into its own crate.
2024-10-15 16:09:53 +00:00
Olivier FAURE 6f8e3824fc
Handle signals in TestHarness (#650) 2024-10-15 16:08:08 +00:00
Bruce Mitchener cc32727e9d
docs: Fix some missing backticks. (#672) 2024-10-15 09:26:27 +00:00
Marco Melorio 634afd7010
Expose font weight parameter in label widget (#669) 2024-10-14 17:01:53 +00:00
Marco Melorio d74a7deea1
Update to Kurbo 0.11.1 (#671)
This allows to remove a TODO comment.
2024-10-14 16:27:40 +00:00
Olivier FAURE 4ad4506bc0
Remove register methods (#636)
Replace with `Widget::accepts_xxx()` methods
Tweak accessibility code
Remove `BuildFocusChain` event

Remove `WidgetState::is_portal`, `register_as_portal()`, and overall
remove the idea of a first-class "portal" concept.
2024-10-13 01:22:20 +00:00
Olivier FAURE a26bf11119
Add target field to EventCtx (#657)
Remove target field from AccessEvent
2024-10-13 01:21:52 +00:00
Richard Dodd 011929321e
update web-sys dep and fix deprecation warning (#668) 2024-10-12 15:41:29 +00:00
Olivier FAURE 76c808b454
Refactor rewrite passes (#639)
Create run_rewrite_passes function.
Remove redundant uses of synthetic WidgetState.
Small bugfixes.
Move RenderRoot::root_layout code into the layout pass. Rename
update_new_widgets pass to update_widget_tree.
2024-10-12 14:37:49 +00:00
Olivier FAURE 9899a700c7
Add needs_rewrite_passes and content_changed methods (#658)
These methods will be used with #639 to implement a fixpoint loop for
rewrite passes.

This also lets us remove `mark_changed`, since we can use
`content_changed` for the same purpose.
2024-10-12 13:33:55 +00:00
Olivier FAURE 72c1bd983d
Refactor Blur case of on_access_event pass (#643)
Match how tab focus works in on_text_event pass.
2024-10-11 13:45:22 +00:00
Philipp Mildenberger f5455d2686
xilem_web: Remove some comment artifacts, put `WithStyle` bound to `Element` interface and document `Element::style` (#667)
I missed comment artifacts in #621, added doc-comment/test for
`SvgElement` and put the `WithStyle` on the `Element` interface bounds,
as it plays better with rust-analyzer and is more consistent with the
other API.
2024-10-10 22:57:17 +00:00
Philipp Mildenberger a4f88b7d5c
xilem_web: Add `Rotate` and `Scale` (CSS) transform views (#621)
This sketches/implements (parts of) the transform modifier API described
in [Add `Affine` transform to `Widget`
trait?](https://xi.zulipchat.com/#narrow/stream/317477-masonry/topic/Add.20.60Affine.60.20transform.20to.20.60Widget.60.20trait.3F/near/472076600)
for xilem_web.

This currently includes `rotate` and `scale`, because there are less
cases to handle for these [CSS transform
functions](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function).
In `rotate` I think we can reduce this to just radians (there are more
units for `<angle>`: `turn`, `grad`, `deg` and `rad` (used here) but
they can all be derived from radians), and percent in scale is kinda
redundant (as `200%` == `2.0`)), for example `translate` has more cases
as it includes all kinds of units (like `px`, `em`, `%` etc.), so this
may require more thought (and is thus probably better for a future PR).

This can be combined with untyped `transform: ...` as style, these
modifier views extend the `transform` style (while the untyped
`style(..)` overwrites previous set values).

The `svgtoy` example is updated to include these views.
2024-10-10 17:44:47 +00:00
Olivier FAURE da92ba6cf0
Add TestHarness::animate_ms method (#661) 2024-10-09 14:01:28 +00:00
Olivier FAURE 6589ac343d
Remove masonry/src/text/reference (#665)
I'm pretty sure no-one has consulted these files in months. They're dead
code, and there's always source control if someone really needs them.
2024-10-09 13:23:27 +00:00
Olivier FAURE e9efc8cb18
Add RenderRoot::request_render_all method (#659)
Add a method which brute-force resets the paint and accessibility flags
for all widgets.
This is useful for rescale, and for testing purposes where you want a
quick and dirty way to repaint everything.
2024-10-09 09:59:44 +00:00
Olivier FAURE 63faaa4416
Add tests checking that pointer capture panics when used in wrong event (#652) 2024-10-09 09:57:40 +00:00
Olivier FAURE 337f7c774e
Make WidgetState private (#655)
This enforces a pattern in the codebase where that WidgetState can only
be accessed through pass contexts, which prevents invalidation bugs.
2024-10-09 09:53:59 +00:00
Olivier FAURE 1d3df8c493
Remove or split up some cruft comments (#662) 2024-10-09 09:33:57 +00:00
Olivier FAURE 0c1312563f
Add StashedChanged event (#649) 2024-10-09 09:31:59 +00:00
Olivier FAURE 801affd01e
Send synthetic PointerLeave event when pointer capture is lost (#647) 2024-10-09 09:31:48 +00:00
Olivier FAURE f6ad804ae6
Remove last mentions of hot state from code (#654) 2024-10-08 17:12:13 +00:00
Olivier FAURE c80605a2b4
Remove tracing boilerplate from widget code (#653)
Each widget implementation was doing its own bespoke tracing in layout.
This removes the bespoke tracing and adds a trace inside the layout pass
logging the same information in a more centralized way.
2024-10-08 16:34:45 +00:00