Commit a845d3f1 authored by Kathleen Brade's avatar Kathleen Brade Committed by Mike Perry
Browse files

Return client window coordinates for mouse event screenX/Y (for dragend, 0,0 is returned).

parent 4cf2489f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -61,14 +61,16 @@ Touch::Target() const
NS_IMETHODIMP
Touch::GetScreenX(int32_t* aScreenX)
{
  *aScreenX = ScreenX();
  bool isChrome = nsContentUtils::IsCallerChrome();
  *aScreenX = isChrome ? ScreenX() : ClientX();
  return NS_OK;
}

NS_IMETHODIMP
Touch::GetScreenY(int32_t* aScreenY)
{
  *aScreenY = ScreenY();
  bool isChrome = nsContentUtils::IsCallerChrome();
  *aScreenY = isChrome ? ScreenY() : ClientY();
  return NS_OK;
}

+1 −0
Original line number Diff line number Diff line
@@ -1061,6 +1061,7 @@ nsDOMEvent::Shutdown()
  }
}

// XXX: This may need adjusting to be client-relative for content
nsIntPoint
nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
                            nsEvent* aEvent,
+20 −0
Original line number Diff line number Diff line
@@ -308,6 +308,19 @@ nsDOMMouseEvent::GetMozMovementY(int32_t* aMovementY)
NS_METHOD nsDOMMouseEvent::GetScreenX(int32_t* aScreenX)
{
  NS_ENSURE_ARG_POINTER(aScreenX);
  bool isChrome = nsContentUtils::IsCallerChrome();
  if (!isChrome)
  {
    // For non-chrome callers, return client coordinates instead.
    // For some events, the result will be zero; specifically, for dragend
    // events (there is no widget associated with dragend events, which
    // causes GetClientX() to return zero).  Since dragend is for the drag
    // originator and not for the receiver, it is probably not widely used
    // (receivers get a drop event).  Therefore, returning 0 should not break
    // many web pages.  Also, a few years ago Firefox returned 0.
    // See:  https://bugzilla.mozilla.org/show_bug.cgi?id=466379
    return GetClientX(aScreenX);
  }
  *aScreenX = ScreenX();
  return NS_OK;
}
@@ -324,6 +337,13 @@ NS_IMETHODIMP
nsDOMMouseEvent::GetScreenY(int32_t* aScreenY)
{
  NS_ENSURE_ARG_POINTER(aScreenY);
  bool isChrome = nsContentUtils::IsCallerChrome();
  if (!isChrome)
  {
    // For non-chrome callers, return client coordinates instead.
    // See also the comment in nsDOMMouseEvent::GetScreenX().
    return GetClientY(aScreenY);
  }
  *aScreenY = ScreenY();
  return NS_OK;
}
+1 −0
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ nsBoxObject::GetHeight(int32_t* aResult)
  return NS_OK;
}

// XXX: Does this need to be client coords for content?
NS_IMETHODIMP
nsBoxObject::GetScreenX(int32_t *_retval)
{