Bug 263099. Fix coordinate translation in event handling when finding the relevant line of nested blocks. r+sr=bzbarsky

This commit is contained in:
roc+%cs.cmu.edu 2005-02-07 01:09:58 +00:00
parent 586327b1cf
commit 3ff2296f52
2 changed files with 15 additions and 20 deletions

View File

@ -6084,9 +6084,8 @@ nsBlockFrame::PaintChildren(nsPresContext* aPresContext,
// XXXldb Does this handle all overlap cases correctly? (How?)
nsresult
nsBlockFrame::GetClosestLine(nsILineIterator *aLI,
const nsPoint &aOrigin,
const nsPoint &aPoint,
nsBlockFrame::GetClosestLine(nsILineIterator *aLI,
const nsPoint &aPoint,
PRInt32 &aClosestLine)
{
if (!aLI)
@ -6124,8 +6123,6 @@ nsBlockFrame::GetClosestLine(nsILineIterator *aLI,
// Check to see if our point lies with the line's Y bounds.
rect+=aOrigin; //offset origin to get comparative coordinates
y = aPoint.y - rect.y;
if (y >=0 && (aPoint.y < (rect.y+rect.height)))
{
@ -6203,22 +6200,21 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext,
if (!shell)
return NS_OK;
nsCOMPtr<nsILineIterator> it( do_QueryInterface(mainframe, &result) );
nsIView* parentWithView;
nsPoint origin;
nsPeekOffsetStruct pos;
nsPoint viewOffset;
nsIView* parentWithView;
GetOffsetFromView(viewOffset, &parentWithView);
while(NS_OK == result)
{ //we are starting aloop to allow us to "drill down to the one we want"
mainframe->GetOffsetFromView(origin, &parentWithView);
if (NS_FAILED(result))
return NS_OK;//do not handle
{ //we are starting aloop to allow us to "drill down to the one we want"
PRInt32 closestLine;
if (NS_FAILED(result = GetClosestLine(it,origin,aEvent->point,closestLine)))
// aEvent->point is relative to our view. We need to make it relative to
// mainframe, via this frame.
if (NS_FAILED(result = GetClosestLine(it,
aEvent->point - viewOffset - mainframe->GetOffsetTo(this), closestLine)))
return result;
//we will now ask where to go. if we cant find what we want"aka another block frame"
//we drill down again
pos.mShell = shell;

View File

@ -286,14 +286,13 @@ protected:
/**
* GetClosestLine will return the line that VERTICALLY owns the point closest to aPoint.y
* aOrigin is the offset for this block frame to its frame.
* aPoint is the point to search for.
* aPoint is the point to search for, relative to the origin of the frame that aLI
* iterates over.
* aClosestLine is the result.
*/
nsresult GetClosestLine(nsILineIterator *aLI,
const nsPoint &aOrigin,
const nsPoint &aPoint,
PRInt32 &aClosestLine);
nsresult GetClosestLine(nsILineIterator *aLI,
const nsPoint &aPoint,
PRInt32 &aClosestLine);
void TryAllLines(nsLineList::iterator* aIterator,
nsLineList::iterator* aEndIterator,