NativeWebKeyboardEvent.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2010 Apple Inc. All rights reserved.
  3. * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
  4. * Copyright (C) 2011, 2012 Igalia S.L
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  17. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  19. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  25. * THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef NativeWebKeyboardEvent_h
  28. #define NativeWebKeyboardEvent_h
  29. #include "WebEvent.h"
  30. #if PLATFORM(MAC)
  31. #include <wtf/RetainPtr.h>
  32. OBJC_CLASS NSView;
  33. #elif PLATFORM(QT)
  34. #include <QKeyEvent>
  35. #elif PLATFORM(GTK)
  36. #include <GOwnPtrGtk.h>
  37. #include <WebCore/CompositionResults.h>
  38. #include <WebCore/GtkInputMethodFilter.h>
  39. typedef union _GdkEvent GdkEvent;
  40. #elif PLATFORM(MANX)
  41. #include <manx/KeyboardEvent.h>
  42. #include <wtf/OwnPtr.h>
  43. #elif PLATFORM(EFL)
  44. #include <Evas.h>
  45. #endif
  46. namespace WebKit {
  47. class NativeWebKeyboardEvent : public WebKeyboardEvent {
  48. public:
  49. #if USE(APPKIT)
  50. NativeWebKeyboardEvent(NSEvent *, NSView *);
  51. #elif PLATFORM(QT)
  52. explicit NativeWebKeyboardEvent(QKeyEvent*);
  53. #elif PLATFORM(GTK)
  54. NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
  55. NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, WebCore::GtkInputMethodFilter::EventFakedForComposition);
  56. #elif PLATFORM(MANX)
  57. NativeWebKeyboardEvent(const Manx::KeyboardEvent&);
  58. #elif PLATFORM(EFL)
  59. NativeWebKeyboardEvent(const Evas_Event_Key_Down*, bool);
  60. NativeWebKeyboardEvent(const Evas_Event_Key_Up*);
  61. #endif
  62. #if USE(APPKIT)
  63. NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
  64. #elif PLATFORM(QT)
  65. const QKeyEvent* nativeEvent() const { return &m_nativeEvent; }
  66. #elif PLATFORM(GTK)
  67. GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
  68. const WebCore::CompositionResults& compositionResults() const { return m_compositionResults; }
  69. bool isFakeEventForComposition() const { return m_fakeEventForComposition; }
  70. #elif PLATFORM(MANX)
  71. const Manx::KeyboardEvent* nativeEvent() const { return &m_nativeEvent; }
  72. #elif PLATFORM(EFL)
  73. const void* nativeEvent() const { return m_nativeEvent; }
  74. bool isFiltered() const { return m_isFiltered; }
  75. #endif
  76. private:
  77. #if USE(APPKIT)
  78. RetainPtr<NSEvent> m_nativeEvent;
  79. #elif PLATFORM(QT)
  80. QKeyEvent m_nativeEvent;
  81. #elif PLATFORM(GTK)
  82. GOwnPtr<GdkEvent> m_nativeEvent;
  83. WebCore::CompositionResults m_compositionResults;
  84. bool m_fakeEventForComposition;
  85. #elif PLATFORM(MANX)
  86. Manx::KeyboardEvent m_nativeEvent;
  87. #elif PLATFORM(EFL)
  88. const void* m_nativeEvent;
  89. bool m_isFiltered;
  90. #endif
  91. };
  92. } // namespace WebKit
  93. #endif // NativeWebKeyboardEvent_h