How to access a document's HTML in Firefox using IAccessible
Asked Answered
D

1

4

I can get an IAccessible object from a Firefox window using this code:

Guid guid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
object obj = null;
int ret = AccessibleObjectFromWindow(hWnd, 
    (uint) OBJID.WINDOW, ref guid, ref obj);
Accessibility.IAccessible acc = (Accessibility.IAccessible)obj;

However, I'm not sure where to go from here. I need to get the full HTML from the document. I know about the IAccessible.get_accValue() method, but I'm not really sure how to use it in relation to Firefox. Any help would be much appreciated.

Derangement answered 12/2, 2009 at 17:19 Comment(0)
D
1

Apparently you can't get the full HTML source using IAccessible. I found this but it doesn't work in FF3.5:

IServiceProvider *pServProv = NULL;
pAccessible->QueryInterface(IID_IServiceProvider, (void**)&pServProv);
ISimpleDOMNode *pSimpleDOMNode;
if (pServProv) {
  const GUID refguid = {0x0c539790, 0x12e4, 0x11cf, 0xb6, 0x61,
                        0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8};
  HRESULT result = pServProv->QueryService(refguid, IID_ISimpleDOMNode,
                                           (void**)&pSimpleDOMNode);
  if (SUCCEEDED(hresult) && pSimpleDOMNode != NULL) {
    /* This is a Mozilla node! Use special ISimpleDOMNode methods described in
      ISimpleDOMNode.idl. */
  }
}

I also found this, which doesn't work in FF3.5 either:

HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_CLIENT,
      IID_IAccessible, (void**)&pAccessible);
if (SUCCEEDED(hr) && pAccessible != NULL) {
HRESULT hr = pAccessible->QueryInterface(
      IID_ISimpleDOMNode, (void**)&pSimpleDOMNode);
}

I'm stuck. :(

Derangement answered 21/8, 2009 at 14:58 Comment(3)
Are you using C++? If you are, are you linking against the xulrunner libraries?Adkison
I'm not linking against the xulrunner libraries, I'm using the objects generated from the supplied .IDL files. I used MIDL to generate the .H files from the .IDL. I'm wondering if maybe the IID_ISimpleDOMNode value in the .H files is wrong, but I'm not sure how to verify it.Derangement
I solved it using the first example here, and recursively processing each node until we reach an HTML node. Then the innerHTML call will succeed.Derangement

© 2022 - 2024 — McMap. All rights reserved.