From: Seungkeun Lee Date: Wed, 8 Apr 2015 01:28:26 +0000 (+0900) Subject: Refactoring - pause/resume , show, hiden related code X-Git-Tag: accepted/tizen/mobile/20151006.042140~76^2~91^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1d3c43ca79af0906ecd6f13eb0f572629dca15d;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Refactoring - pause/resume , show, hiden related code Change-Id: I4cd7f6c98d5a2e29f14f633d43ae11b9086f382e --- diff --git a/src/runtime/native_window.cc b/src/runtime/native_window.cc index aa66515..4b0d797 100755 --- a/src/runtime/native_window.cc +++ b/src/runtime/native_window.cc @@ -172,6 +172,7 @@ void NativeWindow::SetContent(Evas_Object* content) { // If the content is NULL, this call will just delete the previous object. // If the If you wish to preserve it, // issue elm_object_part_content_unset() on it first. + evas_object_show(content); elm_object_part_content_unset(focus_, "elm.swallow.content"); elm_object_part_content_set(focus_, "elm.swallow.content", content); elm_object_focus_set(focus_, EINA_TRUE); diff --git a/src/runtime/web_application.cc b/src/runtime/web_application.cc index e884482..d1bb46e 100755 --- a/src/runtime/web_application.cc +++ b/src/runtime/web_application.cc @@ -92,7 +92,7 @@ void WebApplication::AppControl() { // Reset to context ClearViewStack(); WebView* view = new WebView(window_, ewk_context_); - view->LoadUrl("index.html"); + view->LoadUrl("file:///index.html"); view_stack_.push_front(view); window_->SetContent(view->evas_object()); } else { @@ -109,6 +109,7 @@ void WebApplication::SendAppControlEvent() { } void WebApplication::ClearViewStack() { + window_->SetContent(NULL); auto it = view_stack_.begin(); while (it != view_stack_.end()) { (*it)->Suspend(); @@ -119,21 +120,33 @@ void WebApplication::ClearViewStack() { void WebApplication::Resume() { if (view_stack_.size() > 0 && view_stack_.front() != NULL) - view_stack_.front()->Resume(); + view_stack_.front()->SetVisibility(true); + + // TODO(sngn.lee) : should be check the background support option + // if background suuport options was on, skip below code + + auto it = view_stack_.begin(); + for ( ; it != view_stack_.end(); ++it) { + (*it)->Resume(); + } } void WebApplication::Suspend() { if (view_stack_.size() > 0 && view_stack_.front() != NULL) - view_stack_.front()->Suspend(); + view_stack_.front()->SetVisibility(false); + + // TODO(sngn.lee) : should be check the background support option + // if background suuport options was on, skip below code + auto it = view_stack_.begin(); + for ( ; it != view_stack_.end(); ++it) { + (*it)->Suspend(); + } } void WebApplication::OnCreatedNewWebView(WebView* view, WebView* new_view) { - view->Suspend(); if (view_stack_.size() > 0 && view_stack_.front() != NULL) - view_stack_.front()->Suspend(); + view_stack_.front()->SetVisibility(false); - // TODO(sngn.lee): check the background support option - // new_view.AlwaysRun(false); view_stack_.push_front(new_view); window_->SetContent(new_view->evas_object()); } @@ -152,13 +165,14 @@ void WebApplication::OnClosedWebView(WebView * view) { } } - delete view; - if (view_stack_.size() == 0) { // TODO(sngn.lee): terminate the webapp } else if (current != view_stack_.front()) { + view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); } + + delete view; } std::string WebApplication::GetDataPath() const { diff --git a/src/runtime/web_view.cc b/src/runtime/web_view.cc index 39f41b8..ac0e30e 100755 --- a/src/runtime/web_view.cc +++ b/src/runtime/web_view.cc @@ -37,8 +37,7 @@ WebView::WebView(NativeWindow* window, Ewk_Context* context) : window_(window), context_(context), ewk_view_(NULL), - listener_(NULL), - always_run_(false) { + listener_(NULL) { Initialize(); } @@ -51,32 +50,24 @@ void WebView::LoadUrl(const std::string& url) { } void WebView::Suspend() { - // change the visibility - ewk_view_visibility_set(ewk_view_, EINA_FALSE); - - if (!always_run_) { - // suspend webview - ewk_view_suspend(ewk_view_); - } + // suspend webview + ewk_view_suspend(ewk_view_); } void WebView::Resume() { - if (!always_run_) { - // resume webview - ewk_view_resume(ewk_view_); - } - // change the visiblity - ewk_view_visibility_set(ewk_view_, EINA_TRUE); + // resume webview + ewk_view_resume(ewk_view_); } void WebView::Reload() { ewk_view_reload(ewk_view_); } -void WebView::AlwaysRun(bool run) { - always_run_ = run; +void WebView::SetVisibility(bool show) { + ewk_view_visibility_set(ewk_view_, show ? EINA_TRUE : EINA_FALSE); } + bool WebView::EvalJavascript(const std::string& script) { return ewk_view_script_execute(ewk_view_, script.c_str(), NULL, NULL); } diff --git a/src/runtime/web_view.h b/src/runtime/web_view.h index bee55a8..dc019ef 100755 --- a/src/runtime/web_view.h +++ b/src/runtime/web_view.h @@ -42,7 +42,7 @@ class WebView { void Suspend(); void Resume(); void Reload(); - void AlwaysRun(bool run); + void SetVisibility(bool show); bool EvalJavascript(const std::string& script); void SetEventListener(EventListener* listener); @@ -56,7 +56,6 @@ class WebView { Ewk_Context* context_; Evas_Object* ewk_view_; EventListener* listener_; - bool always_run_; int rotation_handler_id_; };