Revision: 27762
          http://sourceforge.net/p/bibdesk/svn/27762
Author:   hofman
Date:     2022-07-24 19:10:08 +0000 (Sun, 24 Jul 2022)
Log Message:
-----------
keep array of accessibility elements for the icons and update when URLs change. 
This way equal elements are identical.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.h      
2022-07-24 18:47:24 UTC (rev 27761)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.h      
2022-07-24 19:10:08 UTC (rev 27762)
@@ -43,7 +43,6 @@
     NSUInteger _index;
     id _parent;
 }
-+ (id)elementWithIndex:(NSUInteger)anIndex parent:(id)aParent;
 - (id)initWithIndex:(NSUInteger)anIndex parent:(id)aParent;
 - (NSUInteger)index;
 @end

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m      
2022-07-24 18:47:24 UTC (rev 27761)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVAccessibilityIconElement.m      
2022-07-24 19:10:08 UTC (rev 27762)
@@ -41,11 +41,6 @@
 
 @implementation FVAccessibilityIconElement
 
-+ (id)elementWithIndex:(NSUInteger)anIndex parent:(id)aParent;
-{
-    return [[[self alloc] initWithIndex:anIndex parent:aParent] autorelease];
-}
-
 - (id)initWithIndex:(NSUInteger)anIndex parent:(id)aParent;
 {
     if (self = [super init]) {
@@ -55,19 +50,6 @@
     return self;
 }
 
-- (BOOL)isEqual:(id)other {
-    if ([other isKindOfClass:[FVAccessibilityIconElement class]]) {
-        FVAccessibilityIconElement *otherElement = (FVAccessibilityIconElement 
*)other;
-        return _index == otherElement->_index && _parent == 
otherElement->_parent;
-    } else {
-        return NO;
-    }
-}
-
-- (NSUInteger)hash {
-    return _index + [_parent hash];
-}
-
 - (NSUInteger)index {
     return _index;
 }

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2022-07-24 
18:47:24 UTC (rev 27761)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2022-07-24 
19:10:08 UTC (rev 27762)
@@ -458,6 +458,7 @@
     [self _cancelDownloads];
     [_downloads release];
     [_progressIndicators release];
+    [_accessibilityIcons release];
     [_modificationSet release];
     [_modificationLock release];
     [_operationQueue terminate];
@@ -1823,6 +1824,7 @@
     
     [_orderedIcons removeAllObjects];
     [_orderedSubtitles removeAllObjects];
+    [_accessibilityIcons removeAllObjects];
     
     CFDictionaryRemoveAllValues(_infoTable);
     
@@ -1867,6 +1869,20 @@
             insertObjectAtIndex(_orderedSubtitles, insertSel, 
subtitleAtIndex(_dataSource, subtitleSel, self, i), i);
     }
     
+    NSUInteger accessibilityCount = [_accessibilityIcons count];
+    
+    if (accessibilityCount < iMax) {
+        if (nil == _accessibilityIcons)
+            _accessibilityIcons = [[NSMutableArray alloc] init];
+        for (i = accessibilityCount; i < iMax; i++) {
+            FVAccessibilityIconElement *element = [[FVAccessibilityIconElement 
alloc] initWithIndex:i parent:self];
+            [_accessibilityIcons addObject:element];
+            [element release];
+        }
+    } else if (accessibilityCount > iMax) {
+        [_accessibilityIcons removeObjectsInRange:NSMakeRange(iMax, 
accessibilityCount - iMax)];
+    }
+    
     if (NO == isBound)
         [self didChangeValueForKey:@"iconURLs"];
 }
@@ -4567,11 +4583,7 @@
 }
 
 - (NSArray *)accessibilityChildren {
-    NSMutableArray *children = [NSMutableArray array];
-    NSUInteger i, count = [self numberOfIcons];
-    for (i = 0; i < count; i++)
-        [children addObject:[FVAccessibilityIconElement elementWithIndex:i 
parent:self]];
-    return NSAccessibilityUnignoredChildren(children);
+    return _accessibilityIcons;
 }
 
 - (NSArray *)accessibilityVisibleChildren {
@@ -4582,7 +4594,7 @@
     for (i = 0; i < count; i++) {
         NSUInteger r, c;
         if ([self _getGridRow:&r column:&c ofIndex:i] && 
NSIntersectsRect([self _rectOfIconInRow:r column:c], visibleRect))
-            [children addObject:[FVAccessibilityIconElement elementWithIndex:i 
parent:self]];
+            [children addObject:[_accessibilityIcons objectAtIndex:i]];
     }
     return NSAccessibilityUnignoredChildren(children);
 }
@@ -4591,7 +4603,7 @@
     NSMutableArray *children = [NSMutableArray array];
     NSUInteger i = [_selectionIndexes firstIndex];
     while (i != NSNotFound) {
-        [children addObject:[FVAccessibilityIconElement elementWithIndex:i 
parent:self]];
+        [children addObject:[_accessibilityIcons objectAtIndex:i]];
         i = [_selectionIndexes indexGreaterThanIndex:i];
     }
     return NSAccessibilityUnignoredChildren(children);
@@ -4731,7 +4743,7 @@
 #endif
     NSUInteger i = [self _indexAtPoint:localPoint dropOperation:NULL];
     if (i != NSNotFound)
-        return [[FVAccessibilityIconElement elementWithIndex:i parent:self] 
accessibilityHitTest:point];
+        return [[_accessibilityIcons objectAtIndex:i] 
accessibilityHitTest:point];
     return NSAccessibilityUnignoredAncestor(self);
 }
 
@@ -4738,7 +4750,7 @@
 - (id)accessibilityFocusedUIElement {
     NSUInteger i = [_selectionIndexes firstIndex];
     if (i != NSNotFound)
-        return [[FVAccessibilityIconElement elementWithIndex:i parent:self] 
accessibilityFocusedUIElement];
+        return [[_accessibilityIcons objectAtIndex:i] 
accessibilityFocusedUIElement];
     else
         return NSAccessibilityUnignoredAncestor(self);
 }

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to