-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6916 from unoplatform/dev/cdb/bugs/wasm-getbbox
Fixed a potential crash with GetBBox() on WASM
- Loading branch information
Showing
6 changed files
with
252 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Offscreen_Shapes.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Page | ||
x:Class="UITests.Windows_UI_Xaml_Shapes.Offscreen_Shapes" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Shapes" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Grid RowSpacing="6" ColumnSpacing="6" x:Name="grid"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBlock FontSize="20" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="1">XAML</TextBlock> | ||
<TextBlock FontSize="20" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="2" FontStyle="Italic">Deferred</TextBlock> | ||
|
||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0">Ellipse</TextBlock> | ||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="2" Grid.Column="0">Line</TextBlock> | ||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="3" Grid.Column="0">Path</TextBlock> | ||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="4" Grid.Column="0">Polygon</TextBlock> | ||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="5" Grid.Column="0">Polyline</TextBlock> | ||
<TextBlock FontSize="20" VerticalAlignment="Center" Grid.Row="6" Grid.Column="0">Rectangle</TextBlock> | ||
|
||
<Ellipse Grid.Row="1" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" Width="60" Height="40" x:Name="xamlShape1" /> | ||
<Line Grid.Row="2" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" X2="60" Y2="30" x:Name="xamlShape2" /> | ||
<Path Grid.Row="3" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" Width="60" Height="40" x:Name="xamlShape3" Data="M0,0L60,40 0,40 60,0Z" /> | ||
<Polygon Grid.Row="4" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" Width="60" Height="40" x:Name="xamlShape4" Points="0,0 60,40 0,40" /> | ||
<Polyline Grid.Row="5" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" Width="60" Height="40" x:Name="xamlShape5" Points="0,0 60,40 20,30 50,10" /> | ||
<Rectangle Grid.Row="6" Grid.Column="1" Fill="Yellow" Stroke="Green" StrokeThickness="2" Width="60" Height="40" x:Name="xamlShape6" /> | ||
|
||
<TextBlock FontSize="20" Grid.Row="7" Grid.ColumnSpan="4" TextWrapping="Wrap"> The 2 columns should appear identical</TextBlock> | ||
</Grid> | ||
</Page> |
129 changes: 129 additions & 0 deletions
129
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/Offscreen_Shapes.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System.Threading.Tasks; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Markup; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Shapes; | ||
using Uno.Extensions; | ||
using Uno.UI.Samples.Controls; | ||
|
||
namespace UITests.Windows_UI_Xaml_Shapes | ||
{ | ||
[Sample("Shapes")] | ||
public sealed partial class Offscreen_Shapes : Page | ||
{ | ||
public Offscreen_Shapes() | ||
{ | ||
this.InitializeComponent(); | ||
|
||
Loaded += OnLoaded; | ||
} | ||
|
||
private async void OnLoaded(object sender, RoutedEventArgs e) | ||
{ | ||
Loaded -= OnLoaded; | ||
|
||
await Task.Delay(200); | ||
|
||
var sw = xamlShape1.Width; | ||
var sh = xamlShape1.Height; | ||
var sf = xamlShape1.Fill; | ||
var ss = xamlShape1.Stroke; | ||
var sst = xamlShape1.StrokeThickness; | ||
|
||
await SetShape( | ||
1, | ||
new Ellipse | ||
{ | ||
Width = sw, | ||
Height = sh, | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst | ||
}); | ||
|
||
await SetShape( | ||
2, | ||
new Line | ||
{ | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst, | ||
X2=xamlShape2.X2, | ||
Y2=xamlShape2.Y2 | ||
}); | ||
|
||
var p = await SetShape( | ||
3, | ||
new Path | ||
{ | ||
Width = sw, | ||
Height = sh, | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst, | ||
}); | ||
|
||
#if NETFX_CORE | ||
var geometry = XamlReader.Load("<Geometry xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>M0,0L60,40 0,40 60,0Z</Geometry>") as Geometry; | ||
#else | ||
var geometry = (Geometry)"M0,0L60,40 0,40 60,0Z"; | ||
#endif | ||
p.Data = geometry; | ||
|
||
var polygon = await SetShape( | ||
4, | ||
new Polygon | ||
{ | ||
Width = sw, | ||
Height = sh, | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst | ||
}); | ||
|
||
polygon.Points.AddRange(xamlShape4.Points); | ||
|
||
var polyline = await SetShape( | ||
5, | ||
new Polyline | ||
{ | ||
Width = sw, | ||
Height = sh, | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst, | ||
}); | ||
|
||
polyline.Points.AddRange(xamlShape5.Points); | ||
|
||
await SetShape( | ||
6, | ||
new Rectangle | ||
{ | ||
Width = sw, | ||
Height = sh, | ||
Fill = sf, | ||
Stroke = ss, | ||
StrokeThickness = sst | ||
}); | ||
|
||
async Task<T> SetShape<T>(int row, T element) | ||
where T : FrameworkElement | ||
{ | ||
await Task.Yield(); | ||
element.Measure(new Size(100, 100)); | ||
element.Arrange(new Rect(0, 0, 200, 200)); | ||
await Task.Yield(); | ||
Grid.SetColumn(element, 2); | ||
Grid.SetRow(element, row); | ||
element.Name = $"deferredShape{row}"; | ||
|
||
grid.Children.Add(element); | ||
|
||
return element; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.