From: wangjing Date: Tue, 21 Mar 2023 09:08:16 +0000 (+0800) Subject: [M108 Migration][API] Implement ewk_view_edge_scroll_by for all profiles X-Git-Tag: submit/tizen/20230324.160014~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F290198%2F4;p=platform%2Fframework%2Fweb%2Fchromium-efl.git [M108 Migration][API] Implement ewk_view_edge_scroll_by for all profiles 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 --- diff --git a/components/plugins/renderer/webview_plugin.h b/components/plugins/renderer/webview_plugin.h index 886d3ea08e45..2856bf537324 100644 --- a/components/plugins/renderer/webview_plugin.h +++ b/components/plugins/renderer/webview_plugin.h @@ -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, diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 380d147f9563..84f8aae40476 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -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) { diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 688d5a0e4bab..b0696156e5b4 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -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; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index e032c1253d90..e803089f70f8 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -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); } diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 4db3ca59d8ae..d50796e383e9 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -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; diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index 96e32a2f603d..8669e1f7d790 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -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) {} diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 819ddc982b91..2dfc993f47cf 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -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( diff --git a/third_party/blink/public/mojom/BUILD.gn b/third_party/blink/public/mojom/BUILD.gn index 3d36e4a3e901..3e67835c1952 100644 --- a/third_party/blink/public/mojom/BUILD.gn +++ b/third_party/blink/public/mojom/BUILD.gn @@ -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 += [ diff --git a/third_party/blink/public/mojom/page/widget.mojom b/third_party/blink/public/mojom/page/widget.mojom index 46ba93866965..f7feae5d9a0a 100644 --- a/third_party/blink/public/mojom/page/widget.mojom +++ b/third_party/blink/public/mojom/page/widget.mojom @@ -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 diff --git a/third_party/blink/public/mojom/widget/platform_widget.mojom b/third_party/blink/public/mojom/widget/platform_widget.mojom index c4fe956de2be..50071a72ca6f 100644 --- a/third_party/blink/public/mojom/widget/platform_widget.mojom +++ b/third_party/blink/public/mojom/widget/platform_widget.mojom @@ -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, diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h index 15a28caddb18..5a25218085cf 100644 --- a/third_party/blink/public/web/web_view.h +++ b/third_party/blink/public/web/web_view.h @@ -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. diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index 74b18e95586f..316ae20ff332 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -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( + page_->GetFocusController().FocusedOrMainFrame()); + } + + return frame->GetEventHandler().ScrollWithMultiplier(scroll_offset, + result.InnerNode()); +} +#endif + } // namespace blink diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h index cd72cea60fa2..952342be5ee9 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.h +++ b/third_party/blink/renderer/core/exported/web_view_impl.h @@ -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, diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index 43bc4499ab56..b0ae6e6e3a35 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -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; diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index abb3c996fbb6..764b26aa31b9 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h @@ -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, diff --git a/third_party/blink/renderer/core/input/event_handler.cc b/third_party/blink/renderer/core/input/event_handler.cc index d451adeb6fb2..9ef05a6472c0 100644 --- a/third_party/blink/renderer/core/input/event_handler.cc +++ b/third_party/blink/renderer/core/input/event_handler.cc @@ -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(frame->Tree().Parent()); + if (frame) + start_node = frame->DeprecatedLocalOwner(); + } + return false; +} +#endif + void EventHandler::AnimateSnapFling(base::TimeTicks monotonic_time) { scroll_manager_->AnimateSnapFling(monotonic_time); } diff --git a/third_party/blink/renderer/core/input/event_handler.h b/third_party/blink/renderer/core/input/event_handler.h index 6f7855ee6468..60c2c7046409 100644 --- a/third_party/blink/renderer/core/input/event_handler.h +++ b/third_party/blink/renderer/core/input/event_handler.h @@ -269,6 +269,11 @@ class CORE_EXPORT EventHandler final : public GarbageCollected { // 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_; } diff --git a/third_party/blink/renderer/core/input/scroll_manager.cc b/third_party/blink/renderer/core/input/scroll_manager.cc index c1f2ac4840b6..850c18180bec 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.cc +++ b/third_party/blink/renderer/core/input/scroll_manager.cc @@ -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()) diff --git a/third_party/blink/renderer/core/input/scroll_manager.h b/third_party/blink/renderer/core/input/scroll_manager.h index a0ee9e7aa5a7..576d519a1384 100644 --- a/third_party/blink/renderer/core/input/scroll_manager.h +++ b/third_party/blink/renderer/core/input/scroll_manager.h @@ -71,7 +71,8 @@ class CORE_EXPORT ScrollManager : public GarbageCollected, 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). diff --git a/third_party/blink/renderer/platform/widget/widget_base.cc b/third_party/blink/renderer/platform/widget/widget_base.cc index 8c2556cee44a..a699184c7095 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.cc +++ b/third_party/blink/renderer/platform/widget/widget_base.cc @@ -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( diff --git a/third_party/blink/renderer/platform/widget/widget_base.h b/third_party/blink/renderer/platform/widget/widget_base.h index 485070f7268f..ad55f28e10d4 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.h +++ b/third_party/blink/renderer/platform/widget/widget_base.h @@ -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 diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc index 283d714987e8..0f7e55ab4bb5 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc @@ -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, diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h index 4f7c79b48ba1..53c5d146e8a8 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h @@ -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); diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 48136a423453..d7a964dea62a 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -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(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().call(&handled); + else if (offset.x() > 0) + SmartCallback().call(&handled); + + if (offset.y() < 0) + SmartCallback().call(&handled); + else if (offset.y() > 0) + SmartCallback().call(&handled); +} +#endif + void EWebView::HandleRendererProcessCrash() { content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, base::BindOnce(&EWebView::InvokeWebProcessCrashedCallback, diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 05c7ef4c080c..470e0706da78 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -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_; diff --git a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h index 1e577763b2ca..be7eaf7cd855 100644 --- a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h +++ b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h @@ -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*); diff --git a/tizen_src/ewk/efl_integration/public/ewk_view.cc b/tizen_src/ewk/efl_integration/public/ewk_view.cc index f699d1475f0e..ef55affd9198 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_view.cc @@ -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, diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index fd2eae88f558..c6dee1d04cf0 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -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 diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 91c09940229f..44cc7dd55273 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -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, diff --git a/tizen_src/ewk/unittest/BUILD.gn b/tizen_src/ewk/unittest/BUILD.gn index e19c4a45e9a2..e4fd33b057eb 100644 --- a/tizen_src/ewk/unittest/BUILD.gn +++ b/tizen_src/ewk/unittest/BUILD.gn @@ -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 index 000000000000..e2b5474b9626 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_view_edge_scroll_by_func.cpp @@ -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(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(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(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(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)); +}