Skip to content

Commit

Permalink
Clean up Mozilla specific code (#11120)
Browse files Browse the repository at this point in the history
* Don't fetch NODE_CHILD_OF when fetching parent, since this is no longer needed (or useful) for combo boxes.

* Get rid of mozilla.RootApplication, since this object is no longer reachable without NODE_CHILD_OF.

* accParent is broken in Firefox for same-process iframe documents, so we must still use NODE_CHILD_OF for Documents (but nowhere else).

* Gecko now prunes aria-hidden objects from the tree, so the hidden attribute is no longer used.

* NVDA core: Drop code specific to supporting very old versions of Gecko.

* Gecko vbuf backend: Drop code specific to supporting very old versions of Gecko.

* Gecko always sets the focused state correctly now, so drop BrokenFocusedState code.

* Remove unnecessary imports.

* We only allow show/hide/reorder events for specific cases anyway, so the code to ignore these events for the Firefox location bar is redundant.

* Firefox hasn't had a status bar for a long time, so the Firefox app module does nothing. Remove it.
  • Loading branch information
jcsteh committed Aug 3, 2020
1 parent 7e4c288 commit bde1978
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 254 deletions.
66 changes: 3 additions & 63 deletions nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp
Expand Up @@ -63,29 +63,8 @@ CComPtr<IAccessible2> GeckoVBufBackend_t::getLabelElement(IAccessible2_2* elemen
return CComQIPtr<IAccessible2>(ppUnk_smart[0]);
}

#define NAVRELATION_LABELLED_BY 0x1003
const wchar_t EMBEDDED_OBJ_CHAR = 0xFFFC;

HWND findRealMozillaWindow(HWND hwnd) {
if(hwnd==0||!IsWindow(hwnd))
return (HWND)0;

wchar_t className[256];
bool foundWindow=false;
HWND tempWindow=hwnd;
do {
if(GetClassName(tempWindow,className,256)==0)
return hwnd;
if(wcscmp(L"MozillaWindowClass",className)!=0)
foundWindow=true;
else
tempWindow=GetAncestor(tempWindow,GA_PARENT);
} while(tempWindow&&!foundWindow);
if(GetClassName(tempWindow,className,256)!=0&&wcsstr(className,L"Mozilla")==className)
hwnd=tempWindow;
return hwnd;
}

static IAccessible2* IAccessible2FromIdentifier(int docHandle, int ID) {
IAccessible* pacc=NULL;
IServiceProvider* pserv=NULL;
Expand Down Expand Up @@ -187,7 +166,7 @@ inline void fillTableHeaders(VBufStorage_controlFieldNode_t* node, IAccessibleTa
headerCellPacc->Release();
continue;
}
const int headerCellDocHandle = HandleToUlong(findRealMozillaWindow(hwnd));
const int headerCellDocHandle = HandleToUlong(hwnd);
int headerCellID;
if (headerCellPacc->get_uniqueID((long*)&headerCellID) != S_OK) {
headerCellPacc->Release();
Expand Down Expand Up @@ -226,18 +205,11 @@ inline void GeckoVBufBackend_t::fillTableCellInfo_IATable2(VBufStorage_controlFi
}
}

if (this->shouldDisableTableHeaders)
return;

fillTableHeaders(node, paccTableCell, &IAccessibleTableCell::get_columnHeaderCells, L"table-columnheadercells");
fillTableHeaders(node, paccTableCell, &IAccessibleTableCell::get_rowHeaderCells, L"table-rowheadercells");
}

void GeckoVBufBackend_t::versionSpecificInit(IAccessible2* pacc) {
// Defaults.
this->shouldDisableTableHeaders = false;
this->hasEncodedAccDescription = false;

IServiceProvider* serv = NULL;
if (pacc->QueryInterface(IID_IServiceProvider, (void**)&serv) != S_OK)
return;
Expand All @@ -256,35 +228,8 @@ void GeckoVBufBackend_t::versionSpecificInit(IAccessible2* pacc) {
if(toolkitName) {
this->toolkitName = std::wstring(toolkitName, SysStringLen(toolkitName));
}
BSTR toolkitVersion = NULL;
if (iaApp->get_toolkitVersion(&toolkitVersion) != S_OK) {
iaApp->Release();
SysFreeString(toolkitName);
return;
}
iaApp->Release();
iaApp = NULL;

if (wcscmp(toolkitName, L"Gecko") == 0) {
if (wcsncmp(toolkitVersion, L"1.", 2) == 0) {
if (wcsncmp(toolkitVersion, L"1.9.2.", 6) == 0) {
// Gecko 1.9.2.x.
// Retrieve the digits for the final part of the main version number.
wstring verPart;
for (wchar_t* c = &toolkitVersion[6]; iswdigit(*c); c++)
verPart += *c;
if (_wtoi(verPart.c_str()) <= 10) {
// Gecko <= 1.9.2.10 will crash if we try to retrieve headers on some table cells, so disable them.
this->shouldDisableTableHeaders = true;
}
}
// Gecko 1.x uses accDescription to encode position info as well as the description.
this->hasEncodedAccDescription = true;
}
}

SysFreeString(toolkitName);
SysFreeString(toolkitVersion);
}

optional<int>
Expand Down Expand Up @@ -442,7 +387,7 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf(
LOG_DEBUG(L"pacc->get_windowHandle failed");
return NULL;
}
const int docHandle=HandleToUlong(findRealMozillaWindow(docHwnd));
const int docHandle=HandleToUlong(docHwnd);
if(!docHandle) {
LOG_DEBUG(L"bad docHandle");
return NULL;
Expand Down Expand Up @@ -596,11 +541,7 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf(
wstring description;
BSTR rawDesc=NULL;
if(pacc->get_accDescription(varChild,&rawDesc)==S_OK) {
if(this->hasEncodedAccDescription) {
if(wcsncmp(rawDesc,L"Description: ",13)==0)
description=&rawDesc[13];
} else
description=rawDesc;
description=rawDesc;
parentNode->addAttribute(L"description",description);
SysFreeString(rawDesc);
}
Expand Down Expand Up @@ -1208,7 +1149,6 @@ void CALLBACK GeckoVBufBackend_t::renderThread_winEventProcHook(HWINEVENTHOOK ho
if(childID>=0||objectID!=OBJID_CLIENT)
return;
LOG_DEBUG(L"winEvent for window "<<hwnd);
hwnd=findRealMozillaWindow(hwnd);
if(!hwnd) {
LOG_DEBUG(L"Invalid window");
return;
Expand Down
2 changes: 0 additions & 2 deletions nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.h
Expand Up @@ -38,8 +38,6 @@ class GeckoVBufBackend_t: public VBufBackend_t {

void fillTableCellInfo_IATable2(VBufStorage_controlFieldNode_t* node, IAccessibleTableCell* paccTableCell);

bool shouldDisableTableHeaders;
bool hasEncodedAccDescription;
std::wstring toolkitName;

std::optional< LabelInfo > getLabelInfo(IAccessible2* pacc2);
Expand Down
25 changes: 0 additions & 25 deletions source/IAccessibleHandler/internalWinEventHandler.py
Expand Up @@ -96,17 +96,6 @@ def winEventCallback(handle, eventID, window, objectID, childID, threadID, times
elif not isWindow:
return

if childID < 0:
tempWindow = window
while (
tempWindow
and not winUser.getWindowStyle(tempWindow) & winUser.WS_POPUP
and winUser.getClassName(tempWindow) == "MozillaWindowClass"
):
tempWindow = winUser.getAncestor(tempWindow, winUser.GA_PARENT)
if tempWindow and winUser.getClassName(tempWindow).startswith('Mozilla'):
window = tempWindow

windowClassName = winUser.getClassName(window)
if windowClassName == "ConsoleWindowClass":
# #10113: we need to use winEvents to track the real thread for console windows.
Expand All @@ -116,20 +105,6 @@ def winEventCallback(handle, eventID, window, objectID, childID, threadID, times
# and can't be used properly in conjunction with input composition support.
if windowClassName == "Microsoft.IME.UIManager.CandidateWindow.Host" and eventID in MENU_EVENTIDS:
return
# At the moment we can't handle show or hide events on Mozilla Firefox Location bar,
# as there are just too many of them. Ignore show and hide on MozillaDropShadowWindowClass
# windows.
if (
windowClassName.startswith('Mozilla')
and eventID in (
winUser.EVENT_OBJECT_SHOW,
winUser.EVENT_OBJECT_HIDE
) and childID < 0
):
# Mozilla Gecko can sometimes fire win events on a catch-all window which isn't really the real window
# Move up the ancestry to find the real mozilla Window and use that
if winUser.getClassName(window) == 'MozillaDropShadowWindowClass':
return
if eventID == winUser.EVENT_SYSTEM_FOREGROUND:
# We never want to see foreground events for the Program Manager or Shell (task bar)
if windowClassName in ("Progman", "Shell_TrayWnd"):
Expand Down
6 changes: 0 additions & 6 deletions source/NVDAObjects/IAccessible/__init__.py
Expand Up @@ -603,12 +603,6 @@ def __init__(self,windowHandle=None,IAccessibleObject=None,IAccessibleChildID=No
# Try every trick in the book to get the window handle if we don't have it.
if not windowHandle and isinstance(IAccessibleObject,IAccessibleHandler.IAccessible2):
windowHandle=self.IA2WindowHandle
#Mozilla Gecko: we can never use a MozillaWindowClass window for Gecko 1.9
tempWindow=windowHandle
while tempWindow and winUser.getClassName(tempWindow)=="MozillaWindowClass":
tempWindow=winUser.getAncestor(tempWindow,winUser.GA_PARENT)
if tempWindow and winUser.getClassName(tempWindow).startswith('Mozilla'):
windowHandle=tempWindow
try:
Identity=IAccessibleHandler.getIAccIdentity(IAccessibleObject,IAccessibleChildID)
except COMError:
Expand Down

0 comments on commit bde1978

Please sign in to comment.