EventSendingController.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2010, 2011 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 EventSendingController_h
  26. #define EventSendingController_h
  27. #include "JSWrappable.h"
  28. #include <WebKit2/WKEvent.h>
  29. #include <WebKit2/WKGeometry.h>
  30. #include <wtf/PassRefPtr.h>
  31. #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(GTK) && !PLATFORM(EFL)
  32. #define USE_WEBPROCESS_EVENT_SIMULATION
  33. #endif
  34. namespace WTR {
  35. class EventSendingController : public JSWrappable {
  36. public:
  37. static PassRefPtr<EventSendingController> create();
  38. virtual ~EventSendingController();
  39. void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
  40. // JSWrappable
  41. virtual JSClassRef wrapperClass();
  42. void mouseDown(int button, JSValueRef modifierArray);
  43. void mouseUp(int button, JSValueRef modifierArray);
  44. void mouseMoveTo(int x, int y);
  45. void mouseScrollBy(int x, int y);
  46. void continuousMouseScrollBy(int x, int y, bool paged);
  47. JSValueRef contextClick();
  48. void leapForward(int milliseconds);
  49. void scheduleAsynchronousClick();
  50. void keyDown(JSStringRef key, JSValueRef modifierArray, int location);
  51. void scheduleAsynchronousKeyDown(JSStringRef key);
  52. // Zoom functions.
  53. void textZoomIn();
  54. void textZoomOut();
  55. void zoomPageIn();
  56. void zoomPageOut();
  57. void scalePageBy(double scale, double x, double y);
  58. #if ENABLE(TOUCH_EVENTS)
  59. // Touch events.
  60. void addTouchPoint(int x, int y);
  61. void updateTouchPoint(int index, int x, int y);
  62. void setTouchModifier(const JSStringRef &modifier, bool enable);
  63. void setTouchPointRadius(int radiusX, int radiusY);
  64. void touchStart();
  65. void touchMove();
  66. void touchEnd();
  67. void touchCancel();
  68. void clearTouchPoints();
  69. void releaseTouchPoint(int index);
  70. void cancelTouchPoint(int index);
  71. #endif
  72. private:
  73. EventSendingController();
  74. #ifdef USE_WEBPROCESS_EVENT_SIMULATION
  75. void updateClickCount(WKEventMouseButton);
  76. double m_time;
  77. WKPoint m_position;
  78. int m_clickCount;
  79. double m_clickTime;
  80. WKPoint m_clickPosition;
  81. WKEventMouseButton m_clickButton;
  82. #endif
  83. };
  84. } // namespace WTR
  85. #endif // EventSendingController_h