flutter_flutter/engine/core/frame/NewEventHandler.h
Adam Barth 3ddae5ea36 Switch KeyboardEvents over to NewEventHandler
This CL moves KeyboardEvents from the old event model to NewEventHandler. This
CL keeps the basic structure of keydown, keypress, keyup events even though
that's a bit wacky. As with pointer and gesture events, this CL removes
PlatformKeyboardEvent in favor of just using WebKeyboardEvent. I've also made
WebKeyboardEvent align more closely with Mojo's keyboard event.

The CL does change one important aspect of key event handling: on the web the
"keyCode" property of KeyboardEvent changes its meaning depending on whether
the event is a keydown or a keypress event. For the former events, keyCode is
the "virtual" (i.e., windows) key code where for the latter events, keyCode is
the character code. To be more precise, I've renamed keyCode to virtualKeyCode
and I've given it a zero (unknown key code) value during keypress events.

R=ojan@chromium.org, eseidel@chromium.org

Review URL: https://codereview.chromium.org/872233002
2015-01-25 22:46:50 -08:00

57 lines
1.8 KiB
C++

// Copyright 2015 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 SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_
#define SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_
#include <map>
#include "sky/engine/core/dom/Node.h"
#include "sky/engine/core/rendering/HitTestRequest.h"
#include "sky/engine/core/rendering/HitTestResult.h"
#include "sky/engine/wtf/HashMap.h"
namespace blink {
class LocalFrame;
class WebGestureEvent;
class WebKeyboardEvent;
class WebPointerEvent;
class NewEventHandler {
WTF_MAKE_NONCOPYABLE(NewEventHandler);
public:
explicit NewEventHandler(LocalFrame&);
~NewEventHandler();
bool handlePointerEvent(const WebPointerEvent&);
bool handleGestureEvent(const WebGestureEvent&);
bool handleKeyboardEvent(const WebKeyboardEvent&);
private:
bool handlePointerDownEvent(const WebPointerEvent&);
bool handlePointerUpEvent(const WebPointerEvent&);
bool handlePointerMoveEvent(const WebPointerEvent&);
bool handlePointerCancelEvent(const WebPointerEvent&);
bool dispatchGestureEvent(Node& target, const WebGestureEvent& event);
bool dispatchPointerEvent(Node& target, const WebPointerEvent&);
bool dispatchClickEvent(Node& capturingTarget, const WebPointerEvent&);
bool dispatchKeyboardEvent(Node& target, const WebKeyboardEvent& event);
Node* targetForKeyboardEvent() const;
Node* targetForHitTestResult(const HitTestResult& hitTestResult);
HitTestResult performHitTest(const LayoutPoint&);
void updateSelectionForPointerDown(const HitTestResult&, const WebPointerEvent&);
typedef std::map<int, RefPtr<Node>> PointerTargetMap;
LocalFrame& m_frame;
PointerTargetMap m_targetForPointer;
bool m_suppressNextCharEvent;
};
}
#endif // SKY_ENGINE_CORE_FRAME_NEWEVENTHANDLER_H_