Bug 1446711 part 1. Get rid of nsIDOMMouseEvent::GetScreenX/Y. r=qdot
MozReview-Commit-ID: 9Y61WHTDVvF
This commit is contained in:
@@ -30,9 +30,9 @@
|
||||
#include "nsIDOMElement.h"
|
||||
#include "Link.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
#include "mozilla/dom/SVGTitleElement.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
@@ -1187,7 +1187,7 @@ ChromeTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
nsresult
|
||||
ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
||||
MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
|
||||
if (!mouseEvent) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1212,8 +1212,8 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
|
||||
|
||||
mMouseClientX = newMouseX;
|
||||
mMouseClientY = newMouseY;
|
||||
mouseEvent->GetScreenX(&mMouseScreenX);
|
||||
mouseEvent->GetScreenY(&mMouseScreenY);
|
||||
mMouseScreenX = mouseEvent->ScreenX(CallerType::System);
|
||||
mMouseScreenY = mouseEvent->ScreenY(CallerType::System);
|
||||
|
||||
if (mTooltipTimer) {
|
||||
mTooltipTimer->Cancel();
|
||||
|
||||
@@ -37,6 +37,7 @@ class EventMessageAutoOverride;
|
||||
// autogenerated since it has some extra methods.
|
||||
class ExtendableEvent;
|
||||
class KeyboardEvent;
|
||||
class MouseEvent;
|
||||
class TimeEvent;
|
||||
class WantsPopupControlCheck;
|
||||
class XULCommandEvent;
|
||||
@@ -139,6 +140,13 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// MouseEvent has a non-autogeneratable initMouseEvent and other
|
||||
// non-autogeneratable methods.
|
||||
virtual MouseEvent* AsMouseEvent()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// nsIDOMEvent Interface
|
||||
NS_DECL_NSIDOMEVENT
|
||||
|
||||
@@ -401,11 +409,14 @@ private:
|
||||
|
||||
#define NS_FORWARD_TO_EVENT \
|
||||
NS_FORWARD_NSIDOMEVENT(Event::) \
|
||||
using Event::GetTarget; /* Because forwarding shadows. */ \
|
||||
using Event::GetOriginalTarget; /* Because forwarding shadows. */ \
|
||||
virtual void PreventDefault(JSContext* aCx, CallerType aCallerType) override { Event::PreventDefault(aCx, aCallerType); }
|
||||
|
||||
#define NS_FORWARD_NSIDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION(_to) \
|
||||
NS_IMETHOD GetType(nsAString& aType) override { return _to GetType(aType); } \
|
||||
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget) override { return _to GetTarget(aTarget); } \
|
||||
using Event::GetTarget; /* Because forwarding shadows. */ \
|
||||
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget) override { return _to GetCurrentTarget(aCurrentTarget); } \
|
||||
NS_IMETHOD GetEventPhase(uint16_t* aEventPhase) override { return _to GetEventPhase(aEventPhase); } \
|
||||
NS_IMETHOD GetBubbles(bool* aBubbles) override { return _to GetBubbles(aBubbles); } \
|
||||
@@ -418,6 +429,7 @@ private:
|
||||
NS_IMETHOD GetDefaultPrevented(bool* aDefaultPrevented) override { return _to GetDefaultPrevented(aDefaultPrevented); } \
|
||||
NS_IMETHOD StopImmediatePropagation(void) override { return _to StopImmediatePropagation(); } \
|
||||
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) override { return _to GetOriginalTarget(aOriginalTarget); } \
|
||||
using Event::GetOriginalTarget; /* Because forwarding shadows. */ \
|
||||
NS_IMETHOD GetExplicitOriginalTarget(nsIDOMEventTarget** aExplicitOriginalTarget) override { return _to GetExplicitOriginalTarget(aExplicitOriginalTarget); } \
|
||||
NS_IMETHOD GetIsTrusted(bool* aIsTrusted) override { return _to GetIsTrusted(aIsTrusted); } \
|
||||
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) override { return _to SetTarget(aTarget); } \
|
||||
|
||||
@@ -332,14 +332,6 @@ MouseEvent::GetMozMovementY(int32_t* aMovementY)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MouseEvent::GetScreenX(int32_t* aScreenX)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScreenX);
|
||||
*aScreenX = ScreenX(CallerType::System);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
MouseEvent::ScreenX(CallerType aCallerType)
|
||||
{
|
||||
@@ -357,14 +349,6 @@ MouseEvent::ScreenX(CallerType aCallerType)
|
||||
return Event::GetScreenCoords(mPresContext, mEvent, mEvent->mRefPoint).x;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MouseEvent::GetScreenY(int32_t* aScreenY)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aScreenY);
|
||||
*aScreenY = ScreenY(CallerType::System);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
MouseEvent::ScreenY(CallerType aCallerType)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,11 @@ public:
|
||||
return MouseEventBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
virtual MouseEvent* AsMouseEvent() override
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// Web IDL binding methods
|
||||
virtual uint32_t Which(CallerType aCallerType) override
|
||||
{
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
[builtinclass, uuid(5bdab8d8-7933-4c5c-b6d1-ab34481237f7)]
|
||||
interface nsIDOMMouseEvent : nsIDOMUIEvent
|
||||
{
|
||||
readonly attribute long screenX;
|
||||
readonly attribute long screenY;
|
||||
|
||||
readonly attribute long mozMovementX;
|
||||
readonly attribute long mozMovementY;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
#include "mozilla/dom/FragmentOrElement.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
|
||||
// for event firing in context menus
|
||||
#include "nsPresContext.h"
|
||||
@@ -100,16 +101,14 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
(eventType.EqualsLiteral("contextmenu") && mIsContext)))
|
||||
return NS_OK;
|
||||
|
||||
int16_t button;
|
||||
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
|
||||
MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
|
||||
if (!mouseEvent) {
|
||||
//non-ui event passed in. bad things.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the node that was clicked on.
|
||||
EventTarget* target = mouseEvent->AsEvent()->InternalDOMEvent()->GetTarget();
|
||||
EventTarget* target = mouseEvent->GetTarget();
|
||||
nsCOMPtr<nsIDOMNode> targetNode = do_QueryInterface(target);
|
||||
|
||||
if (!targetNode && mIsContext) {
|
||||
@@ -134,15 +133,14 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
}
|
||||
|
||||
{
|
||||
EventTarget* originalTarget = mouseEvent->AsEvent()->InternalDOMEvent()->GetOriginalTarget();
|
||||
EventTarget* originalTarget = mouseEvent->GetOriginalTarget();
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(originalTarget);
|
||||
if (content && EventStateManager::IsRemoteTarget(content)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
bool preventDefault;
|
||||
mouseEvent->AsEvent()->GetDefaultPrevented(&preventDefault);
|
||||
bool preventDefault = mouseEvent->DefaultPrevented();
|
||||
if (preventDefault && targetNode && mIsContext) {
|
||||
// Someone called preventDefault on a context menu.
|
||||
// Let's make sure they are allowed to do so.
|
||||
@@ -203,14 +201,14 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
}
|
||||
else {
|
||||
// Only open popups when the left mouse button is down.
|
||||
mouseEvent->GetButton(&button);
|
||||
if (button != 0)
|
||||
if (mouseEvent->Button() != 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Open the popup. LaunchPopup will call StopPropagation and PreventDefault
|
||||
// in the right situations.
|
||||
LaunchPopup(aEvent, targetContent);
|
||||
LaunchPopup(mouseEvent, targetContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -328,7 +326,7 @@ GetImmediateChild(nsIContent* aContent, nsAtom *aTag)
|
||||
// the popup content in the document.
|
||||
//
|
||||
nsresult
|
||||
nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
|
||||
nsXULPopupListener::LaunchPopup(MouseEvent* aEvent, nsIContent* aTargetContent)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@@ -416,10 +414,8 @@ nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
|
||||
false, true, false, aEvent);
|
||||
}
|
||||
else {
|
||||
int32_t xPos = 0, yPos = 0;
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
|
||||
mouseEvent->GetScreenX(&xPos);
|
||||
mouseEvent->GetScreenY(&yPos);
|
||||
int32_t xPos = aEvent->ScreenX(CallerType::System);
|
||||
int32_t yPos = aEvent->ScreenY(CallerType::System);
|
||||
|
||||
pm->ShowPopupAtScreen(mPopupContent, xPos, yPos, mIsContext, aEvent);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class MouseEvent;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsXULPopupListener : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
@@ -37,7 +43,8 @@ protected:
|
||||
|
||||
// open the popup. aEvent is the event that triggered the popup such as
|
||||
// a mouse click and aTargetContent is the target of this event.
|
||||
virtual nsresult LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent);
|
||||
virtual nsresult LaunchPopup(mozilla::dom::MouseEvent* aEvent,
|
||||
nsIContent* aTargetContent);
|
||||
|
||||
// close the popup when the listener goes away
|
||||
virtual void ClosePopup();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "nsXULTooltipListener.h"
|
||||
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsXULElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsGkAtoms.h"
|
||||
@@ -30,6 +29,7 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
||||
#include "mozilla/dom/BoxObject.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@@ -132,12 +132,12 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent)
|
||||
// timer callback. On win32, we'll get a MouseMove event even when a popup goes away --
|
||||
// even when the mouse doesn't change position! To get around this, we make sure the
|
||||
// mouse has really moved before proceeding.
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
|
||||
if (!mouseEvent)
|
||||
MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
|
||||
if (!mouseEvent) {
|
||||
return;
|
||||
int32_t newMouseX, newMouseY;
|
||||
mouseEvent->GetScreenX(&newMouseX);
|
||||
mouseEvent->GetScreenY(&newMouseY);
|
||||
}
|
||||
int32_t newMouseX = mouseEvent->ScreenX(CallerType::System);
|
||||
int32_t newMouseY = mouseEvent->ScreenY(CallerType::System);
|
||||
|
||||
// filter out false win32 MouseMove event
|
||||
if (mMouseScreenX == newMouseX && mMouseScreenY == newMouseY)
|
||||
@@ -330,7 +330,7 @@ nsXULTooltipListener::RemoveTooltipSupport(nsIContent* aNode)
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
void
|
||||
nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent)
|
||||
nsXULTooltipListener::CheckTreeBodyMove(MouseEvent* aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> sourceNode = do_QueryReferent(mSourceNode);
|
||||
if (!sourceNode)
|
||||
@@ -347,9 +347,8 @@ nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent)
|
||||
nsCOMPtr<nsITreeBoxObject> obx;
|
||||
GetSourceTreeBoxObject(getter_AddRefs(obx));
|
||||
if (bx && obx) {
|
||||
int32_t x, y;
|
||||
aMouseEvent->GetScreenX(&x);
|
||||
aMouseEvent->GetScreenY(&y);
|
||||
int32_t x = aMouseEvent->ScreenX(CallerType::System);
|
||||
int32_t y = aMouseEvent->ScreenY(CallerType::System);
|
||||
|
||||
int32_t row;
|
||||
nsCOMPtr<nsITreeColumn> col;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define nsXULTooltipListener_h__
|
||||
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@@ -22,6 +21,12 @@
|
||||
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class MouseEvent;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsXULTooltipListener final : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
@@ -50,7 +55,7 @@ protected:
|
||||
void KillTooltipTimer();
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
void CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent);
|
||||
void CheckTreeBodyMove(mozilla::dom::MouseEvent* aMouseEvent);
|
||||
nsresult GetSourceTreeBoxObject(nsITreeBoxObject** aBoxObject);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user