From bf0fcea0911664ced311433df1f91cc703b85198 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Thu, 30 Jun 2016 15:36:10 +0200 Subject: [Workaround] Improved Dummy button that fixes all focus issues on webview [Issue] http://suprem.sec.samsung.net/jira/browse/TSAM-5691 [Problem] WebView can't focus and unfocus itself using their own functions. Because of that every application needs to create button that is doing that for them. [Solution] Create improved dummy button that will notify web_view that they are focused and unfocused. Remove excess gray highlight workaround. [Verify] Open inout_picker_test.html > Focus on Date > Change Date > OK. Focus should still be in webview. Change-Id: I5fdab9d1acf788a38be547b08a83cf8b0902ddc1 --- core/AbstractWebEngine/AbstractWebEngine.h | 5 ---- services/SimpleUI/SimpleUI.cpp | 18 ++----------- services/SimpleUI/SimpleUI.h | 3 --- services/WebEngineService/WebEngineService.cpp | 7 ------ services/WebEngineService/WebEngineService.h | 1 - services/WebEngineService/WebView.cpp | 12 --------- services/WebEngineService/WebView.h | 3 --- services/WebPageUI/WebPageUI.cpp | 35 ++++++++++++++++++++++++-- services/WebPageUI/WebPageUI.h | 5 ++++ services/WebPageUI/edc/WebPageUI_mob.edc | 17 +++++++++++++ 10 files changed, 57 insertions(+), 49 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 9ad5f6dd..5bce6330 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -492,11 +492,6 @@ public: */ boost::signals2::signal confirmationRequest; - /** - * Web Engine area clicked - */ - boost::signals2::signal webViewClicked; - /** * All links to RSS/Atom channels were gathered from webpage. */ diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index e929b68c..5b4765be 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -82,7 +82,6 @@ SimpleUI::SimpleUI() , m_tabLimit(0) , m_favoritesLimit(0) , m_wvIMEStatus(false) - , m_webEngineHadFocusBeforeSuspend(false) #if PROFILE_MOBILE , m_current_angle(0) , m_temp_angle(0) @@ -130,32 +129,18 @@ SimpleUI::~SimpleUI() { void SimpleUI::suspend() { - //TODO: Delete when web_view fixed unfocus on suspend issue - m_webEngineHadFocusBeforeSuspend = m_webEngine->hasFocus(); m_webEngine->suspend(); } void SimpleUI::resume() { m_webEngine->resume(); - //TODO: Delete when web_view fixed unfocus on suspend issue - if (m_webEngineHadFocusBeforeSuspend) - m_webEngineFocusWorkaroundTimer = ecore_timer_add(0.0, web_view_set_focus_timer, this); - #if PROFILE_MOBILE if (m_findOnPageUI && (evas_object_visible_get(m_findOnPageUI->getContent()) == EINA_TRUE)) m_findOnPageUI->show_ime(); #endif } -Eina_Bool SimpleUI::web_view_set_focus_timer(void *data) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - SimpleUI * simpleUI = static_cast(data); - simpleUI->m_webEngine->setFocus(); - return ECORE_CALLBACK_CANCEL; -} - void SimpleUI::destroyUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -334,6 +319,8 @@ void SimpleUI::connectUISignals() m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this)); m_webPageUI->hideQuickAccess.connect(boost::bind(&QuickAccess::hideUI, m_quickAccess)); m_webPageUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this)); + m_webPageUI->focusWebView.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::setFocus, m_webEngine.get())); + m_webPageUI->unfocusWebView.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::clearFocus, m_webEngine.get())); #if PROFILE_MOBILE m_webPageUI->hideMoreMenu.connect(boost::bind(&SimpleUI::closeMoreMenu, this)); m_webPageUI->getURIEntry().mobileEntryFocused.connect(boost::bind(&WebPageUI::mobileEntryFocused, m_webPageUI)); @@ -562,7 +549,6 @@ void SimpleUI::connectModelSignals() m_webEngine->uriChanged.connect(boost::bind(&SimpleUI::webEngineURLChanged, this, _1)); m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1)); m_webEngine->downloadStarted.connect(boost::bind(&SimpleUI::downloadStarted, this, _1)); - m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry())); m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->loadStarted.connect(boost::bind(&SimpleUI::loadStarted, this)); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 532a2d99..c95b2c26 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -87,7 +87,6 @@ public: void resume(); void destroyUI(); - static Eina_Bool web_view_set_focus_timer(void *data); private: // setup functions void loadUIServices(); @@ -361,7 +360,6 @@ private: int m_tabLimit; int m_favoritesLimit; bool m_wvIMEStatus; - bool m_webEngineHadFocusBeforeSuspend; std::string m_folder_name; //helper object used to view management @@ -372,7 +370,6 @@ private: int m_current_angle; int m_temp_angle; #endif - Ecore_Timer* m_webEngineFocusWorkaroundTimer; }; } diff --git a/services/WebEngineService/WebEngineService.cpp b/services/WebEngineService/WebEngineService.cpp index 39386c0d..29a021fd 100644 --- a/services/WebEngineService/WebEngineService.cpp +++ b/services/WebEngineService/WebEngineService.cpp @@ -119,7 +119,6 @@ void WebEngineService::connectSignals(std::shared_ptr webView) webView->forwardEnableChanged.connect(boost::bind(&WebEngineService::_forwardEnableChanged, this, _1)); webView->backwardEnableChanged.connect(boost::bind(&WebEngineService::_backwardEnableChanged, this, _1)); webView->confirmationRequest.connect(boost::bind(&WebEngineService::_confirmationRequest, this, _1)); - webView->ewkViewClicked.connect(boost::bind(&WebEngineService::webViewClicked, this)); webView->IMEStateChanged.connect(boost::bind(&WebEngineService::_IMEStateChanged, this, _1)); webView->snapshotCaptured.connect(boost::bind(&WebEngineService::_snapshotCaptured, this, _1, _2)); webView->redirectedWebPage.connect(boost::bind(&WebEngineService::_redirectedWebPage, this, _1, _2)); @@ -146,7 +145,6 @@ void WebEngineService::disconnectSignals(std::shared_ptr webView) webView->forwardEnableChanged.disconnect(boost::bind(&WebEngineService::_forwardEnableChanged, this, _1)); webView->backwardEnableChanged.disconnect(boost::bind(&WebEngineService::_backwardEnableChanged, this, _1)); webView->confirmationRequest.disconnect(boost::bind(&WebEngineService::_confirmationRequest, this, _1)); - webView->ewkViewClicked.disconnect(boost::bind(&WebEngineService::webViewClicked, this)); webView->IMEStateChanged.disconnect(boost::bind(&WebEngineService::_IMEStateChanged, this, _1)); webView->redirectedWebPage.disconnect(boost::bind(&WebEngineService::_redirectedWebPage, this, _1, _2)); #if PROFILE_MOBILE @@ -671,11 +669,6 @@ std::shared_ptr WebEngineService::getFavicon return std::make_shared(); } -void WebEngineService::webViewClicked() -{ - AbstractWebEngine::webViewClicked(); -} - #if PROFILE_MOBILE void WebEngineService::setWebViewSettings(std::shared_ptr webView) { webView->ewkSettingsAutoFittingSet(m_settings[WebEngineSettings::PAGE_OVERVIEW]); diff --git a/services/WebEngineService/WebEngineService.h b/services/WebEngineService/WebEngineService.h index 3da197a4..f673a669 100644 --- a/services/WebEngineService/WebEngineService.h +++ b/services/WebEngineService/WebEngineService.h @@ -236,7 +236,6 @@ private: void _IMEStateChanged(bool); void _snapshotCaptured(std::shared_ptr snapshot, tools::SnapshotType snapshot_type); void _redirectedWebPage(const std::string& oldUrl, const std::string& newUrl); - void webViewClicked(); void _setCertificatePem(const std::string& uri, const std::string& pem); void _setWrongCertificatePem(const std::string& uri, const std::string& pem); #if PROFILE_MOBILE diff --git a/services/WebEngineService/WebView.cpp b/services/WebEngineService/WebView.cpp index 081f5c50..d696605e 100755 --- a/services/WebEngineService/WebView.cpp +++ b/services/WebEngineService/WebView.cpp @@ -229,7 +229,6 @@ void WebView::registerCallbacks() evas_object_smart_callback_add(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this); evas_object_smart_callback_add(m_ewkView, "ssl,certificate,changed", __setCertificatePem, this); - evas_object_event_callback_add(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView, this); evas_object_smart_callback_add(m_ewkView, "icon,received", __faviconChanged, this); evas_object_smart_callback_add(m_ewkView, "editorclient,ime,closed", __IMEClosed, this); @@ -269,7 +268,6 @@ void WebView::unregisterCallbacks() #endif evas_object_smart_callback_del_full(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this); - evas_object_event_callback_del(m_ewkView, EVAS_CALLBACK_MOUSE_DOWN, __setFocusToEwkView); evas_object_smart_callback_del_full(m_ewkView, "icon,received", __faviconChanged, this); evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,closed", __IMEClosed, this); @@ -844,16 +842,6 @@ void WebView::__screenshotCaptured(Evas_Object* image, void* data) snapshot_data->web_view->snapshotCaptured(std::make_shared(image), snapshot_data->snapshot_type); } -void WebView::__setFocusToEwkView(void * data, Evas * /* e */, Evas_Object * /* obj */, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast(data); - - if(!self->hasFocus()) - self->ewkViewClicked(); -} - void WebView::__newWindowRequest(void *data, Evas_Object *, void *out) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/WebEngineService/WebView.h b/services/WebEngineService/WebView.h index 58833313..dd5d4007 100644 --- a/services/WebEngineService/WebView.h +++ b/services/WebEngineService/WebView.h @@ -284,8 +284,6 @@ public: boost::signals2::signal confirmationRequest; - boost::signals2::signal ewkViewClicked; - boost::signals2::signal IMEStateChanged; boost::signals2::signal switchToWebPage; @@ -304,7 +302,6 @@ private: void unregisterCallbacks(); void setupEwkSettings(); - static void __setFocusToEwkView(void * data, Evas * e, Evas_Object * obj, void * event_info); static void __newWindowRequest(void * data, Evas_Object *, void *out); static void __closeWindowRequest(void * data, Evas_Object *, void *); diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index 7190498d..60746dcb 100755 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -56,6 +56,8 @@ WebPageUI::WebPageUI() WebPageUI::~WebPageUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_smart_callback_del(m_dummy_button, "focused", _dummy_button_focused); + evas_object_smart_callback_del(m_dummy_button, "unfocused", _dummy_button_unfocused); } void WebPageUI::init(Evas_Object* parent) @@ -421,6 +423,18 @@ void WebPageUI::createLayout() evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_layout_file_set(m_mainLayout, edjePath("WebPageUI/WebPageUI.edj").c_str(), "main_layout"); + m_dummy_button = elm_button_add(m_mainLayout); + elm_object_style_set(m_dummy_button, "invisible_button"); + evas_object_size_hint_align_set(m_dummy_button, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(m_dummy_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_focus_allow_set(m_dummy_button, EINA_TRUE); + elm_object_focus_set(m_dummy_button, EINA_TRUE); + evas_object_show(m_dummy_button); + elm_object_part_content_set(m_mainLayout, "web_view_dummy_button", m_dummy_button); + + evas_object_smart_callback_add(m_dummy_button, "focused", _dummy_button_focused, this); + evas_object_smart_callback_add(m_dummy_button, "unfocused", _dummy_button_unfocused, this); + createErrorLayout(); createPrivateLayout(); createActions(); @@ -462,6 +476,24 @@ void WebPageUI::createLayout() #endif } +void WebPageUI::_dummy_button_focused(void *data, Evas_Object *, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + WebPageUI* webPageUI = static_cast(data); + webPageUI->focusWebView(); + } +} + +void WebPageUI::_dummy_button_unfocused(void *data, Evas_Object *, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + WebPageUI* webPageUI = static_cast(data); + webPageUI->unfocusWebView(); + } +} + void WebPageUI::createErrorLayout() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -586,8 +618,7 @@ void WebPageUI::hideWebView() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_hide(elm_object_part_content_get(m_mainLayout, "web_view")); - elm_object_part_content_unset(m_mainLayout, "web_view"); + evas_object_hide(elm_object_part_content_unset(m_mainLayout, "web_view")); } void WebPageUI::setErrorButtons() diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 33db8af1..66a7019f 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -112,11 +112,15 @@ public: boost::signals2::signal hideQuickAccess; boost::signals2::signal showQuickAccess; boost::signals2::signal bookmarkManagerClicked; + boost::signals2::signal focusWebView; + boost::signals2::signal unfocusWebView; private: static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); static Eina_Bool _cb_down_pressed_on_urlbar(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); static void _bookmark_manager_clicked(void * data, Evas_Object *, void *); + static void _dummy_button_focused(void *data, Evas_Object *, void *); + static void _dummy_button_unfocused(void *data, Evas_Object *, void *); #if PROFILE_MOBILE static void _more_menu_background_clicked(void* data, Evas_Object*, const char*, const char*); static void _content_clicked(void * data, Evas_Object *, void *); @@ -157,6 +161,7 @@ private: Evas_Object* m_parent; Evas_Object* m_mainLayout; + Evas_Object* m_dummy_button; Evas_Object* m_errorLayout; Evas_Object* m_privateLayout; Evas_Object* m_bookmarkManagerButton; diff --git a/services/WebPageUI/edc/WebPageUI_mob.edc b/services/WebPageUI/edc/WebPageUI_mob.edc index ad412dc5..f6e41796 100644 --- a/services/WebPageUI/edc/WebPageUI_mob.edc +++ b/services/WebPageUI/edc/WebPageUI_mob.edc @@ -297,6 +297,23 @@ collections { base_scale: 2.6; rel2 { relative: 1.0 1.0; to: "bg"; } } } + part { + name: "web_view_dummy_button"; + type: SWALLOW; + mouse_events: 1; + repeat_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0.0 0.0; + fixed: 0 0; + min: 0 0; + max: -1 -1; + rel1 { relative: 0.0 0.0; to: "web_view"; } + rel2 { relative: 1.0 1.0; to: "web_view"; } + } + } part { name: "progressbar_bg"; type: IMAGE; scale: 1; -- cgit v1.2.3