[Project_owners] getting the visible range of an html doc?

Shawn Betts sabetts at vcn.bc.ca
Wed Oct 20 20:00:07 EDT 2004


"Todd Ross" <todd at brainsick.com> writes:

> > Shawn Betts <sabetts at vcn.bc.ca> writes:
> 
> > So, instead I could perform the search and get the rectangle
> > containing startContainer endContainer and see if either is visible
> > (compare rect coords with the window's scrollX, scrollY). I KNOW a
> > node's bounding rectangle can be found because the DOM Inspector
> > flashes it. But it seems the inspector uses it's own flasher module
> > that's written in C++.
> >
> > Is there a way to get this bounding rectangle from XUL? Or will I
> > have to hack C++ to do it?
> 
> Adblock also flashes the elements in the window.  It might be worth
> checking out how they do it.  Just a thought.

I maybe found a way to do it.

nsIAccessible has a function getBounds:

void getBounds ( out PRInt32 x , out PRInt32 y , out PRInt32 width , out PRInt32 height )

But the problem is this 'out' thing. I thot JS can't do pass by
reference. How do I call getBounds? All I've been able to do is get an
error saying it expects an object as arguments:

function test(node)
{
    var acc_serv = Components.classes["@mozilla.org/accessibilityService;1"]
	.createInstance(Components.interfaces.nsIAccessibleRetrieval);
    
    var acc = acc_serv.getAccessibleFor(node);
    var x,y,w,h;

    acc.getBounds(x,y,w,h);
    alert(x + " " + y + " " + w + " " + h);
}

I tried passing in arrays instead:

var x=[]; 
var y=[];
...

but the array doesn't get filled with anything. Is 'out' some kind of
special object?

-Shawn


More information about the Project_owners mailing list