Skip to content

Commit

Permalink
Use new convenience accessibility APIs in OakTextView.mm
Browse files Browse the repository at this point in the history
  • Loading branch information
dusek authored and sorbits committed Dec 4, 2018
1 parent 9ad976a commit 5ee17f2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Frameworks/OakTextView/src/OakTextView.mm
Expand Up @@ -146,9 +146,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
} else if([attribute isEqualToString:NSAccessibilityWindowAttribute] || [attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) {
value = [self.textView accessibilityAttributeValue:attribute];
} else if([attribute isEqualToString:NSAccessibilityPositionAttribute] || [attribute isEqualToString:NSAccessibilitySizeAttribute]) {
NSRect frame = self.frame;
frame = [self.textView convertRect:frame toView:nil];
frame = [self.textView.window convertRectToScreen:frame];
NSRect frame = NSAccessibilityFrameInView(self.textView, self.frame);
if([attribute isEqualToString:NSAccessibilityPositionAttribute])
value = [NSValue valueWithPoint:frame.origin];
else
Expand Down Expand Up @@ -1582,8 +1580,7 @@ - (NSRect)accessibilityFrameForRange:(NSRange)nsRange
return NSZeroRect;
ng::range_t range = [self rangeForNSRange:nsRange];
NSRect rect = documentView->rect_for_range(range.min().index, range.max().index, true);
rect = [self convertRect:rect toView:nil];
return [[self window] convertRectToScreen:rect];
return NSAccessibilityFrameInView(self, rect);
}

// ===================
Expand Down Expand Up @@ -1789,11 +1786,8 @@ - (void)updateZoom:(id)sender
return;

size_t const index = documentView->ranges().last().min().index;
NSRect selectedRect = documentView->rect_at_index(index, false);
selectedRect = [self convertRect:selectedRect toView:nil];
selectedRect = [[self window] convertRectToScreen:selectedRect];
NSRect viewRect = [self convertRect:[self visibleRect] toView:nil];
viewRect = [[self window] convertRectToScreen:viewRect];
NSRect selectedRect = NSAccessibilityFrameInView(self, documentView->rect_at_index(index, false));
NSRect viewRect = NSAccessibilityFrameInView(self, [self visibleRect]);
viewRect.origin.y = [[NSScreen mainScreen] frame].size.height - (viewRect.origin.y + viewRect.size.height);
selectedRect.origin.y = [[NSScreen mainScreen] frame].size.height - (selectedRect.origin.y + selectedRect.size.height);
UAZoomChangeFocus(&viewRect, &selectedRect, kUAZoomFocusTypeInsertionPoint);
Expand Down

0 comments on commit 5ee17f2

Please sign in to comment.