changeset 6842:4c626e6cf0fd

RT-36636: [Accessibility] Hit test and range bounds implemented on Mac
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Wed, 23 Apr 2014 09:14:46 -0700
parents c9c1336a0218
children e8ee46b11faf
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
diffstat 2 files changed, 42 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Wed Apr 23 14:29:51 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Wed Apr 23 09:14:46 2014 -0700
@@ -866,6 +866,17 @@
         return macRole;
     }
 
+    private Bounds flipBounds(Bounds bounds) {
+        View view = getRootView((Scene)getAttribute(SCENE));
+        if (view == null) return null;
+        Screen screen = view.getWindow().getScreen();
+        float height = screen.getHeight();
+        return new BoundingBox(bounds.getMinX(),
+                               height - bounds.getMinY() - bounds.getHeight(),
+                               bounds.getWidth(),
+                               bounds.getHeight());
+    }
+
     /* NSAccessibility Protocol - JNI entry points */
     long[] accessibilityAttributeNames() {
         if (getView() != null) return null; /* Let NSView answer for the Scene */
@@ -1248,16 +1259,7 @@
                  * NSAccessibilityPositionAttribute requires the point relative
                  * to the lower-left corner in screen.
                  */
-                View view = getRootView((Scene)getAttribute(SCENE));
-                if (view != null) {
-                    Screen screen = view.getWindow().getScreen();
-                    float height = screen.getHeight();
-                    Bounds bounds = (Bounds)result;
-                    result = new BoundingBox(bounds.getMinX(),
-                                             height - bounds.getMinY() - bounds.getHeight(),
-                                             bounds.getWidth(),
-                                             bounds.getHeight());
-                }
+                result = flipBounds((Bounds)result);
                 break;
             }
             case NSAccessibilityTitleAttribute: {
@@ -1527,10 +1529,11 @@
         Object value = variant.getValue();
         Object result;
         switch (attr) {
-            case NSAccessibilityCellForColumnAndRowParameterizedAttribute:
+            case NSAccessibilityCellForColumnAndRowParameterizedAttribute: {
                 int[] intArray = (int[])value;
                 result = getAttribute(attr.jfxAttr, intArray[1] /*row*/, intArray[0] /*column*/);
                 break;
+            }
             case NSAccessibilityLineForIndexParameterizedAttribute: {
                 if (getAttribute(ROLE) == Role.TEXT_AREA) {
                     result = getAttribute(attr.jfxAttr, value /*charOffset*/);
@@ -1557,13 +1560,34 @@
                 break;
             }
             case NSAccessibilityBoundsForRangeParameterizedAttribute: {
-                //TODO
-                result = null;
+                int[] intArray = (int[])value; /* range.location, range.length */
+                Bounds[] bounds = (Bounds[])getAttribute(attr.jfxAttr, intArray[0], intArray[0] + intArray[1] - 1);
+                double left = Double.POSITIVE_INFINITY;
+                double top = Double.POSITIVE_INFINITY;
+                double right = Double.NEGATIVE_INFINITY;
+                double bottom = Double.NEGATIVE_INFINITY;
+                if (bounds != null) {
+                    for (int i = 0; i < bounds.length; i++) {
+                        Bounds b = bounds[i];
+                        if (b != null) {
+                            if (b.getMinX() < left) left = b.getMinX();
+                            if (b.getMinY() < top) top = b.getMinY();
+                            if (b.getMaxX() > right) right = b.getMaxX();
+                            if (b.getMaxY() > bottom) bottom = b.getMaxY();
+                        }
+                    }
+                }
+                result = flipBounds(new BoundingBox(left, top, right - left, bottom - top));
                 break;
             }
             case NSAccessibilityRangeForPositionParameterizedAttribute: {
-                //TODO
-                result = null;
+                float[] floatArray = (float[])value;
+                Integer offset = (Integer)getAttribute(attr.jfxAttr, new Point2D(floatArray[0], floatArray[1]));
+                if (offset != null) {
+                    result = new int[] {offset, 1};
+                } else {
+                    result = null;
+                }
                 break;
             }
             default:
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacVariant.java	Wed Apr 23 14:29:51 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacVariant.java	Wed Apr 23 09:14:46 2014 -0700
@@ -171,6 +171,9 @@
             case NSArray_id: return longArray;
             case NSArray_int: return intArray;
             case NSValue_range: return new int[] {int1, int2};
+            case NSValue_point: return new float[] {float1, float2};
+            case NSValue_size: return new float[] {float1, float2};
+            case NSValue_rectangle: return new float[] {float1, float2, float3, float4};
             //TODO REST
         }
         return null;