Skip to content

Update to Parley 2025-03-25. #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 82 additions & 130 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,20 @@ tree_arena = { version = "0.1.0", path = "tree_arena" }
vello = "0.4.0"
wgpu = "23.0.1"
kurbo = "0.11.1"
parley = { version = "0.3.0", features = ["accesskit"] }
parley = { git = "https://github.com/linebender/parley", rev = "eabfb8175848183dde2516d562c6b7eab7f0df84", features = [
"accesskit",
] }
peniko = "0.3.1"
winit = "0.30.4"
winit = "0.30.9"
tracing = { version = "0.1.40", default-features = false }
smallvec = "1.13.2"
hashbrown = "0.15.2"
dpi = "0.1.1"
image = { version = "0.25.2", default-features = false }
web-time = "1.1.0"
bitflags = "2.6.0"
accesskit = "0.17.0"
accesskit_winit = "0.23.0"
accesskit = "0.18.0"
accesskit_winit = "0.24.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update means that we no longer support NativeActivity, an unfortunate regression. We panic at this code.
https://github.com/AccessKit/accesskit/blob/10f4bd1344b98ebb2baf969e62afdd767f5ff1d1/platforms/winit/src/platform_impl/android.rs#L31-L39. It looks like the non-support for NativeActivity is intentional here.

cc @mwcampbell what do you suggest doing in this case? Is there a no-op AccessKit winit backend we can use, or is the only solution to conditionally compile out the accessibility support on Android if we want to support Native Activity?

time = "0.3.36"

[profile.ci]
Expand Down
3 changes: 2 additions & 1 deletion masonry/src/event_loop_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ impl MasonryState<'_> {

let window = event_loop.create_window(attributes).unwrap();

let adapter = Adapter::with_event_loop_proxy(&window, self.proxy.clone());
let adapter =
Adapter::with_event_loop_proxy(event_loop, &window, self.proxy.clone());
let window = Arc::new(window);
// https://github.com/rust-windowing/winit/issues/2308
#[cfg(target_os = "ios")]
Expand Down
8 changes: 4 additions & 4 deletions masonry_core/src/app/render_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::{HashMap, VecDeque};

use accesskit::{ActionRequest, TreeUpdate};
use anymap3::AnyMap;
use parley::fontique::{self, Collection, CollectionOptions, SourceCache};
use parley::fontique::{self, Blob, Collection, CollectionOptions, SourceCache};
use parley::{FontContext, LayoutContext};
use tracing::{info_span, warn};
use tree_arena::{ArenaMut, TreeArena};
Expand Down Expand Up @@ -191,7 +191,7 @@ pub struct RenderRootOptions {
///
/// We expect to develop a much more fully-featured font API in the future, but
/// this is necessary for our testing of Masonry.
pub test_font: Option<Vec<u8>>,
pub test_font: Option<Blob<u8>>,
}

/// Objects emitted by the [`RenderRoot`] to signal that something has changed or require external actions.
Expand Down Expand Up @@ -428,12 +428,12 @@ impl RenderRoot {
/// added to that family.
pub fn register_fonts(
&mut self,
data: Vec<u8>,
data: Blob<u8>,
) -> Vec<(fontique::FamilyId, Vec<fontique::FontInfo>)> {
self.global_state
.font_context
.collection
.register_fonts(data)
.register_fonts(data, None)
}

/// Redraw the window.
Expand Down
1 change: 0 additions & 1 deletion masonry_core/src/passes/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ pub(crate) fn run_accessibility_pass(root: &mut RenderRoot, scale_factor: f64) -
nodes: vec![],
tree: Some(Tree {
root: root.root.id().into(),
app_name: None,
toolkit_name: Some("Masonry".to_string()),
toolkit_version: Some(env!("CARGO_PKG_VERSION").to_string()),
}),
Expand Down
5 changes: 3 additions & 2 deletions masonry_core/src/testing/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::collections::VecDeque;
use std::io::Cursor;
use std::num::NonZeroUsize;
use std::path::PathBuf;
use std::sync::Arc;

use cursor_icon::CursorIcon;
use dpi::LogicalSize;
Expand All @@ -31,7 +32,7 @@ use crate::core::{
use crate::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
use crate::kurbo::{Point, Size, Vec2};
use crate::passes::anim::run_update_anim_pass;
use crate::peniko::Color;
use crate::peniko::{Blob, Color};
use crate::testing::screenshots::get_image_diff;

/// A safe headless environment to test widgets in.
Expand Down Expand Up @@ -229,7 +230,7 @@ impl TestHarness {
env!("CARGO_MANIFEST_DIR"),
"/resources/fonts/roboto/Roboto-Regular.ttf"
));
let data = ROBOTO.to_vec();
let data = Blob::new(Arc::new(ROBOTO));

let mut harness = Self {
render_root: RenderRoot::new(
Expand Down
5 changes: 3 additions & 2 deletions xilem/examples/variable_clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! This example uses variable fonts in a touch sensitive digital clock.
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]

use std::sync::Arc;
use std::time::Duration;

use time::error::IndeterminateOffset;
Expand All @@ -15,7 +16,7 @@ use xilem::view::{
Axis, FlexExt, FlexSpacer, button, flex, inline_prose, label, portal, prose, sized_box, task,
variable_label,
};
use xilem::{EventLoop, EventLoopBuilder, FontWeight, WidgetView, Xilem, palette};
use xilem::{Blob, EventLoop, EventLoopBuilder, FontWeight, WidgetView, Xilem, palette};

/// The state of the application, owned by Xilem and updated by the callbacks below.
struct Clocks {
Expand Down Expand Up @@ -191,7 +192,7 @@ fn run(event_loop: EventLoopBuilder) -> Result<(), EventLoopError> {
};

// Load Roboto Flex so that it can be used at runtime.
let app = Xilem::new(data, app_logic).with_font(ROBOTO_FLEX);
let app = Xilem::new(data, app_logic).with_font(Blob::new(Arc::new(ROBOTO_FLEX)));

app.run_windowed(event_loop, "Clocks".into())?;
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion xilem/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::sync::Arc;

use masonry::app::{AppDriver, EventLoopProxy, MasonryState, MasonryUserEvent};
use masonry::core::WidgetId;
use masonry::peniko::Blob;
use masonry::widgets::RootWidget;

use crate::core::{DynMessage, MessageResult, ProxyError, RawProxy, ViewId};
Expand All @@ -19,7 +20,7 @@ pub struct MasonryDriver<State, Logic, View, ViewState> {
pub(crate) ctx: ViewCtx,
pub(crate) view_state: ViewState,
// Fonts which will be registered on startup.
pub(crate) fonts: Vec<Vec<u8>>,
pub(crate) fonts: Vec<Blob<u8>>,
}

/// The `WidgetId` which async events should be sent to.
Expand Down
6 changes: 3 additions & 3 deletions xilem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub use masonry::app::{EventLoop, EventLoopBuilder};
pub use masonry::kurbo::{Affine, Vec2};
pub use masonry::parley::Alignment as TextAlignment;
pub use masonry::parley::style::FontWeight;
pub use masonry::peniko::Color;
pub use masonry::peniko::{Blob, Color};
pub use masonry::widgets::{InsertNewline, LineBreaking};
pub use masonry::{dpi, palette};
pub use xilem_core as core;
Expand All @@ -174,7 +174,7 @@ pub struct Xilem<State, Logic> {
runtime: tokio::runtime::Runtime,
background_color: Color,
// Font data to include in loading.
fonts: Vec<Vec<u8>>,
fonts: Vec<Blob<u8>>,
}

#[expect(missing_docs, reason = "TODO - Document these items")]
Expand All @@ -198,7 +198,7 @@ where
/// Load a font when this `Xilem` is run.
///
/// This is an interim API whilst font lifecycles are determined.
pub fn with_font(mut self, data: impl Into<Vec<u8>>) -> Self {
pub fn with_font(mut self, data: impl Into<Blob<u8>>) -> Self {
self.fonts.push(data.into());
self
}
Expand Down