Skip to content

Breakup XamlUIService into separate APIs #10430

@rozele

Description

@rozele

Summary

It feels like over time, XamlUIService has become a bit of a dumping ground for various APIs.

  1. It was originally created in 2809c9a to handle looking up tags from elements.
  2. Then we added an option to get a singleton XamlRoot in f52d494
  3. Then we added options to set the HWND in bdd23dc
  4. The an accessibility workaround in 2dfb964
  5. There is a proposed addition for getting the React tag and ReactRootView here: Adds GetReactRootView method to XamlUIService #10403
  6. And another proposal for adding a mechanism to invoke nested Yoga layout here: Add method to invoke nested Yoga layout #10237

It feels like we should separate concerns a bit here and expose a few new APIs:

  1. XamlUIService can remain as a translation layer between XAML views and the React shadow tree to fill the gap of missing shadow nodes in the exposed ABI, e.g.:
void XamlUIService::GetElementFromTag(int64_t tag)
void XamlUIService::GetReactTag(xaml::DependencyObject view)
ReactRootView XamlUIService::GetReactRootView(xaml::DependencyObject view)
  1. A per root view ReactWindowService could be added to ReactRootView to handle things like getting / setting the HWND, getting / setting the XamlRoot, getting / setting the accessibility root, etc.
ReactWindowService ReactRootView::WindowService()
void ReactWindowService::XamlRoot(XamlRoot root);
XamlRoot ReactWindowService::XamlRoot();
void ReactWindowService::HWND(int64_t);
uint64_t ReactWindowService::HWND();
// Do not exist yet, but would be needed to feed scale factors to Yoga
double ReactWindowService::ScaleFactor();
void ReactWindowService::ScaleFactor(double scaleFactor);
  1. A service for the AccessibilityInfoModule, AccessibilityInfoService:
AccessibilityInfoService ReactContext::AccessibilityInfoService();
void AccessibilityInfoService::AccessibleRoot(xaml::FrameworkElement root);
xaml::FrameworkElement AccessibilityInfoService::AccessibleRoot();
  1. An API for event dispatching, EventDispatcher:
EventDispatcher ReactContext::EventDispatcher()
void EventDispatcher::DispatchEvent(...)
// Does not exist yet, but would be useful
void EventDispatcher::DispatchCoalescedEvent(...)
  1. An API for UIManager, UIManagerService:
UIManagerService ReactContext::UIManagerService()
void UIManagerService::UpdateYogaLayout(int64_t tag);
// Does not exist yet, but would expose public surfaces for functionality in iOS/Android
void UIManagerService::AddOnBatchCompleteListener(...);

Motivation

Separation of concerns for the collection of methods exposed in XamlUIService.

Basic Example

No response

Open Questions

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions