Skip to content

Commit

Permalink
Bug 856303 - Paris binding for MouseScrollEvent, r=peterv
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 26aec7e5472d213615918f20168e3fd2277b0591
  • Loading branch information
Olli Pettay authored and Olli Pettay committed Apr 15, 2013
1 parent 190ea4a commit 29a9aaf
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 7 deletions.
17 changes: 11 additions & 6 deletions content/events/src/nsDOMMouseScrollEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
if(mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
mDetail = static_cast<nsMouseScrollEvent*>(mEvent)->delta;
}
SetIsDOMBinding();
}

nsDOMMouseScrollEvent::~nsDOMMouseScrollEvent()
Expand Down Expand Up @@ -78,15 +79,19 @@ NS_IMETHODIMP
nsDOMMouseScrollEvent::GetAxis(int32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = Axis();
return NS_OK;
}

int32_t
nsDOMMouseScrollEvent::Axis()
{
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
*aResult = static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal ?
static_cast<int32_t>(HORIZONTAL_AXIS) :
static_cast<int32_t>(VERTICAL_AXIS);
} else {
*aResult = 0;
return static_cast<nsMouseScrollEvent*>(mEvent)->isHorizontal ?
static_cast<int32_t>(HORIZONTAL_AXIS) :
static_cast<int32_t>(VERTICAL_AXIS);
}
return NS_OK;
return 0;
}

nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
Expand Down
23 changes: 23 additions & 0 deletions content/events/src/nsDOMMouseScrollEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "nsIDOMMouseScrollEvent.h"
#include "nsDOMMouseEvent.h"
#include "mozilla/dom/MouseScrollEventBinding.h"

class nsDOMMouseScrollEvent : public nsDOMMouseEvent,
public nsIDOMMouseScrollEvent
Expand All @@ -24,6 +25,28 @@ class nsDOMMouseScrollEvent : public nsDOMMouseEvent,

// Forward to base class
NS_FORWARD_TO_NSDOMMOUSEEVENT

virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
{
return mozilla::dom::MouseScrollEventBinding::Wrap(aCx, aScope, this);
}

int32_t Axis();

void InitMouseScrollEvent(const nsAString& aType, bool aCanBubble,
bool aCancelable, nsIDOMWindow* aView,
int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
int32_t aClientX, int32_t aClientY,
bool aCtrlKey, bool aAltKey, bool aShiftKey,
bool aMetaKey, uint16_t aButton,
nsIDOMEventTarget* aRelatedTarget, int32_t aAxis,
mozilla::ErrorResult& aRv)
{
aRv = InitMouseScrollEvent(aType, aCanBubble, aCancelable, aView,
aDetail, aScreenX, aScreenY, aClientX, aClientY,
aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
aRelatedTarget, aAxis);
}
};

#endif // nsDOMMouseScrollEvent_h__
5 changes: 5 additions & 0 deletions dom/bindings/Bindings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ DOMInterfaces = {
'hasXPConnectImpls': True,
},

'MouseScrollEvent': {
'nativeType': 'nsDOMMouseScrollEvent',
},


'MozChannel': [
{
'nativeType': 'nsIChannel',
Expand Down
33 changes: 33 additions & 0 deletions dom/webidl/MouseScrollEvent.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/

interface WindowProxy;

interface MouseScrollEvent : MouseEvent
{
const long HORIZONTAL_AXIS = 1;
const long VERTICAL_AXIS = 2;

readonly attribute long axis;

[Throws]
void initMouseScrollEvent(DOMString type,
boolean canBubble,
boolean cancelable,
WindowProxy? view,
long detail,
long screenX,
long screenY,
long clientX,
long clientY,
boolean ctrlKey,
boolean altKey,
boolean shiftKey,
boolean metaKey,
unsigned short button,
EventTarget? relatedTarget,
long axis);
};
1 change: 1 addition & 0 deletions dom/webidl/WebIDL.mk
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ webidl_files = \
MediaStream.webidl \
MessageEvent.webidl \
MouseEvent.webidl \
MouseScrollEvent.webidl \
MozActivity.webidl \
MutationEvent.webidl \
MutationObserver.webidl \
Expand Down
1 change: 0 additions & 1 deletion js/xpconnect/src/dom_quickstubs.qsconf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ members = [

'nsIDOMKeyEvent.*',
'nsIDOMDragEvent.*',
'nsIDOMMouseScrollEvent.*',
'nsIDOMProgressEvent.lengthComputable',
'nsIDOMProgressEvent.loaded',
'nsIDOMProgressEvent.total',
Expand Down

0 comments on commit 29a9aaf

Please sign in to comment.