This patch migrates WebView's focus related patches.
References: https://review.tizen.org/gerrit/c/279552/
Change-Id: I42047923805973b8ac3a9b8290b13771953c0d3e
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
return evas_object_focus_get(content_image_);
}
+void RWHVAuraOffscreenHelperEfl::SetFocusInOutCallbacks(
+ const OnFocusCallback& on_focus_in,
+ const OnFocusCallback& on_focus_out) {
+ on_focus_in_callback_ = on_focus_in;
+ on_focus_out_callback_ = on_focus_out;
+}
+
void RWHVAuraOffscreenHelperEfl::OnFocusIn(void* data,
Evas* evas,
Evas_Object* obj,
RWHVAuraOffscreenHelperEfl* thiz =
static_cast<RWHVAuraOffscreenHelperEfl*>(data);
thiz->FocusRWHVA();
+
+ if (!thiz->on_focus_in_callback_.is_null())
+ thiz->on_focus_in_callback_.Run();
}
void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
aura::client::GetFocusClient(window_host->window())->GetFocusedWindow();
if (focused_window)
focused_window->LostFocus();
+
+ if (!thiz->on_focus_out_callback_.is_null())
+ thiz->on_focus_out_callback_.Run();
}
void RWHVAuraOffscreenHelperEfl::OnHostFocusIn(void* data,
class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
public:
+
+ using OnFocusCallback = base::RepeatingCallback<void(void)>;
+
RWHVAuraOffscreenHelperEfl(RenderWidgetHostViewAura* rwhva,
WebContents* web_contents);
~RWHVAuraOffscreenHelperEfl();
gfx::NativeView GetNativeView();
WebContents* GetWebContents() { return web_contents_; }
+ void SetFocusInOutCallbacks(const OnFocusCallback& on_focus_in,
+ const OnFocusCallback& on_focus_out);
+
private:
static void OnParentViewResize(void* data, Evas*, Evas_Object*, void*);
static void EvasObjectImagePixelsGetCallback(void*, Evas_Object*);
std::unique_ptr<base::OneShotTimer> snapshot_timer_;
base::IDMap<std::unique_ptr<ScreenshotCapturedCallback>>
screen_capture_cb_map_;
+
+ OnFocusCallback on_focus_in_callback_;
+ OnFocusCallback on_focus_out_callback_;
};
} // namespace content
#include <Eina.h>
#include <Elementary.h>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/json/json_string_value_serializer.h"
}
#endif
+void EWebView::OnViewFocusIn(void* data, Evas*, Evas_Object*, void*) {
+ auto view = static_cast<EWebView*>(data);
+ view->SetFocus(EINA_TRUE);
+}
+
+void EWebView::OnViewFocusOut(void* data, Evas*, Evas_Object*, void*) {
+ auto view = static_cast<EWebView*>(data);
+ view->SetFocus(EINA_FALSE);
+}
+
EWebView::EWebView(Ewk_Context* context, Evas_Object* object)
: context_(context),
evas_object_(object),
page_scale_factor_(1.0),
x_delta_(0.0),
y_delta_(0.0),
- is_initialized_(false) {}
+ is_initialized_(false) {
+ if (evas_object_) {
+ evas_object_event_callback_add(evas_object_, EVAS_CALLBACK_FOCUS_IN,
+ OnViewFocusIn, this);
+ evas_object_event_callback_add(evas_object_, EVAS_CALLBACK_FOCUS_OUT,
+ OnViewFocusOut, this);
+ }
+}
void EWebView::Initialize() {
if (is_initialized_) {
if (context_->GetImpl()->browser_context()->IsOffTheRecord())
Ewk_Context::Delete(context_.get());
gin_native_bridge_dispatcher_host_.reset();
+
+ if (evas_object_) {
+ evas_object_event_callback_del(evas_object_, EVAS_CALLBACK_FOCUS_IN,
+ OnViewFocusIn);
+ evas_object_event_callback_del(evas_object_, EVAS_CALLBACK_FOCUS_OUT,
+ OnViewFocusOut);
+ }
}
void EWebView::ReleasePopupMenuList() {
void EWebView::OnCopyFromBackingStore(bool success, const SkBitmap& bitmap) {}
+void EWebView::OnFocusIn() {
+ SmartCallback<EWebViewCallbacks::FocusIn>().call();
+}
+
+void EWebView::OnFocusOut() {
+ SmartCallback<EWebViewCallbacks::FocusOut>().call();
+}
+
void EWebView::RenderViewCreated(RenderViewHost* render_view_host) {
SendDelayedMessages(render_view_host);
UpdateWebkitPreferencesEfl(render_view_host);
-#if !defined(USE_AURA)
- RenderWidgetHostViewEfl* view = static_cast<RenderWidgetHostViewEfl*>(
- render_view_host->GetWidget()->GetView());
- if (view)
- view->SetEvasHandler(evas_event_handler_);
-#endif
+ if (rwhva()) {
+ rwhva()->offscreen_helper()->SetFocusInOutCallbacks(
+ base::BindRepeating(&EWebView::OnFocusIn, base::Unretained(this)),
+ base::BindRepeating(&EWebView::OnFocusOut, base::Unretained(this)));
+ }
+
if (render_view_host) {
WebContents* content = WebContents::FromRenderViewHost(render_view_host);
if (content) {
// from render
void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
+ void OnFocusIn();
+ void OnFocusOut();
+
void RenderViewCreated(content::RenderViewHost* render_view_host);
/**
void ChangeScroll(int& x, int& y);
+ static void OnViewFocusIn(void* data, Evas*, Evas_Object*, void*);
+ static void OnViewFocusOut(void* data, Evas*, Evas_Object*, void*);
+
scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
scoped_refptr<Ewk_Context> context_;
scoped_refptr<Ewk_Context> old_context_;
#endif // IS_TIZEN
URIChanged,
DidNotAllowScript,
- NotificationPermissionReply
+ NotificationPermissionReply,
+ FocusIn,
+ FocusOut
};
template <CallbackType>
DECLARE_EWK_VIEW_CALLBACK(NotificationPermissionReply,
"notification,permission,reply",
Ewk_Notification_Permission*);
+DECLARE_EWK_VIEW_CALLBACK(FocusOut, "webview,focus,out", void);
+DECLARE_EWK_VIEW_CALLBACK(FocusIn, "webview,focus,in", void);
}
#endif