AX: [macOS] Expose the primary screen height through AX API
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 01:27:48 +0000 (01:27 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 01:27:48 +0000 (01:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185742

Reviewed by Chris Fleizach.

Source/WebCore:

Added a new attribute to expose the primary screen size on both
WebAccessibilityObjectWrapper and WKAccessibilityWebPageObject.

Test: accessibility/mac/primary-screen-height.html

* WebCore.xcodeproj/project.pbxproj:
* accessibility/mac/WebAccessibilityObjectWrapperMac.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper primaryScreenHeight]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* platform/PlatformScreen.h:
* platform/mac/PlatformScreenMac.mm:
(WebCore::screenRectForPrimaryScreen):

Source/WebKit:

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityAttributeNames]):
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):

Tools:

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(attributesOfElement):
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::attributesOfElement):

LayoutTests:

* accessibility/mac/primary-screen-height-expected.txt: Added.
* accessibility/mac/primary-screen-height.html: Added.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/mac/primary-screen-height-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/primary-screen-height.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/platform/PlatformScreen.h
Source/WebCore/platform/mac/PlatformScreenMac.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

index d98151b..62b3983 100644 (file)
@@ -1,3 +1,13 @@
+2018-05-17  Nan Wang  <n_wang@apple.com>
+
+        AX: [macOS] Expose the primary screen height through AX API
+        https://bugs.webkit.org/show_bug.cgi?id=185742
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/primary-screen-height-expected.txt: Added.
+        * accessibility/mac/primary-screen-height.html: Added.
+
 2018-05-17  Chris Dumez  <cdumez@apple.com>
 
         RenderLayer::scrollRectToVisible() should not propagate a subframe's scroll to its cross-origin parent
diff --git a/LayoutTests/accessibility/mac/primary-screen-height-expected.txt b/LayoutTests/accessibility/mac/primary-screen-height-expected.txt
new file mode 100644 (file)
index 0000000..aee90e2
--- /dev/null
@@ -0,0 +1,12 @@
+Click
+This tests the primary screen height is exposed to AX API from web process.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS screenHeightFromRootElement > 0 is true
+PASS screenHeightFromWebArea > 0 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/primary-screen-height.html b/LayoutTests/accessibility/mac/primary-screen-height.html
new file mode 100644 (file)
index 0000000..56df80e
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<button id="button1">Click</button>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests the primary screen height is exposed to AX API from web process.");
+    if (window.accessibilityController) {
+       var rootElement = accessibilityController.rootElement;
+        var webArea = accessibilityController.rootElement.childAtIndex(0);
+
+        var screenHeightFromRootElement = rootElement.numberAttributeValue("_AXPrimaryScreenHeight");
+        shouldBeTrue("screenHeightFromRootElement > 0");
+
+        var screenHeightFromWebArea = webArea.numberAttributeValue("_AXPrimaryScreenHeight");
+        shouldBeTrue("screenHeightFromWebArea > 0");
+    }
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index b9d6df1..2cb88b3 100644 (file)
@@ -514,6 +514,9 @@ webkit.org/b/184742 accessibility/mac/async-increment-decrement-action.html [ Sk
 
 webkit.org/b/182752 accessibility/mac/accessibility-make-first-responder.html [ Skip ]
 
+# This test tests the rootElement on WK2.
+webkit.org/b/185742 accessibility/mac/primary-screen-height.html [ Skip ]
+
 # User-installed fonts test infrastructure is not present in WK1
 webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ]
 
index ca90dfc..89853a7 100644 (file)
@@ -1,3 +1,25 @@
+2018-05-17  Nan Wang  <n_wang@apple.com>
+
+        AX: [macOS] Expose the primary screen height through AX API
+        https://bugs.webkit.org/show_bug.cgi?id=185742
+
+        Reviewed by Chris Fleizach.
+
+        Added a new attribute to expose the primary screen size on both
+        WebAccessibilityObjectWrapper and WKAccessibilityWebPageObject.
+
+        Test: accessibility/mac/primary-screen-height.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
+        (-[WebAccessibilityObjectWrapper primaryScreenHeight]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * platform/PlatformScreen.h:
+        * platform/mac/PlatformScreenMac.mm:
+        (WebCore::screenRectForPrimaryScreen):
+
 2018-05-17  Chris Dumez  <cdumez@apple.com>
 
         RenderLayer::scrollRectToVisible() should not propagate a subframe's scroll to its cross-origin parent
index 7065759..b5104d1 100644 (file)
                29A812410FBB9C1D00510293 /* AccessibilityTableColumn.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812230FBB9C1D00510293 /* AccessibilityTableColumn.h */; };
                29A812420FBB9C1D00510293 /* AccessibilityListBoxOption.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812240FBB9C1D00510293 /* AccessibilityListBoxOption.h */; };
                29A812430FBB9C1D00510293 /* AccessibilityListBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812250FBB9C1D00510293 /* AccessibilityListBox.h */; };
-               29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812450FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h */; };
+               29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 29A812450FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */; };
                29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */; };
                29FAF4B6195AB08900A522DC /* TextUndoInsertionMarkupMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AA2A5AD216A4860A00976A25 /* JSSpeechSynthesisEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2A5AC116A485D500976A25 /* JSSpeechSynthesisEvent.h */; };
                AA2A5AD416A4861100975A25 /* SpeechSynthesis.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2A5ABE16A485D500975A25 /* SpeechSynthesis.h */; };
                AA2A5AD616A4861600975A25 /* DOMWindowSpeechSynthesis.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2A5AB916A485D500975A25 /* DOMWindowSpeechSynthesis.h */; };
-               AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */ = {isa = PBXBuildFile; fileRef = AA478A7D16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h */; };
+               AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */ = {isa = PBXBuildFile; fileRef = AA478A7D16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AA4C3A770B2B1679002334A2 /* InlineStyleSheetOwner.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4C3A750B2B1679002334A2 /* InlineStyleSheetOwner.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */ = {isa = PBXBuildFile; fileRef = AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */; };
                AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */; };
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */,
+                               AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */,
                                7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */,
                                7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */,
                                46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */,
                                FD7F299213D4C0CB00AD9535 /* WaveShaperDSPKernel.h in Headers */,
                                FD7F299413D4C0CB00AD9535 /* WaveShaperNode.h in Headers */,
                                FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */,
-                               29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */,
                                AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */,
-                               AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */,
                                2D3EF4481917915C00034184 /* WebActionDisablingCALayerDelegate.h in Headers */,
                                71025ED31F99F0CE004A250C /* WebAnimation.h in Headers */,
                                7132445120109DA500AE7FB2 /* WebAnimationUtilities.h in Headers */,
index ec9c057..c19cf21 100644 (file)
 
 #if PLATFORM(MAC)
 
+#ifndef NSAccessibilityPrimaryScreenHeightAttribute
+#define NSAccessibilityPrimaryScreenHeightAttribute @"_AXPrimaryScreenHeight"
+#endif
+
 @interface WebAccessibilityObjectWrapper : WebAccessibilityObjectWrapperBase
 
 - (id)textMarkerRangeFromVisiblePositions:(const WebCore::VisiblePosition&)startPosition endPosition:(const WebCore::VisiblePosition&)endPosition;
index a102d36..f072af8 100644 (file)
@@ -1656,6 +1656,9 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache* cache, const Visibl
     if (m_object->currentState() != AccessibilityCurrentState::False)
         objectAttributes = [objectAttributes arrayByAddingObjectsFromArray:@[ NSAccessibilityARIACurrentAttribute ]];
     
+    // AppKit needs to know the screen height in order to do the coordinate conversion.
+    objectAttributes = [objectAttributes arrayByAddingObjectsFromArray:@[ NSAccessibilityPrimaryScreenHeightAttribute ]];
+    
     return objectAttributes;
 }
 
@@ -1819,6 +1822,12 @@ static void WebTransformCGPathToNSBezierPath(void *info, const CGPathElement *el
     return [self bezierPathFromPath:transformedPath];
 }
 
+- (NSNumber *)primaryScreenHeight
+{
+    FloatRect screenRect = screenRectForPrimaryScreen();
+    return [NSNumber numberWithFloat:screenRect.height()];
+}
+
 - (NSValue *)position
 {
     IntRect rect = snappedIntRect(m_object->elementRect());
@@ -2700,6 +2709,8 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return [NSValue valueWithSize: NSMakeSize(s.width(), s.height())];
     }
     
+    if ([attributeName isEqualToString: NSAccessibilityPrimaryScreenHeightAttribute])
+        return [self primaryScreenHeight];
     if ([attributeName isEqualToString: NSAccessibilityPositionAttribute])
         return [self position];
     if ([attributeName isEqualToString:NSAccessibilityPathAttribute])
index 59100a2..061ff65 100644 (file)
@@ -85,6 +85,7 @@ NSScreen *screen(NSWindow *);
 NSScreen *screen(PlatformDisplayID);
 
 FloatRect screenRectForDisplay(PlatformDisplayID);
+WEBCORE_EXPORT FloatRect screenRectForPrimaryScreen();
 
 WEBCORE_EXPORT FloatRect toUserSpace(const NSRect&, NSWindow *destination);
 FloatRect toUserSpaceForPrimaryScreen(const NSRect&);
index 6298122..f479519 100644 (file)
@@ -221,6 +221,11 @@ FloatRect screenRectForDisplay(PlatformDisplayID displayID)
     return screen(displayID).frame;
 }
 
+FloatRect screenRectForPrimaryScreen()
+{
+    return screenRectForDisplay(primaryScreenDisplayID());
+}
+
 FloatRect screenRect(Widget* widget)
 {
     if (!screenProperties().isEmpty())
index b78c10b..4068cc9 100644 (file)
@@ -1,3 +1,14 @@
+2018-05-17  Nan Wang  <n_wang@apple.com>
+
+        AX: [macOS] Expose the primary screen height through AX API
+        https://bugs.webkit.org/show_bug.cgi?id=185742
+
+        Reviewed by Chris Fleizach.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
+        (-[WKAccessibilityWebPageObject accessibilityAttributeNames]):
+        (-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):
+
 2018-05-17  Alex Christensen  <achristensen@webkit.org>
 
         Use CompletionHandlers for DelayedReplies
index 6414cfe..fe94e85 100644 (file)
@@ -44,6 +44,7 @@
 #import <WebCore/PageOverlayController.h>
 #import <WebCore/ScrollView.h>
 #import <WebCore/Scrollbar.h>
+#import <WebCore/WebAccessibilityObjectWrapperMac.h>
 #import <pal/spi/mac/NSAccessibilitySPI.h>
 #import <wtf/ObjcRuntimeExtras.h>
 
@@ -70,7 +71,7 @@ using namespace WebKit;
         m_attributeNames = adoptNS([[NSArray alloc] initWithObjects:
                             NSAccessibilityRoleAttribute, NSAccessibilityRoleDescriptionAttribute, NSAccessibilityFocusedAttribute,
                             NSAccessibilityParentAttribute, NSAccessibilityWindowAttribute, NSAccessibilityTopLevelUIElementAttribute,
-                            NSAccessibilityPositionAttribute, NSAccessibilitySizeAttribute, NSAccessibilityChildrenAttribute, nil]);
+                            NSAccessibilityPositionAttribute, NSAccessibilitySizeAttribute, NSAccessibilityChildrenAttribute, NSAccessibilityPrimaryScreenHeightAttribute, nil]);
     
     return m_attributeNames.get();
 }
@@ -147,6 +148,9 @@ using namespace WebKit;
         return [NSValue valueWithPoint:NSMakePoint(point.x(), point.y())];
     }
     
+    if ([attribute isEqualToString:NSAccessibilityPrimaryScreenHeightAttribute])
+        return [[self accessibilityRootObjectWrapper] accessibilityAttributeValue:attribute];
+    
     if ([attribute isEqualToString:NSAccessibilitySizeAttribute]) {
         const IntSize& s = m_page->size();
         return [NSValue valueWithSize:NSMakeSize(s.width(), s.height())];
index cf0517d..7f293dc 100644 (file)
@@ -1,3 +1,15 @@
+2018-05-17  Nan Wang  <n_wang@apple.com>
+
+        AX: [macOS] Expose the primary screen height through AX API
+        https://bugs.webkit.org/show_bug.cgi?id=185742
+
+        Reviewed by Chris Fleizach.
+
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (attributesOfElement):
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::attributesOfElement):
+
 2018-05-17  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r231912.
index 7df0ba8..bd840ce 100644 (file)
@@ -158,6 +158,10 @@ static NSString* attributesOfElement(id accessibilityObject)
         if ([attribute isEqualToString:@"AXPosition"])
             continue;
         
+        // Skip screen-specific information.
+        if ([attribute isEqualToString:@"_AXPrimaryScreenHeight"])
+            continue;
+        
         // accessibilityAttributeValue: can throw an if an attribute is not returned.
         // For DumpRenderTree's purpose, we should ignore those exceptions
         BEGIN_AX_OBJC_EXCEPTIONS
index a42aaf5..ccc7f21 100644 (file)
@@ -172,6 +172,10 @@ static NSString* attributesOfElement(id accessibilityObject)
         if ([attribute isEqualToString:@"AXPosition"])
             continue;
         
+        // Skip screen-specific information.
+        if ([attribute isEqualToString:@"_AXPrimaryScreenHeight"])
+            continue;
+        
         // accessibilityAttributeValue: can throw an if an attribute is not returned.
         // For DumpRenderTree's purpose, we should ignore those exceptions
         BEGIN_AX_OBJC_EXCEPTIONS