| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ |
| 6 #define PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "ppapi/shared_impl/resource.h" |
| 11 #include "ppapi/thunk/ppb_input_event_api.h" | 13 #include "ppapi/thunk/ppb_input_event_api.h" |
| 12 | 14 |
| 13 namespace ppapi { | 15 namespace ppapi { |
| 14 | 16 |
| 15 // IF YOU ADD STUFF TO THIS CLASS | 17 // IF YOU ADD STUFF TO THIS CLASS |
| 16 // ============================== | 18 // ============================== |
| 17 // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h | 19 // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h |
| 18 struct InputEventData { | 20 struct InputEventData { |
| 19 InputEventData(); | 21 InputEventData(); |
| 20 ~InputEventData(); | 22 ~InputEventData(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 PP_FloatPoint wheel_ticks; | 37 PP_FloatPoint wheel_ticks; |
| 36 bool wheel_scroll_by_page; | 38 bool wheel_scroll_by_page; |
| 37 | 39 |
| 38 uint32_t key_code; | 40 uint32_t key_code; |
| 39 | 41 |
| 40 std::string character_text; | 42 std::string character_text; |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 // This simple class implements the PPB_InputEvent_API in terms of the | 45 // This simple class implements the PPB_InputEvent_API in terms of the |
| 44 // shared InputEventData structure | 46 // shared InputEventData structure |
| 45 class InputEventImpl : public thunk::PPB_InputEvent_API { | 47 class InputEventImpl : public Resource, public thunk::PPB_InputEvent_API { |
| 46 public: | 48 public: |
| 47 explicit InputEventImpl(const InputEventData& data); | 49 struct InitAsImpl {}; |
| 50 struct InitAsProxy {}; |
| 51 |
| 52 // The dummy arguments control which version of Resource's constructor is |
| 53 // called for this base class. |
| 54 InputEventImpl(const InitAsImpl&, |
| 55 PP_Instance instance, |
| 56 const InputEventData& data); |
| 57 InputEventImpl(const InitAsProxy&, |
| 58 PP_Instance instance, |
| 59 const InputEventData& data); |
| 60 |
| 61 // Resource overrides. |
| 62 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; |
| 48 | 63 |
| 49 // PPB_InputEvent_API implementation. | 64 // PPB_InputEvent_API implementation. |
| 50 virtual const InputEventData& GetInputEventData() const OVERRIDE; | 65 virtual const InputEventData& GetInputEventData() const OVERRIDE; |
| 51 virtual PP_InputEvent_Type GetType() OVERRIDE; | 66 virtual PP_InputEvent_Type GetType() OVERRIDE; |
| 52 virtual PP_TimeTicks GetTimeStamp() OVERRIDE; | 67 virtual PP_TimeTicks GetTimeStamp() OVERRIDE; |
| 53 virtual uint32_t GetModifiers() OVERRIDE; | 68 virtual uint32_t GetModifiers() OVERRIDE; |
| 54 virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE; | 69 virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE; |
| 55 virtual PP_Point GetMousePosition() OVERRIDE; | 70 virtual PP_Point GetMousePosition() OVERRIDE; |
| 56 virtual int32_t GetMouseClickCount() OVERRIDE; | 71 virtual int32_t GetMouseClickCount() OVERRIDE; |
| 57 virtual PP_FloatPoint GetWheelDelta() OVERRIDE; | 72 virtual PP_FloatPoint GetWheelDelta() OVERRIDE; |
| 58 virtual PP_FloatPoint GetWheelTicks() OVERRIDE; | 73 virtual PP_FloatPoint GetWheelTicks() OVERRIDE; |
| 59 virtual PP_Bool GetWheelScrollByPage() OVERRIDE; | 74 virtual PP_Bool GetWheelScrollByPage() OVERRIDE; |
| 60 virtual uint32_t GetKeyCode() OVERRIDE; | 75 virtual uint32_t GetKeyCode() OVERRIDE; |
| 61 virtual PP_Var GetCharacterText() OVERRIDE; | 76 virtual PP_Var GetCharacterText() OVERRIDE; |
| 62 | 77 |
| 63 protected: | |
| 64 // Derived classes override this to convert a string to a PP_Var in either | |
| 65 // the proxy or the impl. | |
| 66 virtual PP_Var StringToPPVar(const std::string& str) = 0; | |
| 67 | |
| 68 private: | 78 private: |
| 69 InputEventData data_; | 79 InputEventData data_; |
| 80 |
| 81 DISALLOW_IMPLICIT_CONSTRUCTORS(InputEventImpl); |
| 70 }; | 82 }; |
| 71 | 83 |
| 72 } // namespace ppapi | 84 } // namespace ppapi |
| 73 | 85 |
| 74 #endif // PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ | 86 #endif // PPAPI_SHARED_IMPL_INPUT_EVENT_IMPL_H_ |
| 75 | 87 |
| OLD | NEW |