Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2019-05-30 00:06:26 +0300
committerGitHub <noreply@github.com>2019-05-30 00:06:26 +0300
commit46487cd98bf833386952dc3e39e4a3ae4470f63b (patch)
tree25c3c276b1693f632b3409da72209cacaf493dbe /main
parent4b81e3fb4f8809a429d2026b29685dbc9573d7c0 (diff)
parent2d3a003a03fc9a4b61d4105ce7ef10fbd7f77e96 (diff)
Merge pull request #7650 from mono/fix-780731
[A11y] Check the functions have been set correctly before calling
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs13
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AtkCocoaHelper/AtkCocoaHelperMac.cs114
2 files changed, 95 insertions, 32 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
index 998708b5f3..cb59267c37 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/Mono.TextEditor/Gui/TextViewMargin.cs
@@ -138,18 +138,7 @@ namespace Mono.TextEditor
public TextViewMarginAccessibilityProxy ()
{
- Accessible = AccessibilityElementProxy.TextElementProxy ();
- Accessible.Contents = GetContents;
- Accessible.InsertionPointLineNumber = GetInsertionPointLineNumber;
- Accessible.NumberOfCharacters = GetNumberOfCharacters;
- Accessible.FrameForRange = GetFrameForRange;
- Accessible.LineForIndex = GetLineForIndex;
- Accessible.RangeForLine = GetRangeForLine;
- Accessible.StringForRange = GetStringForRange;
- Accessible.RangeForIndex = GetRangeForIndex;
- Accessible.StyleRangeForIndex = GetStyleRangeForIndex;
- Accessible.RangeForPosition = GetRangeForPosition;
- Accessible.GetVisibleCharacterRange = GetVisibleCharacterRange;
+ Accessible = AccessibilityElementProxy.TextElementProxy (GetContents, GetNumberOfCharacters, GetInsertionPointLineNumber, GetFrameForRange, GetLineForIndex, GetRangeForLine, GetStringForRange, GetRangeForIndex, GetStyleRangeForIndex, GetRangeForPosition, GetVisibleCharacterRange);
}
public void Dispose ()
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AtkCocoaHelper/AtkCocoaHelperMac.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AtkCocoaHelper/AtkCocoaHelperMac.cs
index 64150d0e48..4edb386006 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AtkCocoaHelper/AtkCocoaHelperMac.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AtkCocoaHelper/AtkCocoaHelperMac.cs
@@ -38,6 +38,7 @@ using Gdk;
using ObjCRuntime;
using MetalPerformanceShaders;
using MonoDevelop.Components.Mac;
+using LoggingService = MonoDevelop.Core.LoggingService;
namespace MonoDevelop.Components.AtkCocoaHelper
{
@@ -624,9 +625,31 @@ namespace MonoDevelop.Components.AtkCocoaHelper
return new AccessibilityElementProxy (new RealAccessibilityElementButtonProxy ());
}
- public static AccessibilityElementProxy TextElementProxy ()
- {
- return new AccessibilityElementProxy (new RealAccessibilityElementNavigableStaticTextProxy ());
+ public static AccessibilityElementProxy TextElementProxy (Func<string> contents,
+ Func<int> numberOfCharacters,
+ Func<int> insertionPointLineNumber,
+ Func<AtkCocoa.Range, Rectangle> frameForRange,
+ Func<int, int> lineForIndex,
+ Func<int, AtkCocoa.Range> rangeForLine,
+ Func<AtkCocoa.Range, string> stringForRange,
+ Func<int, AtkCocoa.Range> rangeForIndex,
+ Func<int, AtkCocoa.Range> styleRangeForIndex,
+ Func<Point, AtkCocoa.Range> rangeForPosition,
+ Func<AtkCocoa.Range> visibleCharacterRange)
+ {
+ return new AccessibilityElementProxy (new RealAccessibilityElementNavigableStaticTextProxy () {
+ Contents = contents ?? throw new ArgumentNullException (nameof (contents)),
+ NumberOfCharacters = numberOfCharacters ?? throw new ArgumentNullException (nameof (numberOfCharacters)),
+ InsertionPointLineNumber = insertionPointLineNumber ?? throw new ArgumentNullException (nameof (insertionPointLineNumber)),
+ GetFrameForRange = frameForRange ?? throw new ArgumentNullException (nameof (frameForRange)),
+ GetLineForIndex = lineForIndex ?? throw new ArgumentNullException (nameof (lineForIndex)),
+ GetRangeForLine = rangeForLine ?? throw new ArgumentNullException (nameof (rangeForLine)),
+ GetStringForRange = stringForRange ?? throw new ArgumentNullException (nameof (stringForRange)),
+ GetRangeForIndex = rangeForIndex ?? throw new ArgumentNullException (nameof (rangeForIndex)),
+ GetStyleRangeForIndex = styleRangeForIndex ?? throw new ArgumentNullException (nameof (styleRangeForIndex)),
+ GetRangeForPosition = rangeForPosition ?? throw new ArgumentNullException (nameof (rangeForPosition)),
+ GetVisibleCharacterRange = visibleCharacterRange ?? throw new ArgumentNullException (nameof (visibleCharacterRange))
+ });
}
public string Identifier {
@@ -1522,20 +1545,35 @@ namespace MonoDevelop.Components.AtkCocoaHelper
public override nint AccessibilityInsertionPointLineNumber {
get {
- return InsertionPointLineNumber ();
+ try {
+ return InsertionPointLineNumber ();
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return -1;
+ }
}
}
public override nint AccessibilityNumberOfCharacters {
get {
- return NumberOfCharacters ();
+ try {
+ return NumberOfCharacters ();
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return -1;
+ }
}
}
public override NSRange AccessibilityVisibleCharacterRange {
get {
- var realRange = GetVisibleCharacterRange ();
- return new NSRange (realRange.Location, realRange.Length);
+ try {
+ var realRange = GetVisibleCharacterRange ();
+ return new NSRange (realRange.Location, realRange.Length);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return default;
+ }
}
}
@@ -1561,7 +1599,13 @@ namespace MonoDevelop.Components.AtkCocoaHelper
}
var realRange = new AtkCocoa.Range { Location = (int)range.Location, Length = (int)range.Length };
- var frame = GetFrameForRange (realRange);
+ Rectangle frame;
+ try {
+ frame = GetFrameForRange (realRange);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return CGRect.Empty;
+ }
int parentX, parentY;
@@ -1582,43 +1626,73 @@ namespace MonoDevelop.Components.AtkCocoaHelper
[Export ("accessibilityLineForIndex:")]
nint AccessibilityLineForIndex (nint index)
{
- return GetLineForIndex ((int)index);
+ try {
+ return GetLineForIndex ((int)index);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return -1;
+ }
}
[Export ("accessibilityRangeForLine:")]
NSRange AccessibilityRangeForLine (nint line)
{
- var range = GetRangeForLine ((int)line + 1);
- return new NSRange (range.Location, range.Length);
+ try {
+ var range = GetRangeForLine ((int)line + 1);
+ return new NSRange (range.Location, range.Length);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return default;
+ }
}
[Export ("accessibilityStringForRange:")]
string AccessibilityStringForRange (NSRange range)
{
- var realRange = new AtkCocoa.Range { Location = (int)range.Location, Length = (int)range.Length };
- return GetStringForRange (realRange);
+ try {
+ var realRange = new AtkCocoa.Range { Location = (int)range.Location, Length = (int)range.Length };
+ return GetStringForRange (realRange);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return null;
+ }
}
[Export ("accessibilityRangeForIndex:")]
NSRange AccessibilityRangeForIndex (nint index)
{
- var realRange = GetRangeForIndex ((int)index);
- return new NSRange (realRange.Location, realRange.Length);
+ try {
+ var realRange = GetRangeForIndex ((int)index);
+ return new NSRange (realRange.Location, realRange.Length);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return default;
+ }
}
[Export ("accessibilityStyleRangeForIndex:")]
NSRange AccessibililtyStyleRangeForIndex (nint index)
{
- var realRange = GetStyleRangeForIndex ((int)index);
- return new NSRange (realRange.Location, realRange.Length);
+ try {
+ var realRange = GetStyleRangeForIndex ((int)index);
+ return new NSRange (realRange.Location, realRange.Length);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return default;
+ }
}
[Export ("accessibilityRangeForPosition:")]
NSRange AccessibilityRangeForPosition (CGPoint position)
{
- var point = new Point ((int)position.X, (int)position.Y);
- var realRange = GetRangeForPosition (point);
- return new NSRange (realRange.Location, realRange.Length);
+ try {
+ var point = new Point ((int)position.X, (int)position.Y);
+ var realRange = GetRangeForPosition (point);
+ return new NSRange (realRange.Location, realRange.Length);
+ } catch (Exception e) {
+ LoggingService.LogInternalError (e);
+ return default;
+ }
}
}
}