Revision: 3802
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3802&view=rev
Author:   hofman
Date:     2008-04-23 07:55:04 -0700 (Wed, 23 Apr 2008)

Log Message:
-----------
Add edit field for text note to accessible hierarchy.

Modified Paths:
--------------
    trunk/PDFDisplayView_SKExtensions.h
    trunk/PDFDisplayView_SKExtensions.m
    trunk/SKAccessibilityPDFAnnotationElement.h
    trunk/SKAccessibilityPDFAnnotationElement.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m

Modified: trunk/PDFDisplayView_SKExtensions.h
===================================================================
--- trunk/PDFDisplayView_SKExtensions.h 2008-04-23 12:05:01 UTC (rev 3801)
+++ trunk/PDFDisplayView_SKExtensions.h 2008-04-23 14:55:04 UTC (rev 3802)
@@ -39,17 +39,17 @@
 #import <Cocoa/Cocoa.h>
 #import <Quartz/Quartz.h>
 
[EMAIL PROTECTED] SKPDFView;
[EMAIL PROTECTED] SKPDFView, PDFAnnotation;
 
 @interface PDFDisplayView : NSView
 - (void)passwordEntered:(id)sender;
 @end
 
 @interface PDFDisplayView (SKExtensions)
-- (NSRect)screenRectForAnnotationElement:(id)element;
-- (BOOL)isAnnotationElementFocused:(id)element;
-- (void)setFocused:(BOOL)focused forAnnotationElement:(id)element;
-- (void)pressAnnotationElement:(id)element;
+- (NSRect)screenRectForAnnotation:(PDFAnnotation *)annotation;
+- (BOOL)isAnnotationFocused:(PDFAnnotation *)annotation;
+- (void)setFocused:(BOOL)focused forAnnotation:(PDFAnnotation *)annotation;
+- (void)pressAnnotation:(PDFAnnotation *)annotation;
 @end
 
 @interface SKAccessibilityPDFDisplayViewElement : NSObject {

Modified: trunk/PDFDisplayView_SKExtensions.m
===================================================================
--- trunk/PDFDisplayView_SKExtensions.m 2008-04-23 12:05:01 UTC (rev 3801)
+++ trunk/PDFDisplayView_SKExtensions.m 2008-04-23 14:55:04 UTC (rev 3802)
@@ -42,7 +42,6 @@
 #import "SKPDFDocument.h"
 #import "SKStringConstants.h"
 #import "OBUtilities.h"
-#import "SKAccessibilityPDFAnnotationElement.h"
 
 static IMP originalAccessibilityAttributeNames = NULL;
 static IMP originalAccessibilityAttributeValue = NULL;
@@ -95,53 +94,37 @@
 
 - (id)replacementAccessibilityHitTest:(NSPoint)point {
     SKPDFView *pdfView = [self skpdfView];
-    if (pdfView) {
-        NSPoint localPoint = [pdfView convertPoint:[[pdfView window] 
convertScreenToBase:point] fromView:nil];
-        PDFPage *page = [pdfView pageForPoint:localPoint nearest:NO];
-        if (page) {
-            PDFAnnotation *annotation = [page annotationAtPoint:[pdfView 
convertPoint:localPoint toPage:page]];
-            if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation])
-                return [[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:self] accessibilityHitTest:point];
-        }
-        return [[SKAccessibilityPDFDisplayViewElement elementWithParent:self] 
accessibilityHitTest:point];
-    } else {
+    if (pdfView)
+        return [pdfView accessibilityChildAtPoint:point];
+    else
         return originalAccessibilityHitTest(self, _cmd, point);
-    }
 }
 
 - (id)replacementAccessibilityFocusedUIElement {
     SKPDFView *pdfView = [self skpdfView];
-    if (pdfView) {
-        PDFAnnotation *annotation = [pdfView activeAnnotation];
-        if (annotation) {
-            return 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:self]);
-        } else {
-            return 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFDisplayViewElement 
elementWithParent:self]);
-        }
-    } else {
+    if (pdfView)
+        return [pdfView accessibilityFocusedChild];
+    else
         return originalAccessibilityFocusedUIElement(self, _cmd);
-    }
 }
 
-- (NSRect)screenRectForAnnotationElement:(id)element {
+- (NSRect)screenRectForAnnotation:(PDFAnnotation *)annotation {
     NSRect rect = NSZeroRect;
     SKPDFView *pdfView = [self skpdfView];
     if (pdfView) {
-        PDFAnnotation *annotation = [element annotation];
         rect = [pdfView convertRect:[pdfView convertRect:[annotation bounds] 
fromPage:[annotation page]] toView:nil];
         rect.origin = [[pdfView window] convertBaseToScreen:rect.origin];
     }
     return rect;
 }
 
-- (BOOL)isAnnotationElementFocused:(id)element {
-    return [[self skpdfView] activeAnnotation] == [element annotation];
+- (BOOL)isAnnotationFocused:(PDFAnnotation *)annotation {
+    return [[self skpdfView] activeAnnotation] == annotation;
 }
 
-- (void)setFocused:(BOOL)focused forAnnotationElement:(id)element {
+- (void)setFocused:(BOOL)focused forAnnotation:(PDFAnnotation *)annotation {
     SKPDFView *pdfView = [self skpdfView];
     if (pdfView) {
-        PDFAnnotation *annotation = [element annotation];
         if (focused)
             [pdfView setActiveAnnotation:annotation];
         else if ([pdfView activeAnnotation] == annotation)
@@ -149,10 +132,9 @@
     }
 }
 
-- (void)pressAnnotationElement:(id)element {
+- (void)pressAnnotation:(PDFAnnotation *)annotation {
     SKPDFView *pdfView = [self skpdfView];
     if (pdfView) {
-        PDFAnnotation *annotation = [element annotation];
         if ([pdfView activeAnnotation] != annotation)
             [pdfView setActiveAnnotation:annotation];
         [pdfView editActiveAnnotation:self];

Modified: trunk/SKAccessibilityPDFAnnotationElement.h
===================================================================
--- trunk/SKAccessibilityPDFAnnotationElement.h 2008-04-23 12:05:01 UTC (rev 
3801)
+++ trunk/SKAccessibilityPDFAnnotationElement.h 2008-04-23 14:55:04 UTC (rev 
3802)
@@ -46,5 +46,4 @@
 }
 + (id)elementWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent;
 - (id)initWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent;
-- (PDFAnnotation *)annotation;
 @end

Modified: trunk/SKAccessibilityPDFAnnotationElement.m
===================================================================
--- trunk/SKAccessibilityPDFAnnotationElement.m 2008-04-23 12:05:01 UTC (rev 
3801)
+++ trunk/SKAccessibilityPDFAnnotationElement.m 2008-04-23 14:55:04 UTC (rev 
3802)
@@ -76,10 +76,6 @@
     return [annotation hash] + [parent hash];
 }
 
-- (PDFAnnotation *)annotation {
-    return annotation;
-}
-
 - (NSArray *)accessibilityAttributeNames {
     return [annotation accessibilityAttributeNames];
 }
@@ -112,13 +108,13 @@
         // We're in the same top level element as our parent.
         return [NSAccessibilityUnignoredAncestor(parent) 
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
     } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
-        return [NSNumber numberWithBool:[parent 
isAnnotationElementFocused:self]];
+        return [NSNumber numberWithBool:[parent 
isAnnotationFocused:annotation]];
     } else if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) {
         return [NSNumber numberWithBool:NO];
     } else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
-        return [NSValue valueWithPoint:[parent 
screenRectForAnnotationElement:self].origin];
+        return [NSValue valueWithPoint:[parent 
screenRectForAnnotation:annotation].origin];
     } else if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {
-        return [NSValue valueWithSize:[parent 
screenRectForAnnotationElement:self].size];
+        return [NSValue valueWithSize:[parent 
screenRectForAnnotation:annotation].size];
     } else {
         return nil;
     }
@@ -130,7 +126,7 @@
 
 - (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
     if ([attribute isEqualToString:NSAccessibilityFocusedAttribute])
-        [parent setFocused:[value boolValue] forAnnotationElement:self];
+        [parent setFocused:[value boolValue] forAnnotation:annotation];
 }
 
 - (BOOL)accessibilityIsIgnored {
@@ -158,7 +154,7 @@
 
 - (void)accessibilityPerformAction:(NSString *)anAction {
     if ([anAction isEqualToString:NSAccessibilityPressAction])
-        [parent pressAnnotationElement:self];
+        [parent pressAnnotation:annotation];
 }
 
 @end

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2008-04-23 12:05:01 UTC (rev 3801)
+++ trunk/SKPDFView.h   2008-04-23 14:55:04 UTC (rev 3802)
@@ -195,6 +195,8 @@
 - (void)removeHoverRects;
 
 - (NSArray *)accessibilityChildren;
+- (id)accessibilityChildAtPoint:(NSPoint)point;
+- (id)accessibilityFocusedChild;
 
 - (NSUndoManager *)undoManager;
 

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2008-04-23 12:05:01 UTC (rev 3801)
+++ trunk/SKPDFView.m   2008-04-23 14:55:04 UTC (rev 3802)
@@ -2168,12 +2168,43 @@
                     [children addObject:[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:[self documentView]]];
             }
         }
-        return children;
         accessibilityChildren = [children mutableCopy];
     }
-    return accessibilityChildren;
+    if ([self isEditing])
+        return [accessibilityChildren arrayByAddingObject:editField];
+    else
+        return accessibilityChildren;
 }
 
+- (id)accessibilityChildAtPoint:(NSPoint)point {
+    NSPoint localPoint = [self convertPoint:[[self window] 
convertScreenToBase:point] fromView:nil];
+    id child = nil;
+    if ([self isEditing] && NSPointInRect([self convertPoint:localPoint 
toView:[self documentView]], [editField frame])) {
+        child = NSAccessibilityUnignoredDescendant(editField);
+    } else {
+        PDFPage *page = [self pageForPoint:localPoint nearest:NO];
+        if (page) {
+            PDFAnnotation *annotation = [page annotationAtPoint:[self 
convertPoint:localPoint toPage:page]];
+            if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation])
+                child = 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:[self documentView]]);
+        }
+    }
+    if (child == nil)
+        child = 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFDisplayViewElement 
elementWithParent:[self documentView]]);
+    return [child accessibilityHitTest:point];
+}
+
+- (id)accessibilityFocusedChild {
+    id child = nil;
+    if ([self isEditing])
+        child = NSAccessibilityUnignoredDescendant(editField);
+    else if (activeAnnotation)
+        child = 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:activeAnnotation parent:[self documentView]]);
+    else
+        child = 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFDisplayViewElement 
elementWithParent:[self documentView]]);
+    return [child accessibilityFocusedUIElement];
+}
+
 #pragma mark Snapshots
 
 - (void)takeSnapshot:(id)sender {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to