Skip to content

Commit

Permalink
Gecko vbufBackend: implement a replacement AccessibleObjectFromEvent …
Browse files Browse the repository at this point in the history
…that actually works when called from within a 64 bit process. Technically, AccessibleObjectFromWindow is the actual function with the bug, though AccessibleObjectFromEvent calls it.

The new AccessibleObjectFromEvent_fixed only uses custom code where absolutely necessary. It in fact is a macro that only on 64 bit is defined as the custom function, otherwise its just AccessibleObjectFromEvent. Plus, the custom function only does the custom code if the current thread and the thread for the window are the same, otherwise it calls the original AccessibleObjectFromEvent.
The custom code just does the standard wm_getobject, ObjectFromLResult, tries accChild. Pretty much exactly what its clear AccessibleObjectFromEvent/AccessibleObjectFromWindow does. I have no idea why AccessibleObjectFromWindow fails.
In short all this means that virtualBuffers are no longer blank in 64 bit builds of Mozilla Gecko applications.
Fixes #1454.
  • Loading branch information
michaelDCurran committed Jun 17, 2011
1 parent 8f7a77d commit d1fac5b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 39 additions & 1 deletion nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp
Expand Up @@ -31,6 +31,41 @@ using namespace std;

#define NAVRELATION_NODE_CHILD_OF 0x1005

//An implementation of AccessibleObjectFromEvent that works for a window in the same thread, when in a 64 bit process
//Technically AccessibleObjectFromWindow seems to be the broken function
HRESULT _AccessibleObjectFromEvent_fixed(HWND hwnd, long objectID, long childID, IAccessible** pacc, VARIANT* varChild) {
if(GetWindowThreadProcessId(hwnd,NULL)!=GetCurrentThreadId()) {
return AccessibleObjectFromEvent(hwnd,objectID,childID,pacc,varChild);
}
//SendMessage is fine as we are in the same thread as the window
LRESULT l=SendMessage(hwnd,WM_GETOBJECT,0,objectID);
if(l==0) {
return E_FAIL;
}
if(ObjectFromLresult(l,IID_IAccessible,0,(void**)pacc)!=S_OK) {
return E_FAIL;
}
(*varChild).vt=VT_I4;
(*varChild).lVal=childID;
IDispatch* childDisp=NULL;
if((*pacc)->get_accChild(*varChild,&childDisp)==S_OK) {
IAccessible* childPacc=NULL;
if(childDisp->QueryInterface(IID_IAccessible,(void**)&childPacc)==S_OK) {
(*pacc)->Release();
*pacc=childPacc;
(*varChild).lVal=0;
}
childDisp->Release();
}
return S_OK;
}

#ifdef _WIN64
#define AccessibleObjectFromEvent_fixed _AccessibleObjectFromEvent_fixed
#else
#define AccessibleObjectFromEvent_fixed AccessibleObjectFromEvent
#endif

HWND findRealMozillaWindow(HWND hwnd) {
LOG_DEBUG(L"Finding real window for window "<<hwnd);
if(hwnd==0||!IsWindow(hwnd)) {
Expand Down Expand Up @@ -66,7 +101,7 @@ IAccessible2* IAccessible2FromIdentifier(int docHandle, int ID) {
IAccessible2* pacc2=NULL;
VARIANT varChild;
LOG_DEBUG(L"calling AccessibleObjectFromEvent");
if((res=AccessibleObjectFromEvent((HWND)docHandle,OBJID_CLIENT,ID,&pacc,&varChild))!=S_OK) {
if((res=AccessibleObjectFromEvent_fixed((HWND)docHandle,OBJID_CLIENT,ID,&pacc,&varChild))!=S_OK) {
LOG_DEBUG(L"AccessibleObjectFromEvent returned "<<res);
return NULL;
}
Expand Down Expand Up @@ -937,6 +972,9 @@ void CALLBACK GeckoVBufBackend_t::renderThread_winEventProcHook(HWINEVENTHOOK ho
if(childID>=0||objectID!=OBJID_CLIENT) {
return;
}
if(eventID==EVENT_OBJECT_FOCUS) {
LOG_INFO(L"focus event: hwnd "<<hwnd<<L", objectID "<<objectID<<L", childID "<<childID);
}
LOG_DEBUG(L"winEvent for window "<<hwnd);
hwnd=findRealMozillaWindow(hwnd);
if(hwnd==0) {
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Expand Up @@ -96,6 +96,7 @@ Highlights of this release include major improvements concerning punctuation and
- NVDA no longer becomes worse at guessing color names the more colors it announces.
- In Internet Explorer and other MSHTML controls, fixed the inability to read parts of rare pages which contain iframes marked with an ARIA role of presentation. (#1569)
- In Internet Explorer and other MSHTML controls, fixed a rare problem where the focus kept bouncing infinitely between the document and a multi-line editable text field in focus mode. (#1566)
- Browse mode Documents no longer appear blank in 64 bit Mozilla Gecko applications. (#1454)


== Changes for Developers ==
Expand Down

0 comments on commit d1fac5b

Please sign in to comment.