Skip to content

Commit

Permalink
fix!: Move Name and NameProperty from UIElement to `FrameworkEl…
Browse files Browse the repository at this point in the history
…ement`
  • Loading branch information
Youssef1313 committed May 11, 2023
1 parent d7f2cd1 commit bc20032
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 60 deletions.
3 changes: 3 additions & 0 deletions build/PackageDiffIgnore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@
<Member fullName="System.Boolean Uno.Devices.Sensors.INativeDualScreenProvider::IsDualScreen()" reason="Api alignments" />
<Member fullName="Uno.Presentation.Resources.IResourceRegistry Windows.UI.Xaml.ResourceHelper::Registry()" reason="Api alignments" />
<Member fullName="Windows.UI.Xaml.DependencyProperty Windows.UI.Xaml.FrameworkElement::IsEnabledProperty()" reason="Api alignments" />
<Member fullName="System.String Windows.UI.Xaml.UIElement::Name()" reason="Api alignments" />
<Member fullName="System.Boolean Windows.UI.Xaml.FrameworkElement::IsEnabled()" reason="Api alignments" />


Expand Down Expand Up @@ -1170,6 +1171,8 @@
<Member fullName="System.Void Windows.Media.Playback.MediaPlayer.set_Position(System.TimeSpan value)" reason="Api alignments" />
<Member fullName="System.TimeSpan Windows.Media.Playback.MediaPlayer.get_Position()" reason="Api alignments" />

<Member fullName="System.String Windows.UI.Xaml.UIElement.get_Name()" reason="Api alignments" />
<Member fullName="System.Void Windows.UI.Xaml.UIElement.set_Name(System.String)" reason="Api alignments" />
<Member fullName="System.Void Windows.UI.Xaml.Media.Animation.Timeline.Dispose(System.Boolean disposing)" reason="Api alignments" />
<Member fullName="System.Void Windows.UI.Xaml.Media.Animation.Timeline.Dispose()" reason="Api alignments" />

Expand Down
2 changes: 0 additions & 2 deletions src/Uno.UI/UI/Xaml/Documents/TextElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ public bool AllowFocusOnInteraction

#endregion

#if !__WASM__ // WASM version is inheriting from UIElement, so it's already implementing it.
public string Name { get; set; }
#endif

/// <summary>
/// Retrieves the parent RichTextBox/CRichTextBlock/TextBlock.
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/FrameworkElement.netstdref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Windows.UI.Xaml
{
public partial class FrameworkElement : IEnumerable
{

public string Name { get; set; }

bool IFrameworkElementInternal.HasLayouter => throw new NotSupportedException("Reference assembly");

internal T AddChild<T>(T child) where T : View => throw new NotSupportedException("Reference assembly");
Expand Down
25 changes: 21 additions & 4 deletions src/Uno.UI/UI/Xaml/FrameworkElement.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Uno.UI.Xaml;
using System.Numerics;
using Uno.UI;

namespace Windows.UI.Xaml
{
Expand Down Expand Up @@ -59,10 +60,26 @@ internal void RaiseSizeChanged(SizeChangedEventArgs args)
_renderTransform?.UpdateSize(args.NewSize);
}

/// <summary>
/// Identifies the Name dependency property.
/// </summary>
public static new DependencyProperty NameProperty => UIElement.NameProperty;
#region Name Dependency Property

private void OnNameChanged(string oldValue, string newValue)
{
if (FrameworkElementHelper.IsUiAutomationMappingEnabled)
{
Windows.UI.Xaml.Automation.AutomationProperties.SetAutomationId(this, newValue);
}
}

[GeneratedDependencyProperty(DefaultValue = "", ChangedCallback = true)]
internal static DependencyProperty NameProperty { get; } = CreateNameProperty();

public string Name
{
get => GetNameValue();
set => SetNameValue(value);
}

#endregion

#region Margin Dependency Property
[GeneratedDependencyProperty(
Expand Down
29 changes: 25 additions & 4 deletions src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,31 @@ partial void OnBackgroundSizingChangedPartial(DependencyPropertyChangedEventArgs
}
}

/// <summary>
/// Identifies the Name dependency property.
/// </summary>
public static new DependencyProperty NameProperty => UIElement.NameProperty;
#region Name Dependency Property

private void OnNameChanged(string oldValue, string newValue)
{
if (FrameworkElementHelper.IsUiAutomationMappingEnabled)
{
Windows.UI.Xaml.Automation.AutomationProperties.SetAutomationId(this, newValue);
}

if (FeatureConfiguration.UIElement.AssignDOMXamlName)
{
Uno.UI.Xaml.WindowManagerInterop.SetName(HtmlId, newValue);
}
}

[GeneratedDependencyProperty(DefaultValue = "", ChangedCallback = true)]
public static DependencyProperty NameProperty { get; } = CreateNameProperty();

public string Name
{
get => GetNameValue();
set => SetNameValue(value);
}

#endregion

#region Margin Dependency Property
[GeneratedDependencyProperty(
Expand Down
2 changes: 0 additions & 2 deletions src/Uno.UI/UI/Xaml/UIElement.netstdref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public UIElement()

public IntPtr Handle { get; }

public string Name { get; set; }

internal bool IsMeasureDirtyPath => throw new NotSupportedException("Reference assembly");

internal bool IsArrangeDirtyPath => throw new NotSupportedException("Reference assembly");
Expand Down
23 changes: 1 addition & 22 deletions src/Uno.UI/UI/Xaml/UIElement.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal ContainerVisual Visual
if (_visual == null)
{
_visual = Window.Current.Compositor.CreateContainerVisual();
_visual.Comment = $"Owner:{GetType()}/{Name}";
_visual.Comment = $"Owner:{GetType()}/{(this as FrameworkElement)?.Name}";
}

return _visual;
Expand Down Expand Up @@ -227,27 +227,6 @@ private void InnerRemoveChild(UIElement child)

internal UIElement FindFirstChild() => _children.FirstOrDefault();

#region Name Dependency Property

private void OnNameChanged(string oldValue, string newValue)
{
if (FrameworkElementHelper.IsUiAutomationMappingEnabled)
{
Windows.UI.Xaml.Automation.AutomationProperties.SetAutomationId(this, newValue);
}
}

[GeneratedDependencyProperty(DefaultValue = "", ChangedCallback = true)]
internal static DependencyProperty NameProperty { get; } = CreateNameProperty();

public string Name
{
get => GetNameValue();
set => SetNameValue(value);
}

#endregion

partial void InitializeCapture();

internal bool IsPointerCaptured { get; set; }
Expand Down
26 changes: 0 additions & 26 deletions src/Uno.UI/UI/Xaml/UIElement.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,32 +351,6 @@ internal static UIElement GetElementFromHandle(int handle)

private Rect _arranged;

#region Name Dependency Property

private void OnNameChanged(string oldValue, string newValue)
{
if (FrameworkElementHelper.IsUiAutomationMappingEnabled)
{
Windows.UI.Xaml.Automation.AutomationProperties.SetAutomationId(this, newValue);
}

if (FeatureConfiguration.UIElement.AssignDOMXamlName)
{
Uno.UI.Xaml.WindowManagerInterop.SetName(HtmlId, newValue);
}
}

[GeneratedDependencyProperty(DefaultValue = "", ChangedCallback = true)]
public static DependencyProperty NameProperty { get; } = CreateNameProperty();

public string Name
{
get => GetNameValue();
set => SetNameValue(value);
}

#endregion

partial void OnUidChangedPartial()
{
if (FeatureConfiguration.UIElement.AssignDOMXamlName)
Expand Down

0 comments on commit bc20032

Please sign in to comment.