Fix EWK content rendering support.
authorPiotr Tworek <p.tworek@samsung.com>
Thu, 5 Mar 2015 10:41:39 +0000 (19:41 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
With this patch in place it's possible to get a working ubrowser build
that both renders the content, reacts to input and can handle a lot of
EWK API calls.

Note: For the app to work --single-process flag still needs to be
      specified. I'm still looking why it's needed.

Change-Id: I4a585ecd5a8b3a14260386d5c76b3082d6fc6608
Signed-off-by: Piotr Tworek <p.tworek@samsung.com>
tizen_src/chromium_impl/efl/window_factory.cc
tizen_src/chromium_impl/efl/window_factory.h
tizen_src/ewk/efl_integration/common/web_contents_utils.cc
tizen_src/ewk/efl_integration/common/web_contents_utils.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/ewk_global_data.cc

index 0a91be1..e6de039 100644 (file)
@@ -13,11 +13,15 @@ using content::WebContents;
 namespace efl {
 
 std::map<const WebContents*, Evas_Object*> WindowFactory::window_map_;
+WindowFactory::GetHostWindowDelegate WindowFactory::delegate_;
 
 // static
 Evas_Object* WindowFactory::GetHostWindow(const WebContents* web_contents) {
   DCHECK(web_contents);
 
+  if (delegate_)
+    return (*delegate_)(web_contents);
+
   if (window_map_.find(web_contents) != window_map_.end())
     return window_map_[web_contents];
 
index 75301dd..cc6ac37 100644 (file)
@@ -16,13 +16,18 @@ namespace efl {
 
 class WindowFactory {
  public:
-       // TODO: Function should return NativeView, once NativeView typedef is fixed
-       static Evas_Object* GetHostWindow(const content::WebContents*);
+  typedef Evas_Object* (*GetHostWindowDelegate)(const content::WebContents*);
+
+  // TODO: Function should return NativeView, once NativeView typedef is fixed
+  static Evas_Object* GetHostWindow(const content::WebContents*);
+
+  static void SetDelegate(GetHostWindowDelegate d) { delegate_ = d; };
 
  private:
-       static void OnWindowRemoved(void*, Evas_Object*, void*);
+  static void OnWindowRemoved(void*, Evas_Object*, void*);
 
   static std::map<const content::WebContents*, Evas_Object*> window_map_;
+  static GetHostWindowDelegate delegate_;
 };
 
 } // namespace efl
index b5e07fa..92dd762 100644 (file)
@@ -51,10 +51,10 @@ EWebView* WebViewFromViewId(int render_process_id, int render_view_id) {
   return WebViewFromWebContents(web_contents);
 }
 
-EWebView* WebViewFromWebContents(content::WebContents* web_contents) {
+EWebView* WebViewFromWebContents(const content::WebContents* web_contents) {
   CHECK(web_contents);
-  content::WebContentsImplEfl* web_contents_efl =
-      static_cast<content::WebContentsImplEfl*>(web_contents);
+  const content::WebContentsImplEfl* web_contents_efl =
+      static_cast<const content::WebContentsImplEfl*>(web_contents);
   EWebView* wv = static_cast<EWebView*>(web_contents_efl->GetPlatformData());
   // Each WebContents in EFL port should always have EWebView hosting it.
   CHECK(wv);
index cee43c3..25a1a14 100644 (file)
@@ -18,7 +18,7 @@ content::WebContents* WebContentsFromFrameID(int render_process_id,
                                              int render_frame_id);
 EWebView* WebViewFromViewId(int render_process_id,
                             int render_view_id);
-EWebView* WebViewFromWebContents(content::WebContents*);
+EWebView* WebViewFromWebContents(const content::WebContents*);
 } // namespace web_contents_utils
 
 #endif // WEB_CONTENTS_UTILS_H
index ba98036..3661711 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/content_client_efl.h"
 #include "common/render_messages_ewk.h"
 #include "common/version_info.h"
+#include "common/web_contents_utils.h"
 #include "components/sessions/serialized_navigation_entry.h"
 #include "components/sessions/content/content_serialized_navigation_builder.h"
 #include "private/ewk_policy_decision_private.h"
@@ -74,6 +75,7 @@
 
 using namespace content;
 using namespace tizen_webview;
+using web_contents_utils::WebViewFromWebContents;
 
 // GetContentClient() is defined in content_client.cc, but in content_client.h
 // it is hidden by CONTENT_IMPLEMENTATION ifdef. We don't want to define
@@ -364,6 +366,7 @@ EWebView::EWebView(tizen_webview::WebView* owner, tizen_webview::WebContext* con
 #endif
       context_(context),
       evas_object_(object),
+      native_view_(object),
       touch_events_enabled_(false),
       mouse_events_enabled_(false),
       text_zoom_factor_(1.0),
@@ -516,6 +519,16 @@ void EWebView::CreateNewWindow(
   DCHECK(new_object);
 }
 
+//static
+Evas_Object* EWebView::GetHostWindowDelegate(
+    const content::WebContents* wc) {
+  EWebView* thiz = WebViewFromWebContents(wc);
+  Evas_Object* parent = elm_object_top_widget_get(thiz->evas_object_);
+  if (parent)
+    return parent;
+  return thiz->evas_object_;
+}
+
 void EWebView::SetURL(const char* url_string) {
   GURL url(url_string);
   NavigationController::LoadURLParams params(url);
@@ -2302,6 +2315,8 @@ void EWebView::InitializeContent() {
 
   back_forward_list_.reset(
     new tizen_webview::BackForwardList(web_contents_->GetController()));
+
+  native_view_ = static_cast<Evas_Object*>(web_contents_->GetNativeView());
 }
 
 #if defined(OS_TIZEN_MOBILE) && !defined(EWK_BRINGUP)
@@ -2402,81 +2417,45 @@ void EWebView::UrlRequestSet(const char* url,
 }
 
 bool EWebView::HandleShow() {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleShow();
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  evas_object_show(native_view_);
+  return true;
 }
 
 bool EWebView::HandleHide() {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleHide();
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  evas_object_hide(native_view_);
+  return true;
 }
 
 bool EWebView::HandleMove(int x, int y) {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleMove(x, y);
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  evas_object_move(native_view_, x, y);
+  return true;
 }
 
 bool EWebView::HandleResize(int width, int height) {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleResize(width, height);
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  evas_object_resize(native_view_, width, height);
+  return true;
 }
 
 bool EWebView::HandleFocusIn() {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleFocusIn();
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  elm_object_focus_set(native_view_, EINA_TRUE);
+  return true;
 }
 
 bool EWebView::HandleFocusOut() {
-#if defined(EWK_REFACTOR)
-  if (rwhv()) {
-    rwhv()->HandleFocusOut();
-    return true;
-  }
-  return false;
-#else
-  NOTIMPLEMENTED();
-  return false;
-#endif
+  if (!native_view_)
+    return false;
+  elm_object_focus_set(native_view_, EINA_FALSE);
+  return true;
 }
 
 bool EWebView::HandleEvasEvent(const Evas_Event_Mouse_Down* event) {
index d8ec219..cfc3420 100644 (file)
@@ -237,6 +237,7 @@ class EWebView {
   void Initialize();
 
   void CreateNewWindow(content::WebContentsDelegate::WebContentsCreateCallback);
+  static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
 
   tizen_webview::WebView* GetPublicWebView();
 #if defined(EWK_REFACTOR)
@@ -522,6 +523,7 @@ class EWebView {
   scoped_ptr<tizen_webview::Frame> frame_;
   scoped_ptr<tizen_webview::PolicyDecision> window_policy_;
   Evas_Object* evas_object_;
+  Evas_Object* native_view_;
   bool touch_events_enabled_;
   bool mouse_events_enabled_;
   double text_zoom_factor_;
index 9c120c4..d87f5fc 100644 (file)
@@ -23,6 +23,8 @@
 #include "content/browser/utility_process_host_impl.h"
 #include "content/browser/renderer_host/render_process_host_impl.h"
 #include "content/gpu/gpu_thread_override_efl.h"
+#include "efl/window_factory.h"
+#include "eweb_view.h"
 #include "tizen_webview/public/tw_web_context.h"
 #include "ui/base/resource/resource_bundle.h"
 
@@ -88,6 +90,7 @@ EwkGlobalData* EwkGlobalData::GetInstance() {
   DCHECK(message_pump_overridden);
 
   ui::InstallScreenInstance();
+  efl::WindowFactory::SetDelegate(&EWebView::GetHostWindowDelegate);
 
   instance_->content_main_delegate_efl_ = new ContentMainDelegateEfl();
   content::ContentMainParams params(instance_->content_main_delegate_efl_);