Re: How to get the rendered dom element's coordinate infos in JAVAXPCOM
[email protected] Thu, 29 May 2008 05:56:10 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <0cffbdab-5a9c-4d79-9d7e-21de4913411d@l64g2000hse.googlegroups.com> |
Hi there!
A sample below does not match your code, but can provide you with a
clue how to get the coordinates.
I was able to get them the following way.
nsIWebBrowser webBrowser = (nsIWebBrowser) browser.getWebBrowser();
nsIDOMDocument document =
webBrowser.getContentDOMWindow().getDocument();
nsIDOMHTMLDocument htmlDocument = (nsIDOMHTMLDocument)
document.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID);
nsIDOMHTMLElement element = htmlDocument.getBody();
nsIDOMNSHTMLElement nsHtmlElement = (nsIDOMNSHTMLElement)
element.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
System.out.println( "<" + element.getNodeName() + "> (" +
nsHtmlElement.getOffsetLeft() + ", " +
nsHtmlElement.getOffsetTop() + ", " +
nsHtmlElement.getClientWidth() + ", " +
nsHtmlElement.getClientHeight() + ")" );
After that explore the <body> element children, and cast nsIDOMNode to
nsIDOMNSHTMLElement also like that:
nsHtmlElement = (nsIDOMNSHTMLElement)
node.queryInterface(nsIDOMNSHTMLElement.NS_IDOMNSHTMLELEMENT_IID);
Now I need to get coordinates of particular text rows and for the time
being I've found no solution.
Regards,
Igor