@Umang: Each text line has a bounding rectangle. It seems to me that FF / TB put the "simulated right-click" one pixel too low. Therefore, instead of "clicking" the lower edge of the expected text line, it click the upper edge of the text line underneath it.
I think I know the root of the problem. The caret position is stored in twips which are a much more precise unit that pixels. The PrepareToUseCaretPosition() first gets the lowest point of the caret (in twips) then converts it into pixels. This is done using round-to-nearest [1][2], which can return a pixel value outside the bounding rectangle of the expected text line.
This would also explain why the bug is not always hit. Different text sizes / scroll positions might determine rounding in the right direction.
I propose one of the following solutions:
1) Don't "click" on the lower edge of the caret. Click at say 80% or 90% of it.
2) Provide a round-down feature for AppUnitsToDevPixels.
3) (What my patch does) subtract 1, just to make sure.
4) Detect if round-up occurred (check if xInPixels * TwipsPerPixel == xInTwips) and compensate.
I could invest some time and implement these solutions, provided they would be accepted and included in the Mozilla Source Code.
@Umang: Each text line has a bounding rectangle. It seems to me that FF / TB put the "simulated right-click" one pixel too low. Therefore, instead of "clicking" the lower edge of the expected text line, it click the upper edge of the text line underneath it.
I think I know the root of the problem. The caret position is stored in twips which are a much more precise unit that pixels. The PrepareToUseCar etPosition( ) first gets the lowest point of the caret (in twips) then converts it into pixels. This is done using round-to-nearest [1][2], which can return a pixel value outside the bounding rectangle of the expected text line.
This would also explain why the bug is not always hit. Different text sizes / scroll positions might determine rounding in the right direction.
I propose one of the following solutions:
1) Don't "click" on the lower edge of the caret. Click at say 80% or 90% of it. xels.
2) Provide a round-down feature for AppUnitsToDevPi
3) (What my patch does) subtract 1, just to make sure.
4) Detect if round-up occurred (check if xInPixels * TwipsPerPixel == xInTwips) and compensate.
I could invest some time and implement these solutions, provided they would be accepted and included in the Mozilla Source Code.
[1] mozilla/ mozilla/ layout/ base/nsPresCont ext.h @ 561 mozilla/ gfx/public/ nsCoord. h @ 330
[2] mozilla/