[M120 Migration][VD] Support EWK Scroll API for TV WebBrowser
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / eweb_view.cc
index ab7fac0..ce6088c 100644 (file)
@@ -327,6 +327,9 @@ void EWebView::VisibleContentChangedCallback(void* user_data,
                                              Evas_Object* /*object*/,
                                              void* event_info) {
   auto view = static_cast<EWebView*>(user_data);
+  if (!view->GetSelectionController()) {
+    return;
+  }
   auto rect = static_cast<Eina_Rectangle*>(event_info);
   view->GetSelectionController()->SetCustomVisibleViewRect(
       gfx::Rect(rect->x, rect->y, rect->w, rect->h));
@@ -781,6 +784,20 @@ void EWebView::SetFloatVideoWindowState(bool enabled) {
 
     rwhi->SetFloatVideoWindowState(enabled);
 }
+
+void EWebView::SuspendNetworkLoading() {
+  RenderWidgetHostImpl* rwhi = static_cast<RenderWidgetHostImpl*>(
+      web_contents_->GetRenderViewHost()->GetWidget());
+
+  rwhi->SuspendNetworkLoading();
+}
+
+void EWebView::ResumeNetworkLoading() {
+  RenderWidgetHostImpl* rwhi = static_cast<RenderWidgetHostImpl*>(
+      web_contents_->GetRenderViewHost()->GetWidget());
+
+  rwhi->ResumeNetworkLoading();
+}
 #endif // IS_TIZEN_TV
 
 double EWebView::GetTextZoomFactor() const {
@@ -839,13 +856,22 @@ void EWebView::EnterDragState() {
 #endif
 
 void EWebView::SetOrientation(int orientation) {
+  LOG(INFO) << "New ori " << orientation << " GetOrientation "
+            << GetOrientation();
   if (GetOrientation() == orientation)
     return;
+  SetRotationChanged(true);
 
   if (orientation == 0 || orientation == 90 || orientation == 180 ||
       orientation == 270) {
 #if !defined(USE_AURA)
     GetWebContentsViewEfl()->SetOrientation(orientation);
+#else
+#if BUILDFLAG(IS_TIZEN)
+    TRACE_EVENT2("viz", "EWebView::SetOrientation", "orientation", orientation,
+                 "this", (void*)this);
+    wcva()->SetOrientation(orientation);
+#endif
 #endif
     int width = 0;
     int height = 0;
@@ -866,8 +892,12 @@ int EWebView::GetOrientation() {
 #if !defined(USE_AURA)
   return GetWebContentsViewEfl()->GetOrientation();
 #else
+#if BUILDFLAG(IS_TIZEN)
+  return wcva()->GetOrientation();
+#else
   return 0;
 #endif
+#endif
 }
 
 void EWebView::Show() {
@@ -1305,13 +1335,11 @@ void EWebView::SetViewLoadErrorPageCallback(
 }
 
 // Remove below code while ewk_error_cancellation_get has been implemented.
-const char* EWebView::InvokeViewLoadErrorPageCallback(
-    const GURL& url,
-    int error_code,
-    const std::string& error_description) {
-  std::unique_ptr<_Ewk_Error> err(
-      new _Ewk_Error(error_code, url.possibly_invalid_spec().c_str(),
-                     error_description.c_str()));
+const char* EWebView::InvokeViewLoadErrorPageCallback(const GURL& url,
+                                                      int error_code,
+                                                      bool is_cancellation) {
+  std::unique_ptr<_Ewk_Error> err(new _Ewk_Error(
+      error_code, is_cancellation, url.possibly_invalid_spec().c_str()));
   _Ewk_Error_Page error_page;
 
   LOG(INFO) << "EWebView::InvokeLoadErrorPageCallback url: "
@@ -1681,6 +1709,10 @@ SelectionControllerEfl* EWebView::GetSelectionController() const {
 }
 
 void EWebView::SelectFocusedLink() {
+  if (!rwhva()) {
+    return;
+  }
+
   rwhva()->host()->SelectFocusedLink();
 }
 
@@ -2749,6 +2781,17 @@ void EWebView::InvokeEdgeScrollByCallback(const gfx::Point& offset,
 }
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void EWebView::InvokeScrollbarThumbFocusChangedCallback(
+    Ewk_Scrollbar_Orientation orientation,
+    bool focused) {
+  Ewk_Scrollbar_Data data;
+  data.orientation = orientation;
+  data.focused = focused;
+  SmartCallback<EWebViewCallbacks::DidChagneScrollbarsThumbFocus>().call(&data);
+}
+#endif
+
 void EWebView::HandleRendererProcessCrash() {
   content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE,
       base::BindOnce(&EWebView::InvokeWebProcessCrashedCallback,
@@ -3085,6 +3128,11 @@ void EWebView::SendDelayedMessages(RenderViewHost* render_view_host) {
     return;
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (pending_setfocus_closure_)
+    std::move(pending_setfocus_closure_).Run();
+#endif
+
   for (auto iter = delayed_messages_.begin(); iter != delayed_messages_.end();
        ++iter) {
     IPC::Message* message = *iter;