[M120 Migration][VD][Accessibility] Add smart callbacks for spatial navigation 16/309216/3
authorjiangyuwei <yuwei.jiang@samsung.com>
Sun, 7 Apr 2024 06:04:59 +0000 (14:04 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 8 Apr 2024 07:12:50 +0000 (07:12 +0000)
This patch is for changing focus from web view in Tizen TV to browser
when cannot move focus any more by press arrow keys in spatial navigation.

References:
  - https://review.tizen.org/gerrit/291208/

Change-Id: I3c7d860b9f42e6f863c0174ce918490b6fcf0202
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
20 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/widget/platform_widget.mojom
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/page/spatial_navigation.h
third_party/blink/renderer/core/page/spatial_navigation_controller.cc
third_party/blink/renderer/core/page/spatial_navigation_controller.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_callbacks.h
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h

index 4d9c310c0a4fbed15b38ae8c57c8c1885b806235..1ce869038dd9b5316da56c080b12ce496a361101 100644 (file)
@@ -197,6 +197,7 @@ class WebViewPlugin : public blink::WebPlugin, public blink::WebViewObserver {
     void SetCursor(const ui::Cursor& cursor) override;
 #if BUILDFLAG(IS_TIZEN_TV)
     void DidEdgeScrollBy(const gfx::Point& point, bool handled) override {}
+    void MoveFocusToBrowser(int direction) override {}
     void NotifyTrackInfoToBrowser(int active_track_id,
                                   const std::string& url,
                                   const std::string& lang) override {}
index 474dd2dc7e1652cd4c6afa710ba8e7c9e8ba2712..e19024b417910b8f6f6c297071682379b60c85fe 100644 (file)
@@ -2902,6 +2902,13 @@ void RenderWidgetHostImpl::DidEdgeScrollBy(const gfx::Point& offset, bool handle
   view_->DidEdgeScrollBy(offset, handled);
 }
 
+void RenderWidgetHostImpl::MoveFocusToBrowser(int direction) {
+  if (!GetView())
+    return;
+
+  view_->MoveFocusToBrowser(direction);
+}
+
 void RenderWidgetHostImpl::SetTranslatedURL(const std::string& url) {
   if (!blink_widget_)
     return;
index d9abcd9845c5d277d272f1fdba3f581aedc64326..c542a5162de878ebcda0c69a87e22881c525fb29 100644 (file)
@@ -322,6 +322,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   void DidEdgeScrollBy(const gfx::Point& point, bool handled) override;
+  void MoveFocusToBrowser(int direction) override;
   void NotifyTrackInfoToBrowser(int active_track_id,
                                 const std::string& url,
                                 const std::string& lang) override;
index a3d24c31062b0c89ca01f9128a3ac5eee4d5bc2a..8dc88b6a96f4e12253d7642d47aef05093bff42d 100644 (file)
@@ -2364,6 +2364,12 @@ void RenderWidgetHostViewAura::DidEdgeScrollBy(const gfx::Point& offset,
     efl_helper_->DidEdgeScrollBy(offset, handled);
 }
 
+void RenderWidgetHostViewAura::MoveFocusToBrowser(int direction) {
+  if (aura_efl_helper()) {
+    aura_efl_helper()->MoveFocusToBrowser(direction);
+  }
+}
+
 void RenderWidgetHostViewAura::NotifyTrackInfoToBrowser(
     int active_track_id,
     const std::string& url,
index 80bb89fd7438d8838100362135a1a233f13621da..fa133fa42e7a6eaf28068fb7ada8197679ca4be9 100644 (file)
@@ -235,6 +235,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override ;
+  void MoveFocusToBrowser(int direction) override;
   void NotifyTrackInfoToBrowser(int active_track_id,
                                 const std::string& url,
                                 const std::string& lang) override;
index 2b55acf017c2314595fa2c2cf5502e9ab644d17a..5076dde8ac30f8b85a479bb890868a814305a70d 100644 (file)
@@ -507,6 +507,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView {
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   virtual void DidEdgeScrollBy(const gfx::Point& offset, bool handled) {}
+  virtual void MoveFocusToBrowser(int direction) {}
+
   // notify web browser video playing status
   virtual void VideoPlayingStatusReceived(bool is_playing, int callback_id) {}
 
index d2d66abf34ce95077ef8b6915c02253615fddcb3..57d3318f9f19f7f2df8c775c6a6a1d190a84d99e 100644 (file)
@@ -409,6 +409,7 @@ class CONTENT_EXPORT WebContentsDelegate {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void DidEdgeScrollBy(const gfx::Point& offset, bool handled) {}
+  virtual void MoveFocusToBrowser(int direction) {}
   virtual void ShowMicOpenedNotification(bool show) {}
 #endif
 
index 0f8367e97a228ac842ade45d918076bda013c92f..9c2cd90ca6ea8641d9a9677f1271957d4679cf48 100644 (file)
@@ -41,6 +41,9 @@ interface WidgetHost {
   //Browser edge scroll
   DidEdgeScrollBy(gfx.mojom.Point offset, bool handled);
 
+  [EnableIf=is_tizen_tv]
+  MoveFocusToBrowser(int32 direction);
+
   // 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 beb29d0ad82563b00889e063e751bedc30da46f5..153089a75afb483490b0b83b8ce842732ecf75bb 100644 (file)
@@ -5189,6 +5189,10 @@ void WebFrameWidgetImpl::NotifyTrackInfoToBrowser(int active_track_id,
             << " url:" << url << " lang:" << lang;
   widget_base_->NotifyTrackInfoToBrowser(active_track_id, url, lang);
 }
+
+void WebFrameWidgetImpl::MoveFocusToBrowser(int direction) {
+  widget_base_->MoveFocusToBrowser(direction);
+}
 #endif
 
 #if BUILDFLAG(IS_TIZEN)
index c3275061e52275ce28ea9e588d1f2e0ba7e8b51b..64d8a9b84afc5835ad02e72fc1849f9da98b78c1 100644 (file)
@@ -713,6 +713,7 @@ class CORE_EXPORT WebFrameWidgetImpl
   void NotifyTrackInfoToBrowser(int active_track_id,
                                 const std::string& url,
                                 const std::string& lang);
+  void MoveFocusToBrowser(int direction);
 #endif
 
  protected:
index 59639707471f445c2e1432ad241ab20472dd706e..c7de3c5aa911948023c3674ae27202f0a5bab826 100644 (file)
@@ -35,6 +35,18 @@ class HTMLFrameOwnerElement;
 
 enum class SpatialNavigationDirection { kNone, kUp, kRight, kDown, kLeft };
 
+// The direction value in WebFocusType (before Tizen 5.5) is different from
+// SpatialNavigationDirection. While ewk callback is using the int value of
+// them, if can not change ewk interface then we need compatible adaptation
+enum CompatibilityFocusType {
+  kFocusTypeNone = 0,
+  // Spatial navigation.
+  kFocusTypeUp = 3,
+  kFocusTypeDown,
+  kFocusTypeLeft,
+  kFocusTypeRight
+};
+
 constexpr double kMaxDistance = std::numeric_limits<double>::max();
 
 CORE_EXPORT bool IsSpatialNavigationEnabled(const LocalFrame*);
index 47f16c4c240735c01dcdbbc8dc05eec451393a14..fb654f471b35ab84dd7cad34d713333565176a9e 100644 (file)
@@ -37,6 +37,7 @@
 #include "third_party/blink/renderer/core/css/style_change_reason.h"
 
 #if BUILDFLAG(IS_TIZEN_TV)
+#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
 #include "third_party/blink/renderer/platform/keyboard_codes.h"
 #endif
 
@@ -309,6 +310,25 @@ void SpatialNavigationController::Trace(Visitor* visitor) const {
   visitor->Trace(page_);
 }
 
+int SpatialNavigationController::ToCompatibilityFocusType(
+    SpatialNavigationDirection direction) {
+  switch (direction) {
+    case SpatialNavigationDirection::kUp:
+      return CompatibilityFocusType::kFocusTypeUp;
+    case SpatialNavigationDirection::kDown:
+      return CompatibilityFocusType::kFocusTypeDown;
+    case SpatialNavigationDirection::kLeft:
+      return CompatibilityFocusType::kFocusTypeLeft;
+    case SpatialNavigationDirection::kRight:
+      return CompatibilityFocusType::kFocusTypeRight;
+    case SpatialNavigationDirection::kNone:
+      return CompatibilityFocusType::kFocusTypeNone;
+    default:
+      NOTREACHED();
+      return CompatibilityFocusType::kFocusTypeNone;
+  }
+}
+
 bool SpatialNavigationController::Advance(
     SpatialNavigationDirection direction) {
   Node* interest_node = StartingNode();
@@ -357,6 +377,18 @@ bool SpatialNavigationController::Advance(
       document->UpdateStyleAndLayout(DocumentUpdateReason::kSpatialNavigation);
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  Frame* frame = page_->GetFocusController().FocusedOrMainFrame();
+  auto* local_frame = DynamicTo<LocalFrame>(frame);
+  if (!local_frame)
+    return false;
+  WebFrameWidgetImpl* wfwgt =
+      static_cast<WebFrameWidgetImpl*>(local_frame->GetWidgetForLocalRoot());
+  if (!wfwgt)
+    return false;
+  wfwgt->MoveFocusToBrowser(ToCompatibilityFocusType(direction));
+#endif
+
   return false;
 }
 
index 5ec30872c238793e9ba966bc00d38de42c162b02..922c34083af3a0e0e4f61afe1516d2104921120e 100644 (file)
@@ -55,6 +55,7 @@ class CORE_EXPORT SpatialNavigationController final
 #endif
 
  private:
+  int ToCompatibilityFocusType(SpatialNavigationDirection direction);
   // Entry-point into SpatialNavigation advancement. Will return true if an
   // action (moving interest or scrolling), false otherwise.
   bool Advance(SpatialNavigationDirection direction);
index 5cd531ac559aa5c74abbad964742a39468c0f88e..d1446fecb0bbf697c8b99252d240712d62a09345 100644 (file)
@@ -1169,6 +1169,10 @@ void WidgetBase::DidEdgeScrollBy(const gfx::Point& offset, bool handled) {
   widget_host_->DidEdgeScrollBy(offset, handled);
 }
 
+void WidgetBase::MoveFocusToBrowser(int direction) {
+  widget_host_->MoveFocusToBrowser(direction);
+}
+
 void WidgetBase::NotifyTrackInfoToBrowser(int active_track_id,
                                           const std::string& url,
                                           const std::string& lang) {
index d385fc7e6a0df3737254962ba44a158b61dc8be4..b26033776296c34fcba8e39bc8ff4ed0f2be909f 100644 (file)
@@ -266,6 +266,7 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   void DidEdgeScrollBy(const gfx::Point& offset, bool handled);
+  void MoveFocusToBrowser(int direction);
   void NotifyTrackInfoToBrowser(int active_track_id,
                                 const std::string& url,
                                 const std::string& lang);
index c9ad3a8ffa4a2f4f40cf96c2fe52babf37ad1894..e9192bc89eb74be58cc57a5b82d6ce080fbb94d3 100644 (file)
@@ -451,6 +451,11 @@ void RWHVAuraCommonHelperEfl::DidEdgeScrollBy(const gfx::Point& offset,
   web_contents_->GetDelegate()->DidEdgeScrollBy(offset, handled);
 }
 
+void RWHVAuraCommonHelperEfl::MoveFocusToBrowser(int direction) {
+  if (web_contents_)
+    web_contents_->GetDelegate()->MoveFocusToBrowser(direction);
+}
+
 void RWHVAuraCommonHelperEfl::SetParentalRatingResult(const std::string& url,
                                                       bool is_pass) {
   if (rwhv_aura_)
index d79c7c22c173c2e90107d159f6783c0440267c4d..1c1ad6bc1676efbc4e2bce22735d691716ea7fdd 100644 (file)
@@ -137,6 +137,7 @@ class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   void DidEdgeScrollBy(const gfx::Point& offset, bool handled);
+  void MoveFocusToBrowser(int direction);
   void SetPopupMenuVisible(const bool visible);
   void SetPopupMenuBounds(const gfx::Rect& popup_bounds);
   void SetCursorByClient(bool enable) { cursor_set_by_client_ = enable; }
index 9a0ac176ae8b88ac3e3774ccbb91fe2b0101dcf4..06ed6a5896f12d540af9e76bdd7aae213c87015e 100644 (file)
@@ -170,6 +170,7 @@ enum CallbackType {
   NewWindowNavigationPolicyDecision,
 #endif  // IS_TIZEN
 #if BUILDFLAG(IS_TIZEN_TV)
+  AtkKeyEventNotHandled,
   HoverOverLink,
   HoverOutLink,
   ParentalRatingInfo,
@@ -369,6 +370,9 @@ DECLARE_EWK_VIEW_CALLBACK(NewWindowNavigationPolicyDecision, "policy,decision,ne
 
 #if BUILDFLAG(IS_TIZEN_TV)
 DECLARE_EWK_VIEW_CALLBACK(ParentalRatingInfo, "on,parentalrating,info", void*);
+DECLARE_EWK_VIEW_CALLBACK(AtkKeyEventNotHandled,
+                          "atk,keyevent,nothandled",
+                          int*);
 DECLARE_EWK_VIEW_CALLBACK(HoverOverLink, "hover,over,link", const char*);
 DECLARE_EWK_VIEW_CALLBACK(HoverOutLink, "hover,out,link", const char*);
 DECLARE_EWK_VIEW_CALLBACK(LoginFormSubmitted,
index 6c4c6e337d9d140ea1f97e4aa20075369fbaaa59..7eb7f0f7a7399f13956cc11f56b48671a3b3824f 100644 (file)
@@ -823,6 +823,13 @@ void WebContentsDelegateEfl::DidEdgeScrollBy(const gfx::Point& offset,
     web_view_->InvokeEdgeScrollByCallback(offset, handled);
 }
 
+void WebContentsDelegateEfl::MoveFocusToBrowser(int direction) {
+  if (web_view_) {
+    web_view_->SmartCallback<EWebViewCallbacks::AtkKeyEventNotHandled>().call(
+        &direction);
+  }
+}
+
 void WebContentsDelegateEfl::WillDraw(int new_rotation,
                                       gfx::Size frame_data_output_size) {
   if (web_view_) {
index 5dc1bd519441c8568761b063686f858adf90ac90..4e1b8346847ac41bfe14fda4f195b4b766f88256 100644 (file)
@@ -77,6 +77,7 @@ class WebContentsDelegateEfl : public WebContentsDelegate {
 #if BUILDFLAG(IS_TIZEN_TV)
   //Browser edge scroll
   void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override;
+  void MoveFocusToBrowser(int direction) override;
   void NotifyDownloadableFontInfo(const std::string& scheme_id_uri,
                                   const std::string& value,
                                   const std::string& data,