Title: [191637] trunk/Source/WebKit2
Revision
191637
Author
timothy_hor...@apple.com
Date
2015-10-27 13:55:36 -0700 (Tue, 27 Oct 2015)

Log Message

WKView being inside WKWebView leads to weird API issues
https://bugs.webkit.org/show_bug.cgi?id=150174

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView _superAccessibilityAttributeValue:]):
(-[WKView accessibilityFocusedUIElement]):
(-[WKView accessibilityIsIgnored]):
(-[WKView accessibilityHitTest:]):
(-[WKView accessibilityAttributeValue:]):
(-[WKView _processDidExit]):
(-[WKView _pageClosed]):
(-[WKView _updateRemoteAccessibilityRegistration:]): Deleted.
(-[WKView enableAccessibilityIfNecessary]): Deleted.
(-[WKView _toolTipChangedFrom:to:]): Deleted.
(-[WKView _setAccessibilityWebProcessToken:]): Deleted.
(-[WKView _hasFullScreenWindowController]): Deleted.
(-[WKView _fullScreenWindowController]): Deleted.
(-[WKView _closeFullScreenWindowController]): Deleted.
(-[WKView _setSuppressVisibilityUpdates:]): Deleted.
(-[WKView _suppressVisibilityUpdates]): Deleted.
(-[WKView _primaryTrackingArea]): Deleted.
(-[WKView _setPrimaryTrackingArea:]): Deleted.
(-[WKView initWithFrame:processPool:configuration:webView:]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::accessibilityIsIgnored):
(WebKit::WebViewImpl::primaryTrackingArea):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::trackingAreaOptions):
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::setAccessibilityWebProcessToken):
(WebKit::WebViewImpl::updateRemoteAccessibilityRegistration):
(WebKit::WebViewImpl::accessibilityFocusedUIElement):
(WebKit::WebViewImpl::accessibilityHitTest):
(WebKit::WebViewImpl::enableAccessibilityIfNecessary):
(WebKit::WebViewImpl::accessibilityAttributeValue):
(WebKit::WebViewImpl::setPrimaryTrackingArea):
(WebKit::WebViewImpl::toolTipChanged):
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::toolTipChanged):
(WebKit::PageClientImpl::accessibilityWebProcessTokenReceived):
(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
(WebKit::PageClientImpl::closeFullScreenManager):
(WebKit::PageClientImpl::isFullScreen):
(WebKit::PageClientImpl::enterFullScreen):
(WebKit::PageClientImpl::exitFullScreen):
(WebKit::PageClientImpl::beganEnterFullScreen):
(WebKit::PageClientImpl::beganExitFullScreen):
Move accessibility code, and fold in some internal-only methods.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (191636 => 191637)


--- trunk/Source/WebKit2/ChangeLog	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-27 20:55:36 UTC (rev 191637)
@@ -6,6 +6,60 @@
         Reviewed by Anders Carlsson.
 
         * UIProcess/API/mac/WKView.mm:
+        (-[WKView _superAccessibilityAttributeValue:]):
+        (-[WKView accessibilityFocusedUIElement]):
+        (-[WKView accessibilityIsIgnored]):
+        (-[WKView accessibilityHitTest:]):
+        (-[WKView accessibilityAttributeValue:]):
+        (-[WKView _processDidExit]):
+        (-[WKView _pageClosed]):
+        (-[WKView _updateRemoteAccessibilityRegistration:]): Deleted.
+        (-[WKView enableAccessibilityIfNecessary]): Deleted.
+        (-[WKView _toolTipChangedFrom:to:]): Deleted.
+        (-[WKView _setAccessibilityWebProcessToken:]): Deleted.
+        (-[WKView _hasFullScreenWindowController]): Deleted.
+        (-[WKView _fullScreenWindowController]): Deleted.
+        (-[WKView _closeFullScreenWindowController]): Deleted.
+        (-[WKView _setSuppressVisibilityUpdates:]): Deleted.
+        (-[WKView _suppressVisibilityUpdates]): Deleted.
+        (-[WKView _primaryTrackingArea]): Deleted.
+        (-[WKView _setPrimaryTrackingArea:]): Deleted.
+        (-[WKView initWithFrame:processPool:configuration:webView:]): Deleted.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::accessibilityIsIgnored):
+        (WebKit::WebViewImpl::primaryTrackingArea):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::trackingAreaOptions):
+        (WebKit::WebViewImpl::WebViewImpl):
+        (WebKit::WebViewImpl::setAccessibilityWebProcessToken):
+        (WebKit::WebViewImpl::updateRemoteAccessibilityRegistration):
+        (WebKit::WebViewImpl::accessibilityFocusedUIElement):
+        (WebKit::WebViewImpl::accessibilityHitTest):
+        (WebKit::WebViewImpl::enableAccessibilityIfNecessary):
+        (WebKit::WebViewImpl::accessibilityAttributeValue):
+        (WebKit::WebViewImpl::setPrimaryTrackingArea):
+        (WebKit::WebViewImpl::toolTipChanged):
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::toolTipChanged):
+        (WebKit::PageClientImpl::accessibilityWebProcessTokenReceived):
+        (WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
+        (WebKit::PageClientImpl::closeFullScreenManager):
+        (WebKit::PageClientImpl::isFullScreen):
+        (WebKit::PageClientImpl::enterFullScreen):
+        (WebKit::PageClientImpl::exitFullScreen):
+        (WebKit::PageClientImpl::beganEnterFullScreen):
+        (WebKit::PageClientImpl::beganExitFullScreen):
+        Move accessibility code, and fold in some internal-only methods.
+
+2015-10-27  Tim Horton  <timothy_hor...@apple.com>
+
+        WKView being inside WKWebView leads to weird API issues
+        https://bugs.webkit.org/show_bug.cgi?id=150174
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/mac/WKView.mm:
         (-[WKView scrollWheel:]):
         (-[WKView swipeWithEvent:]):
         (-[WKView _superSwipeWithEvent:]):

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191636 => 191637)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2015-10-27 20:55:36 UTC (rev 191637)
@@ -162,10 +162,6 @@
     RetainPtr<_WKRemoteObjectRegistry> _remoteObjectRegistry;
 #endif
 
-    RetainPtr<NSTrackingArea> _primaryTrackingArea;
-
-    RetainPtr<id> _remoteAccessibilityChild;
-
     // For asynchronous validation.
     ValidationMap _validationMap;
 
@@ -2047,6 +2043,14 @@
     [super removeTrackingRect:tag];
 }
 
+- (id)_superAccessibilityAttributeValue:(NSString *)attribute
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    return [super accessibilityAttributeValue:attribute];
+#pragma clang diagnostic pop
+}
+
 - (NSArray *)validAttributesForMarkedText
 {
     static NSArray *validAttributes;
@@ -2169,74 +2173,24 @@
     _data->_page->viewStateDidChange(ViewState::IsVisible);
 }
 
-- (void)_updateRemoteAccessibilityRegistration:(BOOL)registerProcess
-{
-    // When the tree is connected/disconnected, the remote accessibility registration
-    // needs to be updated with the pid of the remote process. If the process is going
-    // away, that information is not present in WebProcess
-    pid_t pid = 0;
-    if (registerProcess)
-        pid = _data->_page->process().processIdentifier();
-    else if (!registerProcess) {
-        pid = WKAXRemoteProcessIdentifier(_data->_remoteAccessibilityChild.get());
-        _data->_remoteAccessibilityChild = nil;
-    }
-    if (pid)
-        WKAXRegisterRemoteProcess(registerProcess, pid); 
-}
-
-- (void)enableAccessibilityIfNecessary
-{
-    if (WebCore::AXObjectCache::accessibilityEnabled())
-        return;
-
-    // After enabling accessibility update the window frame on the web process so that the
-    // correct accessibility position is transmitted (when AX is off, that position is not calculated).
-    WebCore::AXObjectCache::enableAccessibility();
-    _data->_impl->updateWindowAndViewFrames();
-}
-
 - (id)accessibilityFocusedUIElement
 {
-    [self enableAccessibilityIfNecessary];
-    return _data->_remoteAccessibilityChild.get();
+    return _data->_impl->accessibilityFocusedUIElement();
 }
 
 - (BOOL)accessibilityIsIgnored
 {
-    return NO;
+    return _data->_impl->accessibilityIsIgnored();
 }
 
 - (id)accessibilityHitTest:(NSPoint)point
 {
-    [self enableAccessibilityIfNecessary];
-    return _data->_remoteAccessibilityChild.get();
+    return _data->_impl->accessibilityHitTest(NSPointToCGPoint(point));
 }
 
-- (id)accessibilityAttributeValue:(NSString*)attribute
+- (id)accessibilityAttributeValue:(NSString *)attribute
 {
-    [self enableAccessibilityIfNecessary];
-
-    if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
-
-        id child = nil;
-        if (_data->_remoteAccessibilityChild)
-            child = _data->_remoteAccessibilityChild.get();
-        
-        if (!child)
-            return nil;
-        return [NSArray arrayWithObject:child];
-    }
-    if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
-        return NSAccessibilityGroupRole;
-    if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute])
-        return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil);
-    if ([attribute isEqualToString:NSAccessibilityParentAttribute])
-        return NSAccessibilityUnignoredAncestor([self superview]);
-    if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
-        return [NSNumber numberWithBool:YES];
-    
-    return [super accessibilityAttributeValue:attribute];
+    return _data->_impl->accessibilityAttributeValue(attribute);
 }
 
 - (NSView *)hitTest:(NSPoint)point
@@ -2278,14 +2232,14 @@
     if (_data->_impl->layerHostingView())
         _data->_impl->setAcceleratedCompositingRootLayer(nil);
 
-    [self _updateRemoteAccessibilityRegistration:NO];
+    _data->_impl->updateRemoteAccessibilityRegistration(false);
 
     _data->_impl->resetGestureController();
 }
 
 - (void)_pageClosed
 {
-    [self _updateRemoteAccessibilityRegistration:NO];
+    _data->_impl->updateRemoteAccessibilityRegistration(false);
 }
 
 - (void)_didRelaunchProcess
@@ -2378,17 +2332,6 @@
     return _data->_impl->stringForToolTip(tag);
 }
 
-- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip
-{
-    _data->_impl->toolTipChanged(oldToolTip, newToolTip);
-}
-
-- (void)_setAccessibilityWebProcessToken:(NSData *)data
-{
-    _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
-    [self _updateRemoteAccessibilityRegistration:YES];
-}
-
 - (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
 {
     // The call below could release this WKView.
@@ -2546,23 +2489,6 @@
     return [NSArray arrayWithObject:[path lastPathComponent]];
 }
 
-#if ENABLE(FULLSCREEN_API)
-- (BOOL)_hasFullScreenWindowController
-{
-    return _data->_impl->hasFullScreenWindowController();
-}
-
-- (WKFullScreenWindowController *)_fullScreenWindowController
-{
-    return _data->_impl->fullScreenWindowController();
-}
-
-- (void)_closeFullScreenWindowController
-{
-    _data->_impl->closeFullScreenWindowController();
-}
-#endif
-
 - (bool)_executeSavedCommandBySelector:(SEL)selector
 {
     LOG(TextInput, "Executing previously saved command %s", sel_getName(selector));
@@ -2588,28 +2514,6 @@
     _data->_page->handleAlternativeTextUIResult(text);
 }
 
-- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates
-{
-    _data->_page->setSuppressVisibilityUpdates(suppressVisibilityUpdates);
-}
-
-- (BOOL)_suppressVisibilityUpdates
-{
-    return _data->_page->suppressVisibilityUpdates();
-}
-
-- (NSTrackingArea *)_primaryTrackingArea
-{
-    return _data->_primaryTrackingArea.get();
-}
-
-- (void)_setPrimaryTrackingArea:(NSTrackingArea *)trackingArea
-{
-    [self removeTrackingArea:_data->_primaryTrackingArea.get()];
-    _data->_primaryTrackingArea = trackingArea;
-    [self addTrackingArea:trackingArea];
-}
-
 - (instancetype)initWithFrame:(NSRect)frame processPool:(WebProcessPool&)processPool configuration:(Ref<API::PageConfiguration>&&)configuration webView:(WKWebView *)webView
 {
     self = [super initWithFrame:frame];
@@ -2620,16 +2524,7 @@
 
     InitializeWebKit2();
 
-    // Legacy style scrollbars have design details that rely on tracking the mouse all the time.
-    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingCursorUpdate;
-    if (WKRecommendedScrollerStyle() == NSScrollerStyleLegacy)
-        options |= NSTrackingActiveAlways;
-    else
-        options |= NSTrackingActiveInKeyWindow;
-
     _data = [[WKViewData alloc] init];
-    _data->_primaryTrackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:frame options:options owner:self userInfo:nil]);
-    [self addTrackingArea:_data->_primaryTrackingArea.get()];
 
     _data->_pageClient = std::make_unique<PageClientImpl>(self, webView);
     _data->_page = processPool.createWebPage(*_data->_pageClient, WTF::move(configuration));

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (191636 => 191637)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2015-10-27 20:55:36 UTC (rev 191637)
@@ -27,11 +27,6 @@
 
 #import "WKViewPrivate.h"
 
-#import "APIObject.h"
-#import "PluginComplexTextInputState.h"
-#import "SameDocumentNavigationType.h"
-#import "WebFindOptions.h"
-#import "WebHitTestResultData.h"
 #import <wtf/Forward.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
@@ -39,7 +34,6 @@
 @class _WKRemoteObjectRegistry;
 
 namespace API {
-class Object;
 class PageConfiguration;
 }
 
@@ -50,22 +44,14 @@
 namespace WebCore {
 class Image;
 class SharedBuffer;
-class TextIndicator;
-enum class TextIndicatorWindowLifetime : uint8_t;
-enum class TextIndicatorWindowDismissalAnimation : uint8_t;
-struct KeypressCommand;
 }
 
 namespace WebKit {
 class DrawingAreaProxy;
-class LayerTreeContext;
-class ViewSnapshot;
 class WebProcessPool;
 struct ColorSpaceData;
-struct EditorState;
 }
 
-@class WKFullScreenWindowController;
 @class WKWebView;
 #if WK_API_ENABLED
 @class _WKThumbnailView;
@@ -80,15 +66,12 @@
 - (void)_processDidExit;
 - (void)_pageClosed;
 - (void)_didRelaunchProcess;
-- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip;
 - (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState;
 - (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled;
 - (bool)_executeSavedCommandBySelector:(SEL)selector;
 - (NSRect)_convertToDeviceSpace:(NSRect)rect;
 - (NSRect)_convertToUserSpace:(NSRect)rect;
 
-- (void)_setAccessibilityWebProcessToken:(NSData *)data;
-
 - (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
 - (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName;
 #if ENABLE(ATTACHMENT_ELEMENT)
@@ -100,26 +83,16 @@
 - (NSInteger)spellCheckerDocumentTag;
 - (void)handleAcceptedAlternativeText:(NSString*)text;
 
-- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
-- (BOOL)_suppressVisibilityUpdates;
-
 #if WK_API_ENABLED
 @property (nonatomic, setter=_setThumbnailView:) _WKThumbnailView *_thumbnailView;
 #endif
 
 - (void)_addFontPanelObserver;
-// FullScreen
 
-@property (readonly) BOOL _hasFullScreenWindowController;
-@property (readonly) WKFullScreenWindowController *_fullScreenWindowController;
-- (void)_closeFullScreenWindowController;
-
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 - (void)_startWindowDrag;
 #endif
 
-@property (nonatomic, retain, setter=_setPrimaryTrackingArea:) NSTrackingArea *_primaryTrackingArea;
-
 #if WK_API_ENABLED
 @property (nonatomic, readonly) _WKRemoteObjectRegistry *_remoteObjectRegistry;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191636 => 191637)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2015-10-27 20:55:36 UTC (rev 191637)
@@ -55,6 +55,7 @@
 - (void)_superSwipeWithEvent:(NSEvent *)event;
 - (void)_superMagnifyWithEvent:(NSEvent *)event;
 - (void)_superSmartMagnifyWithEvent:(NSEvent *)event;
+- (id)_superAccessibilityAttributeValue:(NSString *)attribute;
 
 // This is a hack; these things live can live on a category (e.g. WKView (Private)) but WKView itself conforms to this protocol.
 // They're not actually optional.
@@ -225,15 +226,25 @@
     void setIgnoresMouseDraggedEvents(bool);
     bool ignoresMouseDraggedEvents() const { return m_ignoresMouseDraggedEvents; }
 
+    void setAccessibilityWebProcessToken(NSData *);
     void accessibilityRegisterUIProcessTokens();
+    void updateRemoteAccessibilityRegistration(bool registerProcess);
+    id accessibilityFocusedUIElement();
+    bool accessibilityIsIgnored() const { return false; }
+    id accessibilityHitTest(CGPoint);
+    void enableAccessibilityIfNecessary();
+    id accessibilityAttributeValue(NSString *);
 
+    NSTrackingArea *primaryTrackingArea() const { return m_primaryTrackingArea.get(); }
+    void setPrimaryTrackingArea(NSTrackingArea *);
+
     NSTrackingRectTag addTrackingRect(CGRect, id owner, void* userData, bool assumeInside);
     NSTrackingRectTag addTrackingRectWithTrackingNum(CGRect, id owner, void* userData, bool assumeInside, int tag);
     void addTrackingRectsWithTrackingNums(CGRect*, id owner, void** userDataList, bool assumeInside, NSTrackingRectTag *trackingNums, int count);
     void removeTrackingRect(NSTrackingRectTag);
     void removeTrackingRects(NSTrackingRectTag *, int count);
     NSString *stringForToolTip(NSToolTipTag tag);
-    void toolTipChanged(NSString *oldToolTip, NSString *newToolTip);
+    void toolTipChanged(const String& oldToolTip, const String& newToolTip);
 
     void setAcceleratedCompositingRootLayer(CALayer *);
     CALayer *acceleratedCompositingRootLayer() const { return m_rootLayer.get(); }
@@ -368,6 +379,8 @@
     bool m_allowsLinkPreview { true };
     bool m_didRegisterForLookupPopoverCloseNotifications { false };
 
+    RetainPtr<NSTrackingArea> m_primaryTrackingArea;
+
     NSToolTipTag m_lastToolTipTag { 0 };
     id m_trackingRectOwner { nil };
     void* m_trackingRectUserData { nullptr };
@@ -382,6 +395,8 @@
     std::unique_ptr<ViewGestureController> m_gestureController;
     bool m_allowsBackForwardNavigationGestures { false };
     bool m_allowsMagnification { false };
+
+    RetainPtr<id> m_remoteAccessibilityChild;
 };
     
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (191636 => 191637)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2015-10-27 20:55:36 UTC (rev 191637)
@@ -321,6 +321,17 @@
 
 namespace WebKit {
 
+static NSTrackingAreaOptions trackingAreaOptions()
+{
+    // Legacy style scrollbars have design details that rely on tracking the mouse all the time.
+    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingCursorUpdate;
+    if (WKRecommendedScrollerStyle() == NSScrollerStyleLegacy)
+        options |= NSTrackingActiveAlways;
+    else
+        options |= NSTrackingActiveInKeyWindow;
+    return options;
+}
+
 WebViewImpl::WebViewImpl(NSView <WebViewImplDelegate> *view, WebPageProxy& page, PageClient& pageClient)
     : m_view(view)
     , m_page(page)
@@ -331,7 +342,10 @@
     , m_layoutStrategy([WKViewLayoutStrategy layoutStrategyWithPage:m_page view:m_view viewImpl:*this mode:kWKLayoutModeViewSize])
     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
     , m_windowVisibilityObserver(adoptNS([[WKWindowVisibilityObserver alloc] initWithView:view impl:*this]))
+    , m_primaryTrackingArea(adoptNS([[NSTrackingArea alloc] initWithRect:m_view.frame options:trackingAreaOptions() owner:m_view userInfo:nil]))
 {
+    [m_view addTrackingArea:m_primaryTrackingArea.get()];
+
     m_page.setIntrinsicDeviceScaleFactor(intrinsicDeviceScaleFactor());
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
@@ -1464,6 +1478,28 @@
     m_ignoresMouseDraggedEvents = ignoresMouseDraggedEvents;
 }
 
+void WebViewImpl::setAccessibilityWebProcessToken(NSData *data)
+{
+    m_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
+    updateRemoteAccessibilityRegistration(true);
+}
+
+void WebViewImpl::updateRemoteAccessibilityRegistration(bool registerProcess)
+{
+    // When the tree is connected/disconnected, the remote accessibility registration
+    // needs to be updated with the pid of the remote process. If the process is going
+    // away, that information is not present in WebProcess
+    pid_t pid = 0;
+    if (registerProcess)
+        pid = m_page.process().processIdentifier();
+    else if (!registerProcess) {
+        pid = WKAXRemoteProcessIdentifier(m_remoteAccessibilityChild.get());
+        m_remoteAccessibilityChild = nil;
+    }
+    if (pid)
+        WKAXRegisterRemoteProcess(registerProcess, pid);
+}
+
 void WebViewImpl::accessibilityRegisterUIProcessTokens()
 {
     // Initialize remote accessibility when the window connection has been established.
@@ -1474,6 +1510,61 @@
     m_page.registerUIProcessAccessibilityTokens(elementToken, windowToken);
 }
 
+id WebViewImpl::accessibilityFocusedUIElement()
+{
+    enableAccessibilityIfNecessary();
+    return m_remoteAccessibilityChild.get();
+}
+
+id WebViewImpl::accessibilityHitTest(CGPoint)
+{
+    return accessibilityFocusedUIElement();
+}
+
+void WebViewImpl::enableAccessibilityIfNecessary()
+{
+    if (WebCore::AXObjectCache::accessibilityEnabled())
+        return;
+
+    // After enabling accessibility update the window frame on the web process so that the
+    // correct accessibility position is transmitted (when AX is off, that position is not calculated).
+    WebCore::AXObjectCache::enableAccessibility();
+    updateWindowAndViewFrames();
+}
+
+id WebViewImpl::accessibilityAttributeValue(NSString *attribute)
+{
+    enableAccessibilityIfNecessary();
+
+    if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
+
+        id child = nil;
+        if (m_remoteAccessibilityChild)
+            child = m_remoteAccessibilityChild.get();
+
+            if (!child)
+                return nil;
+        return [NSArray arrayWithObject:child];
+    }
+    if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
+        return NSAccessibilityGroupRole;
+    if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute])
+        return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil);
+        if ([attribute isEqualToString:NSAccessibilityParentAttribute])
+            return NSAccessibilityUnignoredAncestor([m_view superview]);
+            if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
+                return @YES;
+    
+    return [m_view _superAccessibilityAttributeValue:attribute];
+}
+
+void WebViewImpl::setPrimaryTrackingArea(NSTrackingArea *trackingArea)
+{
+    [m_view removeTrackingArea:m_primaryTrackingArea.get()];
+    m_primaryTrackingArea = trackingArea;
+    [m_view addTrackingArea:trackingArea];
+}
+
 // Any non-zero value will do, but using something recognizable might help us debug some day.
 #define TRACKING_RECT_TAG 0xBADFACE
 
@@ -1571,12 +1662,12 @@
     return nsStringFromWebCoreString(m_page.toolTip());
 }
 
-void WebViewImpl::toolTipChanged(NSString *oldToolTip, NSString *newToolTip)
+void WebViewImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
 {
-    if (oldToolTip)
+    if (!oldToolTip.isNull())
         sendToolTipMouseExited();
     
-    if (newToolTip && [newToolTip length] > 0) {
+    if (!newToolTip.isEmpty()) {
         // See radar 3500217 for why we remove all tooltips rather than just the single one we created.
         [m_view removeAllToolTips];
         NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000);

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (191636 => 191637)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-10-27 20:41:34 UTC (rev 191636)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-10-27 20:55:36 UTC (rev 191637)
@@ -264,7 +264,7 @@
 
 void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
 {
-    [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
+    m_impl->toolTipChanged(oldToolTip, newToolTip);
 }
 
 void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
@@ -474,8 +474,7 @@
 
 void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
 {
-    NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
-    [m_wkView _setAccessibilityWebProcessToken:remoteToken];
+    m_impl->setAccessibilityWebProcessToken([NSData dataWithBytes:data.data() length:data.size()]);
 }
     
 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
@@ -601,7 +600,7 @@
         options |= NSTrackingActiveInKeyWindow;
 
     RetainPtr<NSTrackingArea> trackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:[m_wkView frame] options:options owner:m_wkView userInfo:nil]);
-    [m_wkView _setPrimaryTrackingArea:trackingArea.get()];
+    m_impl->setPrimaryTrackingArea(trackingArea.get());
 }
 
 void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
@@ -658,36 +657,36 @@
 
 void PageClientImpl::closeFullScreenManager()
 {
-    [m_wkView _closeFullScreenWindowController];
+    m_impl->closeFullScreenWindowController();
 }
 
 bool PageClientImpl::isFullScreen()
 {
-    if (!m_wkView._hasFullScreenWindowController)
+    if (!m_impl->hasFullScreenWindowController())
         return false;
 
-    return m_wkView._fullScreenWindowController.isFullScreen;
+    return m_impl->fullScreenWindowController().isFullScreen;
 }
 
 void PageClientImpl::enterFullScreen()
 {
-    [m_wkView._fullScreenWindowController enterFullScreen:nil];
+    [m_impl->fullScreenWindowController() enterFullScreen:nil];
 }
 
 void PageClientImpl::exitFullScreen()
 {
-    [m_wkView._fullScreenWindowController exitFullScreen];
+    [m_impl->fullScreenWindowController() exitFullScreen];
 }
 
 void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
 {
-    [m_wkView._fullScreenWindowController beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
+    [m_impl->fullScreenWindowController() beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
     m_impl->updateSupportsArbitraryLayoutModes();
 }
 
 void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
 {
-    [m_wkView._fullScreenWindowController beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
+    [m_impl->fullScreenWindowController() beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
     m_impl->updateSupportsArbitraryLayoutModes();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to