Skip to content

Commit 7f0beb9

Browse files
committed
cargo fmt
1 parent 012bd4c commit 7f0beb9

File tree

194 files changed

+12577
-5949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+12577
-5949
lines changed

core/src/callbacks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ impl_callback!(IFrameCallback, IFrameCallbackType);
146146

147147
impl IFrameCallback {
148148
pub fn create(cb: IFrameCallbackType) -> Self {
149-
Self { cb, ctx: OptionRefAny::None }
149+
Self {
150+
cb,
151+
ctx: OptionRefAny::None,
152+
}
150153
}
151154
}
152155

core/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl DebugLogger {
181181
if level < self.min_level {
182182
return;
183183
}
184-
184+
185185
// Check category filter
186186
if let Some(ref allowed) = self.category_filter {
187187
if !allowed.contains(&category) {

core/src/dom.rs

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub use crate::events::{
3232
NotEventFilter, WindowEventFilter,
3333
};
3434
pub use crate::id::{Node, NodeHierarchy, NodeId};
35-
pub use azul_css::dynamic_selector::{CssPropertyWithConditions, CssPropertyWithConditionsVec};
3635
use crate::{
3736
callbacks::{
3837
CoreCallback, CoreCallbackData, CoreCallbackDataVec, CoreCallbackType, IFrameCallback,
@@ -52,6 +51,7 @@ use crate::{
5251
},
5352
window::OptionVirtualKeyCodeCombo,
5453
};
54+
pub use azul_css::dynamic_selector::{CssPropertyWithConditions, CssPropertyWithConditionsVec};
5555

5656
static TAG_ID: AtomicUsize = AtomicUsize::new(1);
5757

@@ -955,7 +955,12 @@ pub enum IdOrClass {
955955
Class(AzString),
956956
}
957957

958-
impl_vec!(IdOrClass, IdOrClassVec, IdOrClassVecDestructor, IdOrClassVecDestructorType);
958+
impl_vec!(
959+
IdOrClass,
960+
IdOrClassVec,
961+
IdOrClassVecDestructor,
962+
IdOrClassVecDestructorType
963+
);
959964
impl_vec_debug!(IdOrClass, IdOrClassVec);
960965
impl_vec_partialord!(IdOrClass, IdOrClassVec);
961966
impl_vec_ord!(IdOrClass, IdOrClassVec);
@@ -1089,7 +1094,12 @@ pub enum AttributeType {
10891094
Custom(AttributeNameValue),
10901095
}
10911096

1092-
impl_vec!(AttributeType, AttributeVec, AttributeVecDestructor, AttributeVecDestructorType);
1097+
impl_vec!(
1098+
AttributeType,
1099+
AttributeVec,
1100+
AttributeVecDestructor,
1101+
AttributeVecDestructorType
1102+
);
10931103
impl_vec_debug!(AttributeType, AttributeVec);
10941104
impl_vec_partialord!(AttributeType, AttributeVec);
10951105
impl_vec_ord!(AttributeType, AttributeVec);
@@ -2126,7 +2136,12 @@ impl Clone for NodeData {
21262136
}
21272137

21282138
// Clone, PartialEq, Eq, Hash, PartialOrd, Ord
2129-
impl_vec!(NodeData, NodeDataVec, NodeDataVecDestructor, NodeDataVecDestructorType);
2139+
impl_vec!(
2140+
NodeData,
2141+
NodeDataVec,
2142+
NodeDataVecDestructor,
2143+
NodeDataVecDestructorType
2144+
);
21302145
impl_vec_clone!(NodeData, NodeDataVec, NodeDataVecDestructor);
21312146
impl_vec_mut!(NodeData, NodeDataVec);
21322147
impl_vec_debug!(NodeData, NodeDataVec);
@@ -2476,7 +2491,12 @@ impl NodeData {
24762491
}
24772492

24782493
#[inline]
2479-
pub fn add_callback<C: Into<CoreCallback>>(&mut self, event: EventFilter, data: RefAny, callback: C) {
2494+
pub fn add_callback<C: Into<CoreCallback>>(
2495+
&mut self,
2496+
event: EventFilter,
2497+
data: RefAny,
2498+
callback: C,
2499+
) {
24802500
let callback = callback.into();
24812501
let mut v: CoreCallbackDataVec = Vec::new().into();
24822502
mem::swap(&mut v, &mut self.callbacks);
@@ -2505,7 +2525,7 @@ impl NodeData {
25052525
v.push(IdOrClass::Class(s));
25062526
self.ids_and_classes = v.into();
25072527
}
2508-
2528+
25092529
/// Add an unconditional CSS property (always applies)
25102530
#[inline]
25112531
pub fn add_css_property(&mut self, p: CssProperty) {
@@ -2516,37 +2536,52 @@ impl NodeData {
25162536
v.push(CssPropertyWithConditions::simple(p));
25172537
self.css_props = v.into();
25182538
}
2519-
2539+
25202540
/// Add a CSS property that applies only on hover
25212541
#[inline]
25222542
pub fn add_hover_css_property(&mut self, p: CssProperty) {
2523-
use azul_css::dynamic_selector::{CssPropertyWithConditions, DynamicSelector, PseudoStateType};
2543+
use azul_css::dynamic_selector::{
2544+
CssPropertyWithConditions, DynamicSelector, PseudoStateType,
2545+
};
25242546
let mut v: CssPropertyWithConditionsVec = Vec::new().into();
25252547
mem::swap(&mut v, &mut self.css_props);
25262548
let mut v = v.into_library_owned_vec();
2527-
v.push(CssPropertyWithConditions::with_condition(p, DynamicSelector::PseudoState(PseudoStateType::Hover)));
2549+
v.push(CssPropertyWithConditions::with_condition(
2550+
p,
2551+
DynamicSelector::PseudoState(PseudoStateType::Hover),
2552+
));
25282553
self.css_props = v.into();
25292554
}
2530-
2555+
25312556
/// Add a CSS property that applies only when active (clicked)
25322557
#[inline]
25332558
pub fn add_active_css_property(&mut self, p: CssProperty) {
2534-
use azul_css::dynamic_selector::{CssPropertyWithConditions, DynamicSelector, PseudoStateType};
2559+
use azul_css::dynamic_selector::{
2560+
CssPropertyWithConditions, DynamicSelector, PseudoStateType,
2561+
};
25352562
let mut v: CssPropertyWithConditionsVec = Vec::new().into();
25362563
mem::swap(&mut v, &mut self.css_props);
25372564
let mut v = v.into_library_owned_vec();
2538-
v.push(CssPropertyWithConditions::with_condition(p, DynamicSelector::PseudoState(PseudoStateType::Active)));
2565+
v.push(CssPropertyWithConditions::with_condition(
2566+
p,
2567+
DynamicSelector::PseudoState(PseudoStateType::Active),
2568+
));
25392569
self.css_props = v.into();
25402570
}
2541-
2571+
25422572
/// Add a CSS property that applies only when focused
25432573
#[inline]
25442574
pub fn add_focus_css_property(&mut self, p: CssProperty) {
2545-
use azul_css::dynamic_selector::{CssPropertyWithConditions, DynamicSelector, PseudoStateType};
2575+
use azul_css::dynamic_selector::{
2576+
CssPropertyWithConditions, DynamicSelector, PseudoStateType,
2577+
};
25462578
let mut v: CssPropertyWithConditionsVec = Vec::new().into();
25472579
mem::swap(&mut v, &mut self.css_props);
25482580
let mut v = v.into_library_owned_vec();
2549-
v.push(CssPropertyWithConditions::with_condition(p, DynamicSelector::PseudoState(PseudoStateType::Focus)));
2581+
v.push(CssPropertyWithConditions::with_condition(
2582+
p,
2583+
DynamicSelector::PseudoState(PseudoStateType::Focus),
2584+
));
25502585
self.css_props = v.into();
25512586
}
25522587

@@ -4241,7 +4276,8 @@ impl Dom {
42414276
/// - `aria`: Accessibility information describing table purpose
42424277
#[inline]
42434278
pub fn table_with_aria<S: Into<AzString>>(caption: S, aria: SmallAriaInfo) -> Self {
4244-
let mut table = Self::create_table().with_child(Self::create_caption().with_child(Self::create_text(caption)));
4279+
let mut table = Self::create_table()
4280+
.with_child(Self::create_caption().with_child(Self::create_text(caption)));
42454281
table.root.set_accessibility_info(aria.to_full_info());
42464282
table
42474283
}

core/src/events.rs

Lines changed: 62 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,13 @@ pub fn propagate_event(
659659
let mut result = PropagationResult::default();
660660

661661
// Phase 1: Capture (root → target)
662-
propagate_phase(event, ancestors.iter().copied(), EventPhase::Capture, callbacks, &mut result);
662+
propagate_phase(
663+
event,
664+
ancestors.iter().copied(),
665+
EventPhase::Capture,
666+
callbacks,
667+
&mut result,
668+
);
663669

664670
// Phase 2: Target
665671
if !event.stopped {
@@ -668,7 +674,13 @@ pub fn propagate_event(
668674

669675
// Phase 3: Bubble (target → root)
670676
if !event.stopped {
671-
propagate_phase(event, ancestors.iter().rev().copied(), EventPhase::Bubble, callbacks, &mut result);
677+
propagate_phase(
678+
event,
679+
ancestors.iter().rev().copied(),
680+
EventPhase::Bubble,
681+
callbacks,
682+
&mut result,
683+
);
672684
}
673685

674686
result.default_prevented = event.prevented_default;
@@ -1027,7 +1039,9 @@ pub fn detect_lifecycle_events(
10271039
// Unmount events: nodes in old but not in new
10281040
if let Some(layout) = old_layout {
10291041
for &node_id in old_nodes.difference(&new_nodes) {
1030-
events.push(create_unmount_event(node_id, old_dom_id, layout, &timestamp));
1042+
events.push(create_unmount_event(
1043+
node_id, old_dom_id, layout, &timestamp,
1044+
));
10311045
}
10321046
}
10331047

@@ -1811,7 +1825,7 @@ pub trait EventProvider {
18111825
/// Get all pending events from this manager.
18121826
///
18131827
/// Events should include:
1814-
///
1828+
///
18151829
/// - `target`: The DomNodeId that was affected
18161830
/// - `event_type`: What happened (Input, Scroll, Focus, etc.)
18171831
/// - `source`: EventSource::User for input, EventSource::Programmatic for API calls
@@ -1835,20 +1849,24 @@ pub fn deduplicate_synthetic_events(mut events: Vec<SyntheticEvent>) -> Vec<Synt
18351849
// Coalesce consecutive events with same target and event_type
18361850
let mut result = Vec::with_capacity(events.len());
18371851
let mut iter = events.into_iter();
1838-
1852+
18391853
if let Some(mut prev) = iter.next() {
18401854
for curr in iter {
18411855
if prev.target == curr.target && prev.event_type == curr.event_type {
18421856
// Keep the one with later timestamp
1843-
prev = if curr.timestamp > prev.timestamp { curr } else { prev };
1857+
prev = if curr.timestamp > prev.timestamp {
1858+
curr
1859+
} else {
1860+
prev
1861+
};
18441862
} else {
18451863
result.push(prev);
18461864
prev = curr;
18471865
}
18481866
}
18491867
result.push(prev);
18501868
}
1851-
1869+
18521870
result
18531871
}
18541872

@@ -1872,22 +1890,22 @@ pub fn dispatch_synthetic_events(
18721890
}
18731891

18741892
/// Convert EventType to EventFilters (returns multiple filters for generic + specific events)
1875-
///
1893+
///
18761894
/// For mouse button events, returns both generic (MouseUp) AND specific (LeftMouseUp).
18771895
/// This allows callbacks registered for either filter to be triggered.
18781896
fn event_type_to_filters(event_type: EventType) -> Vec<EventFilter> {
1879-
use EventType as E;
18801897
use EventFilter as EF;
1881-
use HoverEventFilter as H;
1898+
use EventType as E;
18821899
use FocusEventFilter as F;
1900+
use HoverEventFilter as H;
18831901
use WindowEventFilter as W;
18841902

18851903
match event_type {
18861904
// Mouse button events - return BOTH generic and specific
18871905
// Generic first, then specific (bubbling order)
18881906
E::MouseDown => vec![EF::Hover(H::MouseDown), EF::Hover(H::LeftMouseDown)],
18891907
E::MouseUp => vec![EF::Hover(H::MouseUp), EF::Hover(H::LeftMouseUp)],
1890-
1908+
18911909
// Other mouse events
18921910
E::MouseOver => vec![EF::Hover(H::MouseOver)],
18931911
E::MouseEnter => vec![EF::Hover(H::MouseEnter)],
@@ -1952,12 +1970,14 @@ fn get_callback_target(event: &SyntheticEvent) -> Option<CallbackTarget> {
19521970
return Some(CallbackTarget::RootNodes);
19531971
}
19541972

1955-
event.target.node.into_crate_internal().map(|node_id| {
1956-
CallbackTarget::Node {
1973+
event
1974+
.target
1975+
.node
1976+
.into_crate_internal()
1977+
.map(|node_id| CallbackTarget::Node {
19571978
dom_id: event.target.dom,
19581979
node_id,
1959-
}
1960-
})
1980+
})
19611981
}
19621982

19631983
/// Get hit test item for a node target
@@ -2123,9 +2143,9 @@ where
21232143
selection_manager,
21242144
};
21252145

2126-
let (internal_events, user_events) = events
2127-
.iter()
2128-
.fold((Vec::new(), Vec::new()), |(mut internal, mut user), event| {
2146+
let (internal_events, user_events) = events.iter().fold(
2147+
(Vec::new(), Vec::new()),
2148+
|(mut internal, mut user), event| {
21292149
match process_event_for_internal(&ctx, event) {
21302150
Some(InternalEventAction::AddAndSkip(evt)) => {
21312151
internal.push(evt);
@@ -2139,9 +2159,13 @@ where
21392159
}
21402160
}
21412161
(internal, user)
2142-
});
2162+
},
2163+
);
21432164

2144-
PreCallbackFilterResult { internal_events, user_events }
2165+
PreCallbackFilterResult {
2166+
internal_events,
2167+
user_events,
2168+
}
21452169
}
21462170

21472171
/// Context for filtering internal events
@@ -2162,9 +2186,12 @@ fn process_event_for_internal<SM: SelectionManagerQuery>(
21622186
) -> Option<InternalEventAction> {
21632187
match event.event_type {
21642188
EventType::MouseDown => handle_mouse_down(event, ctx.hit_test, ctx.click_count),
2165-
EventType::MouseOver => {
2166-
handle_mouse_over(event, ctx.hit_test, ctx.mouse_state, ctx.drag_start_position)
2167-
}
2189+
EventType::MouseOver => handle_mouse_over(
2190+
event,
2191+
ctx.hit_test,
2192+
ctx.mouse_state,
2193+
ctx.drag_start_position,
2194+
),
21682195
EventType::KeyDown => handle_key_down(
21692196
event,
21702197
ctx.keyboard_state,
@@ -2354,8 +2381,7 @@ pub fn post_callback_filter_internal_events(
23542381
new_focus: Option<DomNodeId>,
23552382
) -> PostCallbackFilterResult {
23562383
if prevent_default {
2357-
let focus_event = (old_focus != new_focus)
2358-
.then_some(PostCallbackSystemEvent::FocusChanged);
2384+
let focus_event = (old_focus != new_focus).then_some(PostCallbackSystemEvent::FocusChanged);
23592385
return PostCallbackFilterResult {
23602386
system_events: focus_event.into_iter().collect(),
23612387
};
@@ -2365,8 +2391,7 @@ pub fn post_callback_filter_internal_events(
23652391
.iter()
23662392
.filter_map(internal_event_to_system_event);
23672393

2368-
let focus_event = (old_focus != new_focus)
2369-
.then_some(PostCallbackSystemEvent::FocusChanged);
2394+
let focus_event = (old_focus != new_focus).then_some(PostCallbackSystemEvent::FocusChanged);
23702395

23712396
let system_events = core::iter::once(PostCallbackSystemEvent::ApplyTextInput)
23722397
.chain(event_actions)
@@ -2377,17 +2402,21 @@ pub fn post_callback_filter_internal_events(
23772402
}
23782403

23792404
/// Convert internal event to post-callback system event
2380-
fn internal_event_to_system_event(event: &PreCallbackSystemEvent) -> Option<PostCallbackSystemEvent> {
2381-
use PreCallbackSystemEvent::*;
2405+
fn internal_event_to_system_event(
2406+
event: &PreCallbackSystemEvent,
2407+
) -> Option<PostCallbackSystemEvent> {
23822408
use PostCallbackSystemEvent::*;
2409+
use PreCallbackSystemEvent::*;
23832410

23842411
match event {
23852412
TextClick { .. } | ArrowKeyNavigation { .. } | DeleteSelection { .. } => {
23862413
Some(ScrollIntoView)
23872414
}
2388-
TextDragSelection { is_dragging, .. } => {
2389-
Some(if *is_dragging { StartAutoScrollTimer } else { CancelAutoScrollTimer })
2390-
}
2415+
TextDragSelection { is_dragging, .. } => Some(if *is_dragging {
2416+
StartAutoScrollTimer
2417+
} else {
2418+
CancelAutoScrollTimer
2419+
}),
23912420
KeyboardShortcut { shortcut, .. } => shortcut_to_system_event(*shortcut),
23922421
}
23932422
}
@@ -2861,4 +2890,4 @@ mod tests {
28612890
// We can't test it directly without making the function public
28622891
// but it's tested indirectly through propagate_event
28632892
}
2864-
}
2893+
}

0 commit comments

Comments
 (0)