8000 Replace boxing IList in HighlightChangedEventArgs and seal derived classes by edwardneal · Pull Request #9559 · dotnet/wpf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace boxing IList in HighlightChangedEventArgs and seal derived classes #9559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// and StickyNote anchors as well.
//

using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Documents;
Expand Down Expand Up @@ -546,7 +546,7 @@ private bool IsFixedContainer
#region Private Types

// Argument for the Changed event, encapsulates a highlight change.
private class AnnotationHighlightChangedEventArgs : HighlightChangedEventArgs
private sealed class AnnotationHighlightChangedEventArgs : HighlightChangedEventArgs
{
// Constructor.
internal AnnotationHighlightChangedEventArgs(ITextPointer start, ITextPointer end)
Expand All @@ -557,7 +557,7 @@ internal AnnotationHighlightChangedEventArgs(ITextPointer start, ITextPointer en
}

// Collection of changed content ranges.
internal override IList Ranges
internal override IList<TextSegment> Ranges
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using MS.Internal.Documents;
using System.Collections;
using System.Collections.Generic;

//
// Description: DocumentSequence's HighlightLayer for TextSelection.
Expand Down Expand Up @@ -68,7 +68,7 @@ internal override StaticTextPointer GetNextChangePosition(StaticTextPointer stat

// Called by the DocumentSequenceTextContainer to communicate changes to its highlight layer
// to the FixedDocumentTextContainer which contains this layer.
internal void RaiseHighlightChangedEvent(IList ranges)
internal void RaiseHighlightChangedEvent(IList<TextSegment> ranges)
{
DocumentsTrace.FixedDocumentSequence.Highlights.Trace($"DSHL.RaiseHighlightChangedEvent ranges={ranges.Count}");
Debug.Assert(ranges.Count > 0);
Expand Down Expand Up @@ -136,16 +136,16 @@ internal override Type OwnerType

#region Private Classes
// Argument for the Changed event, encapsulates a highlight change.
private class DocumentSequenceHighlightChangedEventArgs : HighlightChangedEventArgs
private sealed class DocumentSequenceHighlightChangedEventArgs : HighlightChangedEventArgs
{
// Constructor.
internal DocumentSequenceHighlightChangedEventArgs(IList ranges)
internal DocumentSequenceHighlightChangedEventArgs(IList<TextSegment> ranges)
{
_ranges = ranges;
}

// Collection of changed content ranges.
internal override IList Ranges
internal override IList<TextSegment> Ranges
{
get
{
Expand All @@ -163,7 +163,7 @@ internal override Type OwnerType
}

// Collection of changed content ranges.
private readonly IList _ranges;
private readonly IList<TextSegment> _ranges;
}
#endregion Private Classes
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private void _OnHighlightChanged(object sender, HighlightChangedEventArgs args)
DocumentsTrace.FixedDocumentSequence.TextOM.Trace("===EndNewHighlightRange===");
}
#endif
Debug.Assert(args.Ranges.Count > 0 && ((TextSegment)args.Ranges[0]).Start.CompareTo(((TextSegment)args.Ranges[0]).End) < 0);
Debug.Assert(args.Ranges.Count > 0 && args.Ranges[0].Start.CompareTo(args.Ranges[0].End) < 0);


// For each change range we received, we need to figure out
Expand All @@ -713,7 +713,7 @@ private void _OnHighlightChanged(object sender, HighlightChangedEventArgs args)
List<TextSegment> rangeArray = new List<TextSegment>(4);
while (idxScan < args.Ranges.Count)
{
TextSegment ts = (TextSegment)args.Ranges[idxScan];
TextSegment ts = args.Ranges[idxScan];
DocumentSequenceTextPointer tsEnd = (DocumentSequenceTextPointer)ts.End;
ITextPointer tpChildStart, tpChildEnd;
ChildDocumentBlock lastBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using System.IO.Packaging;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel; // DesignerSerializationVisibility
using System.Globalization;
using MS.Internal.Annotations.Component;
Expand Down Expand Up @@ -1031,7 +1032,7 @@ private void OnHighlightChanged(object sender, HighlightChangedEventArgs args)
Debug.Assert(args.Ranges != null);

DocumentsTrace.FixedTextOM.Highlight.Trace($"HightlightMoved From {0}-{0} To {0}-{0}");
Debug.Assert(args.Ranges.Count > 0 && ((TextSegment)args.Ranges[0]).Start.CompareTo(((TextSegment)args.Ranges[0]).End) < 0);
Debug.Assert(args.Ranges.Count > 0 && args.Ranges[0].Start.CompareTo(args.Ranges[0].End) < 0);

// REVIEW:benwest:7/9/2004: This code is reseting the entire highlight data structure
// on every highlight delta, which scales horribly. It should be possible
Expand Down Expand Up @@ -1130,13 +1131,13 @@ private void OnHighlightChanged(object sender, HighlightChangedEventArgs args)
}
}

ArrayList dirtyPages = new ArrayList();
IList ranges = args.Ranges;
List<int> dirtyPages = new List<int>();
IList<TextSegment> ranges = args.Ranges;

// Find the dirty page
for (int i = 0; i < ranges.Count; i++)
{
TextSegment textSegment = (TextSegment)ranges[i];
TextSegment textSegment = ranges[i];
int startPage = this.FixedContainer.GetPageNumber(textSegment.Start);
int endPage = this.FixedContainer.GetPageNumber(textSegment.End);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ private void OnHighlightChanged(object sender, HighlightChangedEventArgs args)
{
for (i = 0; i < args.Ranges.Count; i++)
{
textSegment = (TextSegment)args.Ranges[i];
textSegment = args.Ranges[i];
_formatter.OnContentInvalidated(false, textSegment.Start, textSegment.End);

if (_formatter is FlowDocumentFormatter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Description: HighlightLayer.Changed event argument.
//

using System.Collections;
using System.Collections.Generic;

namespace System.Windows.Documents
{
Expand All @@ -18,7 +18,7 @@ internal abstract class HighlightChangedEventArgs
/// Sorted, non-overlapping, readonly collection of TextSegments
/// affected by a highlight change.
/// </summary>
internal abstract IList Ranges { get; }
internal abstract IList<TextSegment> Ranges { get; }

/// <summary>
/// Type identifying the owner of the changed layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using MS.Internal;

Expand Down Expand Up @@ -402,7 +403,7 @@ private int LayerCount
#region Private Types

// EventArgs for the Changed event.
private class LayerHighlightChangedEventArgs : HighlightChangedEventArgs
private sealed class LayerHighlightChangedEventArgs : HighlightChangedEventArgs
{
// Constructor.
internal LayerHighlightChangedEventArgs(ReadOnlyCollection<TextSegment> ranges, Type ownerType)
Expand All @@ -412,7 +413,7 @@ internal LayerHighlightChangedEventArgs(ReadOnlyCollection<TextSegment> ranges,
}

// List of changed ranges.
internal override IList Ranges
internal override IList<TextSegment> Ranges
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using MS.Internal;
using System.Windows.Media;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace System.Windows.Documents
Expand Down Expand Up @@ -192,7 +192,7 @@ private static TextDecorationCollection GetErrorTextDecorations()
#region Private Types

// Argument for the Changed event, encapsulates a highlight change.
private class SpellerHighlightChangedEventArgs : HighlightChangedEventArgs
private sealed class SpellerHighlightChangedEventArgs : HighlightChangedEventArgs
{
// Constructor.
internal SpellerHighlightChangedEventArgs(ITextPointer start, ITextPointer end)
Expand All @@ -208,7 +208,7 @@ internal SpellerHighlightChangedEventArgs(ITextPointer start, ITextPointer end)
}

// Collection of changed content ranges.
internal override IList Ranges
internal override IList<TextSegment> Ranges
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

using MS.Internal;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace System.Windows.Documents
Expand Down Expand Up @@ -319,7 +319,7 @@ private bool IsTextRangeEmpty(ITextRange textRange)
#region Private Types

// Argument for the Changed event, encapsulates a highlight change.
private class TextSelectionHighlightChangedEventArgs : HighlightChangedEventArgs
private sealed class TextSelectionHighlightChangedEventArgs : HighlightChangedEventArgs
{
// Constructor.
internal TextSelectionHighlightChangedEventArgs(ITextPointer invalidRangeLeftStart, ITextPointer invalidRangeLeftEnd,
Expand Down Expand Up @@ -350,7 +350,7 @@ internal TextSelectionHighlightChangedEventArgs(ITextPointer invalidRangeLeftSta
}

// Collection of changed content ranges.
internal override IList Ranges
internal override IList<TextSegment> Ranges
{
get
{
Expand Down
0