Title: [232944] trunk/Source/WebCore
Revision
232944
Author
n_w...@apple.com
Date
2018-06-18 14:04:52 -0700 (Mon, 18 Jun 2018)

Log Message

AX: [macOS] When zoom is enabled, focus doesn't follow text cursor
https://bugs.webkit.org/show_bug.cgi?id=186697

Reviewed by Darin Adler.

Now that web process doesn't have access to NSScreen. The conversion of the 
rects is wrong. Fixed this by using the right function that's available in
WebCore to get the rects.

* editing/mac/FrameSelectionMac.mm:
(WebCore::accessibilityConvertScreenRect):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232943 => 232944)


--- trunk/Source/WebCore/ChangeLog	2018-06-18 20:48:07 UTC (rev 232943)
+++ trunk/Source/WebCore/ChangeLog	2018-06-18 21:04:52 UTC (rev 232944)
@@ -1,3 +1,17 @@
+2018-06-18  Nan Wang  <n_w...@apple.com>
+
+        AX: [macOS] When zoom is enabled, focus doesn't follow text cursor
+        https://bugs.webkit.org/show_bug.cgi?id=186697
+
+        Reviewed by Darin Adler.
+
+        Now that web process doesn't have access to NSScreen. The conversion of the 
+        rects is wrong. Fixed this by using the right function that's available in
+        WebCore to get the rects.
+
+        * editing/mac/FrameSelectionMac.mm:
+        (WebCore::accessibilityConvertScreenRect):
+
 2018-06-18  Youenn Fablet  <you...@apple.com>
 
         Expose RTCPeerConnectionIceEventInit constructor

Modified: trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm (232943 => 232944)


--- trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm	2018-06-18 20:48:07 UTC (rev 232943)
+++ trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm	2018-06-18 21:04:52 UTC (rev 232944)
@@ -32,21 +32,6 @@
 
 namespace WebCore {
 
-#if !PLATFORM(IOS)
-static CGRect accessibilityConvertScreenRect(CGRect bounds)
-{
-    NSArray *screens = [NSScreen screens];
-    if ([screens count]) {
-        CGFloat screenHeight = NSHeight([(NSScreen *)[screens objectAtIndex:0] frame]);
-        bounds.origin.y = (screenHeight - (bounds.origin.y + bounds.size.height));
-    } else
-        bounds = CGRectZero;    
-    
-    return bounds;
-}
-#endif // !PLATFORM(IOS)
-    
-    
 void FrameSelection::notifyAccessibilityForSelectionChange(const AXTextStateChangeIntent& intent)
 {
     Document* document = m_frame->document();
@@ -73,10 +58,12 @@
 
     selectionRect = frameView->contentsToScreen(selectionRect);
     viewRect = frameView->contentsToScreen(viewRect);
-    CGRect cgCaretRect = CGRectMake(selectionRect.x(), selectionRect.y(), selectionRect.width(), selectionRect.height());
-    CGRect cgViewRect = CGRectMake(viewRect.x(), viewRect.y(), viewRect.width(), viewRect.height());
-    cgCaretRect = accessibilityConvertScreenRect(cgCaretRect);
-    cgViewRect = accessibilityConvertScreenRect(cgViewRect);
+    NSRect nsCaretRect = NSMakeRect(selectionRect.x(), selectionRect.y(), selectionRect.width(), selectionRect.height());
+    NSRect nsViewRect = NSMakeRect(viewRect.x(), viewRect.y(), viewRect.width(), viewRect.height());
+    nsCaretRect = toUserSpaceForPrimaryScreen(nsCaretRect);
+    nsViewRect = toUserSpaceForPrimaryScreen(nsViewRect);
+    CGRect cgCaretRect = NSRectToCGRect(nsCaretRect);
+    CGRect cgViewRect = NSRectToCGRect(nsViewRect);
 
     UAZoomChangeFocus(&cgViewRect, &cgCaretRect, kUAZoomFocusTypeInsertionPoint);
 #endif // !PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to