1 /* 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24 #ifndef UIEvent_h 25 #define UIEvent_h 26 27 #include "core/events/Event.h" 28 #include "core/events/EventDispatchMediator.h" 29 #include "core/frame/LocalDOMWindow.h" 30 31 namespace WebCore { 32 33 typedef LocalDOMWindow AbstractView; 34 35 struct UIEventInit : public EventInit { 36 UIEventInit(); 37 38 RefPtrWillBeMember<AbstractView> view; 39 int detail; 40 }; 41 42 class UIEvent : public Event { 43 public: create()44 static PassRefPtrWillBeRawPtr<UIEvent> create() 45 { 46 return adoptRefWillBeNoop(new UIEvent); 47 } create(const AtomicString & type,bool canBubble,bool cancelable,PassRefPtrWillBeRawPtr<AbstractView> view,int detail)48 static PassRefPtrWillBeRawPtr<UIEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, int detail) 49 { 50 return adoptRefWillBeNoop(new UIEvent(type, canBubble, cancelable, view, detail)); 51 } create(const AtomicString & type,const UIEventInit & initializer)52 static PassRefPtrWillBeRawPtr<UIEvent> create(const AtomicString& type, const UIEventInit& initializer) 53 { 54 return adoptRefWillBeNoop(new UIEvent(type, initializer)); 55 } 56 virtual ~UIEvent(); 57 58 void initUIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, int detail); 59 view()60 AbstractView* view() const { return m_view.get(); } view(bool & isNull)61 AbstractView* view(bool& isNull) const { isNull = !m_view; return m_view.get(); } detail()62 int detail() const { return m_detail; } 63 64 virtual const AtomicString& interfaceName() const OVERRIDE; 65 virtual bool isUIEvent() const OVERRIDE FINAL; 66 67 virtual int keyCode() const; 68 virtual int charCode() const; 69 70 virtual int layerX(); 71 virtual int layerY(); 72 73 virtual int pageX() const; 74 virtual int pageY() const; 75 76 virtual int which() const; 77 78 virtual void trace(Visitor*) OVERRIDE; 79 80 protected: 81 UIEvent(); 82 UIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, int detail); 83 UIEvent(const AtomicString&, const UIEventInit&); 84 85 private: 86 RefPtrWillBeMember<AbstractView> m_view; 87 int m_detail; 88 }; 89 90 } // namespace WebCore 91 92 #endif // UIEvent_h 93