Patch by Chris Fleizach <cfleizach@apple.com> on 2011-02-13
AX: Update WK2 usage of remote accessibility api
https://bugs.webkit.org/show_bug.cgi?id=54220
Rename some of the remote accessibility methods to be more accurate.
Make sure to unregister the AccessibilityWebPageObject on dealloc.
Send the window remote token along with the WKView remote token.
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::accessibilityWebProcessTokenReceived):
* UIProcess/API/mac/WKView.mm:
(-[WKView _updateRemoteAccessibilityRegistration:]):
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView viewDidMoveToWindow]):
(-[WKView _processDidCrash]):
(-[WKView _pageClosed]):
(-[WKView _setAccessibilityWebProcessToken:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::registerWebProcessAccessibilityToken):
(WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/AccessibilityWebPageObject.mm:
(-[AccessibilityWebPageObject dealloc]):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformInitialize):
(WebKit::WebPage::registerUIProcessAccessibilityTokens):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@78429
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-13 Chris Fleizach <cfleizach@apple.com>
+
+ Reviewed and landed by Sam Weinig.
+
+ AX: Update WK2 usage of remote accessibility api
+ https://bugs.webkit.org/show_bug.cgi?id=54220
+
+ Rename some of the remote accessibility methods to be more accurate.
+ Make sure to unregister the AccessibilityWebPageObject on dealloc.
+ Send the window remote token along with the WKView remote token.
+
+ * UIProcess/API/mac/PageClientImpl.h:
+ * UIProcess/API/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::accessibilityWebProcessTokenReceived):
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _updateRemoteAccessibilityRegistration:]):
+ (-[WKView initWithFrame:contextRef:pageGroupRef:]):
+ (-[WKView viewDidMoveToWindow]):
+ (-[WKView _processDidCrash]):
+ (-[WKView _pageClosed]):
+ (-[WKView _setAccessibilityWebProcessToken:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::registerWebProcessAccessibilityToken):
+ (WebKit::WebPageProxy::registerUIProcessAccessibilityTokens):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/mac/AccessibilityWebPageObject.mm:
+ (-[AccessibilityWebPageObject dealloc]):
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::platformInitialize):
+ (WebKit::WebPage::registerUIProcessAccessibilityTokens):
+
2011-02-11 Alexey Proskuryakov <ap@apple.com>
Reviewed by Anders Carlsson.
virtual void pageDidLeaveAcceleratedCompositing();
#endif
- virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&);
+ virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&);
virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
virtual void setAutodisplay(bool);
[m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut];
}
-void PageClientImpl::accessibilityChildTokenReceived(const CoreIPC::DataReference& data)
+void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data)
{
NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
- [m_wkView _setAccessibilityChildToken:remoteToken];
+ [m_wkView _setAccessibilityWebProcessToken:remoteToken];
}
#if USE(ACCELERATED_COMPOSITING)
[types release];
}
+- (void)_updateRemoteAccessibilityRegistration:(BOOL)registerProcess
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // 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 && _data->_page->process())
+ pid = _data->_page->process()->processIdentifier();
+ else if (!registerProcess) {
+ pid = WKAXRemoteProcessIdentifier(_data->_remoteAccessibilityChild.get());
+ _data->_remoteAccessibilityChild = nil;
+ }
+ if (pid)
+ WKAXRegisterRemoteProcess(registerProcess, pid);
+#endif
+}
+
- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
{
self = [super initWithFrame:frame];
WebContext::statistics().wkViewCount++;
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
- NSData *remoteToken = (NSData *)WKAXRemoteTokenForElement(self);
- CoreIPC::DataReference dataToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteToken bytes]), [remoteToken length]);
- _data->_page->sendAccessibilityPresenterToken(dataToken);
-#endif
-
return self;
}
return YES;
}
-- (void)_setRemoteAccessibilityWindow:(id)window
-{
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
- WKAXInitializeRemoteElementWithWindow(_data->_remoteAccessibilityChild.get(), window);
-#endif
-}
-
- (void)setFrame:(NSRect)rect andScrollBy:(NSSize)offset
{
ASSERT(NSEqualSizes(_data->_resizeScrollOffset, NSZeroSize));
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible | WebPageProxy::ViewIsInWindow);
[self _updateWindowVisibility];
[self _updateWindowAndViewFrames];
+
+ // Initialize remote accessibility when the window connection has been established.
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSData *remoteElementToken = WKAXRemoteTokenForElement(self);
+ NSData *remoteWindowToken = WKAXRemoteTokenForElement([self window]);
+ CoreIPC::DataReference elementToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteElementToken bytes]), [remoteElementToken length]);
+ CoreIPC::DataReference windowToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteWindowToken bytes]), [remoteWindowToken length]);
+ _data->_page->registerUIProcessAccessibilityTokens(elementToken, windowToken);
+#endif
+
} else {
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
_data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow);
}
#endif
}
- [self _setRemoteAccessibilityWindow:[self window]];
}
- (void)_windowDidBecomeKey:(NSNotification *)notification
- (void)_processDidCrash
{
[self setNeedsDisplay:YES];
- [self _setRemoteAccessibilityWindow:nil];
+ [self _updateRemoteAccessibilityRegistration:NO];
}
- (void)_pageClosed
{
- // When the page closes, the references the accessibility child has to the window
- // need to be removed, otherwise it can leak.
- [self _setRemoteAccessibilityWindow:nil];
+ [self _updateRemoteAccessibilityRegistration:NO];
}
- (void)_didRelaunchProcess
}
#endif // USE(ACCELERATED_COMPOSITING)
-- (void)_setAccessibilityChildToken:(NSData *)data
+- (void)_setAccessibilityWebProcessToken:(NSData *)data
{
#if !defined(BUILDING_ON_SNOW_LEOPARD)
- _data->_remoteAccessibilityChild = WKAXRemoteElementForToken((CFDataRef)data);
- [self _setRemoteAccessibilityWindow:[self window]];
+ _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
+ [self _updateRemoteAccessibilityRegistration:YES];
#endif
}
- (void)_pageDidLeaveAcceleratedCompositing;
#endif
-- (void)_setAccessibilityChildToken:(NSData *)data;
+- (void)_setAccessibilityWebProcessToken:(NSData *)data;
- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation;
virtual void clearAllEditCommands() = 0;
virtual void setEditCommandState(const String& commandName, bool isEnabled, int state) = 0;
#if PLATFORM(MAC)
- virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&) = 0;
+ virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0;
virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
#endif
m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
}
-void WebPageProxy::didReceiveAccessibilityPageToken(const CoreIPC::DataReference& data)
-{
-#if PLATFORM(MAC)
- m_pageClient->accessibilityChildTokenReceived(data);
-#endif
-}
-
void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
{
WebFrameProxy* frame = process()->webFrame(frameID);
}
#if PLATFORM(MAC)
-void WebPageProxy::sendAccessibilityPresenterToken(const CoreIPC::DataReference& token)
+
+void WebPageProxy::registerWebProcessAccessibilityToken(const CoreIPC::DataReference& data)
+{
+ m_pageClient->accessibilityWebProcessTokenReceived(data);
+}
+
+void WebPageProxy::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken)
{
if (!isValid())
return;
- process()->send(Messages::WebPage::SendAccessibilityPresenterToken(token), m_pageID);
+ process()->send(Messages::WebPage::RegisterUIProcessAccessibilityTokens(elementToken, windowToken), m_pageID);
}
#endif
bool hasVerticalScrollbar() const { return m_mainFrameHasVerticalScrollbar; }
#if PLATFORM(MAC)
- void sendAccessibilityPresenterToken(const CoreIPC::DataReference&);
+ // Called by the web process through a message.
+ void registerWebProcessAccessibilityToken(const CoreIPC::DataReference&);
+ // Called by the UI process when it is ready to send its tokens to the web process.
+ void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
#endif
void viewScaleFactorDidChange(double);
void didStartProgress();
void didChangeProgress(double);
void didFinishProgress();
- void didReceiveAccessibilityPageToken(const CoreIPC::DataReference&);
void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder*, bool& receivedPolicyAction, uint64_t& policyAction);
void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
StringCallback(WTF::String resultString, uint64_t callbackID)
ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
- DidReceiveAccessibilityPageToken(CoreIPC::DataReference data)
ViewScaleFactorDidChange(double scaleFactor)
#if PLATFORM(MAC)
# Keyboard support messages
InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines)
+
+ # Remote accessibility messages
+ RegisterWebProcessAccessibilityToken(CoreIPC::DataReference data)
#endif
# BackForward messages
static void getLocationAndLengthFromRange(WebCore::Range*, uint64_t& location, uint64_t& length);
#if PLATFORM(MAC)
- void sendAccessibilityPresenterToken(const CoreIPC::DataReference&);
+ void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
AccessibilityWebPageObject* accessibilityRemoteObject();
WebCore::IntPoint accessibilityPosition() const { return m_accessibilityPosition; }
GetMarkedRange() -> (uint64_t location, uint64_t length)
CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result)
FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect)
- SendAccessibilityPresenterToken(CoreIPC::DataReference token)
+ RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken)
#endif
#if PLATFORM(WIN)
ConfirmComposition(WTF::String compositionString)
#import <WebCore/FrameView.h>
#import <WebCore/ScrollView.h>
#import <WebCore/Scrollbar.h>
+#import <WebKitSystemInterface.h>
using namespace WebCore;
using namespace WebKit;
- (void)dealloc
{
+ WKUnregisterUniqueIdForElement(self);
[m_accessibilityChildren release];
[m_attributeNames release];
[m_parent release];
// send data back over
NSData* remoteToken = (NSData *)WKAXRemoteTokenForElement(mockAccessibilityElement);
CoreIPC::DataReference dataToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteToken bytes]), [remoteToken length]);
- send(Messages::WebPageProxy::DidReceiveAccessibilityPageToken(dataToken));
+ send(Messages::WebPageProxy::RegisterWebProcessAccessibilityToken(dataToken));
m_mockAccessibilityElement = mockAccessibilityElement;
#endif
}
return true;
}
-void WebPage::sendAccessibilityPresenterToken(const CoreIPC::DataReference& data)
+void WebPage::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken)
{
#if !defined(BUILDING_ON_SNOW_LEOPARD)
- NSData* tokenData = [NSData dataWithBytes:data.data() length:data.size()];
- [m_mockAccessibilityElement.get() setRemoteParent:WKAXRemoteElementForToken((CFDataRef)tokenData)];
+ NSData* elementTokenData = [NSData dataWithBytes:elementToken.data() length:elementToken.size()];
+ NSData* windowTokenData = [NSData dataWithBytes:windowToken.data() length:windowToken.size()];
+ id remoteElement = WKAXRemoteElementForToken(elementTokenData);
+ id remoteWindow = WKAXRemoteElementForToken(windowTokenData);
+ WKAXSetWindowForRemoteElement(remoteWindow, remoteElement);
+
+ [accessibilityRemoteObject() setRemoteParent:remoteElement];
#endif
}