[M108 Migration][API] Implement ewk_view_edge_scroll_by for all profiles 98/290198/4
authorwangjing <jing124.wang@samsung.com>
Tue, 21 Mar 2023 09:08:16 +0000 (17:08 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 23 Mar 2023 17:56:32 +0000 (17:56 +0000)
This function should be used for browser edge scroll.
Scrolls webpage of view by dx and dy.

"edge,scroll,left"
"edge,scroll,top"
"edge,scroll,bottom"
"edge,scroll,right"

reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/279660/
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/280265/

Change-Id: Ifb4644e75467d1be2c6207c3b2462465303252b7
Signed-off-by: wangjing <jing124.wang@samsung.com>
31 files changed:
components/plugins/renderer/webview_plugin.h
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
content/browser/renderer_host/render_widget_host_view_aura.cc
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/renderer_host/render_widget_host_view_base.h
content/public/browser/web_contents_delegate.h
third_party/blink/public/mojom/BUILD.gn
third_party/blink/public/mojom/page/widget.mojom
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/public/web/web_view.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/exported/web_view_impl.h
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.h
third_party/blink/renderer/core/input/event_handler.cc
third_party/blink/renderer/core/input/event_handler.h
third_party/blink/renderer/core/input/scroll_manager.cc
third_party/blink/renderer/core/input/scroll_manager.h
third_party/blink/renderer/platform/widget/widget_base.cc
third_party/blink/renderer/platform/widget/widget_base.h
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/eweb_view_callbacks.h
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h
tizen_src/ewk/unittest/BUILD.gn
tizen_src/ewk/unittest/utc_blink_ewk_view_edge_scroll_by_func.cpp [new file with mode: 0644]

index 886d3ea08e45fbb2d5827de17eeddb80151e320e..2856bf5373246975a4a24c54cd1449c4b51269b4 100644 (file)
@@ -193,6 +193,9 @@ class WebViewPlugin : public blink::WebPlugin, public blink::WebViewObserver {
 
     // blink::mojom::WidgetHost implementation.
     void SetCursor(const ui::Cursor& cursor) override;
+#if BUILDFLAG(IS_TIZEN_TV)
+    void DidEdgeScrollBy(const gfx::Point& point, bool handled) override {}
+#endif
     void UpdateTooltipUnderCursor(const std::u16string& tooltip_text,
                                   base::i18n::TextDirection hint) override;
     void UpdateTooltipFromKeyboard(const std::u16string& tooltip_text,
index 380d147f95639beb48e815cc348ca8455258ea46..84f8aae40476caeee9065b7c0c635464db9ed7f7 100644 (file)
@@ -2655,6 +2655,15 @@ void RenderWidgetHostImpl::ShowPopup(const gfx::Rect& initial_screen_rect,
   std::move(callback).Run();
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostImpl::DidEdgeScrollBy(const gfx::Point& offset, bool handled) {
+  if (!GetView())
+    return;
+
+  view_->DidEdgeScrollBy(offset, handled);
+}
+#endif
+
 void RenderWidgetHostImpl::UpdateTooltipUnderCursor(
     const std::u16string& tooltip_text,
     base::i18n::TextDirection text_direction_hint) {
index 688d5a0e4bab22980515bde95d1484c41a616a08..b0696156e5b427de4e89ab73e765983b4da967d9 100644 (file)
@@ -314,6 +314,10 @@ class CONTENT_EXPORT RenderWidgetHostImpl
                            const ChildProcessTerminationInfo& info) override;
 
   // blink::mojom::WidgetHost implementation.
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& point, bool handled) override;
+#endif
   void UpdateTooltipUnderCursor(
       const std::u16string& tooltip_text,
       base::i18n::TextDirection text_direction_hint) override;
index e032c1253d90e51afbf20baa0ee3a231333a6e98..e803089f70f8a7ca9f4fcc131a37666e43f3210d 100644 (file)
@@ -2122,6 +2122,13 @@ void RenderWidgetHostViewAura::FocusedNodeChanged(
 #endif
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostViewAura::DidEdgeScrollBy(const gfx::Point& offset,
+    bool handled) {
+    efl_helper_->DidEdgeScrollBy(offset, handled);
+}
+#endif
+
 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
   event_handler_->OnScrollEvent(event);
 }
index 4db3ca59d8ae12fcb0aa108d26909197d971ca12..d50796e383e9d4c67bb8185c19e0ba2d6c1c9add 100644 (file)
@@ -214,6 +214,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
 #endif
                           ) override;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override ;
+#endif
   void OnSynchronizedDisplayPropertiesChanged(bool rotation = false) override;
   viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(
       const cc::RenderFrameMetadata& metadata) override;
index 96e32a2f603dbb7a93782c1e058d1288d5be588e..8669e1f7d7900b105bc2c01de93fe0ab08c24819 100644 (file)
@@ -487,6 +487,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView {
   // Tells the View to destroy itself.
   virtual void Destroy();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  virtual void DidEdgeScrollBy(const gfx::Point& offset, bool handled) {}
+#endif
+
   // Calls UpdateTooltip if the view is under the cursor.
   virtual void UpdateTooltipUnderCursor(const std::u16string& tooltip_text) {}
 
index 819ddc982b914aeb452248eab9079aa98502e0d2..2dfc993f47cf63c6c2c2753faabee54997cf290e 100644 (file)
@@ -395,6 +395,11 @@ class CONTENT_EXPORT WebContentsDelegate {
   // Invoked when a primary main frame navigation occurs.
   virtual void DidNavigatePrimaryMainFramePostCommit(WebContents* source) {}
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  virtual void DidEdgeScrollBy(const gfx::Point& offset, bool handled) {}
+#endif
+
   // Returns a pointer to a service to manage JavaScript dialogs. May return
   // nullptr in which case dialogs aren't shown.
   virtual JavaScriptDialogManager* GetJavaScriptDialogManager(
index 3d36e4a3e9013c11b120ddfddda1440fab6d13ab..3e67835c195268b4d4b2588aa45786b17db6b5ea 100644 (file)
@@ -1123,6 +1123,10 @@ mojom("mojom_core") {
     enabled_features += [ "is_efl" ]
   }
 
+  if (tizen_product_tv) {
+    enabled_features += [ "is_tizen_tv" ]
+  }
+
   if (is_android) {
     # Direct deps (instead of transitive deps) are necessary for java targets.
     public_deps += [
index 46ba93866965a12af4b5aa460edffcf3f15e0d91..f7feae5d9a0a678940b2a016f21413b9e3362a41 100644 (file)
@@ -148,6 +148,10 @@ interface FrameWidget {
   // third_party/blink/public/mojom/frame/viewport_intersection_state.mojom
   SetViewportIntersection(ViewportIntersectionState intersection_state,
                           VisualProperties? visual_properties);
+
+  [EnableIf=is_tizen_tv]
+  //Browser edge scroll
+  EdgeScrollBy(gfx.mojom.Point offset, gfx.mojom.Point mouse_position);
 };
 
 // Implemented in Browser, this interface defines frame-widget-specific methods that
index c4fe956de2beeb53069b7682bb932fb88e5b3d6c..50071a72ca6fc9615a097bb84e46749b285cb39a 100644 (file)
@@ -37,6 +37,10 @@ interface WidgetHost {
   // location of a pointing device.
   SetCursor(ui.mojom.Cursor cursor);
 
+  [EnableIf=is_tizen_tv]
+  //Browser edge scroll
+  DidEdgeScrollBy(gfx.mojom.Point offset, bool handled);
+
   // Sent by a widget to the browser to set the tooltip text for the current
   // cursor position. An empty |tooltip_text| will hide the tooltip view.
   UpdateTooltipUnderCursor(mojo_base.mojom.String16 tooltip_text,
index 15a28caddb18a6a31269b1698eda5a27a1e5e9ab..5a25218085cff1a3592000f4f1faa39e929d839f 100644 (file)
@@ -43,6 +43,7 @@
 #include "third_party/blink/public/platform/cross_variant_mojo_util.h"
 #include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
 #include "third_party/blink/public/platform/web_common.h"
+#include "third_party/blink/renderer/core/scroll/scroll_types.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/display/mojom/screen_orientation.mojom-shared.h"
 
@@ -488,6 +489,11 @@ class BLINK_EXPORT WebView {
   virtual bool IsVideoHoleForRender() const = 0;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  virtual bool EdgeScrollBy(const ScrollOffset&, const gfx::Point&) = 0;
+#endif
+
   // Misc -------------------------------------------------------------
 
   // Returns the number of live WebView instances in this process.
index 74b18e95586fdd8620f66c3d581c7a359c39356b..316ae20ff332e7152e320b922b0d02b868c0f312 100644 (file)
@@ -4338,4 +4338,37 @@ bool WebViewImpl::IsVideoHoleForRender() const {
   return GetPage()->GetSettings().GetVideoHoleEnabled();
 }
 #endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+bool WebViewImpl::EdgeScrollBy(const ScrollOffset& scroll_offset,
+                               const gfx::Point& mouse_point) {
+  if (!MainFrameImpl())
+    return false;
+  const LocalFrameView* view = MainFrameImpl()->GetFrameView();
+  if (!view)
+    return false;
+
+  LayoutView* const layout_view = view->GetLayoutView();
+  if (!layout_view)
+    return false;
+
+  const gfx::Point point(mouse_point);
+  HitTestLocation location(point);
+  const HitTestRequest request(HitTestRequest::kReadOnly |
+                               HitTestRequest::kAllowChildFrameContent);
+  HitTestResult result(request, location);
+
+  layout_view->HitTest(location, result);
+
+  const LocalFrame* frame = result.InnerNodeFrame();
+  if (!frame) {
+    frame = DynamicTo<LocalFrame>(
+        page_->GetFocusController().FocusedOrMainFrame());
+  }
+
+  return frame->GetEventHandler().ScrollWithMultiplier(scroll_offset,
+                                                       result.InnerNode());
+}
+#endif
+
 }  // namespace blink
index cd72cea60fa24491f604acf6127fda16d305c36e..952342be5ee9440ed0d4d46381408034e5ce26e3 100644 (file)
@@ -629,6 +629,11 @@ class CORE_EXPORT WebViewImpl final : public WebView,
   bool IsVideoHoleForRender() const override;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  bool EdgeScrollBy(const ScrollOffset&, const gfx::Point&) override;
+#endif
+
  private:
   FRIEND_TEST_ALL_PREFIXES(WebFrameTest, DivScrollIntoEditableTest);
   FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
index 43bc4499ab56a9de7b21d1f1900531721a3ce10b..b0ae6e6e3a3579894ca3cd82e0e1a1709fba6cdd 100644 (file)
@@ -1301,6 +1301,18 @@ void WebFrameWidgetImpl::Trace(Visitor* visitor) const {
   visitor->Trace(device_emulator_);
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebFrameWidgetImpl::EdgeScrollBy(const gfx::Point& offset, const gfx::Point& mouse_position) {
+  bool handled = false;
+  WebViewImpl* webview = View();
+  if (webview)
+    handled = webview->EdgeScrollBy(
+            blink::ScrollOffset(offset.x(), offset.y()),
+            gfx::Point(mouse_position.x(), mouse_position.y()));
+  widget_base_->DidEdgeScrollBy(offset, handled);
+}
+#endif
+
 void WebFrameWidgetImpl::SetNeedsRecalculateRasterScales() {
   if (!View()->does_composite())
     return;
index abb3c996fbb6048dcefd1738c2c116f6d7a7a109..764b26aa31b90ca439dbc82a3bb078b858c52406 100644 (file)
@@ -791,6 +791,11 @@ class CORE_EXPORT WebFrameWidgetImpl
                         GetStringAtPointCallback callback) override;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void EdgeScrollBy(const gfx::Point& offset, const gfx::Point& mouse_position) override;
+#endif
+
   // mojom::blink::FrameWidgetInputHandler overrides.
   void AddImeTextSpansToExistingText(
       uint32_t start,
index d451adeb6fb2b0b79595706ebab11a643fc48963..9ef05a6472c012f2038633406cd2072d246560cc 100644 (file)
@@ -1402,6 +1402,53 @@ void EventHandler::ClearDragState() {
   should_only_fire_drag_over_event_ = false;
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+bool EventHandler::ScrollNewPosition(const ScrollOffset& scroll_offset,
+                                     LocalFrameView* frame_view) {
+  ScrollableArea* const scrollable_area = frame_view->LayoutViewport();
+  if (!scrollable_area)
+    return false;
+
+  gfx::PointF ori_point = scrollable_area->ScrollPosition();
+  scrollable_area->ScrollBy(scroll_offset, mojom::blink::ScrollType::kUser);
+  gfx::PointF new_point = scrollable_area->ScrollPosition();
+  return new_point != ori_point;
+}
+
+bool EventHandler::ScrollWithMultiplier(const ScrollOffset& scroll_offset,
+                                        Node* start_node) {
+  LocalFrame* frame = frame_;
+  while (frame) {
+    mojom::blink::ScrollDirection vertical_direction =
+        (scroll_offset.y() < 0)
+            ? mojom::blink::ScrollDirection::kScrollUpIgnoringWritingMode
+            : mojom::blink::ScrollDirection::kScrollDownIgnoringWritingMode;
+    mojom::blink::ScrollDirection horizontal_direction =
+        (scroll_offset.x() < 0)
+            ? mojom::blink::ScrollDirection::kScrollLeftIgnoringWritingMode
+            : mojom::blink::ScrollDirection::kScrollRightIgnoringWritingMode;
+    if (scroll_manager_->LogicalScroll(
+            vertical_direction, ui::ScrollGranularity::kScrollByPixel, start_node,
+            nullptr, std::abs(scroll_offset.y())))
+      return true;
+
+    if (scroll_manager_->LogicalScroll(
+            horizontal_direction, ui::ScrollGranularity::kScrollByPixel, start_node,
+            nullptr, std::abs(scroll_offset.x())))
+      return true;
+
+    LocalFrameView* frame_view = frame->View();
+    if (frame_view && ScrollNewPosition(scroll_offset, frame_view))
+      return true;
+
+    frame = DynamicTo<LocalFrame>(frame->Tree().Parent());
+    if (frame)
+      start_node = frame->DeprecatedLocalOwner();
+  }
+  return false;
+}
+#endif
+
 void EventHandler::AnimateSnapFling(base::TimeTicks monotonic_time) {
   scroll_manager_->AnimateSnapFling(monotonic_time);
 }
index 6f7855ee6468320f1c234947d04dcdfea32eb588..60c2c704640925052ad3cdf993d889e666a6f465 100644 (file)
@@ -269,6 +269,11 @@ class CORE_EXPORT EventHandler final : public GarbageCollected<EventHandler> {
   // canceled.
   void ClearDragState();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool ScrollNewPosition(const ScrollOffset&, LocalFrameView*);
+  bool ScrollWithMultiplier(const ScrollOffset&, Node*);
+#endif
+
   EventHandlerRegistry& GetEventHandlerRegistry() const {
     return *event_handler_registry_;
   }
index c1f2ac4840b627c4e643dccfb4dfa94140dabf1a..850c18180bec4742ff71d33babf16786763df19b 100644 (file)
@@ -318,7 +318,8 @@ bool ScrollManager::CanScroll(const ScrollState& scroll_state,
 bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction,
                                   ui::ScrollGranularity granularity,
                                   Node* start_node,
-                                  Node* mouse_press_node) {
+                                  Node* mouse_press_node,
+                                  float data) {
   Node* node = start_node;
 
   if (!node)
@@ -406,8 +407,7 @@ bool ScrollManager::LogicalScroll(mojom::blink::ScrollDirection direction,
         WrapWeakPersistent(scrollable_area)));
     ScrollResult result = scrollable_area->UserScroll(
         granularity,
-        ToScrollDelta(physical_direction,
-                      ScrollableArea::DirectionBasedScrollDelta(granularity)),
+        ToScrollDelta(physical_direction, data),
         std::move(callback));
 
     if (result.DidScroll())
index a0ee9e7aa5a78da2e76d88a069e81d4ef7716cdd..576d519a13847be832486c529566a70f45076739 100644 (file)
@@ -71,7 +71,8 @@ class CORE_EXPORT ScrollManager : public GarbageCollected<ScrollManager>,
   bool LogicalScroll(mojom::blink::ScrollDirection,
                      ui::ScrollGranularity,
                      Node* start_node,
-                     Node* mouse_press_node);
+                     Node* mouse_press_node,
+                     float data = 1.0);
 
   // Performs a logical scroll that chains, crossing frames, starting from
   // the given node or a reasonable default (focus/last clicked).
index 8c2556cee44a2780521e53102db59e2aa32323e6..a699184c70953cd2ff591c5f82396062a55ae63a 100644 (file)
@@ -1014,6 +1014,12 @@ void WidgetBase::SetCursor(const ui::Cursor& cursor) {
   }
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WidgetBase::DidEdgeScrollBy(const gfx::Point& offset, bool handled) {
+  widget_host_->DidEdgeScrollBy(offset, handled);
+}
+#endif
+
 void WidgetBase::UpdateTooltipUnderCursor(const String& tooltip_text,
                                           TextDirection dir) {
   widget_host_->UpdateTooltipUnderCursor(
index 485070f7268f7e02a7dc0e2cee0ff8e0ba6826b2..ad55f28e10d4a42215517204d4e24a92150aecf0 100644 (file)
@@ -239,6 +239,11 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
 
   WidgetBaseClient* client() { return client_; }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& offset, bool handled);
+#endif
+
   void UpdateTooltipUnderCursor(const String& tooltip_text, TextDirection dir);
   // This function allows us to trigger a tooltip to show from a keypress. The
   // tooltip will be positioned relative to the gfx::Rect. That rect corresponds
index 283d714987e866bbf59375ffb2498fff84ed1757..0f7e55ab4bb548bd069b14d1084f5d0ffdc09eea 100644 (file)
@@ -369,6 +369,13 @@ void RWHVAuraCommonHelperEfl::FocusedNodeChanged(
   is_focused_node_editable_ = editable;
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RWHVAuraCommonHelperEfl::DidEdgeScrollBy(const gfx::Point& offset,
+    bool handled) {
+  web_contents_->GetDelegate()->DidEdgeScrollBy(offset, handled);
+}
+#endif
+
 void RWHVAuraCommonHelperEfl::OnGetMainFrameScrollbarVisible(
     int callback_id, bool visible) {
   web_contents_->GetDelegate()->OnGetMainFrameScrollbarVisible(callback_id,
index 4f7c79b48ba12d73c501e55cda6cb1156a93c424..53c5d146e8a80933e84b951ea4f6399743f03c9e 100644 (file)
@@ -102,6 +102,11 @@ class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
 #endif
       bool is_content_editable);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& offset, bool handled) ;
+#endif
+
   void OnGestureEvent(ui::GestureEvent* event);
   void DidChangeInputType(bool is_password_field);
   void BackgroundColorReceived(int callback_id, SkColor bg_color);
index 48136a423453cbcef827f47cde9493176078edd6..d7a964dea62a1f9d1a7d5ede4186768470ac2b3b 100644 (file)
@@ -354,6 +354,7 @@ EWebView::EWebView(Ewk_Context* context, Evas_Object* object)
       x_delta_(0.0),
       y_delta_(0.0),
 #if BUILDFLAG(IS_TIZEN_TV)
+      is_processing_edge_scroll_(false),
       use_early_rwi_(false),
       rwi_info_showed_(false),
 #endif
@@ -2604,6 +2605,73 @@ void EWebView::SyncAcceptLanguages(const std::string& accept_languages) {
     network_context->SetAcceptLanguage(accept_languages);
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+bool EWebView::EdgeScrollBy(int delta_x, int delta_y) {
+  if ((delta_x == 0 && delta_y == 0) || is_processing_edge_scroll_)
+    return false;
+
+  RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
+  if (!render_view_host)
+    return false;
+
+  if (!rwhva())
+    return false;
+
+  gfx::Point offset = gfx::Point(delta_x, delta_y);
+  gfx::Point mouse_position;
+  GetMousePosition(mouse_position);
+  is_processing_edge_scroll_ = true;
+
+  static_cast<RenderViewHostImpl*>(render_view_host)
+      ->GetWidget()
+      ->GetAssociatedFrameWidget()
+      ->EdgeScrollBy(offset, mouse_position);
+  return true;
+}
+
+void EWebView::GetMousePosition(gfx::Point& mouse_position) {
+  int mouse_x, mouse_y;
+  evas_pointer_output_xy_get(GetEvas(), &mouse_x, &mouse_y);
+  Evas_Coord x, y, width, height;
+  evas_object_geometry_get(evas_object(), &x, &y, &width, &height);
+
+  if (mouse_y < y)
+    mouse_y = y + 1;
+  else if (mouse_y > y + height)
+    mouse_y = y + height - 1;
+  if (mouse_x < x)
+    mouse_x = x + 1;
+  else if (mouse_x > x + width)
+    mouse_x = x + width - 1;
+
+  mouse_x -= x;
+  mouse_y -= y;
+
+  mouse_x /=
+      display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+  mouse_y /=
+      display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+
+  mouse_position.set_x(mouse_x);
+  mouse_position.set_y(mouse_y);
+}
+
+void EWebView::InvokeEdgeScrollByCallback(const gfx::Point& offset,
+                                          bool handled) {
+  is_processing_edge_scroll_ = false;
+
+  if (offset.x() < 0)
+    SmartCallback<EWebViewCallbacks::EdgeScrollLeft>().call(&handled);
+  else if (offset.x() > 0)
+    SmartCallback<EWebViewCallbacks::EdgeScrollRight>().call(&handled);
+
+  if (offset.y() < 0)
+    SmartCallback<EWebViewCallbacks::EdgeScrollTop>().call(&handled);
+  else if (offset.y() > 0)
+    SmartCallback<EWebViewCallbacks::EdgeScrollBottom>().call(&handled);
+}
+#endif
+
 void EWebView::HandleRendererProcessCrash() {
   content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE,
       base::BindOnce(&EWebView::InvokeWebProcessCrashedCallback,
index 05c7ef4c080ceb0cf1cb0848b81220c6a74c8841..470e0706da782951e67ca64bc0b2cb3b07529b61 100644 (file)
@@ -688,6 +688,13 @@ class EWebView {
   void ReplyBeforeUnloadConfirmPanel(Eina_Bool result);
   void SyncAcceptLanguages(const std::string& accept_languages);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  bool EdgeScrollBy(int delta_x, int delta_y);
+  void GetMousePosition(gfx::Point&);
+  void InvokeEdgeScrollByCallback(const gfx::Point&, bool);
+#endif
+
   void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
                       const gfx::Vector2dF& latest_overscroll_delta);
 
@@ -922,6 +929,7 @@ class EWebView {
   bool is_initialized_;
 
 #if BUILDFLAG(IS_TIZEN_TV)
+  bool is_processing_edge_scroll_;
   bool use_early_rwi_;
   bool rwi_info_showed_;
   GURL rwi_gurl_;
index 1e577763b2ca8e8c07ddff6c87cfcabb75fc18fe..be7eaf7cd855d27a495ca1c4475452b1f5b163af 100644 (file)
@@ -115,6 +115,10 @@ enum CallbackType {
   EdgeTop,
   EdgeBottom,
 #if BUILDFLAG(IS_TIZEN_TV)
+  EdgeScrollBottom,
+  EdgeScrollLeft,
+  EdgeScrollRight,
+  EdgeScrollTop,
   DeviceConnectionChanged,
   PlaybackLoad,
   PlaybackVideoReady,
@@ -281,6 +285,10 @@ DECLARE_EWK_VIEW_CALLBACK(EdgeTop, "edge,top", void);
 DECLARE_EWK_VIEW_CALLBACK(EdgeBottom, "edge,bottom", void);
 DECLARE_EWK_VIEW_CALLBACK(EdgeRight, "edge,right", void);
 #if BUILDFLAG(IS_TIZEN_TV)
+DECLARE_EWK_VIEW_CALLBACK(EdgeScrollBottom, "edge,scroll,bottom", bool*);
+DECLARE_EWK_VIEW_CALLBACK(EdgeScrollLeft, "edge,scroll,left", bool*);
+DECLARE_EWK_VIEW_CALLBACK(EdgeScrollRight, "edge,scroll,right", bool*);
+DECLARE_EWK_VIEW_CALLBACK(EdgeScrollTop, "edge,scroll,top", bool*);
 DECLARE_EWK_VIEW_CALLBACK(DeviceConnectionChanged,
                           "device,connection,changed",
                           int*);
index f699d1475f0e927cb2220d13ad3b1262cd02a1f9..ef55affd9198278018c05fc022bbd96666416e37 100644 (file)
@@ -1546,7 +1546,14 @@ void ewk_view_clear_all_tiles_resources(Evas_Object* ewkView) {
 Eina_Bool ewk_view_edge_scroll_by(Evas_Object *ewkView, int dx, int dy)
 {
   LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EINA_FALSE);
+  LOG(INFO) << "view: " << ewkView << ", dx:" << dx << ", dy:" << dy;
+  return impl->EdgeScrollBy(dx, dy);
+#else
+  LOG_EWK_API_MOCKUP("edge_scroll_by feature is not enabled");
   return EINA_FALSE;
+#endif
 }
 
 Eina_Bool ewk_view_set_support_video_hole(Evas_Object* ewkView,
index fd2eae88f558f9f869200b6e5c9d608c77fd5b61..c6dee1d04cf0258d7a74f2249747d618a236f0f1 100644 (file)
@@ -762,4 +762,12 @@ void WebContentsDelegateEfl::OnGetMainFrameScrollbarVisible(int callback_id,
                                                             bool visible) {
   web_view_->InvokeMainFrameScrollbarVisibleCallback(callback_id, visible);
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebContentsDelegateEfl::DidEdgeScrollBy(const gfx::Point& offset,
+    bool handled) {
+  if (web_view_)
+    web_view_->InvokeEdgeScrollByCallback(offset, handled);
+}
+#endif
 }  // namespace content
index 91c09940229fba91d2e79544912781c47102391d..44cc7dd552739ab430b9dbb2bd073f101d0f6f1f 100644 (file)
@@ -69,6 +69,11 @@ class WebContentsDelegateEfl : public WebContentsDelegate {
   void DidChangeInputType(bool is_password_input) override;
 
   void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) override;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override;
+#endif
   void RequestCertificateConfirm(
       WebContents* web_contents,
       int cert_error,
index e19c4a45e9a25ceaf308c59801d5e84c3568586c..e4fd33b057ebb4913932ebe60f2ee33c98b5e302 100644 (file)
@@ -317,6 +317,7 @@ test("ewk_unittests") {
     "utc_blink_ewk_view_custom_header_remove_func.cpp",
     "utc_blink_ewk_view_did_change_theme_color_callback_set_func.cpp",
     "utc_blink_ewk_view_draws_transparent_background_set_func.cpp",
+    "utc_blink_ewk_view_edge_scroll_by_func.cpp",
     "utc_blink_ewk_view_encoding_custom_set_func.cpp",
     "utc_blink_ewk_view_forward_func.cpp",
     "utc_blink_ewk_view_forward_possible_func.cpp",
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_view_edge_scroll_by_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_view_edge_scroll_by_func.cpp
new file mode 100644 (file)
index 0000000..e2b5474
--- /dev/null
@@ -0,0 +1,147 @@
+// Copyright 2022 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_view_edge_scroll_by : public utc_blink_ewk_base {
+ protected:
+  enum OrientaionType { Left, Right, Top, Bottom };
+
+  static void EdgeLeft(void* data, Evas_Object* o, void* data_finished) {
+    utc_message("[EdgeLeft] :: \n");
+    if (data) {
+      auto scroll = static_cast<utc_blink_ewk_view_edge_scroll_by*>(data);
+      if (scroll->orientation_ == Left)
+        scroll->EventLoopStop(Success);
+    }
+  }
+
+  static void EdgeRight(void* data, Evas_Object* o, void* data_finished) {
+    utc_message("[EdgeRight] :: \n");
+    if (data) {
+      auto scroll = static_cast<utc_blink_ewk_view_edge_scroll_by*>(data);
+      if (scroll->orientation_ == Right)
+        scroll->EventLoopStop(Success);
+    }
+  }
+
+  static void EdgeTop(void* data, Evas_Object* o, void* data_finished) {
+    utc_message("[EdgeTop] :: \n");
+    if (data) {
+      auto scroll = static_cast<utc_blink_ewk_view_edge_scroll_by*>(data);
+      if (scroll->orientation_ == Top)
+        scroll->EventLoopStop(Success);
+    }
+  }
+
+  static void EdgeBottom(void* data, Evas_Object* o, void* data_finished) {
+    utc_message("[EdgeBottom] :: \n");
+    if (data) {
+      auto scroll = static_cast<utc_blink_ewk_view_edge_scroll_by*>(data);
+      if (scroll->orientation_ == Bottom)
+        scroll->EventLoopStop(Success);
+    }
+  }
+
+  /* Startup function */
+  void PostSetUp() override {
+    evas_object_smart_callback_add(GetEwkWebView(), "edge,scroll,left",
+                                   EdgeLeft, this);
+    evas_object_smart_callback_add(GetEwkWebView(), "edge,scroll,right",
+                                   EdgeRight, this);
+    evas_object_smart_callback_add(GetEwkWebView(), "edge,scroll,top", EdgeTop,
+                                   this);
+    evas_object_smart_callback_add(GetEwkWebView(), "edge,scroll,bottom",
+                                   EdgeBottom, this);
+  }
+
+  /* Cleanup function */
+  void PreTearDown() override {
+    evas_object_smart_callback_del(GetEwkWebView(), "edge,scroll,left",
+                                   EdgeLeft);
+    evas_object_smart_callback_del(GetEwkWebView(), "edge,scroll,right",
+                                   EdgeRight);
+    evas_object_smart_callback_del(GetEwkWebView(), "edge,scroll,top", EdgeTop);
+    evas_object_smart_callback_del(GetEwkWebView(), "edge,scroll,bottom",
+                                   EdgeBottom);
+  }
+
+ protected:
+  OrientaionType orientation_;
+  static const char* const kResource;
+};
+
+const char* const utc_blink_ewk_view_edge_scroll_by::kResource =
+    "/ewk_view/index_big_red_square.html";
+
+/**
+ * @brief Positive test case of ewk_view_edge_scroll_by(),testing scroll left
+ */
+
+TEST_F(utc_blink_ewk_view_edge_scroll_by, POS_TEST_LEFT) {
+  ASSERT_TRUE(
+      ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kResource).c_str()));
+
+  const int kDeltaX = -10;
+  const int kDeltaY = 0;
+  orientation_ = Left;
+
+  ASSERT_TRUE(ewk_view_edge_scroll_by(GetEwkWebView(), kDeltaX, kDeltaY));
+  ASSERT_EQ(Success, EventLoopStart());
+}
+
+/**
+ * @brief Positive test case of ewk_view_edge_scroll_by(),testing scroll right
+ */
+
+TEST_F(utc_blink_ewk_view_edge_scroll_by, POS_TEST_RIGHT) {
+  ASSERT_TRUE(
+      ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kResource).c_str()));
+
+  const int kDeltaX = 10;
+  const int kDeltaY = 0;
+  orientation_ = Right;
+
+  ASSERT_TRUE(ewk_view_edge_scroll_by(GetEwkWebView(), kDeltaX, kDeltaY));
+  ASSERT_EQ(Success, EventLoopStart());
+}
+
+/**
+ * @brief Positive test case of ewk_view_edge_scroll_by(),testing scroll top
+ */
+
+TEST_F(utc_blink_ewk_view_edge_scroll_by, POS_TEST_TOP) {
+  ASSERT_TRUE(
+      ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kResource).c_str()));
+
+  const int kDeltaX = 0;
+  const int kDeltaY = -10;
+  orientation_ = Top;
+
+  ASSERT_TRUE(ewk_view_edge_scroll_by(GetEwkWebView(), kDeltaX, kDeltaY));
+  ASSERT_EQ(Success, EventLoopStart());
+}
+
+/**
+ * @brief Positive test case of ewk_view_edge_scroll_by(),testing scroll bottom
+ */
+
+TEST_F(utc_blink_ewk_view_edge_scroll_by, POS_TEST_BOTTOM) {
+  ASSERT_TRUE(
+      ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kResource).c_str()));
+
+  const int kDeltaX = 0;
+  const int kDeltaY = 10;
+  orientation_ = Bottom;
+
+  ASSERT_TRUE(ewk_view_edge_scroll_by(GetEwkWebView(), kDeltaX, kDeltaY));
+  ASSERT_EQ(Success, EventLoopStart());
+}
+
+/**
+ * @brief Negative test case of ewk_view_edge_scroll_by(), testing for null
+ */
+TEST_F(utc_blink_ewk_view_edge_scroll_by, NEG_TEST) {
+  EXPECT_EQ(EINA_FALSE, ewk_view_edge_scroll_by(NULL, 1916, 1993));
+}