| Index: content/browser/renderer_host/web_input_event_factory_android.cc
|
| diff --git a/content/browser/renderer_host/web_input_event_factory_android.cc b/content/browser/renderer_host/web_input_event_factory_android.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..827ea13cdb898658742c3c42e3f53ebe5dfa8707
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/web_input_event_factory_android.cc
|
| @@ -0,0 +1,159 @@
|
| +// Copyright (c) 2013 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.
|
| +
|
| +#include "content/browser/renderer_host/web_input_event_factory_android.h"
|
| +
|
| +#include "third_party/WebKit/public/web/WebInputEvent.h"
|
| +#include "ui/base/keycodes/keyboard_codes_posix.h"
|
| +#include "ui/base/keycodes/keyboard_code_conversion.h"
|
| +
|
| +namespace content {
|
| +
|
| +using WebKit::WebInputEvent;
|
| +using WebKit::WebKeyboardEvent;
|
| +using WebKit::WebGestureEvent;
|
| +using WebKit::WebMouseEvent;
|
| +using WebKit::WebMouseWheelEvent;
|
| +
|
| +WebKeyboardEvent WebInputEventFactory::keyboardEvent(WebInputEvent::Type type,
|
| + int modifiers,
|
| + double time_sec,
|
| + int keycode,
|
| + int unicodeCharacter,
|
| + bool isSystemKey) {
|
| + WebKeyboardEvent result;
|
| +
|
| + result.type = type;
|
| + result.modifiers = modifiers;
|
| + result.timeStampSeconds = time_sec;
|
| + int windows_key_code = ui::GetCharacterFromKeyCode(keycode, modifiers);
|
| + //int windows_key_code = WebCore::windowsKeyCodeForKeyEvent(keycode);
|
| + //result.windowsKeyCode =
|
| + // WebKeyboardEvent::windowsKeyCodeWithoutLocation(windows_key_code);
|
| + //result.modifiers |=
|
| + // WebKeyboardEvent::locationModifiersFromWindowsKeyCode(windows_key_code);
|
| + result.nativeKeyCode = keycode;
|
| + result.unmodifiedText[0] = unicodeCharacter;
|
| + if (result.windowsKeyCode == ui::VKEY_RETURN) {
|
| + // This is the same behavior as GTK:
|
| + // We need to treat the enter key as a key press of character \r. This
|
| + // is apparently just how webkit handles it and what it expects.
|
| + result.unmodifiedText[0] = '\r';
|
| + }
|
| + result.text[0] = result.unmodifiedText[0];
|
| + result.setKeyIdentifierFromWindowsKeyCode();
|
| + result.isSystemKey = isSystemKey;
|
| +
|
| + return result;
|
| +}
|
| +
|
| +WebMouseEvent WebInputEventFactory::mouseEvent(MouseEventType type,
|
| + WebMouseEvent::Button button,
|
| + double time_sec,
|
| + int windowX,
|
| + int windowY,
|
| + int modifiers,
|
| + int clickCount) {
|
| + WebMouseEvent result;
|
| +
|
| + result.x = windowX;
|
| + result.y = windowY;
|
| + result.windowX = windowX;
|
| + result.windowY = windowY;
|
| + result.timeStampSeconds = time_sec;
|
| + result.clickCount = clickCount;
|
| + result.modifiers = modifiers;
|
| +
|
| + switch (type) {
|
| + case MouseEventTypeDown:
|
| + result.type = WebInputEvent::MouseDown;
|
| + result.button = button;
|
| + break;
|
| + case MouseEventTypeUp:
|
| + result.type = WebInputEvent::MouseUp;
|
| + result.button = button;
|
| + break;
|
| + case MouseEventTypeMove:
|
| + result.type = WebInputEvent::MouseMove;
|
| + result.button = WebMouseEvent::ButtonNone;
|
| + break;
|
| + }
|
| + ;
|
| +
|
| + return result;
|
| +}
|
| +
|
| +// WebMouseWheelEvent
|
| +// ------------------------------------------------------------
|
| +
|
| +WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(
|
| + MouseWheelDirectionType direction,
|
| + double time_sec,
|
| + int windowX,
|
| + int windowY) {
|
| + WebMouseWheelEvent result;
|
| +
|
| + result.type = WebInputEvent::MouseWheel;
|
| + result.x = windowX;
|
| + result.y = windowY;
|
| + result.windowX = windowX;
|
| + result.windowY = windowY;
|
| + result.time_sec = time_sec;
|
| + result.button = WebMouseEvent::ButtonNone;
|
| +
|
| + // The below choices are matched from GTK.
|
| + static const float scrollbarPixelsPerTick = 160.0f / 3.0f;
|
| +
|
| + switch (direction) {
|
| + case MouseWheelDirectionTypeUp:
|
| + result.deltaY = scrollbarPixelsPerTick;
|
| + result.wheelTicksY = 1;
|
| + break;
|
| + case MouseWheelDirectionTypeDown:
|
| + result.deltaY = -scrollbarPixelsPerTick;
|
| + result.wheelTicksY = -1;
|
| + break;
|
| + case MouseWheelDirectionTypeLeft:
|
| + result.deltaX = scrollbarPixelsPerTick;
|
| + result.wheelTicksX = 1;
|
| + break;
|
| + case MouseWheelDirectionTypeRight:
|
| + result.deltaX = -scrollbarPixelsPerTick;
|
| + result.wheelTicksX = -1;
|
| + break;
|
| + }
|
| +
|
| + return result;
|
| +}
|
| +
|
| +// WebGestureEvent ------------------------------------------------------------
|
| +
|
| +// FIXME: remove this obsolete version
|
| +WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
|
| + double time_sec,
|
| + int x,
|
| + int y,
|
| + float,
|
| + float,
|
| + int modifiers) {
|
| + return gestureEvent(type, time_sec, x, y, modifiers);
|
| +}
|
| +
|
| +WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
|
| + double time_sec,
|
| + int x,
|
| + int y,
|
| + int modifiers) {
|
| + WebGestureEvent result;
|
| +
|
| + result.type = type;
|
| + result.x = x;
|
| + result.y = y;
|
| + result.time_sec = time_sec;
|
| + result.modifiers = modifiers;
|
| +
|
| + return result;
|
| +}
|
| +
|
| +} // namespace WebKit
|
|
|