Skip to content

Commit

Permalink
MSHTML vbufBackend: if the language cannot be found out from the curr…
Browse files Browse the repository at this point in the history
…ent DOM node, and our buffer does not have any parents above this node, then go up the DOM node's parents looking for a valid lang attribute. This makes sure that NVDa notices the language for a document in MSHTML when its placed as an attribute on the HTML tag, or if its placed on a tag marked as an application or dialog ARIA role but there is an embedded document. Fixes #1782.
  • Loading branch information
michaelDCurran committed Sep 13, 2011
1 parent 50cc67e commit 86e0d2b
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions nvdaHelper/vbufBackends/mshtml/mshtml.cpp
Expand Up @@ -737,16 +737,33 @@ VBufStorage_fieldNode_t* MshtmlVBufBackend_t::fillVBuf(VBufStorage_buffer_t* buf

//Find out the language
wstring language=L"";
IHTMLElement* pHTMLElement=NULL;
if(pHTMLDOMNode->QueryInterface(IID_IHTMLElement,(void**)&pHTMLElement)==S_OK) {
VARIANT v;
if(pHTMLElement->getAttribute(L"lang",2,&v)==S_OK) {
if(v.vt==VT_BSTR&&v.bstrVal) {
language=v.bstrVal;
//Try getting it from this DOMNode,
//Else if this is the root of our buffer, then keep going up the actual DOM
//E.g. will hit HTML tag etc
IHTMLDOMNode* pHTMLDOMNodeTemp=pHTMLDOMNode;
pHTMLDOMNodeTemp->AddRef();
while(pHTMLDOMNodeTemp) {
IHTMLElement* pHTMLElement=NULL;
if(pHTMLDOMNodeTemp->QueryInterface(IID_IHTMLElement,(void**)&pHTMLElement)==S_OK&&pHTMLElement) {
VARIANT v;
if(pHTMLElement->getAttribute(L"lang",2,&v)==S_OK) {
if(v.vt==VT_BSTR&&v.bstrVal) {
language=v.bstrVal;
}
VariantClear(&v);
}
pHTMLElement->Release();
}
if(!parentNode&&language.empty()) {
IHTMLDOMNode* pHTMLDOMNodeTempParent=NULL;
if(pHTMLDOMNodeTemp->get_parentNode(&pHTMLDOMNodeTempParent)==S_OK&&pHTMLDOMNodeTempParent) {
pHTMLDOMNodeTemp->Release();
pHTMLDOMNodeTemp=pHTMLDOMNodeTempParent;
continue;
}
VariantClear(&v);
}
pHTMLElement->Release();
pHTMLDOMNodeTemp->Release();
pHTMLDOMNodeTemp=NULL;
}
if(parentNode&&language.empty()) {
language=static_cast<MshtmlVBufStorage_controlFieldNode_t*>(parentNode)->language;
Expand Down

0 comments on commit 86e0d2b

Please sign in to comment.