divyang4481 / firebreath

Automatically exported from code.google.com/p/firebreath
0 stars 0 forks source link

getWindowPosition returns incorrect bottom value for Cocoa and Carbon #70

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Rob posted on the mailing list:

Hi all,

There is a bug in the implementation of getWindowPosition for both Carbon and 
Cocoa.  The current code is:
NPRect PluginWindowMacCarbon::getWindowPosition() {
   NPRect windRect;
   windRect.left = m_x;
   windRect.top = m_y;
   windRect.right = m_x + m_width;
   windRect.bottom = m_y - m_height;
   return windRect;
}

The calculation of bottom is wrong for two reasons:
       1. I think it was earlier agreed that the convention for coordinate systems is that the top left is 0,0.
       2. NPRect contains 16 bit unsigned values -- so this value gets mangled.

I think all that needs to be changed is flipping the minus to a plus:
   windRect.bottom = m_y + m_height;

Cheers,
Rob

Original issue reported on code.google.com by amack...@gmail.com on 21 Sep 2010 at 2:00

GoogleCodeExporter commented 8 years ago
This is definitely an interesting problem; I have fixed the issue mentioned, 
but aparently Cocoa events in the browser actually come with top-left 
orientation (according to https://wiki.mozilla.org/NPAPI:CocoaEventModel).  So 
most cocoa devs will be used to bottom left, but the browser provides top-left.

If we are going to do top-left, the Cocoa stuff definitely should be changed 
not to convert the origin on y axis anymore; amackera, I'd prefer if you 
changed this, since you know what code this will affect better than I do.

Original comment by taxilian on 21 Sep 2010 at 8:55

GoogleCodeExporter commented 8 years ago
ok, so this part is done; issue #71 will be pushed to 1.3

Original comment by taxilian on 22 Sep 2010 at 3:28