1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/MouseEvent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,125 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_dom_MouseEvent_h_ 1.10 +#define mozilla_dom_MouseEvent_h_ 1.11 + 1.12 +#include "mozilla/dom/UIEvent.h" 1.13 +#include "mozilla/dom/MouseEventBinding.h" 1.14 +#include "mozilla/EventForwards.h" 1.15 +#include "nsIDOMMouseEvent.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace dom { 1.19 + 1.20 +class MouseEvent : public UIEvent, 1.21 + public nsIDOMMouseEvent 1.22 +{ 1.23 +public: 1.24 + MouseEvent(EventTarget* aOwner, 1.25 + nsPresContext* aPresContext, 1.26 + WidgetMouseEventBase* aEvent); 1.27 + 1.28 + NS_DECL_ISUPPORTS_INHERITED 1.29 + 1.30 + // nsIDOMMouseEvent Interface 1.31 + NS_DECL_NSIDOMMOUSEEVENT 1.32 + 1.33 + // Forward to base class 1.34 + NS_FORWARD_TO_UIEVENT 1.35 + 1.36 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE 1.37 + { 1.38 + return MouseEventBinding::Wrap(aCx, this); 1.39 + } 1.40 + 1.41 + // Web IDL binding methods 1.42 + virtual uint32_t Which() MOZ_OVERRIDE 1.43 + { 1.44 + return Button() + 1; 1.45 + } 1.46 + 1.47 + int32_t ScreenX(); 1.48 + int32_t ScreenY(); 1.49 + int32_t ClientX(); 1.50 + int32_t ClientY(); 1.51 + bool CtrlKey(); 1.52 + bool ShiftKey(); 1.53 + bool AltKey(); 1.54 + bool MetaKey(); 1.55 + int16_t Button(); 1.56 + uint16_t Buttons(); 1.57 + already_AddRefed<EventTarget> GetRelatedTarget(); 1.58 + void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable, 1.59 + nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, 1.60 + int32_t aScreenY, int32_t aClientX, int32_t aClientY, 1.61 + bool aCtrlKey, bool aAltKey, bool aShiftKey, 1.62 + bool aMetaKey, uint16_t aButton, 1.63 + EventTarget* aRelatedTarget, ErrorResult& aRv) 1.64 + { 1.65 + aRv = InitMouseEvent(aType, aCanBubble, aCancelable, 1.66 + aView, aDetail, aScreenX, aScreenY, 1.67 + aClientX, aClientY, aCtrlKey, aAltKey, 1.68 + aShiftKey, aMetaKey, aButton, 1.69 + aRelatedTarget); 1.70 + } 1.71 + bool GetModifierState(const nsAString& aKeyArg) 1.72 + { 1.73 + return GetModifierStateInternal(aKeyArg); 1.74 + } 1.75 + static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal, 1.76 + const nsAString& aType, 1.77 + const MouseEventInit& aParam, 1.78 + ErrorResult& aRv); 1.79 + int32_t MozMovementX() 1.80 + { 1.81 + return GetMovementPoint().x; 1.82 + } 1.83 + int32_t MozMovementY() 1.84 + { 1.85 + return GetMovementPoint().y; 1.86 + } 1.87 + float MozPressure() const; 1.88 + uint16_t MozInputSource() const; 1.89 + void InitNSMouseEvent(const nsAString& aType, 1.90 + bool aCanBubble, bool aCancelable, 1.91 + nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, 1.92 + int32_t aScreenY, int32_t aClientX, int32_t aClientY, 1.93 + bool aCtrlKey, bool aAltKey, bool aShiftKey, 1.94 + bool aMetaKey, uint16_t aButton, 1.95 + EventTarget* aRelatedTarget, 1.96 + float aPressure, uint16_t aInputSource, 1.97 + ErrorResult& aRv) 1.98 + { 1.99 + aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable, 1.100 + aView, aDetail, aScreenX, aScreenY, 1.101 + aClientX, aClientY, aCtrlKey, aAltKey, 1.102 + aShiftKey, aMetaKey, aButton, 1.103 + aRelatedTarget, aPressure, aInputSource); 1.104 + } 1.105 + 1.106 +protected: 1.107 + nsresult InitMouseEvent(const nsAString& aType, 1.108 + bool aCanBubble, 1.109 + bool aCancelable, 1.110 + nsIDOMWindow* aView, 1.111 + int32_t aDetail, 1.112 + int32_t aScreenX, 1.113 + int32_t aScreenY, 1.114 + int32_t aClientX, 1.115 + int32_t aClientY, 1.116 + int16_t aButton, 1.117 + nsIDOMEventTarget* aRelatedTarget, 1.118 + const nsAString& aModifiersList); 1.119 +}; 1.120 + 1.121 +} // namespace dom 1.122 +} // namespace mozilla 1.123 + 1.124 +#define NS_FORWARD_TO_MOUSEEVENT \ 1.125 + NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \ 1.126 + NS_FORWARD_TO_UIEVENT 1.127 + 1.128 +#endif // mozilla_dom_MouseEvent_h_