Bug 129643

Summary: AX: Refactor code in WKAccessibilityWebPageObjectMac to use existing viewToScreenMethods
Product: WebKit Reporter: chris fleizach <cfleizach>
Component: AccessibilityAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

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>