Reuse WebView to response appcontrol request
authorSeungkeun Lee <sngn.lee@samsung.com>
Mon, 5 Oct 2015 05:32:32 +0000 (14:32 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Mon, 5 Oct 2015 07:11:41 +0000 (16:11 +0900)
 - Issue
  WebView re-create was cause re-create renderer process
  Re-creation of WebView was take a long time
 - Proposal
  Reuse WebView(just change the URL of current WebView)

runtime/browser/web_application.cc [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 702bc66..f63586f
@@ -421,11 +421,10 @@ void WebApplication::AppControl(
   if (do_reset) {
     // Reset to context
     ClearViewStack();
-    WebView* view = new WebView(window_, ewk_context_);
+    WebView* view = view_stack_.front();
     SetupWebView(view);
     view->SetDefaultEncoding(res->encoding());
     view->LoadUrl(res->uri(), res->mime());
-    view_stack_.push_front(view);
     window_->SetContent(view->evas_object());
   }
 
@@ -443,12 +442,16 @@ void WebApplication::SendAppControlEvent() {
 
 void WebApplication::ClearViewStack() {
   window_->SetContent(NULL);
+  WebView* front = view_stack_.front();
   auto it = view_stack_.begin();
   for ( ; it != view_stack_.end(); ++it) {
-    (*it)->Suspend();
-    delete *it;
+    if (*it != front) {
+      (*it)->Suspend();
+      delete *it;
+    }
   }
   view_stack_.clear();
+  view_stack_.push_front(front);
 }
 
 void WebApplication::Resume() {