mod anchor;
mod viewport_layer;
pub use viewport_layer::ViewportPlacement;
#[cfg(feature = "conformance")]
pub mod conformance;
mod id;
pub use anchor::{
AnchorAlign, AnchorArrow, AnchorArrowPosition, AnchorPlacement, AnchorPosition, AnchorSide,
};
mod node_map;
pub use node_map::NodeMap;
mod collapse;
mod presence;
pub use presence::{
MAX_PRESENCE_MILLIS, PresenceConfig, PresenceEffect, PresenceStyle, PresenceTiming,
};
mod document;
pub use collapse::{CollapseConfig, MAX_COLLAPSE_MILLIS};
mod graphic;
mod graphic_transition;
pub use graphic::{
GraphicFit, GraphicPoint, GraphicProps, GraphicStroke, MAX_GRAPHIC_COMMANDS,
MAX_GRAPHIC_COORDINATE, PathCommand, StrokeCap,
};
pub use graphic_transition::GraphicTransition;
mod choice;
pub use choice::{ChoiceCommand, ComboboxKind, OptionSemantics};
mod context_menu;
mod tags;
pub use context_menu::{ContextEditPolicy, ContextPoint, ContextSource};
pub use tags::{
MAX_TAG_INPUT_BYTES, MAX_TAG_PASTE_BYTES, TagHostRejection, TagKey, TagSeparators, TagsCommand,
};
mod select;
pub use select::{
MAX_SELECT_BYTES, MAX_SELECT_GROUPS, MAX_SELECT_OPTIONS, SelectEntry, SelectGroup,
SelectOption, SelectProps, SelectSelection,
};
mod range;
pub use range::RangeValue;
mod progress;
pub use progress::ProgressValue;
mod motion;
pub use motion::{GraphicAnimation, MotionPreference};
mod translation;
pub use translation::{
MAX_TRANSLATION_COORDINATE, TranslationKind, TranslationMotion, TranslationOffset,
TranslationPhase,
};
pub mod memory;
mod plan;
pub mod profile;
mod props;
mod semantics;
pub use document::DocumentPart;
mod text;
pub use glory_style as style;
pub use id::{NodeId, NodeIds, RuntimeId};
pub use plan::{MAX_PLAN_NODES, Plan, PlanNode, WeakPlan};
pub use props::*;
pub use semantics::{
Current, Direction, DismissReason, FieldPart, FormAction, FormControl, Layer, LayerFocus,
LayerPlacement, LinkOpen, MenuItemKind, MenuItemSemantics, Orientation, PopupKind, SemanticId,
Semantics,
};
pub use text::normalize_text;
mod clipboard;
mod files;
pub use clipboard::{ClipboardOutcome, ClipboardText, MAX_CLIPBOARD_BYTES};
pub use files::{
FileCapabilities, FileChunk, FileConfig, FileDocumentId, FileEvent, FileFilter,
FileImageFormat, FileImageInfo, FileInfo, FileOrigin, FileOutcome, FilePreview,
FilePreviewError, FilePreviewLimits, FileProps, FileRead, FileRejection, FileToken,
MAX_FILE_BYTES, MAX_FILE_CHUNK_BYTES, MAX_FILE_COUNT, MAX_FILE_FILTER_BYTES, MAX_FILE_FILTERS,
MAX_FILE_HEADER_BYTES, MAX_FILE_METADATA_BYTES, MAX_FILE_MIME_BYTES, MAX_FILE_NAME_BYTES,
MAX_FILE_READS, MAX_PREVIEW_DIMENSION, MAX_PREVIEW_ENCODED_BYTES, MAX_PREVIEW_PIXELS,
inspect_file_preview,
};
mod keyboard;
pub use keyboard::{KeyboardCommand, KeyboardInput};
mod navigation_panel;
pub use navigation_panel::{NavigationPanel, NavigationPanelCommand};
mod grid;
pub use grid::GridCommand;
mod tree;
pub use tree::{TreeCheckState, TreeCommand, TreeItem, TreeNavigation};
mod scroll;
pub use scroll::{ScrollAxes, ScrollCommand, ScrollMetrics, ScrollMovement};
mod sheet;
pub use sheet::{MAX_SHEET_SNAPS, SheetCommand, SheetConfig};
mod slider;
pub use slider::SliderValue;
mod spinbutton;
pub use spinbutton::SpinValue;
mod input_assist;
pub use input_assist::{
InputAssist, InputAutofill, InputMode, MAX_INPUT_PLACEHOLDER_BYTES, validate_input_placeholder,
};
mod text_selection;
pub use text_selection::{SelectionDirection, TextSelection};
mod focus_scope;
pub use focus_scope::{FocusScopeConfig, MAX_FOCUS_SCOPE_NODES, MAX_FOCUS_SCOPES};
mod input_edit;
pub use input_edit::{
InputEdit, InputEditCapture, InputEditIntent, InputEditRejection, MAX_INPUT_EDIT_BYTES,
};
mod splitter;
pub use splitter::RangeCommand;
mod typeahead;
pub use typeahead::{MAX_TYPEAHEAD_MILLIS, validate_typeahead};
mod drag;
pub use drag::{DragCapture, DragPhase};
mod menu;
pub use menu::{MenuCommand, PointerPhase};
mod plot_pointer;
pub use plot_pointer::{
MAX_PLOT_POINTER_COORDINATE, PlotPointer, PlotPointerDevice, PlotPointerPhase,
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VirtualPart {
Root,
Surface,
Row,
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub enum Change<T> {
#[default]
Keep,
Set(T),
Clear,
}
impl<T: Default> Change<T> {
pub fn apply(self, target: &mut T) {
self.apply_or(target, T::default());
}
}
impl<T> Change<T> {
pub fn apply_or(self, target: &mut T, default: T) {
match self {
Self::Keep => {}
Self::Set(value) => *target = value,
Self::Clear => *target = default,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Mutation {
Create {
id: NodeId,
node: Box<Descriptor>,
},
CreatePlan {
plan: Plan,
ids: Vec<NodeId>,
},
Patch {
id: NodeId,
patch: Patch,
},
Place {
id: NodeId,
parent: Option<NodeId>,
before: Option<NodeId>,
},
Suspend {
id: NodeId,
},
Resume {
id: NodeId,
parent: Option<NodeId>,
before: Option<NodeId>,
},
Dispose {
id: NodeId,
},
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Capabilities {
pub clipboard_write: bool,
pub files: Option<FileCapabilities>,
pub measure: bool,
pub scroll: bool,
pub focus: bool,
pub input: bool,
pub collapse_completion: bool,
pub presence_completion: bool,
pub presence_transforms: bool,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct QueryToken(pub u64);
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Query {
RichSelection(NodeId),
FileRead(FileRead),
FilePreview(FileToken),
Bounds(NodeId),
Scroll(NodeId),
ScrollMetrics(NodeId),
Selection(NodeId),
Focus(NodeId),
}
impl Query {
pub fn node(self) -> NodeId {
match self {
Self::FileRead(read) => read.file.node,
Self::FilePreview(file) => file.node,
Self::RichSelection(id)
| Self::Bounds(id)
| Self::Scroll(id)
| Self::ScrollMetrics(id)
| Self::Selection(id)
| Self::Focus(id) => id,
}
}
pub fn validate_target<'a>(self, node: impl Into<DescriptorView<'a>>) -> Result<(), Error> {
let node = node.into();
if matches!(node.props, Props::Group) {
return Err(Error::Unsupported("group has no physical query target"));
}
if matches!(self, Self::RichSelection(_)) && !matches!(node.props, Props::RichEditor(_)) {
return Err(Error::Unsupported("rich selection requires a RichEditor"));
}
if let Self::FileRead(read) = self {
read.validate()?;
}
if let Self::FileRead(FileRead { file, .. }) | Self::FilePreview(file) = self {
file.validate()?;
let Props::File(props) = node.props else {
return Err(Error::Unsupported("file queries require a File control"));
};
if file.revision != props.revision {
return Err(Error::InputRevision {
current: props.revision,
incoming: file.revision,
});
}
if matches!(self, Self::FilePreview(_)) && props.configuration.preview.is_none() {
return Err(Error::Unsupported("file previews are not enabled"));
}
}
if matches!(self, Self::Selection(_)) && !matches!(node.props, Props::Input(_)) {
return Err(Error::Unsupported("selection requires a text input"));
}
Ok(())
}
pub fn validate_response(self, value: &QueryValue) -> Result<(), Error> {
match (self, value) {
(Self::FileRead(read), QueryValue::FileBytes(chunk)) => chunk.validate_read(read)?,
(Self::FilePreview(file), QueryValue::FilePreview(preview)) => {
if let Some(preview) = preview {
preview.validate()?;
if preview.file != file {
return Err(Error::InvalidResponse("file preview token mismatch"));
}
}
}
(Self::RichSelection(_), QueryValue::RichSelection(snapshot)) => snapshot.validate()?,
(Self::Bounds(_), QueryValue::Bounds(rect)) => {
if ![rect.x, rect.y, rect.width, rect.height]
.into_iter()
.all(f64::is_finite)
|| rect.width < 0.0
|| rect.height < 0.0
{
return Err(Error::InvalidResponse("invalid bounds"));
}
}
(Self::Scroll(_), QueryValue::Scroll { x, y }) => {
if !x.is_finite() || !y.is_finite() {
return Err(Error::InvalidResponse("invalid scroll offsets"));
}
}
(Self::ScrollMetrics(_), QueryValue::ScrollMetrics(metrics)) => metrics.validate()?,
(Self::Selection(_), QueryValue::Selection { start, end }) => {
if start > end {
return Err(Error::InvalidResponse("reversed selection"));
}
}
(Self::Focus(_), QueryValue::Focus(_)) => {}
_ => return Err(Error::InvalidResponse("query result kind mismatch")),
}
Ok(())
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Action {
PickFiles {
node: NodeId,
revision: u64,
request: u64,
},
ClearFiles {
node: NodeId,
revision: u64,
},
RemoveFile(FileToken),
CopyText {
node: NodeId,
revision: u64,
request: u64,
},
RaiseLayer(NodeId),
ScrollIntoView(NodeId),
SelectRich {
node: NodeId,
revision: u64,
selection: RichSelection,
},
SelectText {
node: NodeId,
revision: u64,
selection: TextSelection,
},
RevealOption {
node: NodeId,
},
ExitMenu {
node: NodeId,
backwards: bool,
},
Focus(NodeId),
ScrollTo {
node: NodeId,
x: f64,
y: f64,
},
}
impl Action {
pub fn node(self) -> NodeId {
match self {
Self::PickFiles { node, .. }
| Self::ClearFiles { node, .. }
| Self::CopyText { node, .. } => node,
Self::RemoveFile(file) => file.node,
Self::Focus(node)
| Self::RaiseLayer(node)
| Self::ScrollIntoView(node)
| Self::ScrollTo { node, .. }
| Self::ExitMenu { node, .. }
| Self::RevealOption { node } => node,
Self::SelectText { node, .. } | Self::SelectRich { node, .. } => node,
}
}
pub fn validate_target<'a>(self, node: impl Into<DescriptorView<'a>>) -> Result<(), Error> {
let node = node.into();
if let Self::SelectRich {
revision,
selection,
..
} = self
{
let Props::RichEditor(editor) = node.props else {
return Err(Error::Unsupported(
"rich selection action requires a RichEditor",
));
};
if revision != editor.revision {
return Err(Error::InputRevision {
current: editor.revision,
incoming: revision,
});
}
editor.document.validate_selection(selection)?;
if !editor.enabled {
return Err(Error::Unsupported("rich editor is disabled"));
}
}
if let Self::PickFiles { revision, .. }
| Self::ClearFiles { revision, .. }
| Self::RemoveFile(FileToken { revision, .. }) = self
{
let Props::File(props) = node.props else {
return Err(Error::Unsupported("file action requires a File control"));
};
if revision != props.revision {
return Err(Error::InputRevision {
current: props.revision,
incoming: revision,
});
}
if !matches!(self, Self::ClearFiles { .. }) && !props.enabled {
return Err(Error::Unsupported("file control is disabled"));
}
if matches!(self, Self::PickFiles { request: 0, .. }) {
return Err(Error::InvalidProps("file picker request must be positive"));
}
if let Self::RemoveFile(file) = self {
file.validate()?;
}
}
if let Self::CopyText {
revision, request, ..
} = self
{
let source = node
.semantics
.as_ref()
.and_then(|s| s.clipboard.as_ref())
.ok_or(Error::Unsupported("button has no clipboard source"))?;
source.validate()?;
if !matches!(node.props, Props::Button(_))
|| !node.props.enabled()
|| node.semantics.as_ref().is_some_and(|s| s.disabled)
{
return Err(Error::Unsupported("clipboard requires an enabled Button"));
}
if revision != source.revision || request == 0 {
return Err(Error::InvalidProps(
"clipboard request requires the exact source revision and a positive identity",
));
}
}
if matches!(self, Self::RaiseLayer(_))
&& (node.role != Some(Role::Dialog)
|| node.hidden()
|| !node
.semantics
.as_ref()
.and_then(|s| s.layer.as_ref())
.is_some_and(|layer| !layer.modal))
{
return Err(Error::Unsupported(
"raise requires an open nonmodal dialog layer",
));
}
if let Self::SelectText {
revision,
selection,
..
} = self
{
let Props::Input(input) = node.props else {
return Err(Error::Unsupported("text selection requires an Input"));
};
if revision != input.revision {
return Err(Error::InputRevision {
current: input.revision,
incoming: revision,
});
}
selection.byte_range(&input.value)?;
}
if matches!(self, Self::Focus(_))
&& node.semantics.as_ref().is_some_and(|s| s.menubar_item)
&& node.focus != FocusMode::TabStop
{
return Err(Error::Unsupported(
"menubar focus intent no longer names the current root",
));
}
if matches!(self, Self::RevealOption { .. })
&& !node.semantics.as_ref().is_some_and(|s| s.option.is_some())
{
return Err(Error::Unsupported(
"option reveal requires an intrinsic listbox option",
));
}
if matches!(self, Self::Focus(_))
&& (node.role == Some(Role::Listbox)
|| node.semantics.as_ref().is_some_and(|s| s.option.is_some()))
{
return Err(Error::Unsupported(
"listbox options preserve combobox focus",
));
}
if matches!(self, Self::ExitMenu { .. })
&& (node.role != Some(Role::Menu)
|| !node
.semantics
.as_ref()
.and_then(|s| s.layer.as_ref())
.is_some_and(|layer| {
!layer.modal
&& (layer.return_focus.is_some()
|| matches!(layer.placement, LayerPlacement::ContextPoint(_))
&& layer.anchor.is_some())
}))
{
return Err(Error::Unsupported(
"menu exit requires a named nonmodal menu with a return target",
));
}
if let Self::ScrollTo { x, y, .. } = self
&& (!x.is_finite() || !y.is_finite() || x < 0.0 || y < 0.0)
{
return Err(Error::InvalidProps("invalid scroll position"));
}
if matches!(self, Self::Focus(_))
&& node.role == Some(Role::Separator)
&& !node
.semantics
.as_ref()
.is_some_and(|s| s.splitter.is_some())
{
return Err(Error::Unsupported("focus on passive separator"));
}
if matches!(self, Self::Focus(_)) && node.role == Some(Role::Tooltip) {
return Err(Error::Unsupported("focus on passive tooltip"));
}
if matches!(self, Self::Focus(_)) && node.role == Some(Role::ProgressBar) {
return Err(Error::Unsupported("focus on passive progress"));
}
if matches!(node.props, Props::Group) {
return Err(Error::Unsupported("group has no physical action target"));
}
if matches!(self, Self::Focus(_)) && !node.props.enabled() {
return Err(Error::Unsupported("focus on disabled control"));
}
if matches!(self, Self::Focus(_))
&& matches!(&node.props, Props::Image(image) if image.alternative.is_none())
{
return Err(Error::Unsupported("focus on decorative image"));
}
if matches!(self, Self::Focus(_))
&& matches!(node.props, Props::Graphic(graphic) if graphic.alternative.is_none())
{
return Err(Error::Unsupported("focus on decorative graphic"));
}
Ok(())
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Rect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Navigation {
Previous,
Next,
First,
Last,
PagePrevious,
PageNext,
Reveal,
}
#[derive(Clone, Debug, PartialEq)]
pub enum QueryValue {
RichSelection(Box<RichSnapshot>),
FileBytes(Box<FileChunk>),
FilePreview(Option<Box<FilePreview>>),
ScrollMetrics(ScrollMetrics),
Focus(bool),
Bounds(Rect),
Scroll {
x: f64,
y: f64,
},
Selection {
start: usize,
end: usize,
},
}
#[derive(Clone, Debug, PartialEq)]
pub enum Event {
RichCommand {
command: RichCommand,
revision: u64,
},
RichRejected {
revision: u64,
},
RichEdit(Box<RichSnapshot>),
RichSelection(Box<RichSnapshot>),
Files(Box<FileEvent>),
TreeNavigate {
from: NodeId,
command: TreeCommand,
},
Clipboard {
revision: u64,
request: u64,
outcome: ClipboardOutcome,
},
GridNavigate {
from: NodeId,
command: GridCommand,
},
InputEdit(InputEdit),
CollapseComplete {
revision: u64,
},
PresenceComplete {
revision: u64,
},
ContextMenu {
from: NodeId,
point: ContextPoint,
source: ContextSource,
},
Sheet {
from: NodeId,
revision: u64,
command: SheetCommand,
},
NavigationPanel {
from: NodeId,
command: NavigationPanelCommand,
},
Spin {
from: NodeId,
command: RangeCommand,
},
Range {
from: NodeId,
command: RangeCommand,
},
ScrollKeyboard {
from: NodeId,
command: ScrollCommand,
},
ImageStatus {
revision: u64,
status: ImageStatus,
},
Menu {
from: NodeId,
command: MenuCommand,
},
PlotPointer {
from: NodeId,
pointer: PlotPointer,
},
Pointer {
from: NodeId,
related: Option<NodeId>,
phase: PointerPhase,
},
PointerWithin {
from: NodeId,
related: Option<NodeId>,
phase: PointerPhase,
},
Submit {
submitter: Option<NodeId>,
},
Reset,
Activate,
DisplayClick(u16),
Dismiss(DismissReason),
ColorSchemeChanged {
dark: bool,
},
Keyboard {
from: NodeId,
command: KeyboardCommand,
},
Palette {
from: NodeId,
},
Swipe {
from: NodeId,
phase: DragPhase,
x: f64,
y: f64,
revision: u64,
},
Drag {
from: NodeId,
phase: DragPhase,
x: f64,
y: f64,
},
ValueChanged {
value: String,
composing: bool,
revision: u64,
},
Commit {
value: String,
revision: u64,
},
CheckedChanged(bool),
Tags {
from: NodeId,
revision: u64,
command: TagsCommand,
},
Choice {
from: NodeId,
command: ChoiceCommand,
},
SelectChanged {
keys: Vec<SemanticId>,
revision: u64,
},
FocusChanged(bool),
FocusWithin {
node: NodeId,
focused: bool,
},
Navigate {
from: NodeId,
command: Navigation,
},
Typeahead {
from: NodeId,
text: String,
at_millis: u64,
},
Composition {
active: bool,
},
Scroll {
x: f64,
y: f64,
viewport: Rect,
ack: Option<ScrollAck>,
},
Resize {
size: Rect,
viewport: Rect,
},
Anchor {
row: NodeId,
within: f64,
viewport: Rect,
},
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ScrollRequest {
pub x: f64,
pub y: f64,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ScrollAck {
pub requested: ScrollRequest,
pub x: f64,
pub y: f64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum EventKind {
DisplayClick,
RichCommand,
RichRejected,
RichEdit,
RichSelection,
Files,
TreeNavigate,
Clipboard,
GridNavigate,
InputEdit,
CollapseComplete,
PresenceComplete,
ContextMenu,
Tags,
Sheet,
NavigationPanel,
Spin,
Range,
ScrollKeyboard,
ImageStatus,
Menu,
PlotPointer,
Pointer,
PointerWithin,
Submit,
Reset,
Activate,
Dismiss,
ColorSchemeChanged,
Keyboard,
Palette,
Swipe,
Drag,
ValueChanged,
Commit,
CheckedChanged,
SelectChanged,
Choice,
FocusChanged,
FocusWithin,
Navigate,
Typeahead,
Composition,
Scroll,
Resize,
Anchor,
}
#[derive(Clone, Debug)]
pub struct DisplayEvents(pub Vec<u16>);
impl EventKind {
pub fn validate_target<'a>(self, node: impl Into<DescriptorView<'a>>) -> Result<(), Error> {
let node = node.into();
if self == Self::PlotPointer && !matches!(node.props, Props::View) {
return Err(Error::Unsupported(
"plot pointer requires a physical View viewport",
));
}
if self == Self::DisplayClick
&& (!matches!(node.props, Props::Group)
|| node.options.get::<DisplayEvents>().is_none())
{
return Err(Error::InvalidEvent(
"display activation requires a declared instance",
));
}
if matches!(
self,
Self::RichEdit | Self::RichSelection | Self::RichRejected | Self::RichCommand
) && !matches!(node.props, Props::RichEditor(_))
{
return Err(Error::InvalidProps(
"rich observations require a RichEditor",
));
}
if self == Self::Swipe
&& (!matches!(node.props, Props::View)
|| node
.semantics
.as_ref()
.is_none_or(|s| s.swipe_capture.is_none()))
{
return Err(Error::InvalidProps(
"swipe observations require a declared View capture",
));
}
if self == Self::Files && !matches!(node.props, Props::File(_)) {
return Err(Error::InvalidProps(
"file observations require a File control",
));
}
if self == Self::TreeNavigate
&& (node.role != Some(Role::Tree)
|| !matches!(node.props, Props::View)
|| node
.semantics
.as_ref()
.is_none_or(|s| s.tree_navigation.is_none()))
{
return Err(Error::InvalidProps(
"tree navigation requires an opted-in Tree View",
));
}
if self == Self::Clipboard
&& (!matches!(node.props, Props::Button(_))
|| node
.semantics
.as_ref()
.is_none_or(|s| s.clipboard.is_none()))
{
return Err(Error::Unsupported(
"clipboard observation requires a declared Button source",
));
}
if self == Self::GridNavigate
&& (node.role != Some(Role::Grid)
|| !matches!(node.props, Props::View)
|| !node
.semantics
.as_ref()
.is_some_and(|s| s.grid_navigation.is_some()))
{
return Err(Error::InvalidProps(
"grid navigation requires an opted-in Grid View",
));
}
if self == Self::InputEdit
&& !matches!(node.props,Props::Input(p) if !p.multiline&&node.semantics.as_ref().is_some_and(|s|s.input_edit.is_some()))
{
return Err(Error::Unsupported(
"InputEdit requires an opted-in single-line Input",
));
}
if self == Self::PresenceComplete
&& (!matches!(node.props, Props::View)
|| !node
.semantics
.as_ref()
.is_some_and(|s| s.presence.is_some()))
{
return Err(Error::InvalidProps(
"presence completion requires a presence View",
));
}
if self == Self::CollapseComplete
&& (!matches!(node.props, Props::View)
|| !node
.semantics
.as_ref()
.is_some_and(|s| s.collapse.is_some()))
{
return Err(Error::InvalidProps(
"collapse completion requires a collapse View",
));
}
if self == Self::ContextMenu
&& (!matches!(node.props, Props::View)
|| !node
.semantics
.as_ref()
.is_some_and(|s| s.context_menu.is_some()))
{
return Err(Error::InvalidProps(
"context requests require an opted-in region view",
));
}
if self == Self::Tags
&& !matches!(node.props,Props::Input(input) if !input.multiline && node.semantics.as_ref().is_some_and(|s|s.tags_input.is_some()))
{
return Err(Error::InvalidProps(
"tags commands require an opted-in single-line input",
));
}
if self == Self::Sheet && !matches!(node.props, Props::View) {
return Err(Error::InvalidProps("sheet commands require a view"));
}
if self == Self::NavigationPanel
&& !matches!(node.props, Props::Button(_) | Props::Link(_) | Props::View)
{
return Err(Error::InvalidProps(
"navigation panel commands require a physical navigation control or content view",
));
}
if self == Self::Spin
&& !matches!(node.props, Props::Input(p) if !p.multiline && node.semantics.as_ref().is_some_and(|s| s.spinbutton.is_some()))
{
return Err(Error::InvalidProps(
"spin commands require an opted-in single-line input",
));
}
if self == Self::Range
&& (!matches!(node.props, Props::View)
|| !matches!(node.role, Some(Role::Separator | Role::Slider)))
{
return Err(Error::InvalidProps(
"range commands require a slider or splitter separator",
));
}
if self == Self::Choice
&& !node
.semantics
.as_ref()
.is_some_and(|s| s.combobox.is_some())
{
return Err(Error::InvalidProps("choice commands require a combobox"));
}
if self == Self::SelectChanged && !matches!(node.props, Props::Select(_)) {
return Err(Error::InvalidProps("selection event requires a select"));
}
if self == Self::ScrollKeyboard && !matches!(node.props, Props::View) {
return Err(Error::InvalidProps(
"scroll keyboard requires a viewport view",
));
}
if self == Self::ImageStatus && !matches!(node.props, Props::Image(_)) {
return Err(Error::InvalidProps("image status requires an image"));
}
if matches!(self, Self::Submit | Self::Reset) && node.field_part() != Some(FieldPart::Form)
{
return Err(Error::InvalidProps("form request requires a form"));
}
if matches!(
node.role,
Some(Role::Separator | Role::Tooltip | Role::ProgressBar)
) && matches!(
self,
Self::Activate
| Self::Keyboard
| Self::Palette
| Self::ScrollKeyboard
| Self::Drag
| Self::Navigate
| Self::Typeahead
| Self::Menu
| Self::NavigationPanel
| Self::Range
) && !(node.role == Some(Role::Separator)
&& node
.semantics
.as_ref()
.is_some_and(|s| s.splitter.is_some())
&& matches!(self, Self::Range | Self::Drag))
{
return Err(Error::Unsupported("passive separator has no interaction"));
}
if self == Self::Dismiss && !matches!(node.props, Props::View) {
return Err(Error::InvalidProps("dismiss requires a view"));
}
if matches!(self, Self::Drag | Self::ColorSchemeChanged)
&& !matches!(node.props, Props::View)
{
return Err(Error::Unsupported(
"host observation requires a semantic View",
));
}
if self == Self::Palette
&& matches!(
node.props,
Props::Group | Props::Input(_) | Props::Select(_)
)
{
return Err(Error::Unsupported(
"palette shortcut requires a non-editor physical scope or origin",
));
}
if matches!(self, Self::ValueChanged | Self::Commit)
&& !matches!(node.props, Props::Input(_))
|| self == Self::Composition
&& !matches!(node.props, Props::Input(_) | Props::RichEditor(_))
|| matches!(self, Self::CheckedChanged) && !matches!(node.props, Props::Check(_))
{
return Err(Error::InvalidProps("event does not belong to this control"));
}
if matches!(node.props, Props::Group)
&& matches!(
self,
Self::Resize
| Self::Scroll
| Self::Anchor
| Self::FocusChanged
| Self::Drag
| Self::Pointer
)
{
return Err(Error::Unsupported("group has no physical event target"));
}
Ok(())
}
}
impl Event {
pub fn is_user_interaction(&self) -> bool {
!self.is_terminal_loss()
&& !matches!(
self,
Self::Clipboard { .. }
| Self::ImageStatus { .. }
| Self::ColorSchemeChanged { .. }
| Self::Scroll { .. }
| Self::Resize { .. }
| Self::Anchor { .. }
)
}
pub fn is_terminal_loss(&self) -> bool {
if let Self::Files(event) = self {
return !matches!(event.outcome, FileOutcome::Selected(_));
}
matches!(
self,
Self::Clipboard { .. }
| Self::CollapseComplete { .. }
| Self::PresenceComplete { .. }
| Self::FocusChanged(false)
| Self::Composition { active: false }
| Self::FocusWithin { focused: false, .. }
| Self::Swipe {
phase: DragPhase::Cancel,
..
}
| Self::Drag {
phase: DragPhase::Cancel,
..
}
| Self::PlotPointer {
pointer: PlotPointer {
phase: PlotPointerPhase::Leave | PlotPointerPhase::Cancel,
..
},
..
}
| Self::Pointer {
phase: PointerPhase::Leave,
..
}
| Self::PointerWithin {
phase: PointerPhase::Leave,
..
}
)
}
pub(crate) fn origin(&self) -> Option<NodeId> {
match self {
Self::TreeNavigate { from, .. } => Some(*from),
Self::GridNavigate { from, .. } => Some(*from),
Self::ContextMenu { from, .. } => Some(*from),
Self::Tags { from, .. } => Some(*from),
Self::Submit { submitter } => *submitter,
Self::FocusWithin { node, .. } => Some(*node),
Self::Navigate { from, .. } => Some(*from),
Self::Menu { from, .. }
| Self::PlotPointer { from, .. }
| Self::Pointer { from, .. }
| Self::PointerWithin { from, .. } => Some(*from),
Self::Typeahead { from, .. } => Some(*from),
Self::Choice { from, .. } | Self::Keyboard { from, .. } | Self::Palette { from } => {
Some(*from)
}
Self::ScrollKeyboard { from, .. } => Some(*from),
Self::Spin { from, .. } | Self::Range { from, .. } => Some(*from),
Self::Sheet { from, .. } => Some(*from),
Self::NavigationPanel { from, .. } => Some(*from),
Self::Swipe { from, .. } | Self::Drag { from, .. } => Some(*from),
Self::Anchor { row, .. } => Some(*row),
_ => None,
}
}
pub fn validate_payload<'a>(
&self,
target: NodeId,
node: impl Into<DescriptorView<'a>>,
) -> Result<(), Error> {
self.validate_payload_view(target, node.into())
}
fn validate_payload_view(&self, target: NodeId, node: DescriptorView<'_>) -> Result<(), Error> {
if let Self::DisplayClick(slot) = self
&& (*slot >= 256
|| !node
.options
.get::<DisplayEvents>()
.is_some_and(|events| events.0.contains(slot)))
{
return Err(Error::InvalidEvent("undeclared display activation slot"));
}
if let Self::RichRejected { revision } | Self::RichCommand { revision, .. } = self {
let Props::RichEditor(editor) = node.props else {
return Err(Error::InvalidEvent("rich rejection requires its editor"));
};
if *revision > editor.revision {
return Err(Error::InputRevision {
current: editor.revision,
incoming: *revision,
});
}
}
if let Self::RichEdit(snapshot) | Self::RichSelection(snapshot) = self {
let Props::RichEditor(editor) = node.props else {
return Err(Error::InvalidEvent("rich input requires its RichEditor"));
};
snapshot.validate_input(editor)?;
}
if let Self::Swipe {
from,
x,
y,
revision,
..
} = self
{
EventKind::Swipe.validate_target(node)?;
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
if *from != target || !x.is_finite() || !y.is_finite() {
return Err(Error::InvalidEvent(
"swipe requires its exact finite boxed origin",
));
}
let capture = node
.semantics
.as_ref()
.and_then(|s| s.swipe_capture)
.expect("validated swipe capture");
if *revision > capture.revision {
return Err(Error::InputRevision {
current: capture.revision,
incoming: *revision,
});
}
}
if let Self::Files(event) = self {
let Props::File(props) = node.props else {
return Err(Error::InvalidEvent(
"file observations require a File control",
));
};
event.validate_node(target, props)?;
}
if let Self::TreeNavigate { from, command } = self {
EventKind::TreeNavigate.validate_target(node)?;
command.validate()?;
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
if *from == target {
return Err(Error::InvalidEvent(
"tree command requires a descendant TreeItem",
));
}
if matches!(command, TreeCommand::Search { .. })
&& node
.semantics
.as_ref()
.and_then(|s| s.tree_navigation)
.is_none_or(|s| !s.typeahead)
{
return Err(Error::InvalidEvent("tree search is not enabled"));
}
}
if let Self::Clipboard {
revision, request, ..
} = self
{
EventKind::Clipboard.validate_target(node)?;
let source = node
.semantics
.as_ref()
.and_then(|s| s.clipboard.as_ref())
.expect("validated source");
if *request == 0 || *revision > source.revision {
return Err(Error::InvalidEvent(
"clipboard completion has a future revision or zero request",
));
}
}
if let Self::GridNavigate { from, .. } = self {
EventKind::GridNavigate.validate_target(node)?;
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
if *from == target {
return Err(Error::InvalidEvent(
"grid navigation requires a real descendant Button",
));
}
}
if let Self::InputEdit(edit) = self {
EventKind::InputEdit.validate_target(node)?;
let capture = node
.semantics
.as_ref()
.and_then(|s| s.input_edit)
.ok_or(Error::InvalidEvent("input edit capture is absent"))?;
edit.validate(capture)?;
if let Props::Input(input) = node.props
&& edit.revision() > input.revision
{
return Err(Error::InputRevision {
current: input.revision,
incoming: edit.revision(),
});
}
}
if let Self::PresenceComplete { revision } = self {
let config = node
.semantics
.as_ref()
.and_then(|s| s.presence.as_ref())
.ok_or(Error::InvalidEvent(
"presence completion requires a presence View",
))?;
if *revision > config.revision {
return Err(Error::PresenceRevision {
current: config.revision,
incoming: *revision,
});
}
}
if let Self::CollapseComplete { revision } = self {
let config = node
.semantics
.as_ref()
.and_then(|s| s.collapse.as_ref())
.ok_or(Error::InvalidEvent(
"collapse completion requires a collapse View",
))?;
if *revision > config.revision {
return Err(Error::CollapseRevision {
current: config.revision,
incoming: *revision,
});
}
}
if let Self::Sheet {
from,
revision,
command,
} = self
{
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
let config = node
.semantics
.as_ref()
.and_then(|s| s.layer.as_ref())
.and_then(|layer| layer.sheet.as_ref())
.ok_or(Error::InvalidEvent("sheet command requires a sheet"))?;
if *from != target {
return Err(Error::InvalidEvent(
"sheet command origin must equal its target",
));
}
if *revision > config.revision {
return Err(Error::SheetRevision {
current: config.revision,
incoming: *revision,
});
}
if *revision == config.revision
&& match command {
SheetCommand::Snap(index) => *index >= config.fractions.len(),
SheetCommand::Dismiss => !config.dismissible,
}
{
return Err(Error::InvalidEvent(
"sheet command exceeds its accepted configuration",
));
}
}
if let Self::Dismiss(reason) = self {
let layer = node
.semantics
.as_ref()
.and_then(|s| s.layer.as_ref())
.ok_or(Error::InvalidEvent("dismiss requires a layer"))?;
if !match reason {
DismissReason::Gesture => {
layer.sheet.as_ref().is_some_and(|sheet| sheet.dismissible)
}
DismissReason::Escape => layer.escape,
DismissReason::Outside => layer.outside,
DismissReason::AnchorLost => layer.anchor.is_some(),
} {
return Err(Error::InvalidEvent("disabled layer dismissal"));
}
}
if self
.origin()
.is_some_and(|id| id.runtime() != target.runtime())
{
return Err(Error::ForeignRuntime);
}
self.kind().validate_target(node)?;
if matches!(
self,
Self::Choice {
command: ChoiceCommand::RemoveLast,
..
}
) && node.semantics.as_ref().and_then(|value| value.combobox)
!= Some(ComboboxKind::Multiple)
{
return Err(Error::InvalidEvent(
"remove-last requires a multiple combobox",
));
}
let local = |rect: &Rect| {
rect.x == 0.0
&& rect.y == 0.0
&& rect.width.is_finite()
&& rect.height.is_finite()
&& rect.width >= 0.0
&& rect.height >= 0.0
};
match self {
Self::PlotPointer { from, pointer } => {
if *from != target {
return Err(Error::InvalidEvent(
"plot pointer requires its observed viewport origin",
));
}
pointer.validate()?;
}
Self::ContextMenu { from, point, .. } => {
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
point.validate()?;
EventKind::ContextMenu.validate_target(node)?;
}
Self::Spin { from, command } => {
EventKind::Spin.validate_target(node)?;
if *from != target {
return Err(Error::InvalidEvent(
"spin command requires its physical origin",
));
}
let spin = node
.semantics
.as_ref()
.filter(|s| !s.disabled && !s.readonly && node.props.enabled())
.and_then(|s| s.spinbutton.as_ref())
.ok_or(Error::InvalidEvent(
"spin command requires an enabled writable input",
))?;
spin.validate_command(*command)?;
}
Self::Range { from, command } => {
let range = node
.semantics
.as_ref()
.filter(|s| !s.disabled)
.and_then(|s| {
s.splitter
.or_else(|| s.slider.as_ref().map(|slider| slider.range))
})
.ok_or(Error::InvalidEvent(
"range command requires an enabled slider or splitter",
))?;
if *from != target {
return Err(Error::InvalidEvent(
"range command requires its physical origin",
));
}
command.validate(range)?;
}
Self::Choice { from, .. } => {
if *from != target {
return Err(Error::InvalidEvent(
"choice command requires the combobox physical origin",
));
}
}
Self::ScrollKeyboard { from, command } => {
if *from != target
|| !node
.semantics
.as_ref()
.and_then(|s| s.scroll_keyboard)
.is_some_and(|axes| axes.allows(command.axis))
{
return Err(Error::InvalidEvent(
"scroll keyboard requires its opted-in physical viewport and axis",
));
}
}
Self::PointerWithin { related, .. } => {
if related.is_some_and(|related| related.runtime() != target.runtime()) {
return Err(Error::ForeignRuntime);
}
}
Self::NavigationPanel { from, command } => {
if *from != target || matches!(node.props, Props::Group) {
return Err(Error::InvalidEvent(
"navigation panel requires its exact physical origin",
));
}
let marker = node.semantics.as_ref().and_then(|s| s.navigation_panel);
let member = node.semantics.as_ref().is_some_and(|s| s.navigation_item);
if *command == NavigationPanelCommand::Close {
if !member && marker != Some(NavigationPanel::Content) {
return Err(Error::InvalidEvent(
"navigation close requires a content member",
));
}
} else if marker != Some(NavigationPanel::Trigger) {
return Err(Error::InvalidEvent(
"navigation entry requires a disclosure trigger",
));
}
}
Self::Menu { from, .. } | Self::Pointer { from, .. } => {
if *from != target || matches!(node.props, Props::Group) {
return Err(Error::InvalidEvent(
"menu/pointer requires its physical origin",
));
}
if matches!(self, Self::Menu { .. })
&& node.role != Some(Role::Menu)
&& !node.semantics.as_ref().is_some_and(|s| {
s.menu_item.is_some()
|| s.menu_search.is_some()
|| s.popup == Some(PopupKind::Menu)
})
{
return Err(Error::InvalidEvent(
"menu command requires a menu or menu trigger/item",
));
}
if matches!(
self,
Self::Menu {
command: MenuCommand::SearchNext
| MenuCommand::SearchPrevious
| MenuCommand::SearchCommit,
..
}
) && node
.semantics
.as_ref()
.is_none_or(|s| s.menu_search.is_none())
{
return Err(Error::InvalidEvent(
"search commands require a declared menu search editor",
));
}
if node
.semantics
.as_ref()
.is_some_and(|s| s.menu_search.is_some())
&& matches!(self, Self::Menu { command, .. } if !matches!(command, MenuCommand::SearchNext | MenuCommand::SearchPrevious | MenuCommand::SearchCommit | MenuCommand::Exit { .. }))
{
return Err(Error::InvalidEvent(
"menu search editors accept search navigation and exit commands only",
));
}
if let Self::Pointer {
related: Some(related),
..
} = self
&& related.runtime() != target.runtime()
{
return Err(Error::ForeignRuntime);
}
}
Self::Typeahead {
from,
text,
at_millis,
} => {
if *from != target || matches!(node.props, Props::Group) {
return Err(Error::InvalidEvent(
"typeahead requires its physical origin",
));
}
validate_typeahead(text, *at_millis)?;
}
Self::Drag { from, phase, x, y } => {
if !x.is_finite() || !y.is_finite() {
return Err(Error::InvalidEvent("drag coordinates must be finite"));
}
if *phase != DragPhase::Drop && *from != target {
return Err(Error::InvalidEvent("drag phase requires source target"));
}
}
Self::Keyboard { from, command } => {
if *from != target || matches!(node.props, Props::Group) {
return Err(Error::InvalidEvent("keyboard requires its physical origin"));
}
if *command == KeyboardCommand::Submit && !matches!(node.props, Props::Input(_)) {
return Err(Error::InvalidEvent("submit requires a text control"));
}
}
Self::Palette { from } => {
if from.runtime() != target.runtime() {
return Err(Error::ForeignRuntime);
}
if *from != target {
return Err(Error::InvalidEvent(
"palette shortcut requires its physical origin",
));
}
EventKind::Palette.validate_target(node)?;
}
Self::Navigate { from, .. } if *from != target => {
return Err(Error::InvalidEvent(
"navigation origin must match its event target",
));
}
Self::Scroll {
x,
y,
viewport,
ack,
} => {
if !x.is_finite() || !y.is_finite() || !local(viewport) {
return Err(Error::InvalidEvent("invalid scroll geometry"));
}
if ack.is_some_and(|ack| {
!ack.requested.x.is_finite()
|| !ack.requested.y.is_finite()
|| ack.requested.x < 0.0
|| ack.requested.y < 0.0
|| !ack.x.is_finite()
|| !ack.y.is_finite()
}) {
return Err(Error::InvalidEvent("invalid scroll acknowledgement"));
}
}
Self::Resize { size, viewport } if !local(size) || !local(viewport) => {
return Err(Error::InvalidEvent("invalid resize geometry"));
}
Self::Anchor {
within, viewport, ..
} if !within.is_finite() || *within < 0.0 || !local(viewport) => {
return Err(Error::InvalidEvent("invalid anchor geometry"));
}
Self::SelectChanged { keys, revision } => {
if let Props::Select(select) = node.props {
select.validate_user_selection(keys)?;
if *revision > select.selection.revision {
return Err(Error::SelectRevision {
current: select.selection.revision,
incoming: *revision,
});
}
}
}
Self::ImageStatus { revision, .. } => {
if let Props::Image(image) = node.props
&& *revision > image.revision
{
return Err(Error::ImageRevision {
current: image.revision,
incoming: *revision,
});
}
}
Self::ValueChanged {
value, revision, ..
}
| Self::Commit { value, revision } => {
if matches!(&node.props, Props::Input(input) if !input.multiline && value.contains(['\r', '\n']))
{
return Err(Error::InvalidEvent(
"single-line input event cannot contain line breaks",
));
}
if value.contains(['\0', '\r']) {
return Err(Error::InvalidEvent("input event text is not normalized"));
}
if let Props::Input(input) = &node.props
&& *revision > input.revision
{
return Err(Error::InputRevision {
current: input.revision,
incoming: *revision,
});
}
}
Self::Tags {
from,
revision,
command,
} => {
if *from != target {
return Err(Error::InvalidEvent(
"tags command requires its exact input origin",
));
}
command.validate()?;
if let Props::Input(input) = node.props
&& *revision > input.revision
{
return Err(Error::InputRevision {
current: input.revision,
incoming: *revision,
});
}
}
_ => {}
}
Ok(())
}
pub fn kind(&self) -> EventKind {
match self {
Self::RichCommand { .. } => EventKind::RichCommand,
Self::RichRejected { .. } => EventKind::RichRejected,
Self::TreeNavigate { .. } => EventKind::TreeNavigate,
Self::Files(_) => EventKind::Files,
Self::Clipboard { .. } => EventKind::Clipboard,
Self::GridNavigate { .. } => EventKind::GridNavigate,
Self::InputEdit(_) => EventKind::InputEdit,
Self::CollapseComplete { .. } => EventKind::CollapseComplete,
Self::PresenceComplete { .. } => EventKind::PresenceComplete,
Self::ContextMenu { .. } => EventKind::ContextMenu,
Self::Tags { .. } => EventKind::Tags,
Self::Spin { .. } => EventKind::Spin,
Self::Range { .. } => EventKind::Range,
Self::Sheet { .. } => EventKind::Sheet,
Self::NavigationPanel { .. } => EventKind::NavigationPanel,
Self::ScrollKeyboard { .. } => EventKind::ScrollKeyboard,
Self::ImageStatus { .. } => EventKind::ImageStatus,
Self::Menu { .. } => EventKind::Menu,
Self::PlotPointer { .. } => EventKind::PlotPointer,
Self::Pointer { .. } => EventKind::Pointer,
Self::PointerWithin { .. } => EventKind::PointerWithin,
Self::Submit { .. } => EventKind::Submit,
Self::Reset => EventKind::Reset,
Self::Activate => EventKind::Activate,
Self::DisplayClick(_) => EventKind::DisplayClick,
Self::Dismiss(_) => EventKind::Dismiss,
Self::ColorSchemeChanged { .. } => EventKind::ColorSchemeChanged,
Self::Keyboard { .. } => EventKind::Keyboard,
Self::Palette { .. } => EventKind::Palette,
Self::RichEdit(_) => EventKind::RichEdit,
Self::RichSelection(_) => EventKind::RichSelection,
Self::Swipe { .. } => EventKind::Swipe,
Self::Drag { .. } => EventKind::Drag,
Self::ValueChanged { .. } => EventKind::ValueChanged,
Self::Commit { .. } => EventKind::Commit,
Self::CheckedChanged(_) => EventKind::CheckedChanged,
Self::SelectChanged { .. } => EventKind::SelectChanged,
Self::Choice { .. } => EventKind::Choice,
Self::FocusChanged(_) => EventKind::FocusChanged,
Self::FocusWithin { .. } => EventKind::FocusWithin,
Self::Navigate { .. } => EventKind::Navigate,
Self::Typeahead { .. } => EventKind::Typeahead,
Self::Composition { .. } => EventKind::Composition,
Self::Scroll { .. } => EventKind::Scroll,
Self::Resize { .. } => EventKind::Resize,
Self::Anchor { .. } => EventKind::Anchor,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Input {
Event {
node: NodeId,
event: Event,
},
Response {
token: QueryToken,
applied: u64,
result: Result<QueryValue, Error>,
},
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Error {
Backend(String),
ForeignRuntime,
NodeGone(NodeId),
StaleNode(NodeId),
DuplicateNode(NodeId),
InvalidPlacement(&'static str),
InvalidProps(&'static str),
Unsupported(&'static str),
UnsupportedStyle {
profile: &'static str,
version: u32,
requirement: style::Unsupported,
},
InvalidReceipt {
previous: u64,
applied: u64,
},
QueryWatermark {
expected: u64,
applied: u64,
},
InvalidResponse(&'static str),
InvalidEvent(&'static str),
InputRevision {
current: u64,
incoming: u64,
},
InputRevisionExhausted,
SelectRevision {
current: u64,
incoming: u64,
},
SelectRevisionExhausted,
ImageRevision {
current: u64,
incoming: u64,
},
ImageRevisionExhausted,
SheetRevision {
current: u64,
incoming: u64,
},
SheetRevisionExhausted,
CollapseRevision {
current: u64,
incoming: u64,
},
CollapseRevisionExhausted,
PresenceRevision {
current: u64,
incoming: u64,
},
PresenceRevisionExhausted,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for Error {}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Receipt {
pub applied: u64,
}
pub trait Render {
fn flush_display(&mut self) -> Result<(), Error> {
Ok(())
}
fn preflight(&self, _node: DescriptorView<'_>, _patch: Option<&Patch>) -> Result<(), Error> {
Ok(())
}
fn preflight_place(
&self,
_tree: &memory::Memory,
_child: memory::Subtree<'_>,
_parent: Option<NodeId>,
) -> Result<(), Error> {
Ok(())
}
fn set_profile(&mut self, profile: Option<profile::Profile>) -> Option<profile::Profile> {
profile
}
fn needs_observe(&self) -> bool {
false
}
fn style_profile(&self) -> style::Profile {
style::Profile::NONE
}
fn listen(&mut self, _node: NodeId, _kind: EventKind, _enabled: bool) -> Result<(), Error> {
Ok(())
}
fn supports_plot_pointer(&self) -> bool {
false
}
fn capabilities(&self) -> Capabilities;
fn apply(&mut self, mutations: &[Mutation]) -> Result<Receipt, Error>;
fn bounds_now(&mut self, _node: NodeId) -> Option<Result<Rect, Error>> {
None
}
fn request(&mut self, query: Query, token: QueryToken) -> Result<(), Error>;
fn action(&mut self, _action: Action) -> Result<(), Error> {
Err(Error::Unsupported("platform action"))
}
fn drain(&mut self, inputs: &mut Vec<Input>);
}
mod environment;
mod table;
pub use environment::{Environment, LanguageTag};
pub use table::{MAX_CELL_HEADERS, MAX_TABLE_SPAN, SortDirection, TableMetadata};
mod swipe;
pub use swipe::SwipeCapture;
mod rich_document;
pub use rich_document::{
MAX_RICH_BLOCKS, MAX_RICH_LINK_BYTES, MAX_RICH_METADATA_BYTES, MAX_RICH_RUNS,
MAX_RICH_TEXT_BYTES, RichBlock, RichBlockKind, RichDocument, RichFormat, RichMarks, RichPoint,
RichRun, RichSelection,
};
mod rich;
pub use rich::{RichCommand, RichEditorProps, RichSnapshot};