Hi,
I am embedding XULRunner 1.9.0.6 in my C++ app. I want to get at the
computed styles for elements in the DOM tree. All the code I found on
the web to do this follows the same basic format:
nsCOMPtr<nsIDOMDocumentView> domView = do_QueryInterface
(domDocument,&rv);
if(NS_FAILED(rv) || !domView) printf("domView failed %08X\n", rv);
nsCOMPtr<nsIDOMAbstractView> abstractView;
rv = domView->GetDefaultView(getter_AddRefs(abstractView));
if(NS_FAILED(rv) || !abstractView) printf("abstractView failed %08X
\n", rv);
nsCOMPtr<nsIDOMViewCSS> viewCSS;
viewCSS = do_QueryInterface(abstractView, &rv);
if(NS_FAILED(rv) || !viewCSS) printf("viewCSS failed %08X\n", rv);
...
...
...
nsCOMPtr<nsIDOMCSSStyleDeclaration> style;
rv = viewCSS->GetComputedStyle(DOMelement.get(), EmptyString(),
style.get());
if(NS_FAILED(rv) || !style) printf("style failed %08X\n", rv);
The problem is that when I run this code, abstractView is always NULL.
I can't figure out what is causing GetDefaultView to return an
invalid nsIDOMAbstractView? This code is being executed in the
OnStateChange callback in nsIWebProgressListener, when STATE_STOP and
STATE_IS_DOCUMENT (page has been fully loaded). Both domDocument and
domView appear to be valid; I can traverse the DOM tree just fine.
Any help would be greatly appreciated!!
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding