Bug 129643 - AX: Refactor code in WKAccessibilityWebPageObjectMac to use existing viewToScreenMethods
Summary: AX: Refactor code in WKAccessibilityWebPageObjectMac to use existing viewToSc...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-03-03 17:00 PST by chris fleizach
Modified: 2014-03-03 17:01 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chris fleizach 2014-03-03 17:00:15 PST
There's a bunch of code in the hit-testing that could probably be reduced by moving to a viewToScreen method

//#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (id)accessibilityHitTest:(NSPoint)point
{
    // Hit-test point comes in as bottom-screen coordinates. Needs to be normalized to the frame of the web page.
    NSPoint remotePosition = [[self accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue];
    NSSize remoteSize = [[self accessibilityAttributeValue:NSAccessibilitySizeAttribute] sizeValue];
    
    // Get the y position of the WKView (we have to screen-flip and go from bottom left to top left).
    CGFloat screenHeight = [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height;
    remotePosition.y = (screenHeight - remotePosition.y) - remoteSize.height;
    
    point.y = screenHeight - point.y;
    
    // Re-center point into the web page's frame.
    point.y -= remotePosition.y;
    point.x -= remotePosition.x;
    
    WebCore::FrameView* frameView = m_page ? m_page->mainFrameView() : 0;
    if (frameView) {
        point.y += frameView->scrollPosition().y();
        point.x += frameView->scrollPosition().x();
    }
    
    return [[self accessibilityRootObjectWrapper] accessibilityHitTest:point];
}
Comment 1 Radar WebKit Bug Importer 2014-03-03 17:01:00 PST
<rdar://problem/16217817>