rewite GetScreen* to use nsIWidget::WidgetToScreen(), which actually will work under linux and mac. (rev pavlov, appr cyeh). Bug #9114.

This commit is contained in:
pinkerton%netscape.com 1999-07-07 22:40:22 +00:00
parent d6584e757a
commit aebf313276
2 changed files with 40 additions and 60 deletions

View File

@ -220,43 +220,33 @@ NS_METHOD nsDOMEvent::SetInputRange(nsIDOMTextRangeList* aInputRange)
NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
{
// pinkerton -- i don't understand how we can assume that mEvent
// is a nsGUIEvent, but we are.
if ( !mEvent || !((nsGUIEvent*)mEvent)->widget )
return NS_ERROR_FAILURE;
nsRect bounds, offset;
offset.x = 0;
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
//Add extra since loop will free one.
NS_IF_ADDREF(parent);
nsIWidget* tmp;
while (nsnull != parent) {
parent->GetBounds(bounds);
offset.x += bounds.x;
tmp = parent;
parent = tmp->GetParent();
NS_RELEASE(tmp);
}
*aScreenX = mEvent->refPoint.x + offset.x;
bounds.x = mEvent->refPoint.x;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
*aScreenX = offset.x;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
{
// pinkerton -- i don't understand how we can assume that mEvent
// is a nsGUIEvent, but we are.
if ( !mEvent || !((nsGUIEvent*)mEvent)->widget )
return NS_ERROR_FAILURE;
nsRect bounds, offset;
offset.y = 0;
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
//Add extra since loop will free one.
NS_IF_ADDREF(parent);
nsIWidget* tmp;
while (nsnull != parent) {
parent->GetBounds(bounds);
offset.y += bounds.y;
tmp = parent;
parent = tmp->GetParent();
NS_RELEASE(tmp);
}
*aScreenY = mEvent->refPoint.y + offset.y;
bounds.y = mEvent->refPoint.y;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
*aScreenY = offset.y;
return NS_OK;
}

View File

@ -220,43 +220,33 @@ NS_METHOD nsDOMEvent::SetInputRange(nsIDOMTextRangeList* aInputRange)
NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
{
// pinkerton -- i don't understand how we can assume that mEvent
// is a nsGUIEvent, but we are.
if ( !mEvent || !((nsGUIEvent*)mEvent)->widget )
return NS_ERROR_FAILURE;
nsRect bounds, offset;
offset.x = 0;
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
//Add extra since loop will free one.
NS_IF_ADDREF(parent);
nsIWidget* tmp;
while (nsnull != parent) {
parent->GetBounds(bounds);
offset.x += bounds.x;
tmp = parent;
parent = tmp->GetParent();
NS_RELEASE(tmp);
}
*aScreenX = mEvent->refPoint.x + offset.x;
bounds.x = mEvent->refPoint.x;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
*aScreenX = offset.x;
return NS_OK;
}
NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
{
// pinkerton -- i don't understand how we can assume that mEvent
// is a nsGUIEvent, but we are.
if ( !mEvent || !((nsGUIEvent*)mEvent)->widget )
return NS_ERROR_FAILURE;
nsRect bounds, offset;
offset.y = 0;
nsIWidget* parent = ((nsGUIEvent*)mEvent)->widget;
//Add extra since loop will free one.
NS_IF_ADDREF(parent);
nsIWidget* tmp;
while (nsnull != parent) {
parent->GetBounds(bounds);
offset.y += bounds.y;
tmp = parent;
parent = tmp->GetParent();
NS_RELEASE(tmp);
}
*aScreenY = mEvent->refPoint.y + offset.y;
bounds.y = mEvent->refPoint.y;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
*aScreenY = offset.y;
return NS_OK;
}