Skip to content

Commit 2f87d29

Browse files
committed
AX: Every hit-test does one more main-thread round-trip than is necessary
https://bugs.webkit.org/show_bug.cgi?id=294212 rdar://152851160 Reviewed by Joshua Hoffman. Prior to this commit, we did one main-thread trip to convert the point, and then a separate one to actually do the hit test. Combine this into one main-thread trip. * Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: (-[WKAccessibilityWebPageObject accessibilityHitTest:]): Canonical link: https://commits.webkit.org/296024@main
1 parent 965167c commit 2f87d29

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,11 @@ - (BOOL)accessibilityShouldUseUniqueId
331331
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
332332
- (id)accessibilityHitTest:(NSPoint)point
333333
{
334-
auto convertedPoint = ax::retrieveValueFromMainThread<WebCore::IntPoint>([&point, PROTECTED_SELF] () -> WebCore::IntPoint {
335-
if (!protectedSelf->m_page)
336-
return WebCore::IntPoint(point);
337-
338-
// PDF plug-in handles the scroll view offset natively as part of the layer conversions.
339-
if (protectedSelf->m_page->mainFramePlugIn())
340-
return WebCore::IntPoint(point);
334+
return ax::retrieveAutoreleasedValueFromMainThread<id>([&point, PROTECTED_SELF] () -> id {
335+
// PDF plug-in handles the scroll view offset natively as part of the layer conversions, so don't
336+
// do a coordinate conversion for those hit tests.
337+
if (!protectedSelf->m_page || protectedSelf->m_page->mainFramePlugIn())
338+
return [[protectedSelf accessibilityRootObjectWrapper:[protectedSelf focusedLocalFrame]] accessibilityHitTest:WebCore::IntPoint(point)];
341339

342340
auto convertedPoint = protectedSelf->m_page->screenToRootView(WebCore::IntPoint(point));
343341

@@ -351,10 +349,8 @@ - (id)accessibilityHitTest:(NSPoint)point
351349
auto obscuredContentInsets = page->obscuredContentInsets();
352350
convertedPoint.move(-obscuredContentInsets.left(), -obscuredContentInsets.top());
353351
}
354-
return convertedPoint;
352+
return [[protectedSelf accessibilityRootObjectWrapper:[protectedSelf focusedLocalFrame]] accessibilityHitTest:convertedPoint];
355353
});
356-
357-
return [[self accessibilityRootObjectWrapper:[self focusedLocalFrame]] accessibilityHitTest:convertedPoint];
358354
}
359355
ALLOW_DEPRECATED_DECLARATIONS_END
360356

0 commit comments

Comments
 (0)