Title: [152786] trunk/Source/WebKit2
Revision
152786
Author
[email protected]
Date
2013-07-17 09:44:43 -0700 (Wed, 17 Jul 2013)

Log Message

AX: VoiceOver not working with data detection page overlays
https://bugs.webkit.org/show_bug.cgi?id=118680

Reviewed by Tim Horton.

Expose API methods so that a client implementing data detectors is able to respond
to the needs of accessibility clients like VoiceOver.

* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(PageOverlayClientImpl::supportsDataDetection):
(PageOverlayClientImpl::dataDetectorExistsAtPoint):
(PageOverlayClientImpl::dataDetectorCopyTypeAtPoint):
(PageOverlayClientImpl::showDataDetectorMenuAtPoint):
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h:
* WebProcess/WebPage/PageOverlay.cpp:
(WebKit::PageOverlay::supportsDataDetection):
(WebKit::PageOverlay::dataDetectorExistsAtPoint):
(WebKit::PageOverlay::dataDetectorCopyTypeAtPoint):
(WebKit::PageOverlay::dataDetectorOpenMenuAtPoint):
* WebProcess/WebPage/PageOverlay.h:
(WebKit::PageOverlay::Client::supportsDataDetection):
(WebKit::PageOverlay::Client::dataDetectorExistsAtPoint):
(WebKit::PageOverlay::Client::dataDetectorCopyTypeAtPoint):
(WebKit::PageOverlay::Client::showDataDetectorMenuAtPoint):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::pageOverlayOpenDataDetectorMenuAtPoint):
(WebKit::WebPage::pageOverlayDataDetectorCopyTypeAtPoint):
(WebKit::WebPage::pageOverlayDataDetectorExistsAtPoint):
(WebKit::WebPage::pageOverlaySupportsDataDetection):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
(-[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]):
(-[WKAccessibilityWebPageObject _convertScreenPointToWindow:]):
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:forParameter:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (152785 => 152786)


--- trunk/Source/WebKit2/ChangeLog	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-17 16:44:43 UTC (rev 152786)
@@ -1,3 +1,40 @@
+2013-07-17  Chris Fleizach  <[email protected]>
+
+        AX: VoiceOver not working with data detection page overlays
+        https://bugs.webkit.org/show_bug.cgi?id=118680
+
+        Reviewed by Tim Horton.
+
+        Expose API methods so that a client implementing data detectors is able to respond
+        to the needs of accessibility clients like VoiceOver.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
+        (PageOverlayClientImpl::supportsDataDetection):
+        (PageOverlayClientImpl::dataDetectorExistsAtPoint):
+        (PageOverlayClientImpl::dataDetectorCopyTypeAtPoint):
+        (PageOverlayClientImpl::showDataDetectorMenuAtPoint):
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h:
+        * WebProcess/WebPage/PageOverlay.cpp:
+        (WebKit::PageOverlay::supportsDataDetection):
+        (WebKit::PageOverlay::dataDetectorExistsAtPoint):
+        (WebKit::PageOverlay::dataDetectorCopyTypeAtPoint):
+        (WebKit::PageOverlay::dataDetectorOpenMenuAtPoint):
+        * WebProcess/WebPage/PageOverlay.h:
+        (WebKit::PageOverlay::Client::supportsDataDetection):
+        (WebKit::PageOverlay::Client::dataDetectorExistsAtPoint):
+        (WebKit::PageOverlay::Client::dataDetectorCopyTypeAtPoint):
+        (WebKit::PageOverlay::Client::showDataDetectorMenuAtPoint):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::pageOverlayOpenDataDetectorMenuAtPoint):
+        (WebKit::WebPage::pageOverlayDataDetectorCopyTypeAtPoint):
+        (WebKit::WebPage::pageOverlayDataDetectorExistsAtPoint):
+        (WebKit::WebPage::pageOverlaySupportsDataDetection):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
+        (-[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]):
+        (-[WKAccessibilityWebPageObject _convertScreenPointToWindow:]):
+        (-[WKAccessibilityWebPageObject accessibilityAttributeValue:forParameter:]):
+
 2013-07-17  Dong-Gwan Kim  <[email protected]>
 
         [EFL][WK2] EWK2CookieManagerTest should be defined by inheriting from EWK2UnitTestBase.

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp	2013-07-17 16:44:43 UTC (rev 152786)
@@ -115,6 +115,34 @@
         }
     }
     
+    virtual bool supportsDataDetection(PageOverlay* pageOverlay)
+    {
+        if (!m_client.dataDetectionCallbacks.supportsDataDetectors)
+            return false;
+        return m_client.dataDetectionCallbacks.supportsDataDetectors(toAPI(pageOverlay), m_client.clientInfo);
+    }
+    
+    virtual bool dataDetectorExistsAtPoint(PageOverlay* pageOverlay, const WebCore::IntPoint& point)
+    {
+        if (!m_client.dataDetectionCallbacks.dataDetectorExistsAtPoint)
+            return false;
+        return m_client.dataDetectionCallbacks.dataDetectorExistsAtPoint(toAPI(pageOverlay), WKPointMake(point.x(), point.y()), m_client.clientInfo);
+    }
+    
+    virtual WKStringRef dataDetectorCopyTypeAtPoint(PageOverlay* pageOverlay, const WebCore::IntPoint& point)
+    {
+        if (!m_client.dataDetectionCallbacks.dataDetectorCopyTypeAtPoint)
+            return 0;
+        return m_client.dataDetectionCallbacks.dataDetectorCopyTypeAtPoint(toAPI(pageOverlay), WKPointMake(point.x(), point.y()), m_client.clientInfo);
+    }
+    
+    virtual bool showDataDetectorMenuAtPoint(PageOverlay* pageOverlay, const WebCore::IntPoint& point)
+    {
+        if (!m_client.dataDetectionCallbacks.showDataDetectorMenuAtPoint)
+            return false;
+        return m_client.dataDetectionCallbacks.showDataDetectorMenuAtPoint(toAPI(pageOverlay), WKPointMake(point.x(), point.y()), m_client.clientInfo);
+    }
+    
     WKBundlePageOverlayClient m_client;
 };
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h	2013-07-17 16:44:43 UTC (rev 152786)
@@ -49,6 +49,18 @@
 typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
 typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
 
+typedef bool (*WKDataDetectionIsSupportedCallback)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
+typedef bool (*WKDataDetectionExistsAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
+typedef WKStringRef (*WKDataDetectionTypeAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
+typedef bool (*WKDataDetectionShowMenuAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
+
+struct WKBundlePageOverlayDataDetectionCallbacks {
+    WKDataDetectionIsSupportedCallback                                 supportsDataDetectors;
+    WKDataDetectionExistsAtPointCallback                               dataDetectorExistsAtPoint;
+    WKDataDetectionTypeAtPointCallback                                 dataDetectorCopyTypeAtPoint;
+    WKDataDetectionShowMenuAtPointCallback                             showDataDetectorMenuAtPoint;
+};
+    
 struct WKBundlePageOverlayClient {
     int                                                                 version;
     const void *                                                        clientInfo;
@@ -59,6 +71,7 @@
     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
+    struct WKBundlePageOverlayDataDetectionCallbacks                    dataDetectionCallbacks;
 };
 typedef struct WKBundlePageOverlayClient WKBundlePageOverlayClient;
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp	2013-07-17 16:44:43 UTC (rev 152786)
@@ -130,6 +130,26 @@
     return m_client->mouseEvent(this, mouseEvent);
 }
 
+bool PageOverlay::supportsDataDetection()
+{
+    return m_client->supportsDataDetection(this);
+}
+    
+bool PageOverlay::dataDetectorExistsAtPoint(const WebCore::IntPoint& point)
+{
+    return m_client->dataDetectorExistsAtPoint(this, point);
+}
+
+WKStringRef PageOverlay::dataDetectorCopyTypeAtPoint(const WebCore::IntPoint& point)
+{
+    return m_client->dataDetectorCopyTypeAtPoint(this, point);
+}
+
+bool PageOverlay::dataDetectorOpenMenuAtPoint(const WebCore::IntPoint& point)
+{
+    return m_client->showDataDetectorMenuAtPoint(this, point);
+}
+    
 void PageOverlay::startFadeInAnimation()
 {
     m_fractionFadedIn = 0.0;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.h (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.h	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.h	2013-07-17 16:44:43 UTC (rev 152786)
@@ -27,11 +27,13 @@
 #define PageOverlay_h
 
 #include "APIObject.h"
+#include "WKBase.h"
 #include <WebCore/RunLoop.h>
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
     class GraphicsContext;
+    class IntPoint;
     class IntRect;
 }
 
@@ -52,6 +54,11 @@
         virtual void didMoveToWebPage(PageOverlay*, WebPage*) = 0;
         virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) = 0;
         virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&) = 0;
+
+        virtual bool supportsDataDetection(PageOverlay*) { return false; }
+        virtual bool dataDetectorExistsAtPoint(PageOverlay*, const WebCore::IntPoint&) { return false; }
+        virtual WKStringRef dataDetectorCopyTypeAtPoint(PageOverlay*, const WebCore::IntPoint&) { return 0; }
+        virtual bool showDataDetectorMenuAtPoint(PageOverlay*, const WebCore::IntPoint&) { return false; }
     };
 
     static PassRefPtr<PageOverlay> create(Client*);
@@ -64,6 +71,11 @@
     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
     bool mouseEvent(const WebMouseEvent&);
 
+    bool supportsDataDetection();
+    bool dataDetectorExistsAtPoint(const WebCore::IntPoint&);
+    WKStringRef dataDetectorCopyTypeAtPoint(const WebCore::IntPoint&);
+    bool dataDetectorOpenMenuAtPoint(const WebCore::IntPoint&);
+    
     void startFadeInAnimation();
     void startFadeOutAnimation();
     void stopFadeOutAnimation();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-07-17 16:44:43 UTC (rev 152786)
@@ -1837,7 +1837,51 @@
     send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(gestureEvent.type()), handled));
 }
 #endif
+    
+bool WebPage::pageOverlayOpenDataDetectorMenuAtPoint(const WebCore::IntPoint& point)
+{
+    if (!m_pageOverlays.size())
+        return false;
+    PageOverlayList::reverse_iterator end = m_pageOverlays.rend();
+    for (PageOverlayList::reverse_iterator it = m_pageOverlays.rbegin(); it != end; ++it)
+        if ((*it)->supportsDataDetection())
+            return (*it)->dataDetectorOpenMenuAtPoint(point);
+    return false;
+}
 
+WKStringRef WebPage::pageOverlayDataDetectorCopyTypeAtPoint(const WebCore::IntPoint& point)
+{
+    if (!m_pageOverlays.size())
+        return 0;
+    PageOverlayList::reverse_iterator end = m_pageOverlays.rend();
+    for (PageOverlayList::reverse_iterator it = m_pageOverlays.rbegin(); it != end; ++it)
+        if ((*it)->supportsDataDetection())
+            return (*it)->dataDetectorCopyTypeAtPoint(point);
+    return 0;
+}
+
+bool WebPage::pageOverlayDataDetectorExistsAtPoint(const WebCore::IntPoint& point)
+{
+    if (!m_pageOverlays.size())
+        return false;
+    PageOverlayList::reverse_iterator end = m_pageOverlays.rend();
+    for (PageOverlayList::reverse_iterator it = m_pageOverlays.rbegin(); it != end; ++it)
+        if ((*it)->supportsDataDetection())
+            return (*it)->dataDetectorExistsAtPoint(point);
+    return false;
+}
+
+bool WebPage::pageOverlaySupportsDataDetection()
+{
+    if (!m_pageOverlays.size())
+        return false;
+    PageOverlayList::reverse_iterator end = m_pageOverlays.rend();
+    for (PageOverlayList::reverse_iterator it = m_pageOverlays.rbegin(); it != end; ++it)
+        if ((*it)->supportsDataDetection())
+            return true;
+    return false;
+}
+    
 void WebPage::validateCommand(const String& commandName, uint64_t callbackID)
 {
     bool isEnabled = false;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-07-17 16:44:43 UTC (rev 152786)
@@ -664,6 +664,11 @@
     WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; }
     void setScrollPinningBehavior(uint32_t /* WebCore::ScrollPinningBehavior */ pinning);
 
+    bool pageOverlaySupportsDataDetection();
+    bool pageOverlayOpenDataDetectorMenuAtPoint(const WebCore::IntPoint&);
+    WKStringRef pageOverlayDataDetectorCopyTypeAtPoint(const WebCore::IntPoint&);
+    bool pageOverlayDataDetectorExistsAtPoint(const WebCore::IntPoint&);
+    
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm (152785 => 152786)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm	2013-07-17 16:40:11 UTC (rev 152785)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm	2013-07-17 16:44:43 UTC (rev 152786)
@@ -28,6 +28,8 @@
 
 #import "WebFrame.h"
 #import "WebPage.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
 #import <WebCore/AXObjectCache.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameView.h>
@@ -39,6 +41,10 @@
 using namespace WebCore;
 using namespace WebKit;
 
+static NSString *NSAccessibilityDataDetectorExistsAtPoint        = @"AXDataDetectorExistsAtPoint";
+static NSString *NSAccessibilityDidShowDataDetectorMenuAtPoint   = @"AXDidShowDataDetectorMenuAtPoint";
+static NSString *NSAccessibilityDataDetectorTypeAtPoint          = @"AXDataDetectorTypeAtPoint";
+
 @implementation WKAccessibilityWebPageObject
 
 - (id)accessibilityRootObjectWrapper
@@ -103,6 +109,16 @@
     return m_attributeNames;
 }
 
+- (NSArray *)accessibilityParameterizedAttributeNames
+{
+    NSArray *names = nil;
+    
+    if (m_page->pageOverlaySupportsDataDetection())
+        names = [NSArray arrayWithObjects:NSAccessibilityDataDetectorExistsAtPoint, NSAccessibilityDataDetectorTypeAtPoint, NSAccessibilityDidShowDataDetectorMenuAtPoint,  nil];
+    
+    return names;
+}
+
 - (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute
 {
     return NO;
@@ -162,6 +178,40 @@
     return nil;
 }
 
+- (NSPoint)_convertScreenPointToWindow:(NSPoint)point
+{
+    return m_page->screenToWindow(IntPoint(point.x, point.y));
+}
+
+- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter
+{
+    if ([attribute isEqualToString:NSAccessibilityDidShowDataDetectorMenuAtPoint]) {
+        if (![parameter isKindOfClass:[NSValue class]])
+            return nil;
+        
+        NSPoint point = [self _convertScreenPointToWindow:[(NSValue *)parameter pointValue]];
+        return [NSNumber numberWithBool:m_page->pageOverlayOpenDataDetectorMenuAtPoint(IntPoint(point))];
+    }
+    if ([attribute isEqualToString:NSAccessibilityDataDetectorTypeAtPoint]) {
+        if (![parameter isKindOfClass:[NSValue class]])
+            return nil;
+        
+        NSPoint point = [self _convertScreenPointToWindow:[(NSValue *)parameter pointValue]];
+        WKRetainPtr<WKStringRef> type = adoptWK(m_page->pageOverlayDataDetectorCopyTypeAtPoint(IntPoint(point)));
+        if (type)
+            return [(NSString *)WKStringCopyCFString(kCFAllocatorDefault, type.get()) autorelease];
+    }
+    if ([attribute isEqualToString:NSAccessibilityDataDetectorExistsAtPoint]) {
+        if (![parameter isKindOfClass:[NSValue class]])
+            return nil;
+        
+        NSPoint point = [self _convertScreenPointToWindow:[(NSValue *)parameter pointValue]];
+        return [NSNumber numberWithBool:m_page->pageOverlayDataDetectorExistsAtPoint(IntPoint(point))];
+    }
+    
+    return nil;
+}
+
 - (BOOL)accessibilityShouldUseUniqueId
 {
     return YES;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to