Revision: 3796
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3796&view=rev
Author:   hofman
Date:     2008-04-22 16:48:18 -0700 (Tue, 22 Apr 2008)

Log Message:
-----------
Faux UI elements retain ivars. Don't keep pdfview to avoid retain cycles.

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

Modified: trunk/PDFDisplayView_SKExtensions.h
===================================================================
--- trunk/PDFDisplayView_SKExtensions.h 2008-04-22 22:04:46 UTC (rev 3795)
+++ trunk/PDFDisplayView_SKExtensions.h 2008-04-22 23:48:18 UTC (rev 3796)
@@ -39,12 +39,14 @@
 #import <Cocoa/Cocoa.h>
 #import <Quartz/Quartz.h>
 
[EMAIL PROTECTED] SKPDFView;
 
 @interface PDFDisplayView : NSView
 - (void)passwordEntered:(id)sender;
 @end
 
 @interface PDFDisplayView (SKExtensions)
+- (SKPDFView *)skpdfView;
 @end
 
 @interface SKAccessibilityPDFDisplayViewElement : NSObject {

Modified: trunk/PDFDisplayView_SKExtensions.m
===================================================================
--- trunk/PDFDisplayView_SKExtensions.m 2008-04-22 22:04:46 UTC (rev 3795)
+++ trunk/PDFDisplayView_SKExtensions.m 2008-04-22 23:48:18 UTC (rev 3796)
@@ -102,7 +102,7 @@
         if (page) {
             PDFAnnotation *annotation = [page annotationAtPoint:[pdfView 
convertPoint:localPoint toPage:page]];
             if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation]) {
-                return [[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation pdfView:pdfView parent:self] 
accessibilityHitTest:point];
+                return [[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:self] accessibilityHitTest:point];
             }
         }
         return [[SKAccessibilityPDFDisplayViewElement elementWithParent:self] 
accessibilityHitTest:point];
@@ -116,7 +116,7 @@
     if (pdfView) {
         PDFAnnotation *annotation = [pdfView activeAnnotation];
         if (annotation) {
-            return 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation pdfView:pdfView parent:self]);
+            return 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:self]);
         } else {
             return 
NSAccessibilityUnignoredAncestor([SKAccessibilityPDFDisplayViewElement 
elementWithParent:self]);
         }
@@ -154,11 +154,16 @@
 
 - (id)initWithParent:(id)aParent {
     if (self = [super init]) {
-        parent = aParent;
+        parent = [aParent retain];
     }
     return self;
 }
 
+- (void)dealloc {
+    [parent release];
+    [super dealloc];
+}
+
 - (BOOL)isEqual:(id)object {
     if ([object isKindOfClass:[SKAccessibilityPDFDisplayViewElement class]]) {
         SKAccessibilityPDFDisplayViewElement *other = 
(SKAccessibilityPDFDisplayViewElement *)object;

Modified: trunk/SKAccessibilityPDFAnnotationElement.h
===================================================================
--- trunk/SKAccessibilityPDFAnnotationElement.h 2008-04-22 22:04:46 UTC (rev 
3795)
+++ trunk/SKAccessibilityPDFAnnotationElement.h 2008-04-22 23:48:18 UTC (rev 
3796)
@@ -38,13 +38,12 @@
 
 #import <Cocoa/Cocoa.h>
 
[EMAIL PROTECTED] PDFAnnotation, SKPDFView;
[EMAIL PROTECTED] PDFAnnotation;
 
 @interface SKAccessibilityPDFAnnotationElement : NSObject {
     PDFAnnotation *annotation;
-    SKPDFView *pdfView;
     id parent;
 }
-+ (id)elementWithAnnotation:(PDFAnnotation *)anAnnotation pdfView:(SKPDFView 
*)aPdfView parent:(id)aParent;
-- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation pdfView:(SKPDFView 
*)aPdfView parent:(id)aParent;
++ (id)elementWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent;
+- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent;
 @end

Modified: trunk/SKAccessibilityPDFAnnotationElement.m
===================================================================
--- trunk/SKAccessibilityPDFAnnotationElement.m 2008-04-22 22:04:46 UTC (rev 
3795)
+++ trunk/SKAccessibilityPDFAnnotationElement.m 2008-04-22 23:48:18 UTC (rev 
3796)
@@ -40,35 +40,41 @@
 #import <Quartz/Quartz.h>
 #import "SKPDFView.h"
 #import "PDFAnnotation_SKExtensions.h"
+#import "PDFDisplayView_SKExtensions.h"
 #import "SKStringConstants.h"
 
 
 @implementation SKAccessibilityPDFAnnotationElement
 
-+ (id)elementWithAnnotation:(PDFAnnotation *)anAnnotation pdfView:(SKPDFView 
*)aPdfView parent:(id)aParent {
-    return [[[self alloc] elementWithAnnotation:anAnnotation pdfView:aPdfView 
parent:aParent] autorelease];
++ (id)elementWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent {
+    return [[[self alloc] elementWithAnnotation:anAnnotation parent:aParent] 
autorelease];
 }
 
-- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation pdfView:(SKPDFView 
*)aPdfView parent:(id)aParent {
+- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation parent:(id)aParent {
     if (self = [super init]) {
-        annotation = anAnnotation;
-        pdfView = aPdfView;
-        parent = aParent;
+        annotation = [anAnnotation retain];
+        parent = [aParent retain];
     }
     return self;
 }
 
+- (void)dealloc {
+    [annotation release];
+    [parent release];
+    [super dealloc];
+}
+
 - (BOOL)isEqual:(id)object {
     if ([object isKindOfClass:[SKAccessibilityPDFAnnotationElement class]]) {
         SKAccessibilityPDFAnnotationElement *other = 
(SKAccessibilityPDFAnnotationElement *)object;
-        return annotation == other->annotation && pdfView == other->pdfView;
+        return annotation == other->annotation && parent == other->parent;
     } else {
         return NO;
     }
 }
 
 - (unsigned int)hash {
-    return [annotation hash] + [pdfView hash];
+    return [annotation hash] + [parent hash];
 }
 
 - (NSArray *)accessibilityAttributeNames {
@@ -103,13 +109,15 @@
         // We're in the same top level element as our parent.
         return [NSAccessibilityUnignoredAncestor(parent) 
accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
     } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
-        return [NSNumber numberWithBool:[pdfView activeAnnotation] == 
annotation];
+        return [NSNumber numberWithBool:[[parent skpdfView] activeAnnotation] 
== annotation];
     } else if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) {
         return [NSNumber numberWithBool:NO];
     } else if ([attribute isEqualToString:NSAccessibilityPositionAttribute]) {
+        SKPDFView *pdfView = [parent skpdfView];
         NSRect rect = [pdfView convertRect:[annotation bounds] 
fromPage:[annotation page]];
         return [NSValue valueWithPoint:[[pdfView window] 
convertBaseToScreen:[pdfView convertPoint:rect.origin toView:nil]]];
     } else if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {
+        SKPDFView *pdfView = [parent skpdfView];
         NSRect rect = [pdfView convertRect:[annotation bounds] 
fromPage:[annotation page]];
         return [NSValue valueWithSize:[pdfView convertSize:rect.size 
toView:nil]];
     } else {
@@ -124,9 +132,9 @@
 - (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
     if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
         if ([value boolValue])
-            [pdfView setActiveAnnotation:annotation];
-        else if ([pdfView activeAnnotation] == annotation)
-            [pdfView setActiveAnnotation:nil];
+            [[parent skpdfView] setActiveAnnotation:annotation];
+        else if ([[parent skpdfView] activeAnnotation] == annotation)
+            [[parent skpdfView] setActiveAnnotation:nil];
     }
 }
 
@@ -155,6 +163,7 @@
 
 - (void)accessibilityPerformAction:(NSString *)anAction {
     if ([anAction isEqualToString:NSAccessibilityPressAction]) {
+        SKPDFView *pdfView = [parent skpdfView];
         if ([pdfView activeAnnotation] != annotation)
             [pdfView setActiveAnnotation:annotation];
         [pdfView editActiveAnnotation:self];

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2008-04-22 22:04:46 UTC (rev 3795)
+++ trunk/SKPDFView.m   2008-04-22 23:48:18 UTC (rev 3796)
@@ -1904,7 +1904,7 @@
     [self setNeedsDisplayForAnnotation:wasAnnotation];
     [page removeAnnotation:wasAnnotation];
     if (accessibilityChildren)
-        [accessibilityChildren 
removeObject:[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:wasAnnotation pdfView:self parent:[self documentView]]];
+        [accessibilityChildren 
removeObject:[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:wasAnnotation parent:[self documentView]]];
     if (wasNote)
         [self resetHoverRects];
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidRemoveAnnotationNotification object:self 
@@ -2165,7 +2165,7 @@
             PDFAnnotation *annotation;
             while (annotation = [annotationEnum nextObject]) {
                 if ([[annotation type] isEqualToString:SKLinkString] || 
[annotation isNoteAnnotation])
-                    [children addObject:[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation pdfView:self parent:[self documentView]]];
+                    [children addObject:[SKAccessibilityPDFAnnotationElement 
elementWithAnnotation:annotation parent:[self documentView]]];
             }
         }
         return children;


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