michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_MouseEvent_h_ michael@0: #define mozilla_dom_MouseEvent_h_ michael@0: michael@0: #include "mozilla/dom/UIEvent.h" michael@0: #include "mozilla/dom/MouseEventBinding.h" michael@0: #include "mozilla/EventForwards.h" michael@0: #include "nsIDOMMouseEvent.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class MouseEvent : public UIEvent, michael@0: public nsIDOMMouseEvent michael@0: { michael@0: public: michael@0: MouseEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetMouseEventBase* aEvent); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIDOMMouseEvent Interface michael@0: NS_DECL_NSIDOMMOUSEEVENT michael@0: michael@0: // Forward to base class michael@0: NS_FORWARD_TO_UIEVENT michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE michael@0: { michael@0: return MouseEventBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: // Web IDL binding methods michael@0: virtual uint32_t Which() MOZ_OVERRIDE michael@0: { michael@0: return Button() + 1; michael@0: } michael@0: michael@0: int32_t ScreenX(); michael@0: int32_t ScreenY(); michael@0: int32_t ClientX(); michael@0: int32_t ClientY(); michael@0: bool CtrlKey(); michael@0: bool ShiftKey(); michael@0: bool AltKey(); michael@0: bool MetaKey(); michael@0: int16_t Button(); michael@0: uint16_t Buttons(); michael@0: already_AddRefed GetRelatedTarget(); michael@0: void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable, michael@0: nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, michael@0: int32_t aScreenY, int32_t aClientX, int32_t aClientY, michael@0: bool aCtrlKey, bool aAltKey, bool aShiftKey, michael@0: bool aMetaKey, uint16_t aButton, michael@0: EventTarget* aRelatedTarget, ErrorResult& aRv) michael@0: { michael@0: aRv = InitMouseEvent(aType, aCanBubble, aCancelable, michael@0: aView, aDetail, aScreenX, aScreenY, michael@0: aClientX, aClientY, aCtrlKey, aAltKey, michael@0: aShiftKey, aMetaKey, aButton, michael@0: aRelatedTarget); michael@0: } michael@0: bool GetModifierState(const nsAString& aKeyArg) michael@0: { michael@0: return GetModifierStateInternal(aKeyArg); michael@0: } michael@0: static already_AddRefed Constructor(const GlobalObject& aGlobal, michael@0: const nsAString& aType, michael@0: const MouseEventInit& aParam, michael@0: ErrorResult& aRv); michael@0: int32_t MozMovementX() michael@0: { michael@0: return GetMovementPoint().x; michael@0: } michael@0: int32_t MozMovementY() michael@0: { michael@0: return GetMovementPoint().y; michael@0: } michael@0: float MozPressure() const; michael@0: uint16_t MozInputSource() const; michael@0: void InitNSMouseEvent(const nsAString& aType, michael@0: bool aCanBubble, bool aCancelable, michael@0: nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, michael@0: int32_t aScreenY, int32_t aClientX, int32_t aClientY, michael@0: bool aCtrlKey, bool aAltKey, bool aShiftKey, michael@0: bool aMetaKey, uint16_t aButton, michael@0: EventTarget* aRelatedTarget, michael@0: float aPressure, uint16_t aInputSource, michael@0: ErrorResult& aRv) michael@0: { michael@0: aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable, michael@0: aView, aDetail, aScreenX, aScreenY, michael@0: aClientX, aClientY, aCtrlKey, aAltKey, michael@0: aShiftKey, aMetaKey, aButton, michael@0: aRelatedTarget, aPressure, aInputSource); michael@0: } michael@0: michael@0: protected: michael@0: nsresult InitMouseEvent(const nsAString& aType, michael@0: bool aCanBubble, michael@0: bool aCancelable, michael@0: nsIDOMWindow* aView, michael@0: int32_t aDetail, michael@0: int32_t aScreenX, michael@0: int32_t aScreenY, michael@0: int32_t aClientX, michael@0: int32_t aClientY, michael@0: int16_t aButton, michael@0: nsIDOMEventTarget* aRelatedTarget, michael@0: const nsAString& aModifiersList); michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #define NS_FORWARD_TO_MOUSEEVENT \ michael@0: NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \ michael@0: NS_FORWARD_TO_UIEVENT michael@0: michael@0: #endif // mozilla_dom_MouseEvent_h_