changeset 6857:54b08edc5557

RT-36636: [Accessibility] - Hit test and bounds natives from Mac
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 22 Apr 2014 17:01:17 -0700
parents 73368266ee9f
children 82eec770a3b2
files modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java modules/graphics/src/main/java/com/sun/glass/ui/mac/MacVariant.java modules/graphics/src/main/native-glass/mac/GlassAccessible.h modules/graphics/src/main/native-glass/mac/GlassAccessible.m
diffstat 4 files changed, 67 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Apr 22 16:16:05 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Apr 22 17:01:17 2014 -0700
@@ -162,6 +162,8 @@
         NSAccessibilityRangeForLineParameterizedAttribute(LINE_START, MacVariant::createNSValueForRange, MacVariant.NSNumber_Int),
         NSAccessibilityAttributedStringForRangeParameterizedAttribute(TITLE, MacVariant::createNSAttributedString, MacVariant.NSValue_range),
         NSAccessibilityCellForColumnAndRowParameterizedAttribute(CELL_AT_ROW_COLUMN, MacVariant::createNSObject, MacVariant.NSArray_int),
+        NSAccessibilityRangeForPositionParameterizedAttribute(OFFSET_AT_POINT, MacVariant::createNSValueForRange, MacVariant.NSValue_point),
+        NSAccessibilityBoundsForRangeParameterizedAttribute(BOUNDS_FOR_RANGE, MacVariant::createNSValueForRectangle, MacVariant.NSValue_range),
 
         ;long ptr; /* Initialized natively - treat as final */
         Attribute jfxAttr;
@@ -1554,6 +1556,16 @@
                 }
                 break;
             }
+            case NSAccessibilityBoundsForRangeParameterizedAttribute: {
+                //TODO
+                result = null;
+                break;
+            }
+            case NSAccessibilityRangeForPositionParameterizedAttribute: {
+                //TODO
+                result = null;
+                break;
+            }
             default:
                 result = getAttribute(attr.jfxAttr, value);
         }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacVariant.java	Tue Apr 22 16:16:05 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacVariant.java	Tue Apr 22 17:01:17 2014 -0700
@@ -33,23 +33,23 @@
 class MacVariant {
     final static int NSArray_id = 1;
     final static int NSArray_NSString = 2;
-    final static int NSArray_int = 18;
-    final static int NSArray_range = 19;
-    final static int NSAttributedString = 3;
-    final static int NSData = 4;
-    final static int NSDate = 5;
-    final static int NSDictionary = 6;
-    final static int NSNumber_Boolean = 7;
-    final static int NSNumber_Int = 8;
-    final static int NSNumber_Float = 9;
-    final static int NSNumber_Double = 10;
-    final static int NSString = 11;
-    final static int NSURL = 12;
-    final static int NSValue_point = 13;
-    final static int NSValue_size = 14;
-    final static int NSValue_rectangle = 15;
-    final static int NSValue_range = 15;
-    final static int NSObject = 17; /* id */
+    final static int NSArray_int = 3;
+    final static int NSArray_range = 4;
+    final static int NSAttributedString = 5;
+    final static int NSData = 6;
+    final static int NSDate = 7;
+    final static int NSDictionary = 8;
+    final static int NSNumber_Boolean = 9;
+    final static int NSNumber_Int = 10;
+    final static int NSNumber_Float = 11;
+    final static int NSNumber_Double = 12;
+    final static int NSString = 13;
+    final static int NSURL = 14;
+    final static int NSValue_point = 15;
+    final static int NSValue_size = 16;
+    final static int NSValue_rectangle = 17;
+    final static int NSValue_range = 18;
+    final static int NSObject = 19; /* id */
 
     int type;
     long[] longArray;
@@ -57,6 +57,8 @@
     String[] stringArray;
     float float1;
     float float2;
+    float float3;
+    float float4;
     int int1;
     int int2;
     String string;
@@ -119,6 +121,17 @@
         return variant;
     }
 
+    static MacVariant createNSValueForRectangle(Object result) {
+        Bounds bounds = (Bounds)result;
+        MacVariant variant = new MacVariant();
+        variant.type = NSValue_rectangle;
+        variant.float1 = (float)bounds.getMinX();
+        variant.float2 = (float)bounds.getMinY();
+        variant.float3 = (float)bounds.getWidth();
+        variant.float4 = (float)bounds.getHeight();
+        return variant;
+    }
+
     static MacVariant createNSValueForRange(Object result) {
         int[] range = (int[])result;
         MacVariant variant = new MacVariant();
--- a/modules/graphics/src/main/native-glass/mac/GlassAccessible.h	Tue Apr 22 16:16:05 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassAccessible.h	Tue Apr 22 17:01:17 2014 -0700
@@ -72,6 +72,8 @@
 jfieldID jVariantLong1;
 jfieldID jVariantFloat1;
 jfieldID jVariantFloat2;
+jfieldID jVariantFloat3;
+jfieldID jVariantFloat4;
 jfieldID jVariantDouble1;
 jfieldID jVariantString;
 
--- a/modules/graphics/src/main/native-glass/mac/GlassAccessible.m	Tue Apr 22 16:16:05 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassAccessible.m	Tue Apr 22 17:01:17 2014 -0700
@@ -299,6 +299,13 @@
         jfloat height = (*env)->GetFloatField(env, variant, jVariantFloat2);
         return [NSValue valueWithSize: NSMakeSize(width, height)];
     }
+    case com_sun_glass_ui_mac_MacVariant_NSValue_rectangle: {
+        jfloat x = (*env)->GetFloatField(env, variant, jVariantFloat1);
+        jfloat y = (*env)->GetFloatField(env, variant, jVariantFloat2);
+        jfloat width = (*env)->GetFloatField(env, variant, jVariantFloat3);
+        jfloat height = (*env)->GetFloatField(env, variant, jVariantFloat4);
+        return [NSValue valueWithRect: NSMakeRect(x, y, width, height)];
+    }
     case com_sun_glass_ui_mac_MacVariant_NSValue_range: {
         jint start = (*env)->GetIntField(env, variant, jVariantInt1);
         jint length = (*env)->GetIntField(env, variant, jVariantInt2);
@@ -441,6 +448,10 @@
         if ((*env)->ExceptionCheck(env)) return;
         jVariantFloat2 = (*env)->GetFieldID(env, jVariantClass, "float2", "F");
         if ((*env)->ExceptionCheck(env)) return;
+        jVariantFloat3 = (*env)->GetFieldID(env, jVariantClass, "float3", "F");
+        if ((*env)->ExceptionCheck(env)) return;
+        jVariantFloat4 = (*env)->GetFieldID(env, jVariantClass, "float4", "F");
+        if ((*env)->ExceptionCheck(env)) return;
         jVariantDouble1 = (*env)->GetFieldID(env, jVariantClass, "double1", "D");
         if ((*env)->ExceptionCheck(env)) return;
         jVariantString = (*env)->GetFieldID(env, jVariantClass, "string", "Ljava/lang/String;");
@@ -559,18 +570,30 @@
         NSPoint value = [n pointValue];
         (*env)->SetFloatField(env, jVariant, jVariantFloat1, value.x);
         (*env)->SetFloatField(env, jVariant, jVariantFloat2, value.y);
+        break;
     }
     case com_sun_glass_ui_mac_MacVariant_NSValue_size: {
         NSValue* n = (NSValue*)id;
         NSSize value = [n sizeValue];
         (*env)->SetFloatField(env, jVariant, jVariantFloat1, value.width);
         (*env)->SetFloatField(env, jVariant, jVariantFloat2, value.height);
+        break;
+    }
+    case com_sun_glass_ui_mac_MacVariant_NSValue_rectangle: {
+        NSValue* n = (NSValue*)id;
+        NSRect value = [n rectValue];
+        (*env)->SetFloatField(env, jVariant, jVariantFloat1, value.origin.x);
+        (*env)->SetFloatField(env, jVariant, jVariantFloat2, value.origin.y);
+        (*env)->SetFloatField(env, jVariant, jVariantFloat3, value.size.width);
+        (*env)->SetFloatField(env, jVariant, jVariantFloat4, value.size.height);
+        break;
     }
     case com_sun_glass_ui_mac_MacVariant_NSValue_range: {
         NSValue* n = (NSValue*)id;
         NSRange value = [n rangeValue];
         (*env)->SetIntField(env, jVariant, jVariantInt1, value.location);
         (*env)->SetIntField(env, jVariant, jVariantInt2, value.length);
+        break;
     }
     }
     return jVariant;