NS_IMETHODIMP
nsDOMMouseEvent::GetClientY(PRInt32* aClientY)
{
  NS_ENSURE_ARG_POINTER(aClientY);
  *aClientY = GetClientPoint().y;
  return NS_OK;
}
// ---- nsDOMNSUIEvent implementation -------------------
nsPoint
nsDOMUIEvent::GetPagePoint()
{
  if (((nsGUIEvent*)mEvent)->widget) {
    // Native event; calculate using presentation
    nsPoint pt(0, 0);
    nsIPresShell* shell = mPresContext->GetPresShell();
    if (!shell) {
      return pt;
    }
    nsIScrollableFrame* scrollframe = shell->GetRootScrollFrameAsScrollable();

    if (scrollframe)
      pt += scrollframe->GetScrollPosition();
    nsIFrame* rootFrame = shell->GetRootFrame();
    if (rootFrame)
      pt += nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame);
    return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
                   nsPresContext::AppUnitsToIntCSSPixels(pt.y));
  }

  // If event was initialized manually using InitMouseEvent(...),
  // page coordinates must be the same as client coordinates. See bug 405632.
  return mPrivateDataDuplicated ? mPagePoint : GetClientPoint();
}
示例#3
0
NS_METHOD
nsDOMUIEvent::DuplicatePrivateData()
{
  mClientPoint = GetClientPoint();
  mLayerPoint = GetLayerPoint();
  mPagePoint = GetPagePoint();
  // GetScreenPoint converts mEvent->refPoint to right coordinates.
  nsIntPoint screenPoint = GetScreenPoint();
  nsresult rv = nsDOMEvent::DuplicatePrivateData();
  if (NS_SUCCEEDED(rv)) {
    mEvent->refPoint = screenPoint;
  }
  return rv;
}
示例#4
0
// ---- nsDOMNSUIEvent implementation -------------------
nsIntPoint
nsDOMUIEvent::GetPagePoint()
{
  if (mPrivateDataDuplicated) {
    return mPagePoint;
  }

  nsIntPoint pagePoint = GetClientPoint();

  // If there is some scrolling, add scroll info to client point.
  if (mPresContext && mPresContext->GetPresShell()) {
    nsIPresShell* shell = mPresContext->GetPresShell();
    nsIScrollableFrame* scrollframe = shell->GetRootScrollFrameAsScrollable();
    if (scrollframe) {
      nsPoint pt = scrollframe->GetScrollPosition();
      pagePoint += nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
                              nsPresContext::AppUnitsToIntCSSPixels(pt.y));
    }
  }

  return pagePoint;
}
NS_METHOD nsDOMMouseEvent::GetClientX(PRInt32* aClientX)
{
  NS_ENSURE_ARG_POINTER(aClientX);
  *aClientX = GetClientPoint().x;
  return NS_OK;
}
示例#6
0
ZeroRect ZeroInputManager::GetClientRect() {
	int x = static_cast<int>(GetClientPoint().x);
	int y = static_cast<int>(GetClientPoint().y);
	ZeroRect rect(x, y, x + 1, y + 1);
	return rect;
}