blob: 47a8e4917b74c73876d158f46161973844e06167 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_
#define WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_
#include "third_party/npapi/bindings/npapi.h"
namespace WebKit {
class WebInputEvent;
class WebKeyboardEvent;
class WebMouseEvent;
class WebMouseWheelEvent;
}
namespace webkit {
namespace npapi {
// Utility class to translating WebInputEvent structs to equivalent structures
// suitable for sending to Mac plugins (via NPP_HandleEvent).
class PluginWebEventConverter {
public:
PluginWebEventConverter();
virtual ~PluginWebEventConverter();
// Initializes a converter for the given web event. Returns false if the event
// could not be converted.
bool InitWithEvent(const WebKit::WebInputEvent& web_event);
// Returns a pointer to a plugin event--suitable for passing to
// NPP_HandleEvent--corresponding to the the web event this converter was
// created with. The pointer is valid only as long as this object is.
// Returns NULL iff InitWithEvent returned false.
NPCocoaEvent* plugin_event() { return &cocoa_event_; }
private:
// Stores a converted plugin representation of the given web event, suitable
// for returning from plugin_event.
// Returns true if the event was successfully converted.
bool ConvertKeyboardEvent(const WebKit::WebKeyboardEvent& web_event);
bool ConvertMouseEvent(const WebKit::WebMouseEvent& web_event);
bool ConvertMouseWheelEvent(const WebKit::WebMouseWheelEvent& web_event);
// Returns the Cocoa translation of web_event's modifiers.
static NSUInteger CocoaModifiers(const WebKit::WebInputEvent& web_event);
NPCocoaEvent cocoa_event_;
DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter);
};
} // namespace npapi
} // namespace webkit
#endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_
|