提交 11408b3f 编写于 作者: M Martin Zikmund

fix: Workaround jumping ScrollViewers on Skia

上级 22c2c0e6
......@@ -94,8 +94,8 @@ namespace Windows.UI.Xaml
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || false || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool UseLayoutRounding
{
get
......@@ -554,8 +554,8 @@ namespace Windows.UI.Xaml
// Skipping already declared property RightTappedEvent
// Skipping already declared property DragEnterEvent
// Skipping already declared property TappedEvent
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || false || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty UseLayoutRoundingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(UseLayoutRounding), typeof(bool),
......
......@@ -21,6 +21,7 @@ using Windows.UI.Xaml.Input;
using Uno;
using Uno.Extensions;
using Uno.Foundation.Logging;
using Uno.UI.Extensions;
#if __ANDROID__
......@@ -49,6 +50,7 @@ using Microsoft.UI.Input;
#else
using Windows.Devices.Input;
using Windows.UI.Input;
using Windows.UI.Xaml.Media;
#endif
namespace Windows.UI.Xaml.Controls
......@@ -775,23 +777,16 @@ namespace Windows.UI.Xaml.Controls
ExtentWidth = 0;
}
var scrollableHeight = Math.Max(ExtentHeight - ViewportHeight, 0);
// On Skia, the ExtentHeight can include a rounding error, which may cause
// unwanted ScrollBar to pop in and out of existence.
if (scrollableHeight < 0.1)
{
scrollableHeight = 0;
}
// For scrollable height and scrollable width we apply rounding
// to ensure there is no unwanted difference caused by double
// precision, which could then cause the scroll bars to appear
// for no reason.
var scrollableHeight = Math.Max(Math.Round(ExtentHeight - ViewportHeight, 4), 0);
ScrollableHeight = scrollableHeight;
var scrollableWidth = Math.Max(ExtentWidth - ViewportWidth, 0);
// On Skia, the ExtentWidth can include a rounding error, which may cause
// unwanted ScrollBar to pop in and out of existence.
if (scrollableWidth < 0.1)
{
scrollableWidth = 0;
}
var scrollableWidth = Math.Max(Math.Round(ExtentWidth - ViewportWidth, 4), 0);
ScrollableWidth = scrollableWidth;
......@@ -941,6 +936,15 @@ namespace Windows.UI.Xaml.Controls
base.OnApplyTemplate();
#if __SKIA__
// To work around non-uniformly applied layout rounding behavior, we need to force set layout
// rounding on the child Grid currently. #12082
if (this.FindFirstDescendant<Grid>() is { } grid)
{
grid.UseLayoutRounding = false;
}
#endif
var scpTemplatePart = GetTemplateChild(Parts.WinUI3.Scroller) ?? GetTemplateChild(Parts.Uwp.ScrollContentPresenter);
_presenter = scpTemplatePart as _ScrollContentPresenter;
......
......@@ -956,7 +956,7 @@ namespace Windows.UI.Xaml
internal bool GetUseLayoutRounding()
{
#if __SKIA__
return true;
return UseLayoutRounding;
#else
return false;
#endif
......
......@@ -41,6 +41,19 @@ namespace Windows.UI.Xaml
UpdateHitTest();
}
public bool UseLayoutRounding
{
get => (bool)this.GetValue(UseLayoutRoundingProperty);
set => this.SetValue(UseLayoutRoundingProperty, value);
}
public static DependencyProperty UseLayoutRoundingProperty { get; } =
DependencyProperty.Register(
nameof(UseLayoutRounding),
typeof(bool),
typeof(UIElement),
new FrameworkPropertyMetadata(true));
internal bool IsChildrenRenderOrderDirty { get; set; } = true;
partial void InitializeKeyboard();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册