On 9/13/2013 10:04 AM, Mike de Boer wrote:
…reliably from C++?

Some background: in bug 257061 I'm implementing to count and display the number 
of found items in the findbar. Gavin mentions in 
https://bugzilla.mozilla.org/show_bug.cgi?id=257061#c88 that there has to be 
some prior art related to checking if an element/ node is currently visible.

The question(s): How does one check if an element/ node is visible reliably? 
nsTypeAheadFind::IsRangeVisible() does this for ranges by traversing through 
layout frames and more; is there a similar method available for nodes? Or is a 
Javascript method still the best one?

Local searches through the codebase and with MXR I couldn't find anything (I 
tried many variations!).

This is a hard problem, and it depends on what question you're asking:

* Is a node visible if it's in the window but some other window is covering the current window? * Is a node visible if it's currently scrolled out of view but would be visible when scrolled?
* What about if overflow:hidden is set on whatever is scrollable?
* What about if it's in a background tab?

In general we don't track visibility of objects, and computing one more of these kinds of visibility can be rather expensive. We do have heuristics for plugins to inform them when they can stop painting, but that involves special code on plugin elements to track their layer state, and wouldn't scale to arbitrary elements (and it's focused on painting visibility so that even windows which "cover" the plugin make it invisible).

--BDS

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to