AX: embedded attachments do not work correctly with text marker APIs on macOS
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 01:08:53 +0000 (01:08 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 01:08:53 +0000 (01:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183751

Reviewed by Chris Fleizach.

In WebKit1, embedded attachments are not working well with text marker APIs.
We should use the corresponding attachment view in the following cases:
1. Hit testing on an attachment object.
2. Getting the attachment object at a text marker position.
3. Asking for the associated element with NSAccessibilityAttachmentTextAttribute.

Not able to construct a layout test because it relies on embedded attachments.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetElement):
(-[WebAccessibilityObjectWrapper accessibilityHitTest:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 78b2545..fbf7382 100644 (file)
@@ -1,3 +1,23 @@
+2018-03-19  Nan Wang  <n_wang@apple.com>
+
+        AX: embedded attachments do not work correctly with text marker APIs on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=183751
+
+        Reviewed by Chris Fleizach.
+
+        In WebKit1, embedded attachments are not working well with text marker APIs.
+        We should use the corresponding attachment view in the following cases:
+        1. Hit testing on an attachment object.
+        2. Getting the attachment object at a text marker position.
+        3. Asking for the associated element with NSAccessibilityAttachmentTextAttribute. 
+
+        Not able to construct a layout test because it relies on embedded attachments.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetElement):
+        (-[WebAccessibilityObjectWrapper accessibilityHitTest:]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+
 2018-03-19  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, another quick fix for r229699
index 6bb557a..580d982 100644 (file)
@@ -1015,7 +1015,11 @@ static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, N
         if (!cache)
             return;
         
-        AXUIElementRef axElement = NSAccessibilityCreateAXUIElementRef(object->wrapper());
+        id objectWrapper = object->wrapper();
+        if ([attribute isEqualToString:NSAccessibilityAttachmentTextAttribute] && object->isAttachment() && [objectWrapper attachmentView])
+            objectWrapper = [objectWrapper attachmentView];
+        
+        AXUIElementRef axElement = NSAccessibilityCreateAXUIElementRef(objectWrapper);
         if (axElement) {
             [attrString addAttribute:attribute value:(id)axElement range:range];
             CFRelease(axElement);
@@ -3307,8 +3311,11 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     
     m_object->updateChildrenIfNecessary();
     RefPtr<AccessibilityObject> axObject = m_object->accessibilityHitTest(IntPoint(point));
-    if (axObject)
+    if (axObject) {
+        if (axObject->isAttachment() && [axObject->wrapper() attachmentView])
+            return [axObject->wrapper() attachmentView];
         return NSAccessibilityUnignoredAncestor(axObject->wrapper());
+    }
     return NSAccessibilityUnignoredAncestor(self);
 }
 
@@ -3991,6 +3998,8 @@ static void formatForDebugger(const VisiblePositionRange& range, char* buffer, u
         AccessibilityObject* axObject = [self accessibilityObjectForTextMarker:textMarker];
         if (!axObject)
             return nil;
+        if (axObject->isAttachment() && [axObject->wrapper() attachmentView])
+            return [axObject->wrapper() attachmentView];
         return axObject->wrapper();
     }