NPAPI/X11 : Plugin Visibility

For the past week or two, I have been working on getting Flash to work on Maemo5/N900. Read more about it here.

Today, I fixed a part of 44594. For mobile, it would be very efficient if Flash gets notified when it goes out of view or when the browser is minimized. There has been some discussion about this but no no consensus. We have to move on and so we have decided to set an empty clip rect in the NPWindow struct to notify the plugin about it’s invisibility (I don’t like this, I prefer explicit notifications on what is happenning but oh well).

ATM, clip rect is always set to 0 in windowless mode which breaks the above mechanism. So, I set out to find out it’s meaning. I found that Flash doesn’t care about the value of clipRect at all which made is quite hard to figure what exactly it’s meaning is. A note from an Adobe person in the above thread seems to indicate clipRect is actually respected only on the Mac for Flash!

I now set the clipRect based on my understanding of NPWindow. If reading specs is your thing, please read the spec and see if your understanding matches with mine.

Read the spec? Ok, Quiz time.
1. In windowless mode, if NPWindow.x, y = (10, 10) and if the clipRect is (20, 20, 50×50) in _plugin_ coordinates, what should we set NPWindow.clipRect to?
2. In windowed mode, if a plugin of size 100×100 is at position 50, 50 wrt to the page, and we scroll 60 pixels in either direction, what is NPWindow.x,y and clipRect.

1. clipRect = (30, 30, 50×50). Atleast as per the doc, the clip rect is wrt to drawable and not the plugin’s origin.
2. NPWindow.x,y = -10, -10. clipRect = (0, 0, 90×90). The value of x,y is not debatable 🙂 It has to be set to -10, -10 based on empirical data and it’s actually wrt the viewport and not the page as the doc suggestes. So, I made clipRect also wrt the viewport.

Good news is even if your answers to the above are different, it doesn’t matter because Flash ignores clipRect 🙂

66095 is the commit in webkit.