--- /dev/null
+// Copyright 2015 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EVAS_EVENT_HANDLER_H
+#define EVAS_EVENT_HANDLER_H
+
+#include "base/memory/ref_counted.h"
+
+#include <Evas.h>
+
+namespace content {
+
+class EvasEventHandler: public base::RefCountedThreadSafe<EvasEventHandler> {
+ public:
+ virtual ~EvasEventHandler() {}
+
+ virtual bool HandleEvent_FocusIn() { return false; }
+ virtual bool HandleEvent_FocusOut() { return false; }
+ virtual bool HandleEvent_KeyUp (const Evas_Event_Key_Up*) { return false; }
+ virtual bool HandleEvent_KeyDown (const Evas_Event_Key_Down*) { return false; }
+ virtual bool HandleEvent_MouseDown (const Evas_Event_Mouse_Down*) { return false; }
+ virtual bool HandleEvent_MouseUp (const Evas_Event_Mouse_Up*) { return false; }
+ virtual bool HandleEvent_MouseMove (const Evas_Event_Mouse_Move*) { return false; }
+ virtual bool HandleEvent_MouseWheel (const Evas_Event_Mouse_Wheel*) { return false; }
+
+};
+
+} // namespace content
+
+#endif // EVAS_EVENT_HANDLER_H
#define MAX_SURFACE_WIDTH_EGL 4096 //max supported Framebuffer width
#define MAX_SURFACE_HEIGHT_EGL 4096 //max supported Framebuffer height
+namespace {
+const char kSmartCallbackName_MotionEnable[] = "motion,enable";
+const char kSmartCallbackName_MotionMove[] = "motion,move";
+const char kSmartCallbackName_MotionZoom[] = "motion,zoom";
+}
+
namespace content {
void RenderWidgetHostViewBase::GetDefaultScreenInfo(
evas_object_smart_callback_add(content_image_elm_host_,
"unfocused", OnHostFocusOut, this);
+ if (smart_parent_) {
+ evas_object_smart_callback_add(smart_parent_,
+ kSmartCallbackName_MotionEnable, OnMotionEnable, this);
+ evas_object_smart_callback_add(smart_parent_,
+ kSmartCallbackName_MotionMove, OnMotionMove, this);
+ evas_object_smart_callback_add(smart_parent_,
+ kSmartCallbackName_MotionZoom, OnMotionZoom, this);
+ }
+
evas_object_event_callback_add(content_image_, EVAS_CALLBACK_MOUSE_DOWN,
OnPointerDown, this);
evas_object_event_callback_add(content_image_, EVAS_CALLBACK_MOUSE_UP,
evas_object_smart_callback_del(content_image_elm_host_,
"unfocused", OnHostFocusOut);
+ if (smart_parent_) {
+ evas_object_smart_callback_del(smart_parent_,
+ kSmartCallbackName_MotionEnable, OnMotionEnable);
+ evas_object_smart_callback_del(smart_parent_,
+ kSmartCallbackName_MotionMove, OnMotionMove);
+ evas_object_smart_callback_del(smart_parent_,
+ kSmartCallbackName_MotionZoom, OnMotionZoom);
+ }
+
evas_object_event_callback_del(content_image_, EVAS_CALLBACK_MOUSE_DOWN,
OnPointerDown);
evas_object_event_callback_del(content_image_, EVAS_CALLBACK_MOUSE_UP,
}
}
+void RenderWidgetHostViewEfl::SetEvasHandler(scoped_refptr<EvasEventHandler> evas_event_handler) {
+ evas_event_handler_ = evas_event_handler;
+}
+
bool RenderWidgetHostViewEfl::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewEfl, message)
void RenderWidgetHostViewEfl::OnFocusIn(
void* data, Evas*, Evas_Object*, void*) {
RenderWidgetHostViewEfl* thiz = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (thiz->evas_event_handler_.get())
+ if (thiz->evas_event_handler_->HandleEvent_FocusIn())
+ return;
+
thiz->host_->SetActive(true);
thiz->host_->GotFocus();
void RenderWidgetHostViewEfl::OnFocusOut(
void* data, Evas*, Evas_Object*, void*) {
RenderWidgetHostViewEfl* thiz = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (thiz->evas_event_handler_.get())
+ if (thiz->evas_event_handler_->HandleEvent_FocusOut())
+ return;
+
thiz->host_->SetActive(false);
thiz->host_->LostCapture();
thiz->Blur();
}
+void RenderWidgetHostViewEfl::OnMotionEnable(
+ void* data, Evas_Object*, void*) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewEfl::OnMotionMove(
+ void* data, Evas_Object*, void*) {
+ NOTIMPLEMENTED();
+}
+
+void RenderWidgetHostViewEfl::OnMotionZoom(
+ void* data, Evas_Object* eo, void* event_info) {
+ NOTIMPLEMENTED();
+}
+
void RenderWidgetHostViewEfl::OnPointerDown(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_MouseDown(static_cast<Evas_Event_Mouse_Down*>(event_info)))
+ return;
rwhv->Focus();
void RenderWidgetHostViewEfl::OnPointerUp(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_MouseUp(static_cast<Evas_Event_Mouse_Up*>(event_info)))
+ return;
if (!rwhv->touch_events_enabled_) {
blink::WebMouseEvent event = MakeWebMouseEvent(
void RenderWidgetHostViewEfl::OnPointerMove(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_MouseMove(static_cast<Evas_Event_Mouse_Move*>(event_info)))
+ return;
if (!rwhv->touch_events_enabled_) {
blink::WebMouseEvent event = MakeWebMouseEvent(obj,
void RenderWidgetHostViewEfl::OnKeyDown(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_KeyDown(static_cast<Evas_Event_Key_Down*>(event_info)))
+ return;
+
rwhv->host_->ForwardKeyboardEvent(MakeWebKeyboardEvent(
true, static_cast<Evas_Event_Key_Down*>(event_info)));
}
void RenderWidgetHostViewEfl::OnKeyUp(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_KeyUp(static_cast<Evas_Event_Key_Up*>(event_info)))
+ return;
+
rwhv->host_->ForwardKeyboardEvent(MakeWebKeyboardEvent(
false, static_cast<Evas_Event_Key_Up*>(event_info)));
}
void RenderWidgetHostViewEfl::OnMouseWheel(
void* data, Evas* evas, Evas_Object* obj, void* event_info) {
RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+ if (rwhv->evas_event_handler_.get())
+ if (rwhv->evas_event_handler_->HandleEvent_MouseWheel(static_cast<Evas_Event_Mouse_Wheel*>(event_info)))
+ return;
if (!rwhv->touch_events_enabled_) {
blink::WebMouseWheelEvent event = MakeWebMouseEvent(
#include "base/basictypes.h"
#include "base/format_macros.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
+#include "content/browser/renderer_host/evas_event_handler.h"
#include "content/common/content_export.h"
#include "cc/layers/delegated_frame_provider.h"
#include "cc/layers/delegated_frame_resource_collection.h"
void Init_EvasGL(int width, int height);
void CreateNativeSurface(int width, int height);
+ void SetEvasHandler(scoped_refptr<EvasEventHandler> evas_event_handler);
+
void HandleGestureBegin();
void HandleGestureEnd();
void HandleGesture(ui::GestureEvent*);
static void OnHostFocusIn(void* data, Evas_Object*, void*);
static void OnHostFocusOut(void* data, Evas_Object*, void*);
+ static void OnMotionEnable(void* data, Evas_Object*, void*);
+ static void OnMotionMove(void* data, Evas_Object*, void*);
+ static void OnMotionZoom(void* data, Evas_Object*, void*);
+
static void OnPointerDown(void* data, Evas*, Evas_Object*, void*);
static void OnPointerUp(void* data, Evas*, Evas_Object*, void*);
static void OnPointerMove(void* data, Evas*, Evas_Object*, void*);
// Whether we are currently loading.
bool is_loading_;
+ scoped_refptr<EvasEventHandler> evas_event_handler_;
+
// YUV readback pipeline.
scoped_ptr<content::ReadbackYUVInterface>
yuv_readback_pipeline_;
'tizen_webview/public/tw_webview_delegate.h',
'tizen_webview/public/tw_hit_test.h',
'tizen_webview/public/tw_web_context.h',
- #'tizen_webview/public/tw_webview_evas_event_handler.h',
- #'tizen_webview/public/tw_webview_evas_event_handler.cc',
+ 'tizen_webview/public/tw_webview_evas_event_handler.h',
+ 'tizen_webview/public/tw_webview_evas_event_handler.cc',
'tizen_webview/public/tw_webview.h',
'tizen_webview/public/tw_webview.cc',
'tizen_webview/public/tw_web_context.cc',
InitializeContent();
selection_controller_.reset(new content::SelectionControllerEfl(this, *web_contents_.get()));
+ evas_event_handler_ = new tizen_webview::WebViewEvasEventHandler(public_webview_);
scroll_detector_.reset(new ScrollDetector(this));
void EWebView::OnCopyFromBackingStore(bool success, const SkBitmap& bitmap) {
}
+void EWebView::RenderViewCreated(RenderViewHost* render_view_host) {
+ SendDelayedMessages(render_view_host);
+ RenderWidgetHostViewEfl* view = static_cast<RenderWidgetHostViewEfl*>(render_view_host->GetView());
+ if (view)
+ view->SetEvasHandler(evas_event_handler_);
+}
+
void EWebView::SetOverrideEncoding(const std::string& encoding) {
web_contents_->SetOverrideEncoding(encoding);
}
// Callback OnCopyFromBackingStore will be called once we get the snapshot from render
void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
+ void RenderViewCreated(content::RenderViewHost* render_view_host);
+
/**
* Creates a snapshot of given rectangle from EWebView
*
gfx::Point GetContextMenuPosition() const;
- void SendDelayedMessages(content::RenderViewHost* render_view_host);
-
/// ---- Event handling
bool HandleShow();
bool HandleHide();
void HandlePostponedGesture(int x, int y, ui::EventType type);
private:
void InitializeContent();
+ void SendDelayedMessages(content::RenderViewHost* render_view_host);
+
void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
Eina_Bool AsyncRequestHitTestDataAtBlinkCords(int x, int y,
Ewk_Hit_Test_Mode mode,
void ReleasePopupMenuList();
tizen_webview::WebView* public_webview_;
+ scoped_refptr<tizen_webview::WebViewEvasEventHandler> evas_event_handler_;
scoped_refptr<tizen_webview::WebContext> context_;
scoped_refptr<tizen_webview::WebContext> old_context_;
scoped_ptr<content::WebContents> web_contents_;
bool WebViewDelegateEwk::RequestHandleEvent_FocusIn(WebView* wv) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->focus_in) {
+ // XXX: is it what we want, or do we want to return false if api->focus_in
+ // returns false?
sd->api->focus_in(sd);
return true;
}
bool WebViewDelegateEwk::RequestHandleEvent_FocusOut(WebView* wv) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->focus_out) {
+ // XXX: is it what we want, or do we want to return false if api->focus_out
+ // returns false?
sd->api->focus_out(sd);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_MouseUp(WebView* wv,
- Evas_Event_Mouse_Up* event_info) {
+ const Evas_Event_Mouse_Up* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->mouse_up) {
+ // XXX: is it what we want, or do we want to return false if api->mouse_up
+ // returns false?
sd->api->mouse_up(sd, event_info);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_MouseDown(WebView* wv,
- Evas_Event_Mouse_Down* event_info) {
+ const Evas_Event_Mouse_Down* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->mouse_down) {
+ // XXX: is it what we want, or do we want to return false if api->mouse_down
+ // returns false?
sd->api->mouse_down(sd, event_info);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_MouseMove(WebView* wv,
- Evas_Event_Mouse_Move* event_info) {
+ const Evas_Event_Mouse_Move* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->mouse_move) {
+ // XXX: is it what we want, or do we want to return false if api->mouse_move
+ // returns false?
sd->api->mouse_move(sd, event_info);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_MouseWheel(WebView* wv,
- Evas_Event_Mouse_Wheel* event_info) {
+ const Evas_Event_Mouse_Wheel* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->mouse_wheel) {
+ // XXX: is it what we want, or do we want to return false if api->mouse_wheel
+ // returns false?
sd->api->mouse_wheel(sd, event_info);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_KeyUp(WebView* wv,
- Evas_Event_Key_Up* event_info) {
+ const Evas_Event_Key_Up* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->key_up) {
+ // XXX: is it what we want, or do we want to return false if api->key_up
+ // returns false?
sd->api->key_up(sd, event_info);
return true;
}
}
bool WebViewDelegateEwk::RequestHandleEvent_KeyDown(WebView* wv,
- Evas_Event_Key_Down* event_info) {
+ const Evas_Event_Key_Down* event_info) {
Ewk_View_Smart_Data* sd = GetEwkViewSmartDataFromWebView(wv);
if (sd && sd->api && sd->api->key_down) {
+ // XXX: is it what we want, or do we want to return false if api->key_down
+ // returns false?
sd->api->key_down(sd, event_info);
return true;
}
// Event handlers
bool RequestHandleEvent_FocusIn(WebView* wv);
bool RequestHandleEvent_FocusOut(WebView* wv);
- bool RequestHandleEvent_MouseUp(WebView* wv, Evas_Event_Mouse_Up* event_info);
- bool RequestHandleEvent_MouseDown(WebView* wv, Evas_Event_Mouse_Down* event_info);
- bool RequestHandleEvent_MouseMove(WebView* wv, Evas_Event_Mouse_Move* event_info);
- bool RequestHandleEvent_MouseWheel(WebView* wv, Evas_Event_Mouse_Wheel* event_info);
- bool RequestHandleEvent_KeyUp(WebView* wv, Evas_Event_Key_Up* event_info);
- bool RequestHandleEvent_KeyDown(WebView* wv, Evas_Event_Key_Down* event_info);
+ bool RequestHandleEvent_MouseUp(WebView* wv, const Evas_Event_Mouse_Up* event_info);
+ bool RequestHandleEvent_MouseDown(WebView* wv, const Evas_Event_Mouse_Down* event_info);
+ bool RequestHandleEvent_MouseMove(WebView* wv, const Evas_Event_Mouse_Move* event_info);
+ bool RequestHandleEvent_MouseWheel(WebView* wv, const Evas_Event_Mouse_Wheel* event_info);
+ bool RequestHandleEvent_KeyUp(WebView* wv, const Evas_Event_Key_Up* event_info);
+ bool RequestHandleEvent_KeyDown(WebView* wv, const Evas_Event_Key_Down* event_info);
private:
WebViewDelegateEwk() {}
DISALLOW_COPY_AND_ASSIGN(WebViewDelegateEwk);
virtual bool RequestHandleEvent_FocusIn(WebView* wv) { return false; }
virtual bool RequestHandleEvent_FocusOut(WebView* wv) { return false; }
virtual bool RequestHandleEvent_MouseUp(
- WebView* wv, Evas_Event_Mouse_Up* event_info) { return false; }
+ WebView* wv, const Evas_Event_Mouse_Up* event_info) { return false; }
virtual bool RequestHandleEvent_MouseDown(
- WebView* wv, Evas_Event_Mouse_Down* event_info) { return false; }
+ WebView* wv, const Evas_Event_Mouse_Down* event_info) { return false; }
virtual bool RequestHandleEvent_MouseMove(
- WebView* wv, Evas_Event_Mouse_Move* event_info) { return false; }
+ WebView* wv, const Evas_Event_Mouse_Move* event_info) { return false; }
virtual bool RequestHandleEvent_MouseWheel(
- WebView* wv, Evas_Event_Mouse_Wheel* event_info) { return false; }
+ WebView* wv, const Evas_Event_Mouse_Wheel* event_info) { return false; }
virtual bool RequestHandleEvent_KeyUp(
- WebView* wv, Evas_Event_Key_Up* event_info) { return false; }
+ WebView* wv, const Evas_Event_Key_Up* event_info) { return false; }
virtual bool RequestHandleEvent_KeyDown(
- WebView* wv, Evas_Event_Key_Down* event_info) { return false; }
+ WebView* wv, const Evas_Event_Key_Down* event_info) { return false; }
};
} // namespace tizen_webview
#include "tw_webview_evas_event_handler.h"
#include "tizen_webview/public/tw_webview_delegate.h"
-#include "tizen_webview/public/tw_touch_point.h"
#include "eweb_view.h"
-#if defined(OS_TIZEN_MOBILE)
-#include "browser/motion/wkext_motion.h"
-#endif
-#include "browser/renderer_host/web_event_factory_efl.h"
-#include "browser/renderer_host/render_widget_host_view_efl.h"
-
-#define RETURN_IF_TRUE(val) if((val)) return
-
-#define RETURN_IF_FALSE(val) if(!(val)) return
-
-#define EVAS_EVENT_CALLBACK_ADD(event_type, callback) \
- evas_object_event_callback_add(evas_object_, event_type,\
- reinterpret_cast<Evas_Object_Event_Cb>(callback), \
- reinterpret_cast<void*>(webview_))
-
-#define EVAS_EVENT_CALLBACK_DEL(event_type, callback) \
- evas_object_event_callback_del(evas_object_, event_type,\
- reinterpret_cast<Evas_Object_Event_Cb>(callback))
-
-#define EVAS_SMART_CALLBACK_ADD(event_type, callback) \
- evas_object_smart_callback_add(evas_object_, event_type,\
- reinterpret_cast<Evas_Smart_Cb>(callback), \
- reinterpret_cast<void*>(webview_))
-
-#define EVAS_SMART_CALLBACK_DEL(event_type, callback) \
- evas_object_smart_callback_del(evas_object_, event_type,\
- reinterpret_cast<Evas_Smart_Cb>(callback))
-
-#define EVAS_EVENT_DISPATCH_STANDARD_FLOW_1(our_name) \
- WebView* wv = data; \
- WebViewDelegate* wvd = WebViewDelegate::GetInstance(); \
- if (!wvd) return; \
- bool handled = wvd->RequestHandleEvent_ ## our_name (wv); \
- if (!handled && wv->GetEvasEventHandler()) { \
- wv->GetEvasEventHandler()->HandleEventDefault_ ## our_name (); \
- } \
-
-#define EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(our_name, evas_event_name) \
- WebView* wv = data; \
- WebViewDelegate* wvd = WebViewDelegate::GetInstance(); \
- if (!wvd) return; \
- evas_event_name * ei = \
- static_cast< evas_event_name *>(event_info); \
- bool handled = wvd->RequestHandleEvent_ ## our_name(wv, ei); \
- if (!handled && wv->GetEvasEventHandler()) { \
- wv->GetEvasEventHandler()->HandleEventDefault_ ## our_name (ei); \
- } \
-
namespace {
-const char kSmartCallbackName_MotionEnable[] = "motion,enable";
-const char kSmartCallbackName_MotionMove[] = "motion,move";
-const char kSmartCallbackName_MotionZoom[] = "motion,zoom";
-
inline bool isHardwareBackKey(const Evas_Event_Key_Down *event) {
#ifdef OS_TIZEN
return (strcmp(event->key, "XF86Stop") == 0);
WebViewEvasEventHandler::WebViewEvasEventHandler(WebView* wv)
: webview_ (wv) {
- evas_object_ = webview_->AsEvasObject();
- is_focus_handler_bound_ = false;
- is_key_handler_bound_ = false;
- is_mouse_handler_bound_ = false;
- is_motion_handler_bound_ = false;
- is_touch_handler_bound_ = false;
-}
-
-void WebViewEvasEventHandler::BindFocusEventHandlers() {
- RETURN_IF_TRUE(is_focus_handler_bound_);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_FOCUS_IN, __OnFocusIn);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_FOCUS_OUT, __OnFocusOut);
- is_focus_handler_bound_ = true;
-}
-
-void WebViewEvasEventHandler::UnbindFocusEventHandlers() {
- RETURN_IF_FALSE(is_focus_handler_bound_);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_FOCUS_IN, __OnFocusIn);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_FOCUS_OUT, __OnFocusOut);
- is_focus_handler_bound_ = false;
-}
-
-void WebViewEvasEventHandler::BindKeyEventHandlers() {
- RETURN_IF_TRUE(is_key_handler_bound_);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_KEY_DOWN, __OnKeyDown);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_KEY_UP, __OnKeyUp);
- is_key_handler_bound_ = true;
-}
-
-void WebViewEvasEventHandler::UnbindKeyEventHandlers() {
- RETURN_IF_FALSE(is_key_handler_bound_);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_KEY_DOWN, __OnKeyDown);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_KEY_UP, __OnKeyUp);
- is_key_handler_bound_ = false;
-}
-
-void WebViewEvasEventHandler::BindMouseEventHandlers() {
- RETURN_IF_TRUE(is_mouse_handler_bound_);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_DOWN, __OnMouseDown);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_UP, __OnMouseUp);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_MOVE, __OnMouseMove);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_WHEEL, __OnMouseWheel);
- is_mouse_handler_bound_ = true;
-}
-
-void WebViewEvasEventHandler::UnbindMouseEventHandlers() {
- RETURN_IF_FALSE(is_mouse_handler_bound_);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_DOWN, __OnMouseDown);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_UP, __OnMouseUp);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_MOVE, __OnMouseMove);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_WHEEL, __OnMouseWheel);
- is_mouse_handler_bound_ = false;
-}
-
-void WebViewEvasEventHandler::BindMotionEventHandlers() {
- RETURN_IF_TRUE(is_motion_handler_bound_);
- EVAS_SMART_CALLBACK_ADD(kSmartCallbackName_MotionEnable, __OnMotionEnable);
- EVAS_SMART_CALLBACK_ADD(kSmartCallbackName_MotionMove, __OnMotionMove);
- EVAS_SMART_CALLBACK_ADD(kSmartCallbackName_MotionZoom, __OnMotionZoom);
- is_motion_handler_bound_ = true;
-}
-
-
-void WebViewEvasEventHandler::UnbindMotionEventHandlers() {
- RETURN_IF_FALSE(is_motion_handler_bound_);
- EVAS_SMART_CALLBACK_DEL(kSmartCallbackName_MotionEnable, __OnMotionEnable);
- EVAS_SMART_CALLBACK_DEL(kSmartCallbackName_MotionMove, __OnMotionMove);
- EVAS_SMART_CALLBACK_DEL(kSmartCallbackName_MotionZoom, __OnMotionZoom);
- is_motion_handler_bound_ = false;
-}
-
-void WebViewEvasEventHandler::BindTouchEventHandlers() {
- RETURN_IF_TRUE(is_touch_handler_bound_);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_DOWN, __OnTouchDown);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_UP, __OnTouchUp);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MOUSE_MOVE, __OnTouchMove);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MULTI_DOWN, __OnTouchDown);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MULTI_UP, __OnTouchUp);
- EVAS_EVENT_CALLBACK_ADD(EVAS_CALLBACK_MULTI_MOVE, __OnTouchMove);
- is_touch_handler_bound_ = true;
-}
-
-void WebViewEvasEventHandler::UnbindTouchEventHandlers() {
- RETURN_IF_FALSE(is_touch_handler_bound_);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_DOWN, __OnTouchDown);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_UP, __OnTouchUp);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MOUSE_MOVE, __OnTouchMove);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MULTI_DOWN, __OnTouchDown);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MULTI_UP, __OnTouchUp);
- EVAS_EVENT_CALLBACK_DEL(EVAS_CALLBACK_MULTI_MOVE, __OnTouchMove);
- is_touch_handler_bound_ = false;
-}
-
-// ----- Evas Event Callbacks -------------------------------------------------
-
-void WebViewEvasEventHandler::__OnFocusIn(
- WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_1(FocusIn);
-}
-
-void WebViewEvasEventHandler::__OnFocusOut(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_1(FocusOut);
-}
-
-
-void WebViewEvasEventHandler::__OnKeyDown(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(KeyDown, Evas_Event_Key_Down);
-}
-
-void WebViewEvasEventHandler::__OnKeyUp(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(KeyUp, Evas_Event_Key_Up);
-}
-
-void WebViewEvasEventHandler::__OnMouseDown(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(MouseDown, Evas_Event_Mouse_Down);
-}
-
-void WebViewEvasEventHandler::__OnMouseUp(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(MouseUp, Evas_Event_Mouse_Up);
-}
-
-void WebViewEvasEventHandler::__OnMouseMove(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(MouseMove, Evas_Event_Mouse_Move);
-}
-
-void WebViewEvasEventHandler::__OnMouseWheel(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- EVAS_EVENT_DISPATCH_STANDARD_FLOW_2(MouseWheel, Evas_Event_Mouse_Wheel);
-}
-
-void WebViewEvasEventHandler::__OnMotionEnable(WebView* data, Evas_Object *eo, void *event_info) {
-#if defined(OS_TIZEN_MOBILE)
- bool* enable = static_cast<bool*>(event_info);
- wkext_motion_tilt_enable_set(data->AsEvasObject(), *enable, g_default_tilt_motion_sensitivity);
-#else
- DLOG(WARNING) << "Not Supported Event called in " << __PRETTY_FUNCTION__ ;
-#endif
-}
-
-void WebViewEvasEventHandler::__OnMotionMove(WebView* data, Evas_Object *eo, void *event_info) {
- // Not implemented yet.
-}
-
-void WebViewEvasEventHandler::__OnMotionZoom(WebView* data, Evas_Object *eo, void *event_info) {
-#if defined(OS_TIZEN_MOBILE)
- data->GetImpl()->rwhv()->makePinchZoom(event_info);
-#else
- DLOG(WARNING) << "Not Supported Event called in " << __PRETTY_FUNCTION__ ;
-#endif
-}
-
-void WebViewEvasEventHandler::__OnTouchDown(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- data->GetEvasEventHandler()->HandleEventDefault_TouchEvents(EWK_TOUCH_START);
}
-void WebViewEvasEventHandler::__OnTouchUp(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- data->GetEvasEventHandler()->HandleEventDefault_TouchEvents(EWK_TOUCH_END);
-}
-
-void WebViewEvasEventHandler::__OnTouchMove(WebView* data, Evas *e, Evas_Object *obj, void *event_info) {
- data->GetEvasEventHandler()->HandleEventDefault_TouchEvents(EWK_TOUCH_MOVE);
+bool WebViewEvasEventHandler::HandleEvent_FocusIn() {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
+ return false;
+ return wvd->RequestHandleEvent_FocusIn(webview_);
}
-
-// ----- Default Event Handlers -----------------------------------------------
-bool WebViewEvasEventHandler::HandleEventDefault_FocusIn() {
- return webview_->HandleFocusIn();
+bool WebViewEvasEventHandler::HandleEvent_FocusOut() {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
+ return false;
+ return wvd->RequestHandleEvent_FocusOut(webview_);
}
-bool WebViewEvasEventHandler::HandleEventDefault_FocusOut() {
- return webview_->HandleFocusOut();
-}
+bool WebViewEvasEventHandler::HandleEvent_KeyDown(const Evas_Event_Key_Down* event_info) {
+ bool handled = false;
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (wvd) {
+ handled = wvd->RequestHandleEvent_KeyDown(webview_, event_info);
+ if (handled)
+ return handled;
+ }
-bool WebViewEvasEventHandler::HandleEventDefault_KeyDown(const Evas_Event_Key_Down* event_info) {
- bool handled = false;
if (isHardwareBackKey(event_info)) {
if (webview_->GetContextMenuController()) {
DVLOG(1) << "Hiding context menu due to back key press";
webview_->ClearSelection();
handled = true;
}
- return handled;
}
- return webview_->HandleEvasEvent(event_info);
+ return handled;
}
-bool WebViewEvasEventHandler::HandleEventDefault_KeyUp(const Evas_Event_Key_Up* event_info) {
- return webview_->HandleEvasEvent(event_info);
-}
-
-bool WebViewEvasEventHandler::HandleEventDefault_MouseDown(const Evas_Event_Mouse_Down* event_info) {
- webview_->SetFocus(true);
- return webview_->HandleEvasEvent(event_info);
-}
+bool WebViewEvasEventHandler::HandleEvent_KeyUp(const Evas_Event_Key_Up* event_info) {
-bool WebViewEvasEventHandler::HandleEventDefault_MouseUp(const Evas_Event_Mouse_Up* event_info) {
- return webview_->HandleEvasEvent(event_info);
-}
-
-bool WebViewEvasEventHandler::HandleEventDefault_MouseMove(const Evas_Event_Mouse_Move* event_info) {
- return webview_->HandleEvasEvent(event_info);
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
+ return false;
+ return wvd->RequestHandleEvent_KeyUp(webview_, event_info);
}
-bool WebViewEvasEventHandler::HandleEventDefault_MouseWheel(const Evas_Event_Mouse_Wheel* event_info) {
- return webview_->HandleEvasEvent(event_info);
+bool WebViewEvasEventHandler::HandleEvent_MouseDown(const Evas_Event_Mouse_Down* event_info) {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
+ return false;
+ return wvd->RequestHandleEvent_MouseDown(webview_, event_info);
}
-bool WebViewEvasEventHandler::HandleEventDefault_TextSelectionDown(int x, int y) {
- if (!webview_->GetSelectionController()) {
+bool WebViewEvasEventHandler::HandleEvent_MouseUp(const Evas_Event_Mouse_Up* event_info) {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
return false;
- }
- return webview_->GetSelectionController()->TextSelectionDown(x, y);
+ return wvd->RequestHandleEvent_MouseUp(webview_, event_info);
}
-bool WebViewEvasEventHandler::HandleEventDefault_TextSelectionUp(int x, int y) {
- if (!webview_->GetSelectionController()) {
+bool WebViewEvasEventHandler::HandleEvent_MouseMove(const Evas_Event_Mouse_Move* event_info) {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
return false;
- }
- return webview_->GetSelectionController()->TextSelectionUp(x, y);
+ return wvd->RequestHandleEvent_MouseMove(webview_, event_info);
}
-bool WebViewEvasEventHandler::HandleEventDefault_TouchEvents(Ewk_Touch_Event_Type type) {
- // These constants are used to map multi touch's touch id(s).
- // The poorly-written Tizen API document says:
- // "0 for Mouse Event and device id for Multi Event."
- // "The point which comes from Mouse Event has id 0 and"
- // "The point which comes from Multi Event has id that is same as Multi Event's device id."
- static const int kMultiTouchIDMapPart0SingleIndex = 0; // This constant is to map touch id 0 to 0, or [0] -> [0]
- static const int kMultiTouchIDMapPart1StartIndex = 13; // This constant is to map [13, 23] -> [1, 11]
- static const int kMultiTouchIDMapPart1EndIndex = 23; // This constant is to map [13, 23] -> [1, 11]
- static const int kMultiTouchIDMapPart1DiffValue = 12; // 13 - 1 = 12, 23 - 11 = 12
-
- Evas_Object_Smart_Clipped_Data* clip_data =
- WebViewDelegate::GetInstance()->GetSmartClippedData(evas_object_);
- DCHECK(clip_data);
-
- unsigned count = evas_touch_point_list_count(clip_data->evas);
- if (!count) {
+bool WebViewEvasEventHandler::HandleEvent_MouseWheel(const Evas_Event_Mouse_Wheel* event_info) {
+ WebViewDelegate* wvd = WebViewDelegate::GetInstance();
+ if (!wvd)
return false;
- }
-
- Evas_Coord_Point pt;
- Eina_List* points = 0;
- for (unsigned i = 0; i < count; ++i) {
- tizen_webview::Touch_Point* point = new tizen_webview::Touch_Point;
- // evas_touch_point_list_nth_id_get returns [0] or [13, )
- // Multi touch's touch id [[0], [13, 23]] should be mapped to [[0], [1, 11]]
- // Internet Blame URL:
- // https://groups.google.com/d/msg/mailing-enlightenment-devel/-R-ezCzpkTk/HJ0KBCdz6CgJ
- point->id = evas_touch_point_list_nth_id_get(clip_data->evas, i);
- DCHECK(point->id == kMultiTouchIDMapPart0SingleIndex || point->id >= kMultiTouchIDMapPart1StartIndex);
- if (point->id >= kMultiTouchIDMapPart1StartIndex && point->id <= kMultiTouchIDMapPart1EndIndex) {
- point->id -= kMultiTouchIDMapPart1DiffValue;
- } else if (point->id > kMultiTouchIDMapPart1EndIndex) {
- LOG(ERROR) << "evas_touch_point_list_nth_id_get() returned a value greater than ("
- << kMultiTouchIDMapPart1EndIndex << "). It is ignored.";
- }
- evas_touch_point_list_nth_xy_get(clip_data->evas, i, &point->x, &point->y);
- pt.x = point->x;
- pt.y = point->y;
- point->state = evas_touch_point_list_nth_state_get(clip_data->evas, i);
- if (type == EWK_TOUCH_CANCEL)
- point->state = EVAS_TOUCH_POINT_CANCEL;
- points = eina_list_append(points, point);
- }
-
- if (type == EWK_TOUCH_START)
- webview_->SetFocus(EINA_TRUE);
-
- webview_->HandleTouchEvents(type, points,
- evas_key_modifier_get(clip_data->evas));
-
-#if defined(OS_TIZEN_MOBILE)
- if (count >= 2) {
- if (type == EWK_TOUCH_START) {
- LOG(ERROR) << " wkext_motion_tilt_start";
- wkext_motion_tilt_start(evas_object_, &pt);
- } else if(type == EWK_TOUCH_END) {
- wkext_motion_tilt_stop();
- }
- }
-#else
- // Silence unused variable warning
- (void)(pt);
-#endif
-
- void* data;
- EINA_LIST_FREE(points, data)
- delete static_cast<Touch_Point*>(data);
- return true;
+ return wvd->RequestHandleEvent_MouseWheel(webview_, event_info);
}
} // namespace tizen_webview
#ifndef TIZEN_WEBVIEW_EVENT_TW_WEBVIEW_EVAS_EVENT_HANDLER_H_
#define TIZEN_WEBVIEW_EVENT_TW_WEBVIEW_EVAS_EVENT_HANDLER_H_
-#include <Evas.h>
+#include "content/browser/renderer_host/evas_event_handler.h"
namespace tizen_webview {
class WebView;
-class WebViewDelegate;
-class WebViewEvasEventHandler {
+class WebViewEvasEventHandler: public content::EvasEventHandler {
public:
explicit WebViewEvasEventHandler(WebView*);
- // Default event handlers of WebView.
- void BindKeyEventHandlers();
- void UnbindKeyEventHandlers();
- void BindMouseEventHandlers();
- void UnbindMouseEventHandlers();
- void BindFocusEventHandlers();
- void UnbindFocusEventHandlers();
- void BindMotionEventHandlers();
- void UnbindMotionEventHandlers();
- void BindTouchEventHandlers();
- void UnbindTouchEventHandlers();
-
- // ---- Evas Event callbacks
- // Each callback will be registered to Evas Object to handle a specified
- // evas event. It should be EFL's Evas_Event_Cb type because it will be
- // passed in as an arguement of evas_event_callback_add().
- // Evas will trigger corresponding callback given evas object and event.
- // Each callback basically does followings:
- // - firstly, ask WebViewDelegate to handle the event
- // - If WebViewDelegate return true, the event is not processed any more
- // - Otherwise, forward the event to corresponding default event handler
- typedef void (*Evas_Event_Callback)(WebView* data, Evas *e,
- Evas_Object* obj, void* event_info);
- static void __OnFocusIn (WebView*, Evas*, Evas_Object*, void*);
- static void __OnFocusOut (WebView*, Evas*, Evas_Object*, void*);
- static void __OnKeyDown (WebView*, Evas*, Evas_Object*, void*);
- static void __OnKeyUp (WebView*, Evas*, Evas_Object*, void*);
- static void __OnMouseDown (WebView*, Evas*, Evas_Object*, void*);
- static void __OnMouseUp (WebView*, Evas*, Evas_Object*, void*);
- static void __OnMouseMove (WebView*, Evas*, Evas_Object*, void*);
- static void __OnMouseWheel(WebView*, Evas*, Evas_Object*, void*);
- static void __OnTouchDown (WebView*, Evas*, Evas_Object*, void*);
- static void __OnTouchUp (WebView*, Evas*, Evas_Object*, void*);
- static void __OnTouchMove (WebView*, Evas*, Evas_Object*, void*);
-
- // --- Evas smart object event callbacks
- // Each callback will be registered to Evas Smart Object to handle a evas
- // smart event. It should be EFL's Evas_Smart_Cb type because it will be
- // passed in as an arguement of evas_event_callback_add().
- typedef void (*Evas_Smart_Callback)(WebView* data, Evas_Object* obj,
- void* event_info);
- static void __OnMotionEnable(WebView*, Evas_Object*, void*);
- static void __OnMotionMove (WebView*, Evas_Object*, void*);
- static void __OnMotionZoom (WebView*, Evas_Object*, void*);
-
- // ---- Default event handlers
- // It is usually (but not always) invoked when the given event is not handled
- // by WebViewDelegate.
- // It's made public to allow a WebView Client to invoke it directly if
- // necessary (e.g, to implement Ewk webview's smart api).
- bool HandleEventDefault_FocusIn();
- bool HandleEventDefault_FocusOut();
- bool HandleEventDefault_KeyDown(const Evas_Event_Key_Down*);
- bool HandleEventDefault_KeyUp (const Evas_Event_Key_Up*);
- bool HandleEventDefault_MouseDown (const Evas_Event_Mouse_Down*);
- bool HandleEventDefault_MouseUp (const Evas_Event_Mouse_Up*);
- bool HandleEventDefault_MouseMove (const Evas_Event_Mouse_Move*);
- bool HandleEventDefault_MouseWheel(const Evas_Event_Mouse_Wheel*);
- bool HandleEventDefault_TextSelectionDown(int x, int y);
- bool HandleEventDefault_TextSelectionUp (int x, int y);
- bool HandleEventDefault_TouchEvents(Ewk_Touch_Event_Type type);
+ // ---- event handlers
+ bool HandleEvent_FocusIn() override;
+ bool HandleEvent_FocusOut() override;
+ bool HandleEvent_KeyDown (const Evas_Event_Key_Down*) override;
+ bool HandleEvent_KeyUp (const Evas_Event_Key_Up*) override;
+ bool HandleEvent_MouseDown (const Evas_Event_Mouse_Down*) override;
+ bool HandleEvent_MouseUp (const Evas_Event_Mouse_Up*) override;
+ bool HandleEvent_MouseMove (const Evas_Event_Mouse_Move*) override;
+ bool HandleEvent_MouseWheel(const Evas_Event_Mouse_Wheel*) override;
private:
WebView* webview_;
- Evas_Object* evas_object_;
- bool is_focus_handler_bound_;
- bool is_key_handler_bound_;
- bool is_mouse_handler_bound_;
- bool is_motion_handler_bound_;
- bool is_touch_handler_bound_;
};
} // namespace tizen_webview
}
void WebContentsDelegateEfl::RenderViewCreated(RenderViewHost* render_view_host) {
- web_view_->SendDelayedMessages(render_view_host);
+ web_view_->RenderViewCreated(render_view_host);
}
void WebContentsDelegateEfl::RenderProcessGone(base::TerminationStatus status) {