Skip to content

Commit

Permalink
Bug 1446711 part 5. Get rid of nsIDOMMouseEvent::GetButton. r=qdot
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: AZWzObh01uI
  • Loading branch information
bzbarsky committed Mar 20, 2018
1 parent bd7fa05 commit 52c19ee
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 58 deletions.
8 changes: 0 additions & 8 deletions dom/events/MouseEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,6 @@ MouseEvent::InitNSMouseEvent(const nsAString& aType,
mouseEventBase->inputSource = aInputSource;
}

NS_IMETHODIMP
MouseEvent::GetButton(int16_t* aButton)
{
NS_ENSURE_ARG_POINTER(aButton);
*aButton = Button();
return NS_OK;
}

int16_t
MouseEvent::Button()
{
Expand Down
1 change: 0 additions & 1 deletion dom/interfaces/events/nsIDOMMouseEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface nsIDOMMouseEvent : nsIDOMUIEvent
readonly attribute long mozMovementX;
readonly attribute long mozMovementY;

readonly attribute short button;
readonly attribute unsigned short buttons;
readonly attribute nsIDOMEventTarget relatedTarget;

Expand Down
3 changes: 1 addition & 2 deletions dom/xbl/nsXBLEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "nsCOMPtr.h"
#include "nsAtom.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsXBLPrototypeHandler.h"
#include "nsContentUtils.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
Expand Down Expand Up @@ -64,7 +63,7 @@ nsXBLMouseEventHandler::~nsXBLMouseEventHandler()
bool
nsXBLMouseEventHandler::EventMatched(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouse(do_QueryInterface(aEvent));
MouseEvent* mouse = aEvent->InternalDOMEvent()->AsMouseEvent();
return mouse && mProtoHandler->MouseEventMatched(mouse);
}

Expand Down
17 changes: 8 additions & 9 deletions dom/xbl/nsXBLPrototypeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "nsGlobalWindowCommands.h"
#include "nsIContent.h"
#include "nsAtom.h"
#include "nsIDOMMouseEvent.h"
#include "nsNameSpaceManager.h"
#include "nsIDocument.h"
#include "nsIController.h"
Expand Down Expand Up @@ -50,6 +49,7 @@
#include "mozilla/dom/HTMLTextAreaElement.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/layers/KeyboardMap.h"
#include "xpcpublic.h"
Expand Down Expand Up @@ -728,22 +728,21 @@ nsXBLPrototypeHandler::KeyEventMatched(
}

bool
nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent)
nsXBLPrototypeHandler::MouseEventMatched(MouseEvent* aMouseEvent)
{
if (mDetail == -1 && mMisc == 0 && (mKeyMask & cAllModifiers) == 0)
return true; // No filters set up. It's generic.

int16_t button;
aMouseEvent->GetButton(&button);
if (mDetail != -1 && (button != mDetail))
if (mDetail != -1 && (aMouseEvent->Button() != mDetail)) {
return false;
}

int32_t clickcount;
aMouseEvent->GetDetail(&clickcount);
if (mMisc != 0 && (clickcount != mMisc))
if (mMisc != 0 && (aMouseEvent->Detail() != mMisc)) {
return false;
}

return ModifiersMatchMask(aMouseEvent, IgnoreModifierState());
return ModifiersMatchMask(static_cast<nsIDOMMouseEvent*>(aMouseEvent),
IgnoreModifierState());
}

struct keyCodeData {
Expand Down
12 changes: 2 additions & 10 deletions dom/xbl/nsXBLPrototypeHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
class nsIDOMEvent;
class nsIContent;
class nsIDOMUIEvent;
class nsIDOMMouseEvent;
class nsIObjectInputStream;
class nsIObjectOutputStream;
class nsXBLPrototypeBinding;
Expand All @@ -35,6 +34,7 @@ namespace dom {
class AutoJSAPI;
class EventTarget;
class KeyboardEvent;
class MouseEvent;
} // namespace dom

namespace layers {
Expand Down Expand Up @@ -118,15 +118,7 @@ class nsXBLPrototypeHandler
uint32_t aCharCode,
const IgnoreModifierState& aIgnoreModifierState);

bool MouseEventMatched(nsIDOMMouseEvent* aMouseEvent);
inline bool MouseEventMatched(nsAtom* aEventType,
nsIDOMMouseEvent* aEvent)
{
if (!EventTypeEquals(aEventType)) {
return false;
}
return MouseEventMatched(aEvent);
}
bool MouseEventMatched(mozilla::dom::MouseEvent* aMouseEvent);

already_AddRefed<mozilla::dom::Element> GetHandlerElement();

Expand Down
6 changes: 2 additions & 4 deletions editor/libeditor/HTMLEditorEventListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,12 @@ HTMLEditorEventListener::MouseDown(MouseEvent* aMouseEvent)
// XXX This should be easier to do!
// But eDOMEvents_contextmenu and eContextMenu is not exposed in any event
// interface :-(
int16_t buttonNumber;
nsresult rv = aMouseEvent->GetButton(&buttonNumber);
NS_ENSURE_SUCCESS(rv, rv);
int16_t buttonNumber = aMouseEvent->Button();

bool isContextClick = buttonNumber == 2;

int32_t clickCount;
rv = aMouseEvent->GetDetail(&clickCount);
nsresult rv = aMouseEvent->GetDetail(&clickCount);
NS_ENSURE_SUCCESS(rv, rv);

nsCOMPtr<nsIDOMEventTarget> target = aMouseEvent->GetExplicitOriginalTarget();
Expand Down
8 changes: 3 additions & 5 deletions extensions/spellcheck/src/mozInlineSpellChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "mozilla/TextEditor.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/Selection.h"
#include "mozInlineSpellWordUtil.h"
#include "mozISpellI18NManager.h"
Expand All @@ -50,7 +51,6 @@
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMEvent.h"
Expand Down Expand Up @@ -1854,14 +1854,12 @@ mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent)
nsresult
mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
NS_ENSURE_TRUE(mouseEvent, NS_OK);

// ignore any errors from HandleNavigationEvent as we don't want to prevent
// anyone else from seeing this event.
int16_t button;
mouseEvent->GetButton(&button);
HandleNavigationEvent(button != 0);
HandleNavigationEvent(mouseEvent->Button() != 0);
return NS_OK;
}

Expand Down
10 changes: 2 additions & 8 deletions layout/forms/nsListControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,14 +1564,8 @@ bool
nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent)
{
// only allow selection with the left button
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
if (mouseEvent) {
int16_t whichButton;
if (NS_SUCCEEDED(mouseEvent->GetButton(&whichButton))) {
return whichButton != 0?false:true;
}
}
return false;
MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
return mouseEvent && mouseEvent->Button() == 0;
}

nscoord
Expand Down
12 changes: 5 additions & 7 deletions layout/xul/nsSplitterFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "nsNameSpaceManager.h"
#include "nsScrollbarButtonFrame.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsIPresShell.h"
#include "nsFrameList.h"
#include "nsHTMLParts.h"
Expand All @@ -40,6 +39,7 @@
#include "nsContentUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/UniquePtr.h"
#include "nsBindingManager.h"
Expand Down Expand Up @@ -625,15 +625,13 @@ nsresult
nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
{
NS_ENSURE_TRUE(mOuter, NS_OK);
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
if (!mouseEvent)
dom::MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
if (!mouseEvent) {
return NS_OK;

int16_t button = 0;
mouseEvent->GetButton(&button);
}

// only if left button
if (button != 0)
if (mouseEvent->Button() != 0)
return NS_OK;

if (SplitterElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
Expand Down
7 changes: 3 additions & 4 deletions toolkit/components/satchel/nsFormFillController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/PageTransitionEvent.h"
#include "mozilla/Logging.h"
#include "nsIFormAutoComplete.h"
Expand All @@ -34,7 +35,6 @@
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsILoginManager.h"
#include "nsIDOMMouseEvent.h"
#include "mozilla/ModuleUtils.h"
#include "nsToolkitCompsCID.h"
#include "nsEmbedCID.h"
Expand Down Expand Up @@ -1179,7 +1179,7 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
nsresult
nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
if (!mouseEvent) {
return NS_ERROR_FAILURE;
}
Expand All @@ -1190,8 +1190,7 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
return NS_OK;
}

int16_t button;
mouseEvent->GetButton(&button);
int16_t button = mouseEvent->Button();

// In case of a right click we set a timestamp that
// will be checked in Focus() to avoid showing
Expand Down

0 comments on commit 52c19ee

Please sign in to comment.