Skip to content

Use StrongBox<Rect> over object field in GlyphRun #10879

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -15,6 +15,7 @@

using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media.Converters;
using System.Windows.Media.Composition;
using System.Windows.Media.TextFormatting;
Expand Down Expand Up @@ -1226,9 +1227,9 @@ public Rect ComputeInkBoundingBox()

if ((_flags & GlyphRunFlags.CacheInkBounds) != 0)
{
if (_inkBoundingBox != null)
if (_inkBoundingBox is not null)
{
return (Rect)_inkBoundingBox;
return _inkBoundingBox.Value;
}
}

Expand Down Expand Up @@ -1401,7 +1402,7 @@ public Rect ComputeInkBoundingBox()

if ((_flags & GlyphRunFlags.CacheInkBounds) != 0)
{
_inkBoundingBox = bounds;
_inkBoundingBox = new StrongBox<Rect>(bounds);
}

return bounds;
Expand Down Expand Up @@ -2463,7 +2464,7 @@ private enum GlyphRunFlags : byte
private IList<bool> _caretStops;
private XmlLanguage _language;
private string _deviceFontName;
private object _inkBoundingBox; // Used when CacheInkBounds is on
private StrongBox<Rect> _inkBoundingBox; // Used when CacheInkBounds is on
private TextFormattingMode _textFormattingMode;
private float _pixelsPerDip = MS.Internal.FontCache.Util.PixelsPerDip;

Expand Down