Browse Source

Remove IValueFrame.

And use the concrete `ValueFrame` (renamed from `ValueFrameBase`) as this was the only implementation of the interface.
refactor/style-priorities
Steven Kirk 4 years ago
parent
commit
caf5686777
  1. 4
      src/Avalonia.Base/PropertyStore/BindingEntry.cs
  2. 6
      src/Avalonia.Base/PropertyStore/BindingEntry`1.cs
  3. 2
      src/Avalonia.Base/PropertyStore/IValueEntry.cs
  4. 2
      src/Avalonia.Base/PropertyStore/IValueEntry`1.cs
  5. 56
      src/Avalonia.Base/PropertyStore/IValueFrame.cs
  6. 2
      src/Avalonia.Base/PropertyStore/ImmediateValueFrame.cs
  7. 4
      src/Avalonia.Base/PropertyStore/UntypedBindingEntry.cs
  8. 2
      src/Avalonia.Base/PropertyStore/ValueFrame.cs
  9. 20
      src/Avalonia.Base/PropertyStore/ValueStore.cs
  10. 2
      src/Avalonia.Base/Styling/StyleBase.cs
  11. 10
      src/Avalonia.Base/Styling/StyleInstance.cs

4
src/Avalonia.Base/PropertyStore/BindingEntry.cs

@ -9,14 +9,14 @@ namespace Avalonia.PropertyStore
IObserver<object?>,
IDisposable
{
private readonly ValueFrameBase _frame;
private readonly ValueFrame _frame;
private readonly IObservable<object?> _source;
private IDisposable? _subscription;
private bool _hasValue;
private object? _value;
public BindingEntry(
ValueFrameBase frame,
ValueFrame frame,
AvaloniaProperty property,
IObservable<object?> source)
{

6
src/Avalonia.Base/PropertyStore/BindingEntry`1.cs

@ -12,14 +12,14 @@ namespace Avalonia.PropertyStore
IObserver<BindingValue<T>>,
IDisposable
{
private readonly ValueFrameBase _frame;
private readonly ValueFrame _frame;
private readonly object _source;
private IDisposable? _subscription;
private bool _hasValue;
private T? _value;
public BindingEntry(
ValueFrameBase frame,
ValueFrame frame,
StyledPropertyBase<T> property,
IObservable<BindingValue<T>> source)
{
@ -29,7 +29,7 @@ namespace Avalonia.PropertyStore
}
public BindingEntry(
ValueFrameBase frame,
ValueFrame frame,
StyledPropertyBase<T> property,
IObservable<T> source)
{

2
src/Avalonia.Base/PropertyStore/IValueEntry.cs

@ -3,7 +3,7 @@
namespace Avalonia.PropertyStore
{
/// <summary>
/// Represents an untyped value entry in an <see cref="IValueFrame"/>.
/// Represents an untyped value entry in a <see cref="ValueFrame"/>.
/// </summary>
internal interface IValueEntry
{

2
src/Avalonia.Base/PropertyStore/IValueEntry`1.cs

@ -1,7 +1,7 @@
namespace Avalonia.PropertyStore
{
/// <summary>
/// Represents a typed value entry in an <see cref="IValueFrame"/>.
/// Represents a typed value entry in a <see cref="ValueFrame"/>.
/// </summary>
internal interface IValueEntry<T> : IValueEntry
{

56
src/Avalonia.Base/PropertyStore/IValueFrame.cs

@ -1,56 +0,0 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Data;
namespace Avalonia.PropertyStore
{
/// <summary>
/// Represents a collection of property values in a <see cref="PropertyStore.ValueStore"/>.
/// </summary>
/// <remarks>
/// A value frame is an abstraction over the following sources of values in an
/// <see cref="AvaloniaObject"/>:
///
/// - A style
/// - Local values
/// - Animation values
/// </remarks>
internal interface IValueFrame : IDisposable
{
/// <summary>
/// Gets the number of value entries in the frame.
/// </summary>
int EntryCount { get; }
/// <summary>
/// Gets a value indicating whether the frame is active.
/// </summary>
bool IsActive { get; }
/// <summary>
/// Gets the value store that owns the frame.
/// </summary>
ValueStore? Owner { get; }
/// <summary>
/// Gets the frame's priority.
/// </summary>
BindingPriority Priority { get; }
/// <summary>
/// Retreives the frame's value entry with the specified index.
/// </summary>
IValueEntry GetEntry(int index);
/// <summary>
/// Sets the owner of the value frame.
/// </summary>
/// <param name="owner">The new owner.</param>
void SetOwner(ValueStore? owner);
/// <summary>
/// Tries to retreive the frame's value entry for the specified property.
/// </summary>
bool TryGetEntry(AvaloniaProperty property, [NotNullWhen(true)] out IValueEntry? entry);
}
}

2
src/Avalonia.Base/PropertyStore/ImmediateValueFrame.cs

@ -7,7 +7,7 @@ namespace Avalonia.PropertyStore
/// Holds values in a <see cref="ValueStore"/> set by one of the SetValue or AddBinding
/// overloads with non-LocalValue priority.
/// </summary>
internal class ImmediateValueFrame : ValueFrameBase
internal class ImmediateValueFrame : ValueFrame
{
public ImmediateValueFrame(BindingPriority priority)
{

4
src/Avalonia.Base/PropertyStore/UntypedBindingEntry.cs

@ -10,14 +10,14 @@ namespace Avalonia.PropertyStore
IObserver<object?>,
IDisposable
{
private readonly ValueFrameBase _frame;
private readonly ValueFrame _frame;
private readonly IObservable<object?> _source;
private IDisposable? _subscription;
private bool _hasValue;
private T? _value;
public UntypedBindingEntry(
ValueFrameBase frame,
ValueFrame frame,
StyledPropertyBase<T> property,
IObservable<object?> source)
{

2
src/Avalonia.Base/PropertyStore/ValueFrameBase.cs → src/Avalonia.Base/PropertyStore/ValueFrame.cs

@ -5,7 +5,7 @@ using Avalonia.Utilities;
namespace Avalonia.PropertyStore
{
internal abstract class ValueFrameBase : IValueFrame
internal abstract class ValueFrame
{
private readonly AvaloniaPropertyValueStore<IValueEntry> _entries = new();

20
src/Avalonia.Base/PropertyStore/ValueStore.cs

@ -11,7 +11,7 @@ namespace Avalonia.PropertyStore
{
internal class ValueStore
{
private readonly List<IValueFrame> _frames = new();
private readonly List<ValueFrame> _frames = new();
private Dictionary<int, IDisposable>? _localValueBindings;
private Dictionary<AvaloniaProperty, EffectiveValue>? _effectiveValues;
private int _inheritedValueCount;
@ -22,7 +22,7 @@ namespace Avalonia.PropertyStore
public AvaloniaObject Owner { get; }
public ValueStore? InheritanceAncestor { get; private set; }
public IReadOnlyList<IValueFrame> Frames => _frames;
public IReadOnlyList<ValueFrame> Frames => _frames;
public void BeginStyling() => ++_styling;
@ -32,7 +32,7 @@ namespace Avalonia.PropertyStore
ReevaluateEffectiveValues();
}
public void AddFrame(IValueFrame style)
public void AddFrame(ValueFrame style)
{
InsertFrame(style);
ReevaluateEffectiveValues();
@ -366,7 +366,7 @@ namespace Avalonia.PropertyStore
/// </summary>
/// <param name="property">The previously bound property.</param>
/// <param name="frame">The frame which contained the binding.</param>
public void OnBindingCompleted(AvaloniaProperty property, IValueFrame frame)
public void OnBindingCompleted(AvaloniaProperty property, ValueFrame frame)
{
var priority = frame.Priority;
@ -378,11 +378,11 @@ namespace Avalonia.PropertyStore
}
/// <summary>
/// Called by an <see cref="IValueFrame"/> when its <see cref="IValueFrame.IsActive"/>
/// Called by a <see cref="ValueFrame"/> when its <see cref="ValueFrame.IsActive"/>
/// state changes.
/// </summary>
/// <param name="frame">The frame which produced the change.</param>
public void OnFrameActivationChanged(IValueFrame frame)
public void OnFrameActivationChanged(ValueFrame frame)
{
ReevaluateEffectiveValues();
}
@ -523,12 +523,12 @@ namespace Avalonia.PropertyStore
}
/// <summary>
/// Called by an <see cref="IValueFrame"/> to re-evaluate the effective value when a value
/// Called by a <see cref="ValueFrame"/> to re-evaluate the effective value when a value
/// is removed.
/// </summary>
/// <param name="frame">The frame on which the change occurred.</param>
/// <param name="property">The property whose value was removed.</param>
public void OnValueEntryRemoved(IValueFrame frame, AvaloniaProperty property)
public void OnValueEntryRemoved(ValueFrame frame, AvaloniaProperty property)
{
Debug.Assert(frame.IsActive);
@ -548,7 +548,7 @@ namespace Avalonia.PropertyStore
}
}
public bool RemoveFrame(IValueFrame frame)
public bool RemoveFrame(ValueFrame frame)
{
if (_frames.Remove(frame))
{
@ -570,7 +570,7 @@ namespace Avalonia.PropertyStore
null);
}
private void InsertFrame(IValueFrame frame)
private void InsertFrame(ValueFrame frame)
{
Debug.Assert(!_frames.Contains(frame));

2
src/Avalonia.Base/Styling/StyleBase.cs

@ -81,7 +81,7 @@ namespace Avalonia.Styling
return _resources?.TryGetResource(key, out result) ?? false;
}
internal IValueFrame Attach(IStyleable target, IStyleActivator? activator)
internal ValueFrame Attach(IStyleable target, IStyleActivator? activator)
{
if (target is not AvaloniaObject ao)
throw new InvalidOperationException("Styles can only be applied to AvaloniaObjects.");

10
src/Avalonia.Base/Styling/StyleInstance.cs

@ -10,13 +10,13 @@ namespace Avalonia.Styling
/// Stores state for a <see cref="Style"/> that has been instanced on a control.
/// </summary>
/// <remarks>
/// <see cref="StyleInstance"/> implements the <see cref="IValueFrame"/> interface meaning that
/// it is injected directly into the value store of an <see cref="AvaloniaObject"/>. Depending
/// on the setters present on the style, it may be possible to share a single style instance
/// among all controls that the style is applied to; meaning that a single style instance can
/// <see cref="StyleInstance"/> is based on <see cref="ValueFrame"/> meaning that it is
/// injected directly into the value store of an <see cref="AvaloniaObject"/>. Depending on
/// the setters present on the style, it may be possible to share a single style instance
/// among all controls that the style is applied to, meaning that a single style instance can
/// apply to multiple controls.
/// </remarks>
internal class StyleInstance : ValueFrameBase, IStyleInstance, IStyleActivatorSink, IDisposable
internal class StyleInstance : ValueFrame, IStyleInstance, IStyleActivatorSink, IDisposable
{
private readonly IStyleActivator? _activator;
private List<ISetterInstance>? _setters;

Loading…
Cancel
Save