Skip to content

Commit 25b7e9a

Browse files
committed
fix(frender-html): refactor macros
1 parent 9ac75da commit 25b7e9a

File tree

8 files changed

+1509
-349
lines changed

8 files changed

+1509
-349
lines changed

packages/frender-html/src/html.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ pub mod behaviors;
1313
#[cfg(not(feature = "macros_not_expanded"))]
1414
pub mod behavior_type_traits;
1515

16+
#[cfg(not(feature = "macros_not_expanded"))]
17+
mod event_types_macros;
18+
1619
#[cfg(not(feature = "macros_not_expanded"))]
1720
#[cfg(feature = "components")]
1821
pub mod markers;
@@ -41,14 +44,7 @@ crate::macros::def_intrinsic_component_props!(
4144
mod __ {
4245
#[behaviors]
4346
#[cfg(feature = "macros_not_expanded")]
44-
pub mod behaviors {
45-
#[cfg(feature = "web")]
46-
use crate::shims::prelude::*;
47-
48-
use frender_dom::OnEvent;
49-
50-
use super::*;
51-
}
47+
pub mod behaviors;
5248

5349
#[behaviors_prelude]
5450
mod behaviors_prelude {}
@@ -60,6 +56,10 @@ crate::macros::def_intrinsic_component_props!(
6056
#[event_types]
6157
mod event_types {}
6258

59+
#[event_types_macros]
60+
#[cfg(feature = "macros_not_expanded")]
61+
mod event_types_macros;
62+
6363
#[tag_and_props_markers]
6464
#[cfg(feature = "components")]
6565
#[cfg(feature = "macros_not_expanded")]
@@ -126,6 +126,14 @@ crate::macros::def_intrinsic_component_props!(
126126
#[cfg(all(feature = "macros_not_expanded"))] // wrap any to prevent auto expanding by frender-html-expand
127127
mod props_macros;
128128

129+
#[imp_element_proxy_attrs]
130+
#[cfg(feature = "ElementProxyAttrs")]
131+
expand_const_block! {}
132+
133+
#[imp_web]
134+
#[cfg(feature = "web")]
135+
expand_const_block! {}
136+
129137
#[RenderHtml]
130138
pub trait RenderHtml {
131139
additional_bounds!(dyn 'static + RenderTextFromKnown<Self::Text> + Render + RenderWithContext);
@@ -1475,7 +1483,7 @@ crate::macros::def_intrinsic_component_props!(
14751483
ElementWithNameAttribute,
14761484
ElementWithHeightWidthU32Attributes,
14771485
);
1478-
trait_bounds!(frender_form_control::input::InputElement<Renderer> + ElementWithTypeAttribute<Renderer>);
1486+
trait_bounds!(frender_form_control::input::InputElement<Renderer> + behaviors::ElementWithTypeAttribute<Renderer>);
14791487
define!(tags = (input { custom_content_model },));
14801488
impl_for_web!();
14811489

packages/frender-html/src/html/behavior_type_traits.rs

Lines changed: 90 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::event_types;
12
use crate::update_element::OnEventType;
23
pub trait Node: crate::UiHandleType {
34
type Node<Renderer: ?Sized + super::RenderHtml>: super::behaviors::Node<Renderer>
@@ -7,41 +8,41 @@ pub trait Node: crate::UiHandleType {
78
pub trait Element:
89
crate::UiHandleType
910
+ Node
10-
+ OnEventType<super::event_types::on_cancel>
11-
+ OnEventType<super::event_types::on_error>
12-
+ OnEventType<super::event_types::on_scroll>
13-
+ OnEventType<super::event_types::on_security_policy_violation>
14-
+ OnEventType<super::event_types::on_select>
15-
+ OnEventType<super::event_types::on_wheel>
16-
+ OnEventType<super::event_types::on_copy>
17-
+ OnEventType<super::event_types::on_cut>
18-
+ OnEventType<super::event_types::on_paste>
19-
+ OnEventType<super::event_types::on_composition_end>
20-
+ OnEventType<super::event_types::on_composition_start>
21-
+ OnEventType<super::event_types::on_composition_update>
22-
+ OnEventType<super::event_types::on_blur>
23-
+ OnEventType<super::event_types::on_focus>
24-
+ OnEventType<super::event_types::on_focus_in>
25-
+ OnEventType<super::event_types::on_focus_out>
26-
+ OnEventType<super::event_types::on_fullscreen_change>
27-
+ OnEventType<super::event_types::on_fullscreen_error>
28-
+ OnEventType<super::event_types::on_key_down>
29-
+ OnEventType<super::event_types::on_key_up>
30-
+ OnEventType<super::event_types::on_aux_click>
31-
+ OnEventType<super::event_types::on_click>
32-
+ OnEventType<super::event_types::on_context_menu>
33-
+ OnEventType<super::event_types::on_double_click>
34-
+ OnEventType<super::event_types::on_mouse_down>
35-
+ OnEventType<super::event_types::on_mouse_enter>
36-
+ OnEventType<super::event_types::on_mouse_leave>
37-
+ OnEventType<super::event_types::on_mouse_move>
38-
+ OnEventType<super::event_types::on_mouse_out>
39-
+ OnEventType<super::event_types::on_mouse_over>
40-
+ OnEventType<super::event_types::on_mouse_up>
41-
+ OnEventType<super::event_types::on_touch_cancel>
42-
+ OnEventType<super::event_types::on_touch_end>
43-
+ OnEventType<super::event_types::on_touch_move>
44-
+ OnEventType<super::event_types::on_touch_start>
11+
+ OnEventType<event_types::on_cancel>
12+
+ OnEventType<event_types::on_error>
13+
+ OnEventType<event_types::on_scroll>
14+
+ OnEventType<event_types::on_security_policy_violation>
15+
+ OnEventType<event_types::on_select>
16+
+ OnEventType<event_types::on_wheel>
17+
+ OnEventType<event_types::on_copy>
18+
+ OnEventType<event_types::on_cut>
19+
+ OnEventType<event_types::on_paste>
20+
+ OnEventType<event_types::on_composition_end>
21+
+ OnEventType<event_types::on_composition_start>
22+
+ OnEventType<event_types::on_composition_update>
23+
+ OnEventType<event_types::on_blur>
24+
+ OnEventType<event_types::on_focus>
25+
+ OnEventType<event_types::on_focus_in>
26+
+ OnEventType<event_types::on_focus_out>
27+
+ OnEventType<event_types::on_fullscreen_change>
28+
+ OnEventType<event_types::on_fullscreen_error>
29+
+ OnEventType<event_types::on_key_down>
30+
+ OnEventType<event_types::on_key_up>
31+
+ OnEventType<event_types::on_aux_click>
32+
+ OnEventType<event_types::on_click>
33+
+ OnEventType<event_types::on_context_menu>
34+
+ OnEventType<event_types::on_double_click>
35+
+ OnEventType<event_types::on_mouse_down>
36+
+ OnEventType<event_types::on_mouse_enter>
37+
+ OnEventType<event_types::on_mouse_leave>
38+
+ OnEventType<event_types::on_mouse_move>
39+
+ OnEventType<event_types::on_mouse_out>
40+
+ OnEventType<event_types::on_mouse_over>
41+
+ OnEventType<event_types::on_mouse_up>
42+
+ OnEventType<event_types::on_touch_cancel>
43+
+ OnEventType<event_types::on_touch_end>
44+
+ OnEventType<event_types::on_touch_move>
45+
+ OnEventType<event_types::on_touch_start>
4546
{
4647
type Element<Renderer: ?Sized + super::RenderHtml>: super::behaviors::Element<Renderer>
4748
+ ::frender_common::convert::IdentityAs<Self::OfBehaviorType<Renderer>>
@@ -260,35 +261,35 @@ pub trait ElementWithDateTimeAttribute: crate::UiHandleType + Element {
260261
pub trait HtmlElement:
261262
crate::UiHandleType
262263
+ Element
263-
+ OnEventType<super::event_types::on_invalid>
264-
+ OnEventType<super::event_types::on_animation_cancel>
265-
+ OnEventType<super::event_types::on_animation_end>
266-
+ OnEventType<super::event_types::on_animation_iteration>
267-
+ OnEventType<super::event_types::on_animation_start>
268-
+ OnEventType<super::event_types::on_before_input>
269-
+ OnEventType<super::event_types::on_input>
270-
+ OnEventType<super::event_types::on_change>
271-
+ OnEventType<super::event_types::on_got_pointer_capture>
272-
+ OnEventType<super::event_types::on_lost_pointer_capture>
273-
+ OnEventType<super::event_types::on_pointer_cancel>
274-
+ OnEventType<super::event_types::on_pointer_down>
275-
+ OnEventType<super::event_types::on_pointer_enter>
276-
+ OnEventType<super::event_types::on_pointer_leave>
277-
+ OnEventType<super::event_types::on_pointer_move>
278-
+ OnEventType<super::event_types::on_pointer_out>
279-
+ OnEventType<super::event_types::on_pointer_over>
280-
+ OnEventType<super::event_types::on_pointer_up>
281-
+ OnEventType<super::event_types::on_transition_cancel>
282-
+ OnEventType<super::event_types::on_transition_end>
283-
+ OnEventType<super::event_types::on_transition_run>
284-
+ OnEventType<super::event_types::on_transition_start>
285-
+ OnEventType<super::event_types::on_drag>
286-
+ OnEventType<super::event_types::on_drag_end>
287-
+ OnEventType<super::event_types::on_drag_enter>
288-
+ OnEventType<super::event_types::on_drag_leave>
289-
+ OnEventType<super::event_types::on_drag_over>
290-
+ OnEventType<super::event_types::on_drag_start>
291-
+ OnEventType<super::event_types::on_drop>
264+
+ OnEventType<event_types::on_invalid>
265+
+ OnEventType<event_types::on_animation_cancel>
266+
+ OnEventType<event_types::on_animation_end>
267+
+ OnEventType<event_types::on_animation_iteration>
268+
+ OnEventType<event_types::on_animation_start>
269+
+ OnEventType<event_types::on_before_input>
270+
+ OnEventType<event_types::on_input>
271+
+ OnEventType<event_types::on_change>
272+
+ OnEventType<event_types::on_got_pointer_capture>
273+
+ OnEventType<event_types::on_lost_pointer_capture>
274+
+ OnEventType<event_types::on_pointer_cancel>
275+
+ OnEventType<event_types::on_pointer_down>
276+
+ OnEventType<event_types::on_pointer_enter>
277+
+ OnEventType<event_types::on_pointer_leave>
278+
+ OnEventType<event_types::on_pointer_move>
279+
+ OnEventType<event_types::on_pointer_out>
280+
+ OnEventType<event_types::on_pointer_over>
281+
+ OnEventType<event_types::on_pointer_up>
282+
+ OnEventType<event_types::on_transition_cancel>
283+
+ OnEventType<event_types::on_transition_end>
284+
+ OnEventType<event_types::on_transition_run>
285+
+ OnEventType<event_types::on_transition_start>
286+
+ OnEventType<event_types::on_drag>
287+
+ OnEventType<event_types::on_drag_end>
288+
+ OnEventType<event_types::on_drag_enter>
289+
+ OnEventType<event_types::on_drag_leave>
290+
+ OnEventType<event_types::on_drag_over>
291+
+ OnEventType<event_types::on_drag_start>
292+
+ OnEventType<event_types::on_drop>
292293
{
293294
type HtmlElement<Renderer: ?Sized + super::RenderHtml>: super::behaviors::HtmlElement<Renderer>
294295
+ ::frender_common::convert::IdentityAs<Self::OfBehaviorType<Renderer>>
@@ -384,28 +385,28 @@ pub trait HtmlMediaElement:
384385
+ HtmlElement
385386
+ ElementWithSrcAttribute
386387
+ ElementWithCrossOriginAttribute
387-
+ OnEventType<super::event_types::on_abort>
388-
+ OnEventType<super::event_types::on_can_play>
389-
+ OnEventType<super::event_types::on_can_play_through>
390-
+ OnEventType<super::event_types::on_duration_change>
391-
+ OnEventType<super::event_types::on_emptied>
392-
+ OnEventType<super::event_types::on_ended>
393-
+ OnEventType<super::event_types::on_loaded_data>
394-
+ OnEventType<super::event_types::on_loaded_metadata>
395-
+ OnEventType<super::event_types::on_load_start>
396-
+ OnEventType<super::event_types::on_pause>
397-
+ OnEventType<super::event_types::on_play>
398-
+ OnEventType<super::event_types::on_playing>
399-
+ OnEventType<super::event_types::on_progress>
400-
+ OnEventType<super::event_types::on_rate_change>
401-
+ OnEventType<super::event_types::on_resize>
402-
+ OnEventType<super::event_types::on_seeked>
403-
+ OnEventType<super::event_types::on_seeking>
404-
+ OnEventType<super::event_types::on_stalled>
405-
+ OnEventType<super::event_types::on_suspend>
406-
+ OnEventType<super::event_types::on_time_update>
407-
+ OnEventType<super::event_types::on_volume_change>
408-
+ OnEventType<super::event_types::on_waiting>
388+
+ OnEventType<event_types::on_abort>
389+
+ OnEventType<event_types::on_can_play>
390+
+ OnEventType<event_types::on_can_play_through>
391+
+ OnEventType<event_types::on_duration_change>
392+
+ OnEventType<event_types::on_emptied>
393+
+ OnEventType<event_types::on_ended>
394+
+ OnEventType<event_types::on_loaded_data>
395+
+ OnEventType<event_types::on_loaded_metadata>
396+
+ OnEventType<event_types::on_load_start>
397+
+ OnEventType<event_types::on_pause>
398+
+ OnEventType<event_types::on_play>
399+
+ OnEventType<event_types::on_playing>
400+
+ OnEventType<event_types::on_progress>
401+
+ OnEventType<event_types::on_rate_change>
402+
+ OnEventType<event_types::on_resize>
403+
+ OnEventType<event_types::on_seeked>
404+
+ OnEventType<event_types::on_seeking>
405+
+ OnEventType<event_types::on_stalled>
406+
+ OnEventType<event_types::on_suspend>
407+
+ OnEventType<event_types::on_time_update>
408+
+ OnEventType<event_types::on_volume_change>
409+
+ OnEventType<event_types::on_waiting>
409410
{
410411
type HtmlMediaElement<Renderer: ?Sized + super::RenderHtml>: super::behaviors::HtmlMediaElement<Renderer>
411412
+ ::frender_common::convert::IdentityAs<Self::OfBehaviorType<Renderer>>
@@ -484,9 +485,9 @@ pub trait HtmlFormElement:
484485
+ ElementWithAcceptAttribute
485486
+ ElementWithRelAttribute
486487
+ ElementWithNameAttribute
487-
+ OnEventType<super::event_types::on_form_data>
488-
+ OnEventType<super::event_types::on_reset>
489-
+ OnEventType<super::event_types::on_submit>
488+
+ OnEventType<event_types::on_form_data>
489+
+ OnEventType<event_types::on_reset>
490+
+ OnEventType<event_types::on_submit>
490491
{
491492
type HtmlFormElement<Renderer: ?Sized + super::RenderHtml>: super::behaviors::HtmlFormElement<Renderer>
492493
+ ::frender_common::convert::IdentityAs<Self::OfBehaviorType<Renderer>>

0 commit comments

Comments
 (0)