1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/KeyboardEvent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 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_KeyboardEvent_h_ 1.10 +#define mozilla_dom_KeyboardEvent_h_ 1.11 + 1.12 +#include "mozilla/dom/UIEvent.h" 1.13 +#include "mozilla/dom/KeyboardEventBinding.h" 1.14 +#include "mozilla/EventForwards.h" 1.15 +#include "nsIDOMKeyEvent.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace dom { 1.19 + 1.20 +class KeyboardEvent : public UIEvent, 1.21 + public nsIDOMKeyEvent 1.22 +{ 1.23 +public: 1.24 + KeyboardEvent(EventTarget* aOwner, 1.25 + nsPresContext* aPresContext, 1.26 + WidgetKeyboardEvent* aEvent); 1.27 + 1.28 + NS_DECL_ISUPPORTS_INHERITED 1.29 + 1.30 + // nsIDOMKeyEvent Interface 1.31 + NS_DECL_NSIDOMKEYEVENT 1.32 + 1.33 + // Forward to base class 1.34 + NS_FORWARD_TO_UIEVENT 1.35 + 1.36 + static already_AddRefed<KeyboardEvent> Constructor( 1.37 + const GlobalObject& aGlobal, 1.38 + const nsAString& aType, 1.39 + const KeyboardEventInit& aParam, 1.40 + ErrorResult& aRv); 1.41 + 1.42 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE 1.43 + { 1.44 + return KeyboardEventBinding::Wrap(aCx, this); 1.45 + } 1.46 + 1.47 + bool AltKey(); 1.48 + bool CtrlKey(); 1.49 + bool ShiftKey(); 1.50 + bool MetaKey(); 1.51 + 1.52 + bool GetModifierState(const nsAString& aKey) 1.53 + { 1.54 + return GetModifierStateInternal(aKey); 1.55 + } 1.56 + 1.57 + bool Repeat(); 1.58 + bool IsComposing(); 1.59 + uint32_t CharCode(); 1.60 + uint32_t KeyCode(); 1.61 + virtual uint32_t Which() MOZ_OVERRIDE; 1.62 + uint32_t Location(); 1.63 + 1.64 + void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable, 1.65 + nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey, 1.66 + bool aShiftKey, bool aMetaKey, 1.67 + uint32_t aKeyCode, uint32_t aCharCode, 1.68 + ErrorResult& aRv) 1.69 + { 1.70 + aRv = InitKeyEvent(aType, aCanBubble, aCancelable, aView, 1.71 + aCtrlKey, aAltKey, aShiftKey,aMetaKey, 1.72 + aKeyCode, aCharCode); 1.73 + } 1.74 + 1.75 +private: 1.76 + // True, if the instance is created with Constructor(). 1.77 + bool mInitializedByCtor; 1.78 + // If the instance is created with Constructor(), which may have independent 1.79 + // value. mInitializedWhichValue stores it. I.e., this is invalid when 1.80 + // mInitializedByCtor is false. 1.81 + uint32_t mInitialzedWhichValue; 1.82 +}; 1.83 + 1.84 +} // namespace dom 1.85 +} // namespace mozilla 1.86 + 1.87 +#endif // mozilla_dom_KeyboardEvent_h_