Bug 1446711 part 5. Get rid of nsIDOMMouseEvent::GetButton. r=qdot

MozReview-Commit-ID: AZWzObh01uI
This commit is contained in:
Boris Zbarsky
2018-03-20 00:16:06 -04:00
parent 038b06c23d
commit 3352976d14
10 changed files with 26 additions and 58 deletions

View File

@@ -227,14 +227,6 @@ MouseEvent::InitNSMouseEvent(const nsAString& aType,
mouseEventBase->inputSource = aInputSource; mouseEventBase->inputSource = aInputSource;
} }
NS_IMETHODIMP
MouseEvent::GetButton(int16_t* aButton)
{
NS_ENSURE_ARG_POINTER(aButton);
*aButton = Button();
return NS_OK;
}
int16_t int16_t
MouseEvent::Button() MouseEvent::Button()
{ {

View File

@@ -19,7 +19,6 @@ interface nsIDOMMouseEvent : nsIDOMUIEvent
readonly attribute long mozMovementX; readonly attribute long mozMovementX;
readonly attribute long mozMovementY; readonly attribute long mozMovementY;
readonly attribute short button;
readonly attribute unsigned short buttons; readonly attribute unsigned short buttons;
readonly attribute nsIDOMEventTarget relatedTarget; readonly attribute nsIDOMEventTarget relatedTarget;

View File

@@ -7,7 +7,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsAtom.h" #include "nsAtom.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsXBLPrototypeHandler.h" #include "nsXBLPrototypeHandler.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
@@ -64,7 +63,7 @@ nsXBLMouseEventHandler::~nsXBLMouseEventHandler()
bool bool
nsXBLMouseEventHandler::EventMatched(nsIDOMEvent* aEvent) nsXBLMouseEventHandler::EventMatched(nsIDOMEvent* aEvent)
{ {
nsCOMPtr<nsIDOMMouseEvent> mouse(do_QueryInterface(aEvent)); MouseEvent* mouse = aEvent->InternalDOMEvent()->AsMouseEvent();
return mouse && mProtoHandler->MouseEventMatched(mouse); return mouse && mProtoHandler->MouseEventMatched(mouse);
} }

View File

@@ -15,7 +15,6 @@
#include "nsGlobalWindowCommands.h" #include "nsGlobalWindowCommands.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsAtom.h" #include "nsAtom.h"
#include "nsIDOMMouseEvent.h"
#include "nsNameSpaceManager.h" #include "nsNameSpaceManager.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIController.h" #include "nsIController.h"
@@ -50,6 +49,7 @@
#include "mozilla/dom/HTMLTextAreaElement.h" #include "mozilla/dom/HTMLTextAreaElement.h"
#include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h" #include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "mozilla/layers/KeyboardMap.h" #include "mozilla/layers/KeyboardMap.h"
#include "xpcpublic.h" #include "xpcpublic.h"
@@ -728,22 +728,21 @@ nsXBLPrototypeHandler::KeyEventMatched(
} }
bool bool
nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent) nsXBLPrototypeHandler::MouseEventMatched(MouseEvent* aMouseEvent)
{ {
if (mDetail == -1 && mMisc == 0 && (mKeyMask & cAllModifiers) == 0) if (mDetail == -1 && mMisc == 0 && (mKeyMask & cAllModifiers) == 0)
return true; // No filters set up. It's generic. return true; // No filters set up. It's generic.
int16_t button; if (mDetail != -1 && (aMouseEvent->Button() != mDetail)) {
aMouseEvent->GetButton(&button);
if (mDetail != -1 && (button != mDetail))
return false; return false;
}
int32_t clickcount; if (mMisc != 0 && (aMouseEvent->Detail() != mMisc)) {
aMouseEvent->GetDetail(&clickcount);
if (mMisc != 0 && (clickcount != mMisc))
return false; return false;
}
return ModifiersMatchMask(aMouseEvent, IgnoreModifierState()); return ModifiersMatchMask(static_cast<nsIDOMMouseEvent*>(aMouseEvent),
IgnoreModifierState());
} }
struct keyCodeData { struct keyCodeData {

View File

@@ -22,7 +22,6 @@
class nsIDOMEvent; class nsIDOMEvent;
class nsIContent; class nsIContent;
class nsIDOMUIEvent; class nsIDOMUIEvent;
class nsIDOMMouseEvent;
class nsIObjectInputStream; class nsIObjectInputStream;
class nsIObjectOutputStream; class nsIObjectOutputStream;
class nsXBLPrototypeBinding; class nsXBLPrototypeBinding;
@@ -35,6 +34,7 @@ namespace dom {
class AutoJSAPI; class AutoJSAPI;
class EventTarget; class EventTarget;
class KeyboardEvent; class KeyboardEvent;
class MouseEvent;
} // namespace dom } // namespace dom
namespace layers { namespace layers {
@@ -118,15 +118,7 @@ public:
uint32_t aCharCode, uint32_t aCharCode,
const IgnoreModifierState& aIgnoreModifierState); const IgnoreModifierState& aIgnoreModifierState);
bool MouseEventMatched(nsIDOMMouseEvent* aMouseEvent); bool MouseEventMatched(mozilla::dom::MouseEvent* aMouseEvent);
inline bool MouseEventMatched(nsAtom* aEventType,
nsIDOMMouseEvent* aEvent)
{
if (!EventTypeEquals(aEventType)) {
return false;
}
return MouseEventMatched(aEvent);
}
already_AddRefed<mozilla::dom::Element> GetHandlerElement(); already_AddRefed<mozilla::dom::Element> GetHandlerElement();

View File

@@ -95,14 +95,12 @@ HTMLEditorEventListener::MouseDown(MouseEvent* aMouseEvent)
// XXX This should be easier to do! // XXX This should be easier to do!
// But eDOMEvents_contextmenu and eContextMenu is not exposed in any event // But eDOMEvents_contextmenu and eContextMenu is not exposed in any event
// interface :-( // interface :-(
int16_t buttonNumber; int16_t buttonNumber = aMouseEvent->Button();
nsresult rv = aMouseEvent->GetButton(&buttonNumber);
NS_ENSURE_SUCCESS(rv, rv);
bool isContextClick = buttonNumber == 2; bool isContextClick = buttonNumber == 2;
int32_t clickCount; int32_t clickCount;
rv = aMouseEvent->GetDetail(&clickCount); nsresult rv = aMouseEvent->GetDetail(&clickCount);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMEventTarget> target = aMouseEvent->GetExplicitOriginalTarget(); nsCOMPtr<nsIDOMEventTarget> target = aMouseEvent->GetExplicitOriginalTarget();

View File

@@ -41,6 +41,7 @@
#include "mozilla/TextEditor.h" #include "mozilla/TextEditor.h"
#include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h" #include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/Selection.h" #include "mozilla/dom/Selection.h"
#include "mozInlineSpellWordUtil.h" #include "mozInlineSpellWordUtil.h"
#include "mozISpellI18NManager.h" #include "mozISpellI18NManager.h"
@@ -50,7 +51,6 @@
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsIDOMEvent.h" #include "nsIDOMEvent.h"
@@ -1854,14 +1854,12 @@ mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent)
nsresult nsresult
mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent) mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent)
{ {
nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent); MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
NS_ENSURE_TRUE(mouseEvent, NS_OK); NS_ENSURE_TRUE(mouseEvent, NS_OK);
// ignore any errors from HandleNavigationEvent as we don't want to prevent // ignore any errors from HandleNavigationEvent as we don't want to prevent
// anyone else from seeing this event. // anyone else from seeing this event.
int16_t button; HandleNavigationEvent(mouseEvent->Button() != 0);
mouseEvent->GetButton(&button);
HandleNavigationEvent(button != 0);
return NS_OK; return NS_OK;
} }

View File

@@ -1564,14 +1564,8 @@ bool
nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent) nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent)
{ {
// only allow selection with the left button // only allow selection with the left button
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent); MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
if (mouseEvent) { return mouseEvent && mouseEvent->Button() == 0;
int16_t whichButton;
if (NS_SUCCEEDED(mouseEvent->GetButton(&whichButton))) {
return whichButton != 0?false:true;
}
}
return false;
} }
nscoord nscoord

View File

@@ -21,7 +21,6 @@
#include "nsNameSpaceManager.h" #include "nsNameSpaceManager.h"
#include "nsScrollbarButtonFrame.h" #include "nsScrollbarButtonFrame.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsFrameList.h" #include "nsFrameList.h"
#include "nsHTMLParts.h" #include "nsHTMLParts.h"
@@ -40,6 +39,7 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/MouseEvents.h" #include "mozilla/MouseEvents.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsBindingManager.h" #include "nsBindingManager.h"
@@ -625,15 +625,13 @@ nsresult
nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
{ {
NS_ENSURE_TRUE(mOuter, NS_OK); NS_ENSURE_TRUE(mOuter, NS_OK);
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent)); dom::MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
if (!mouseEvent) if (!mouseEvent) {
return NS_OK; return NS_OK;
}
int16_t button = 0;
mouseEvent->GetButton(&button);
// only if left button // only if left button
if (button != 0) if (mouseEvent->Button() != 0)
return NS_OK; return NS_OK;
if (SplitterElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled, if (SplitterElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,

View File

@@ -14,6 +14,7 @@
#include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h" #include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/PageTransitionEvent.h" #include "mozilla/dom/PageTransitionEvent.h"
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "nsIFormAutoComplete.h" #include "nsIFormAutoComplete.h"
@@ -34,7 +35,6 @@
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsRect.h" #include "nsRect.h"
#include "nsILoginManager.h" #include "nsILoginManager.h"
#include "nsIDOMMouseEvent.h"
#include "mozilla/ModuleUtils.h" #include "mozilla/ModuleUtils.h"
#include "nsToolkitCompsCID.h" #include "nsToolkitCompsCID.h"
#include "nsEmbedCID.h" #include "nsEmbedCID.h"
@@ -1179,7 +1179,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
nsresult nsresult
nsFormFillController::MouseDown(nsIDOMEvent* aEvent) nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
{ {
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent)); MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
if (!mouseEvent) { if (!mouseEvent) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@@ -1190,8 +1190,7 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
return NS_OK; return NS_OK;
} }
int16_t button; int16_t button = mouseEvent->Button();
mouseEvent->GetButton(&button);
// In case of a right click we set a timestamp that // In case of a right click we set a timestamp that
// will be checked in Focus() to avoid showing // will be checked in Focus() to avoid showing