PlatformWebView.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2010 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef PlatformWebView_h
  26. #define PlatformWebView_h
  27. #if USE(CG)
  28. #include <CoreGraphics/CGGeometry.h>
  29. #endif
  30. #ifdef __APPLE__
  31. #ifdef __OBJC__
  32. @class WKView;
  33. @class NSWindow;
  34. #else
  35. class WKView;
  36. class NSWindow;
  37. #endif
  38. typedef WKView *PlatformWKView;
  39. typedef NSWindow *PlatformWindow;
  40. #elif defined(WIN32) || defined(_WIN32)
  41. typedef WKViewRef PlatformWKView;
  42. typedef HWND PlatformWindow;
  43. #elif PLATFORM(GTK)
  44. typedef WKViewRef PlatformWKView;
  45. typedef GtkWidget *PlatformWindow;
  46. #elif PLATFORM(EFL)
  47. typedef struct _Ecore_Evas Ecore_Evas;
  48. #if USE(EO)
  49. typedef struct _Eo Evas_Object;
  50. #else
  51. typedef struct _Evas_Object Evas_Object;
  52. #endif
  53. typedef Evas_Object* PlatformWKView;
  54. typedef Ecore_Evas* PlatformWindow;
  55. #elif PLATFORM(QT)
  56. QT_BEGIN_NAMESPACE
  57. class QQuickView;
  58. QT_END_NAMESPACE
  59. class QQuickWebView;
  60. typedef QQuickWebView* PlatformWKView;
  61. typedef QQuickView* PlatformWindow;
  62. #endif
  63. namespace TestWebKitAPI {
  64. #if PLATFORM(WIN)
  65. class WindowMessageObserver;
  66. #endif
  67. class PlatformWebView {
  68. public:
  69. PlatformWebView(WKContextRef, WKPageGroupRef = 0);
  70. ~PlatformWebView();
  71. WKPageRef page() const;
  72. PlatformWKView platformView() const { return m_view; }
  73. void resizeTo(unsigned width, unsigned height);
  74. void focus();
  75. void simulateSpacebarKeyPress();
  76. void simulateAltKeyPress();
  77. void simulateRightClick(unsigned x, unsigned y);
  78. void simulateMouseMove(unsigned x, unsigned y);
  79. #if PLATFORM(WIN)
  80. void simulateAKeyDown();
  81. void setParentWindowMessageObserver(WindowMessageObserver* observer) { m_parentWindowMessageObserver = observer; }
  82. #endif
  83. private:
  84. #if PLATFORM(WIN)
  85. static void registerWindowClass();
  86. static LRESULT CALLBACK wndProc(HWND, UINT message, WPARAM, LPARAM);
  87. #endif
  88. PlatformWKView m_view;
  89. PlatformWindow m_window;
  90. #if PLATFORM(WIN)
  91. WindowMessageObserver* m_parentWindowMessageObserver;
  92. #endif
  93. };
  94. } // namespace TestWebKitAPI
  95. #endif // PlatformWebView_h