NVDA Helper
In-process and lite high-speed utilities for NVDA
mshtml.cpp File Reference
#include <map>
#include <algorithm>
#include <windows.h>
#include <oleacc.h>
#include <oleidl.h>
#include <atlcomcli.h>
#include <mshtml.h>
#include <set>
#include <string>
#include <sstream>
#include <vbufBase/backend.h>
#include <vbufBase/utils.h>
#include <remote/dllmain.h>
#include <common/log.h>
#include "node.h"

Go to the source code of this file.

Macros

#define macro_addHTMLCurrentStyleToNodeAttrs(styleName, attrName, node, currentStyleObj, tempBSTR)
 
#define macro_addHTMLCurrentStyleToNodeAttrs_var(styleName, attrName, node, currentStyleObj, tempVar)
 
#define macro_addHTMLAttributeToMap(attribName, allowEmpty, attribsObj, attribsMap, tempVar, tempAttrObj)
 

Functions

void incBackendLibRefCount ()
 
void decBackendLibRefCount ()
 
template<typename toInterface >
HRESULT queryService (IUnknown *pUnknown, const IID &siid, toInterface **pIface)
 A utility template function to queryService from a given IUnknown to the given service with the given service ID and interface eing returned.
 
void getIAccessibleInfo (IAccessible *pacc, wstring *name, int *role, wstring *value, int *states, wstring *description, wstring *keyboardShortcut)
 
template<typename toInterface >
HRESULT getHTMLSubdocumentBodyFromIAccessibleFrame (IAccessible *pacc, toInterface **pIface)
 
IHTMLElement * LocateHTMLElementInDocument (IHTMLDocument3 *pHTMLDocument3, const wstring &ID)
 
int getIDFromHTMLDOMNode (IHTMLDOMNode *pHTMLDOMNode)
 
wstring getTextFromHTMLDOMNode (IHTMLDOMNode *pHTMLDOMNode, bool allowPreformattedText, bool isStartOfBlock)
 
void getCurrentStyleInfoFromHTMLDOMNode (IHTMLDOMNode *pHTMLDOMNode, bool &dontRender, bool &isBlock, bool &hidden, wstring &listStyle)
 
void getAttributesFromHTMLDOMNode (IHTMLDOMNode *pHTMLDOMNode, wstring &nodeName, map< wstring, wstring > &attribsMap)
 
void fillTextFormatting_helper (IHTMLElement2 *pHTMLElement2, VBufStorage_fieldNode_t *node)
 
void fillTextFormattingForNode (IHTMLDOMNode *pHTMLDOMNode, VBufStorage_fieldNode_t *node)
 
void fillTextFormattingForTextNode (VBufStorage_controlFieldNode_t *parentNode, VBufStorage_textFieldNode_t *textNode)
 
void fillExplicitTableHeadersForCell (VBufStorage_controlFieldNode_t &cell, int docHandle, wstring &headersAttr, fillVBuf_tableInfo &tableInfo)
 
void handleColsSpannedByPrevRows (fillVBuf_tableInfo &tableInfo)
 
fillVBuf_tableInfofillVBuf_helper_collectAndUpdateTableInfo (VBufStorage_controlFieldNode_t *parentNode, wstring nodeName, int docHandle, int ID, fillVBuf_tableInfo *tableInfo, map< wstring, wstring > &attribsMap)
 
UINT getHTMLWindowMessage ()
 
VBufBackend_tMshtmlVBufBackend_t_createInstance (int docHandle, int ID)
 

Variables

const int TABLEHEADER_COLUMN = 0x1
 
const int TABLEHEADER_ROW = 0x2
 
const unsigned int FORMATSTATE_INSERTED =1
 
const unsigned int FORMATSTATE_DELETED =2
 
const unsigned int FORMATSTATE_MARKED =4
 
const unsigned int FORMATSTATE_STRONG =8
 
const unsigned int FORMATSTATE_EMPH =16
 

Macro Definition Documentation

◆ macro_addHTMLCurrentStyleToNodeAttrs

#define macro_addHTMLCurrentStyleToNodeAttrs ( styleName,
attrName,
node,
currentStyleObj,
tempBSTR )
Value:
{\
currentStyleObj->get_##styleName(&tempBSTR);\
if(tempBSTR) {\
LOG_DEBUG(L"Got "<<L#styleName);\
node->addAttribute(L#attrName,tempBSTR);\
SysFreeString(tempBSTR);\
tempBSTR=NULL;\
} else {\
LOG_DEBUG(L"Failed to get "<<L#styleName);\
}\
}

Referenced by fillTextFormatting_helper().

◆ macro_addHTMLCurrentStyleToNodeAttrs_var

#define macro_addHTMLCurrentStyleToNodeAttrs_var ( styleName,
attrName,
node,
currentStyleObj,
tempVar )
Value:
{\
currentStyleObj->get_##styleName(&tempVar);\
if(tempVar.vt==VT_BSTR && tempVar.bstrVal) {\
LOG_DEBUG(L"Got "<<L#styleName);\
node->addAttribute(L#attrName,tempVar.bstrVal);\
VariantClear(&tempVar);\
} else {\
LOG_DEBUG(L"Failed to get "<<L#styleName);\
}\
}

Referenced by fillTextFormatting_helper().

◆ macro_addHTMLAttributeToMap

#define macro_addHTMLAttributeToMap ( attribName,
allowEmpty,
attribsObj,
attribsMap,
tempVar,
tempAttrObj )
Value:
{\
attribsObj->getNamedItem(CComBSTR(attribName),&tempAttrObj);\
if(tempAttrObj) {\
VariantInit(&tempVar);\
tempAttrObj->get_nodeValue(&tempVar);\
if(tempVar.vt==VT_BSTR&&tempVar.bstrVal&&(allowEmpty||SysStringLen(tempVar.bstrVal)>0)) {\
attribsMap[L"HTMLAttrib::" attribName]=tempVar.bstrVal;\
} else if(tempVar.vt==VT_I2||tempVar.vt==VT_I4) {\
wostringstream* s=new wostringstream;\
(*s)<<((tempVar.vt==VT_I2)?tempVar.iVal:tempVar.lVal);\
attribsMap[L"HTMLAttrib::" attribName]=s->str();\
delete s;\
}\
VariantClear(&tempVar);\
tempAttrObj->Release();\
tempAttrObj=NULL;\
}\
}

Referenced by getAttributesFromHTMLDOMNode().

Function Documentation

◆ incBackendLibRefCount()

◆ decBackendLibRefCount()

◆ queryService()

template<typename toInterface >
HRESULT queryService ( IUnknown * pUnknown,
const IID & siid,
toInterface ** pIface )
inline

A utility template function to queryService from a given IUnknown to the given service with the given service ID and interface eing returned.

Parameters
siidthe service iid

References HRESULT(), and LOG_DEBUG.

Referenced by MshtmlVBufBackend_t::fillVBuf(), getHTMLSubdocumentBodyFromIAccessibleFrame(), and LocateHTMLElementInDocument().

◆ getIAccessibleInfo()

void getIAccessibleInfo ( IAccessible * pacc,
wstring * name,
int * role,
wstring * value,
int * states,
wstring * description,
wstring * keyboardShortcut )
inline

References LOG_DEBUG.

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ getHTMLSubdocumentBodyFromIAccessibleFrame()

template<typename toInterface >
HRESULT getHTMLSubdocumentBodyFromIAccessibleFrame ( IAccessible * pacc,
toInterface ** pIface )
inline

◆ LocateHTMLElementInDocument()

IHTMLElement * LocateHTMLElementInDocument ( IHTMLDocument3 * pHTMLDocument3,
const wstring & ID )

◆ getIDFromHTMLDOMNode()

int getIDFromHTMLDOMNode ( IHTMLDOMNode * pHTMLDOMNode)
inline

References LOG_DEBUG.

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ getTextFromHTMLDOMNode()

wstring getTextFromHTMLDOMNode ( IHTMLDOMNode * pHTMLDOMNode,
bool allowPreformattedText,
bool isStartOfBlock )
inline

References LOG_DEBUG.

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ getCurrentStyleInfoFromHTMLDOMNode()

void getCurrentStyleInfoFromHTMLDOMNode ( IHTMLDOMNode * pHTMLDOMNode,
bool & dontRender,
bool & isBlock,
bool & hidden,
wstring & listStyle )
inline

References LOG_DEBUG.

Referenced by MshtmlVBufBackend_t::fillVBuf().

◆ getAttributesFromHTMLDOMNode()

void getAttributesFromHTMLDOMNode ( IHTMLDOMNode * pHTMLDOMNode,
wstring & nodeName,
map< wstring, wstring > & attribsMap )
inline

◆ fillTextFormatting_helper()

◆ fillTextFormattingForNode()

void fillTextFormattingForNode ( IHTMLDOMNode * pHTMLDOMNode,
VBufStorage_fieldNode_t * node )
inline

◆ fillTextFormattingForTextNode()

void fillTextFormattingForTextNode ( VBufStorage_controlFieldNode_t * parentNode,
VBufStorage_textFieldNode_t * textNode )
inline

◆ fillExplicitTableHeadersForCell()

void fillExplicitTableHeadersForCell ( VBufStorage_controlFieldNode_t & cell,
int docHandle,
wstring & headersAttr,
fillVBuf_tableInfo & tableInfo )
inline

◆ handleColsSpannedByPrevRows()

◆ fillVBuf_helper_collectAndUpdateTableInfo()

◆ getHTMLWindowMessage()

UINT getHTMLWindowMessage ( )

◆ MshtmlVBufBackend_t_createInstance()

VBufBackend_t * MshtmlVBufBackend_t_createInstance ( int docHandle,
int ID )

References LOG_DEBUG.

Variable Documentation

◆ TABLEHEADER_COLUMN

const int TABLEHEADER_COLUMN = 0x1

◆ TABLEHEADER_ROW

◆ FORMATSTATE_INSERTED

const unsigned int FORMATSTATE_INSERTED =1

◆ FORMATSTATE_DELETED

const unsigned int FORMATSTATE_DELETED =2

◆ FORMATSTATE_MARKED

const unsigned int FORMATSTATE_MARKED =4

◆ FORMATSTATE_STRONG

const unsigned int FORMATSTATE_STRONG =8

◆ FORMATSTATE_EMPH

const unsigned int FORMATSTATE_EMPH =16