1use waft_embedder::{Matrix4, Offset, Rect, Size, TextDirection};
12use waft_foundation::{
13 App, Handle, HandleId, ListenableHandle, ListenableObject, Listener, Ref, Retained,
14};
15
16use crate::layer::LayerLink;
17use crate::object::AnyRenderObject;
18
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24pub enum SelectionResult {
25 Next,
28 Previous,
30 End,
32 Pending,
34 None,
36}
37
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
40pub struct SelectedContentRange {
41 pub start_offset: i32,
43 pub end_offset: i32,
45}
46
47impl SelectedContentRange {
48 pub fn new(start_offset: i32, end_offset: i32) -> SelectedContentRange {
50 debug_assert!(start_offset >= 0 && end_offset >= 0);
51 SelectedContentRange {
52 start_offset,
53 end_offset,
54 }
55 }
56}
57
58#[derive(Clone, Debug)]
60pub struct SelectedContent {
61 pub plain_text: String,
63}
64
65impl SelectedContent {
66 pub fn new(plain_text: impl Into<String>) -> SelectedContent {
68 SelectedContent {
69 plain_text: plain_text.into(),
70 }
71 }
72}
73
74pub trait SelectionHandler: ListenableObject {
80 fn value(self: Handle<Self>, app: &App) -> SelectionGeometry;
82
83 fn push_handle_layers(
86 self: Handle<Self>,
87 app: &mut App,
88 start_handle: Option<Ref<LayerLink>>,
89 end_handle: Option<Ref<LayerLink>>,
90 );
91
92 fn selected_content(self: Handle<Self>, app: &App) -> Option<SelectedContent>;
94
95 fn selection(self: Handle<Self>, app: &App) -> Option<SelectedContentRange>;
97
98 fn dispatch_selection_event(
100 self: Handle<Self>,
101 app: &mut App,
102 event: &SelectionEvent,
103 ) -> SelectionResult;
104
105 fn content_length(self: Handle<Self>, app: &App) -> usize;
107}
108
109pub trait Selectable: SelectionHandler {
115 fn as_selectable(self: Handle<Self>) -> AnySelectable {
117 AnySelectable {
118 id: self.id(),
119 vtable: const { &SelectableVTable::of::<Self>() },
120 }
121 }
122
123 fn get_transform_to(
125 self: Handle<Self>,
126 app: &App,
127 ancestor: Option<AnyRenderObject>,
128 ) -> Matrix4;
129
130 fn size(self: Handle<Self>, app: &mut App) -> Size;
132
133 fn bounding_boxes(self: Handle<Self>, app: &mut App) -> Vec<Rect>;
135
136 fn dispose_selectable(self: Handle<Self>, app: &mut App);
138}
139
140#[derive(Clone, Copy)]
143pub struct AnySelectable {
144 id: HandleId,
145 vtable: &'static SelectableVTable,
146}
147
148pub type PushHandleLayers = fn(&mut App, HandleId, Option<Ref<LayerLink>>, Option<Ref<LayerLink>>);
150
151struct SelectableVTable {
152 value: fn(&App, HandleId) -> SelectionGeometry,
153 push_handle_layers: PushHandleLayers,
154 selected_content: fn(&App, HandleId) -> Option<SelectedContent>,
155 selection: fn(&App, HandleId) -> Option<SelectedContentRange>,
156 dispatch_selection_event: fn(&mut App, HandleId, &SelectionEvent) -> SelectionResult,
157 content_length: fn(&App, HandleId) -> usize,
158 get_transform_to: fn(&App, HandleId, Option<AnyRenderObject>) -> Matrix4,
159 size: fn(&mut App, HandleId) -> Size,
160 bounding_boxes: fn(&mut App, HandleId) -> Vec<Rect>,
161 dispose_selectable: fn(&mut App, HandleId),
162 add_listener: fn(&mut App, HandleId, Listener),
163 remove_listener: fn(&mut App, HandleId, &Listener),
164}
165
166impl SelectableVTable {
167 const fn of<A: Selectable>() -> SelectableVTable {
168 SelectableVTable {
169 value: |app, id| A::value(resolve(id), app),
170 push_handle_layers: |app, id, start, end| {
171 A::push_handle_layers(resolve(id), app, start, end)
172 },
173 selected_content: |app, id| A::selected_content(resolve(id), app),
174 selection: |app, id| A::selection(resolve(id), app),
175 dispatch_selection_event: |app, id, event| {
176 A::dispatch_selection_event(resolve(id), app, event)
177 },
178 content_length: |app, id| A::content_length(resolve(id), app),
179 get_transform_to: |app, id, ancestor| A::get_transform_to(resolve(id), app, ancestor),
180 size: |app, id| A::size(resolve(id), app),
181 bounding_boxes: |app, id| A::bounding_boxes(resolve(id), app),
182 dispose_selectable: |app, id| A::dispose_selectable(resolve(id), app),
183 add_listener: |app, id, listener| {
184 ListenableObject::add_listener(resolve::<A>(id), app, listener)
185 },
186 remove_listener: |app, id, listener| {
187 ListenableObject::remove_listener(resolve::<A>(id), app, listener)
188 },
189 }
190 }
191}
192
193fn resolve<A: 'static>(id: HandleId) -> Handle<A> {
194 Handle::from_id(id)
195}
196
197impl AnySelectable {
198 pub fn id(self) -> HandleId {
200 self.id
201 }
202
203 pub fn value(self, app: &App) -> SelectionGeometry {
205 (self.vtable.value)(app, self.id)
206 }
207
208 pub fn push_handle_layers(
210 self,
211 app: &mut App,
212 start_handle: Option<Ref<LayerLink>>,
213 end_handle: Option<Ref<LayerLink>>,
214 ) {
215 (self.vtable.push_handle_layers)(app, self.id, start_handle, end_handle)
216 }
217
218 pub fn selected_content(self, app: &App) -> Option<SelectedContent> {
220 (self.vtable.selected_content)(app, self.id)
221 }
222
223 pub fn selection(self, app: &App) -> Option<SelectedContentRange> {
225 (self.vtable.selection)(app, self.id)
226 }
227
228 pub fn dispatch_selection_event(
230 self,
231 app: &mut App,
232 event: &SelectionEvent,
233 ) -> SelectionResult {
234 (self.vtable.dispatch_selection_event)(app, self.id, event)
235 }
236
237 pub fn content_length(self, app: &App) -> usize {
239 (self.vtable.content_length)(app, self.id)
240 }
241
242 pub fn get_transform_to(self, app: &App, ancestor: Option<AnyRenderObject>) -> Matrix4 {
244 (self.vtable.get_transform_to)(app, self.id, ancestor)
245 }
246
247 pub fn size(self, app: &mut App) -> Size {
249 (self.vtable.size)(app, self.id)
250 }
251
252 pub fn bounding_boxes(self, app: &mut App) -> Vec<Rect> {
254 (self.vtable.bounding_boxes)(app, self.id)
255 }
256
257 pub fn dispose_selectable(self, app: &mut App) {
259 (self.vtable.dispose_selectable)(app, self.id)
260 }
261
262 pub fn add_listener(self, app: &mut App, listener: Listener) {
265 (self.vtable.add_listener)(app, self.id, listener)
266 }
267
268 pub fn remove_listener(self, app: &mut App, listener: &Listener) {
270 (self.vtable.remove_listener)(app, self.id, listener)
271 }
272}
273
274impl std::fmt::Debug for AnySelectable {
275 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
276 f.debug_struct("AnySelectable")
277 .field("id", &self.id)
278 .finish()
279 }
280}
281
282waft_foundation::erased_handle!(AnySelectable: Selectable => Selectable::as_selectable);
283
284#[derive(Debug, Default)]
286pub struct SelectionRegistrantData {
287 registrar: Option<SelectionRegistrarRef>,
288 subscribed_to_selection_registrar: bool,
289}
290
291impl SelectionRegistrantData {
292 pub fn new() -> SelectionRegistrantData {
294 SelectionRegistrantData::default()
295 }
296}
297
298pub trait SelectionRegistrant: Selectable {
303 fn selection_registrant_data(self: Handle<Self>, app: &App) -> &SelectionRegistrantData;
305
306 fn selection_registrant_data_mut(
308 self: Handle<Self>,
309 app: &mut App,
310 ) -> &mut SelectionRegistrantData;
311
312 fn registrar(self: Handle<Self>, app: &App) -> Option<AnySelectionRegistrar> {
314 self.selection_registrant_data(app)
315 .registrar
316 .as_ref()
317 .map(Retained::handle)
318 }
319
320 fn set_registrar(self: Handle<Self>, app: &mut App, value: Option<SelectionRegistrarRef>) {
322 let registrar = self.registrar(app);
323 if value.as_ref().map(Retained::handle) == registrar {
324 return;
325 }
326 let listener = Listener::handle_method(self, Self::update_selection_registrar_subscription);
327 if value.is_none() {
328 self.remove_listener_from(app, &listener);
330 } else if registrar.is_none() {
331 self.add_listener_to(app, listener);
333 }
334 self.remove_selection_registrar_subscription(app);
335 self.selection_registrant_data_mut(app).registrar = value;
336 self.update_selection_registrar_subscription(app);
337 }
338
339 fn update_selection_registrar_subscription(self: Handle<Self>, app: &mut App) {
341 let Some(registrar) = self.registrar(app) else {
342 self.selection_registrant_data_mut(app)
343 .subscribed_to_selection_registrar = false;
344 return;
345 };
346 let has_content = self.value(app).has_content;
347 let subscribed = self
348 .selection_registrant_data(app)
349 .subscribed_to_selection_registrar;
350 if subscribed && !has_content {
351 registrar.remove(app, self.as_selectable());
352 self.selection_registrant_data_mut(app)
353 .subscribed_to_selection_registrar = false;
354 } else if !subscribed && has_content {
355 registrar.add(app, self.as_selectable());
356 self.selection_registrant_data_mut(app)
357 .subscribed_to_selection_registrar = true;
358 }
359 }
360
361 fn remove_selection_registrar_subscription(self: Handle<Self>, app: &mut App) {
363 if self
364 .selection_registrant_data(app)
365 .subscribed_to_selection_registrar
366 {
367 let registrar = self
368 .registrar(app)
369 .expect("a subscribed registrant has a registrar");
370 registrar.remove(app, self.as_selectable());
371 self.selection_registrant_data_mut(app)
372 .subscribed_to_selection_registrar = false;
373 }
374 }
375
376 fn dispose_selection_registrant(self: Handle<Self>, app: &mut App) {
379 self.remove_selection_registrar_subscription(app);
380 }
381}
382
383pub trait SelectionRegistrar: Sized + 'static {
385 fn as_selection_registrar(self: Handle<Self>) -> AnySelectionRegistrar {
387 AnySelectionRegistrar {
388 id: self.id(),
389 vtable: const { &SelectionRegistrarVTable::of::<Self>() },
390 }
391 }
392
393 fn add(self: Handle<Self>, app: &mut App, selectable: AnySelectable);
395
396 fn remove(self: Handle<Self>, app: &mut App, selectable: AnySelectable);
398}
399
400#[derive(Clone, Copy)]
402pub struct AnySelectionRegistrar {
403 id: HandleId,
404 vtable: &'static SelectionRegistrarVTable,
405}
406
407struct SelectionRegistrarVTable {
408 add: fn(&mut App, HandleId, AnySelectable),
409 remove: fn(&mut App, HandleId, AnySelectable),
410}
411
412impl SelectionRegistrarVTable {
413 const fn of<A: SelectionRegistrar>() -> SelectionRegistrarVTable {
414 SelectionRegistrarVTable {
415 add: |app, id, selectable| A::add(resolve(id), app, selectable),
416 remove: |app, id, selectable| A::remove(resolve(id), app, selectable),
417 }
418 }
419}
420
421impl AnySelectionRegistrar {
422 pub fn id(self) -> HandleId {
424 self.id
425 }
426
427 pub fn add(self, app: &mut App, selectable: AnySelectable) {
429 (self.vtable.add)(app, self.id, selectable)
430 }
431
432 pub fn remove(self, app: &mut App, selectable: AnySelectable) {
434 (self.vtable.remove)(app, self.id, selectable)
435 }
436}
437
438impl std::fmt::Debug for AnySelectionRegistrar {
439 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
440 f.debug_struct("AnySelectionRegistrar")
441 .field("id", &self.id)
442 .finish()
443 }
444}
445
446pub type SelectionRegistrarRef = Retained<AnySelectionRegistrar>;
451
452waft_foundation::erased_handle!(AnySelectionRegistrar: SelectionRegistrar => SelectionRegistrar::as_selection_registrar);
453
454#[derive(Clone, Copy, Debug, PartialEq, Eq)]
456pub enum SelectionStatus {
457 Uncollapsed,
459 Collapsed,
461 None,
463}
464
465#[derive(Clone, Debug, PartialEq)]
467pub struct SelectionGeometry {
468 pub start_selection_point: Option<SelectionPoint>,
470 pub end_selection_point: Option<SelectionPoint>,
472 pub status: SelectionStatus,
474 pub selection_rects: Vec<Rect>,
476 pub has_content: bool,
478}
479
480impl SelectionGeometry {
481 pub fn new(status: SelectionStatus, has_content: bool) -> SelectionGeometry {
484 SelectionGeometry {
485 start_selection_point: None,
486 end_selection_point: None,
487 status,
488 selection_rects: Vec::new(),
489 has_content,
490 }
491 }
492
493 pub fn start_selection_point(mut self, value: Option<SelectionPoint>) -> SelectionGeometry {
495 self.start_selection_point = value;
496 self.debug_assert_points_have_selection();
497 self
498 }
499
500 pub fn end_selection_point(mut self, value: Option<SelectionPoint>) -> SelectionGeometry {
502 self.end_selection_point = value;
503 self.debug_assert_points_have_selection();
504 self
505 }
506
507 pub fn selection_rects(mut self, value: Vec<Rect>) -> SelectionGeometry {
509 self.selection_rects = value;
510 self
511 }
512
513 pub fn status(mut self, value: SelectionStatus) -> SelectionGeometry {
515 self.status = value;
516 self
517 }
518
519 pub fn has_content(mut self, value: bool) -> SelectionGeometry {
521 self.has_content = value;
522 self
523 }
524
525 fn debug_assert_points_have_selection(&self) {
526 debug_assert!(
527 (self.start_selection_point.is_none() && self.end_selection_point.is_none())
528 || self.status != SelectionStatus::None
529 );
530 }
531
532 pub fn has_selection(&self) -> bool {
534 self.status != SelectionStatus::None
535 }
536
537 pub fn copy_with(&self) -> SelectionGeometry {
539 self.clone()
540 }
541}
542
543#[derive(Clone, Copy, Debug, PartialEq)]
545pub struct SelectionPoint {
546 pub local_position: Offset,
548 pub line_height: f64,
550 pub handle_type: TextSelectionHandleType,
552}
553
554impl SelectionPoint {
555 pub fn new(
557 local_position: Offset,
558 line_height: f64,
559 handle_type: TextSelectionHandleType,
560 ) -> SelectionPoint {
561 SelectionPoint {
562 local_position,
563 line_height,
564 handle_type,
565 }
566 }
567}
568
569#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
571pub enum TextSelectionHandleType {
572 Left,
574 Right,
576 Collapsed,
578}
579
580pub struct SelectionUtils;
582
583impl SelectionUtils {
584 pub fn get_result_based_on_rect(target_rect: Rect, point: Offset) -> SelectionResult {
589 if target_rect.contains(point) {
590 return SelectionResult::End;
591 }
592 if point.dy() < target_rect.top {
593 return SelectionResult::Previous;
594 }
595 if point.dy() > target_rect.bottom {
596 return SelectionResult::Next;
597 }
598 if point.dx() >= target_rect.right {
599 SelectionResult::Next
600 } else {
601 SelectionResult::Previous
602 }
603 }
604
605 pub fn adjust_drag_offset(
611 target_rect: Rect,
612 point: Offset,
613 direction: TextDirection,
614 ) -> Offset {
615 if target_rect.contains(point) {
616 return point;
617 }
618 if point.dy() <= target_rect.top
619 || point.dy() <= target_rect.bottom && point.dx() <= target_rect.left
620 {
621 if direction == TextDirection::Ltr {
623 Offset::new(target_rect.left, target_rect.top)
624 } else {
625 Offset::new(target_rect.right, target_rect.top)
626 }
627 } else {
628 if direction == TextDirection::Ltr {
630 Offset::new(target_rect.right, target_rect.bottom)
631 } else {
632 Offset::new(target_rect.left, target_rect.bottom)
633 }
634 }
635 }
636}
637
638#[derive(Clone, Copy, Debug, PartialEq, Eq)]
640pub enum TextGranularity {
641 Character,
643 Word,
645 Paragraph,
647 Line,
649 Document,
651}
652
653#[derive(Clone, Copy, Debug, PartialEq, Eq)]
655pub enum SelectionExtendDirection {
656 PreviousLine,
658 NextLine,
660 Forward,
662 Backward,
664}
665
666#[derive(Clone, Debug)]
671pub enum SelectionEvent {
672 StartEdgeUpdate {
674 global_position: Offset,
676 granularity: TextGranularity,
678 },
679 EndEdgeUpdate {
681 global_position: Offset,
683 granularity: TextGranularity,
685 },
686 Clear,
688 SelectAll,
690 SelectWord {
692 global_position: Offset,
694 },
695 SelectParagraph {
697 global_position: Offset,
699 absorb: bool,
701 },
702 GranularlyExtendSelection {
704 forward: bool,
706 is_end: bool,
708 granularity: TextGranularity,
710 },
711 DirectionallyExtendSelection {
713 dx: f64,
715 is_end: bool,
717 direction: SelectionExtendDirection,
719 },
720}
721
722impl SelectionEvent {
723 pub fn ty(&self) -> SelectionEventType {
725 match self {
726 SelectionEvent::StartEdgeUpdate { .. } => SelectionEventType::StartEdgeUpdate,
727 SelectionEvent::EndEdgeUpdate { .. } => SelectionEventType::EndEdgeUpdate,
728 SelectionEvent::Clear => SelectionEventType::Clear,
729 SelectionEvent::SelectAll => SelectionEventType::SelectAll,
730 SelectionEvent::SelectWord { .. } => SelectionEventType::SelectWord,
731 SelectionEvent::SelectParagraph { .. } => SelectionEventType::SelectParagraph,
732 SelectionEvent::GranularlyExtendSelection { .. } => {
733 SelectionEventType::GranularlyExtendSelection
734 }
735 SelectionEvent::DirectionallyExtendSelection { .. } => {
736 SelectionEventType::DirectionallyExtendSelection
737 }
738 }
739 }
740
741 pub fn for_start(
743 global_position: Offset,
744 granularity: Option<TextGranularity>,
745 ) -> SelectionEvent {
746 SelectionEvent::StartEdgeUpdate {
747 global_position,
748 granularity: granularity.unwrap_or(TextGranularity::Character),
749 }
750 }
751
752 pub fn for_end(
754 global_position: Offset,
755 granularity: Option<TextGranularity>,
756 ) -> SelectionEvent {
757 SelectionEvent::EndEdgeUpdate {
758 global_position,
759 granularity: granularity.unwrap_or(TextGranularity::Character),
760 }
761 }
762
763 pub fn copy_with(
765 &self,
766 dx: Option<f64>,
767 is_end: Option<bool>,
768 direction: Option<SelectionExtendDirection>,
769 ) -> SelectionEvent {
770 match self {
771 SelectionEvent::DirectionallyExtendSelection {
772 dx: old_dx,
773 is_end: old_is_end,
774 direction: old_direction,
775 } => SelectionEvent::DirectionallyExtendSelection {
776 dx: dx.unwrap_or(*old_dx),
777 is_end: is_end.unwrap_or(*old_is_end),
778 direction: direction.unwrap_or(*old_direction),
779 },
780 event => event.clone(),
781 }
782 }
783}
784
785#[derive(Clone, Copy, Debug, PartialEq, Eq)]
787pub enum SelectionEventType {
788 StartEdgeUpdate,
790 EndEdgeUpdate,
792 Clear,
794 SelectAll,
796 SelectWord,
798 SelectParagraph,
800 GranularlyExtendSelection,
802 DirectionallyExtendSelection,
804}
805
806#[cfg(test)]
807mod tests {
808 use super::*;
809
810 const RECT: Rect = Rect::from_ltrb(100.0, 100.0, 300.0, 600.0);
811 const OUTSIDE_TOP_LEFT: Offset = Offset::new(50.0, 50.0);
812 const OUTSIDE_LEFT: Offset = Offset::new(50.0, 200.0);
813 const OUTSIDE_BOTTOM_LEFT: Offset = Offset::new(50.0, 700.0);
814 const OUTSIDE_TOP: Offset = Offset::new(200.0, 50.0);
815 const OUTSIDE_TOP_RIGHT: Offset = Offset::new(350.0, 50.0);
816 const OUTSIDE_RIGHT: Offset = Offset::new(350.0, 200.0);
817 const OUTSIDE_BOTTOM_RIGHT: Offset = Offset::new(350.0, 700.0);
818 const OUTSIDE_BOTTOM: Offset = Offset::new(200.0, 700.0);
819 const CENTER: Offset = Offset::new(150.0, 300.0);
820
821 #[test]
823 fn selection_based_on_rect_works() {
824 assert_eq!(
825 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_TOP_LEFT),
826 SelectionResult::Previous
827 );
828 assert_eq!(
829 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_LEFT),
830 SelectionResult::Previous
831 );
832 assert_eq!(
833 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_BOTTOM_LEFT),
834 SelectionResult::Next
835 );
836 assert_eq!(
837 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_TOP),
838 SelectionResult::Previous
839 );
840 assert_eq!(
841 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_TOP_RIGHT),
842 SelectionResult::Previous
843 );
844 assert_eq!(
845 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_RIGHT),
846 SelectionResult::Next
847 );
848 assert_eq!(
849 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_BOTTOM_RIGHT),
850 SelectionResult::Next
851 );
852 assert_eq!(
853 SelectionUtils::get_result_based_on_rect(RECT, OUTSIDE_BOTTOM),
854 SelectionResult::Next
855 );
856 assert_eq!(
857 SelectionUtils::get_result_based_on_rect(RECT, CENTER),
858 SelectionResult::End
859 );
860 }
861
862 #[test]
864 fn adjust_drag_offset_works() {
865 let top_left = Offset::new(RECT.left, RECT.top);
866 let top_right = Offset::new(RECT.right, RECT.top);
867 let bottom_left = Offset::new(RECT.left, RECT.bottom);
868 let bottom_right = Offset::new(RECT.right, RECT.bottom);
869
870 for (point, expected) in [
872 (OUTSIDE_TOP_LEFT, top_left),
873 (OUTSIDE_LEFT, top_left),
874 (OUTSIDE_BOTTOM_LEFT, bottom_right),
875 (OUTSIDE_TOP, top_left),
876 (OUTSIDE_TOP_RIGHT, top_left),
877 (OUTSIDE_RIGHT, bottom_right),
878 (OUTSIDE_BOTTOM_RIGHT, bottom_right),
879 (OUTSIDE_BOTTOM, bottom_right),
880 (CENTER, CENTER),
881 ] {
882 assert_eq!(
883 SelectionUtils::adjust_drag_offset(RECT, point, TextDirection::Ltr),
884 expected
885 );
886 }
887 for (point, expected) in [
889 (OUTSIDE_TOP_LEFT, top_right),
890 (OUTSIDE_LEFT, top_right),
891 (OUTSIDE_BOTTOM_LEFT, bottom_left),
892 (OUTSIDE_TOP, top_right),
893 (OUTSIDE_TOP_RIGHT, top_right),
894 (OUTSIDE_RIGHT, bottom_left),
895 (OUTSIDE_BOTTOM_RIGHT, bottom_left),
896 (OUTSIDE_BOTTOM, bottom_left),
897 (CENTER, CENTER),
898 ] {
899 assert_eq!(
900 SelectionUtils::adjust_drag_offset(RECT, point, TextDirection::Rtl),
901 expected
902 );
903 }
904 }
905}