[M120 Migration] Fix show IME 55/309755/3
authorfang fengrong <fr.fang@samsung.com>
Tue, 16 Apr 2024 08:10:25 +0000 (16:10 +0800)
committerBot Blink <blinkbot@samsung.com>
Fri, 19 Apr 2024 03:16:25 +0000 (03:16 +0000)
1. [VD] Do not show IME if click is prevented or
scrollbar
Do not 'ShowVirtualKeyboard' when mouse up event occurs
if the previous mouse down event is 'preventDefault'
by JavaScript.

Bug: DF170215-01023

Check if it is mouse click on the scrollbar before
|ShowVirtualKeyboard|.
No need to show VirtualKeyboard if click on the scrollbar.

2. [HBBTV] Trigger auto show IME when webview focus in

The patch is for fixing hbbtv can not auto show IME issue.

Current, only element been set focus can tigger show IME autolly,
but show IME autolly also need based on webview been focused.
If element been focused first, and webview been focused later,
then can not show IME.

So here, add another trigger to show IME autolly.

refer:
https://review.tizen.org/gerrit/#/c/288827

Change-Id: I025fa50f075f3d816467e7b7550e6c3002271d5d
Signed-off-by: fang fengrong <fr.fang@samsung.com>
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/platform/widget/input/widget_base_input_handler.cc

index e12739b..a2dcd9d 100644 (file)
@@ -516,6 +516,11 @@ class BLINK_EXPORT WebView {
   // Returns the number of live WebView instances in this process.
   static size_t GetWebViewCount();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual bool IsHitScrollbar() { return false; }
+  virtual bool IsMouseDownEventSwallowed() { return false; }
+#endif
+
   // Sets whether web or OS-level Attribution Reporting is supported. See
   // https://github.com/WICG/attribution-reporting-api/blob/main/app_to_web.md
   virtual void SetPageAttributionSupport(
index 5d19945..b0e55f4 100644 (file)
@@ -2025,6 +2025,15 @@ void WebViewImpl::SetPageFocus(bool enable) {
         }
       }
 #if BUILDFLAG(IS_TIZEN_TV)
+      // Trigger auto show IME when webview focus in
+      if (IsHbbTV()) {
+        if (MainFrameImpl() && MainFrameImpl()->FrameWidgetImpl()) {
+          MainFrameImpl()
+              ->FrameWidgetImpl()
+              ->DidUpdateTextOfFocusedElementByNonUserInput();
+        }
+      }
+
       if (element) {
         // Accessibility needs to be informed that system focus has moved
         // into the web area again, even if focus did not change within
@@ -3783,6 +3792,23 @@ void WebViewImpl::RemoveObserver(WebViewObserver* observer) {
 }
 
 #if BUILDFLAG(IS_TIZEN_TV)
+bool WebViewImpl::IsHitScrollbar() {
+  const LocalFrame* frame =
+      DynamicTo<LocalFrame>(page_->GetFocusController().FocusedOrMainFrame());
+  if (!frame)
+    return false;
+  return frame->GetEventHandler().PressedScrollbar();
+}
+
+bool WebViewImpl::IsMouseDownEventSwallowed() {
+  if (!MainFrameImpl() || !MainFrameImpl()->GetFrame())
+    return false;
+  return MainFrameImpl()
+      ->GetFrame()
+      ->GetEventHandler()
+      .MousePressEventSwallowed();
+}
+
 void WebViewImpl::SetFloatVideoWindowState(bool enable) {
   if (!GetPage())
     return;
index 195da37..b45d3c6 100644 (file)
@@ -246,6 +246,11 @@ class CORE_EXPORT WebViewImpl final : public WebView,
   const SessionStorageNamespaceId& GetSessionStorageNamespaceId() override;
   bool IsFencedFrameRoot() const override;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool IsHitScrollbar() override;
+  bool IsMouseDownEventSwallowed() override;
+#endif
+
 #if BUILDFLAG(IS_EFL)
   bool PaintSoftBitmap(SkCanvas*, const gfx::Rect&) override;
   bool HasAcceleratedCanvasWithinViewport() const override;
index 153089a..f51c6bd 100644 (file)
@@ -4724,6 +4724,14 @@ bool WebFrameWidgetImpl::RequestMainFrameScrollbarVisible(bool& visible) {
 }
 
 #if BUILDFLAG(IS_TIZEN_TV)
+bool WebFrameWidgetImpl::IsHitScrollbar() {
+  return View()->IsHitScrollbar();
+}
+
+bool WebFrameWidgetImpl::IsMouseDownEventSwallowed() {
+  return View()->IsMouseDownEventSwallowed();
+}
+
 void WebFrameWidgetImpl::SetFloatVideoWindowState(bool enabled) {
   View()->SetFloatVideoWindowState(enabled);
 }
index 64d8a9b..632277f 100644 (file)
@@ -803,6 +803,8 @@ class CORE_EXPORT WebFrameWidgetImpl
   void SelectFocusedLink() override;
   gfx::Rect RequestSelectionRect() override;
 #if BUILDFLAG(IS_TIZEN_TV)
+  bool IsHitScrollbar() override;
+  bool IsMouseDownEventSwallowed() override;
   void SetFloatVideoWindowState(bool enabled) override;
   void SuspendNetworkLoading() override;
   void ResumeNetworkLoading() override;
index 6404005..49372f2 100644 (file)
@@ -802,6 +802,7 @@ WebInputEventResult EventHandler::HandleMousePressEvent(
 
 #if BUILDFLAG(IS_TIZEN_TV)
   handled_mouse_left_button_press_event_ = false;
+  mouse_press_event_swallowed_ = false;
 #endif
 
   HitTestRequest request(HitTestRequest::kActive);
@@ -945,6 +946,9 @@ WebInputEventResult EventHandler::HandleMousePressEvent(
             ? event_result != WebInputEventResult::kNotHandled
             : true;
   }
+
+  if (mev.GetScrollbar())
+    pressed_scrollbar_ = true;
 #endif
 
   if (PassMousePressEventToScrollbar(mev))
@@ -968,6 +972,11 @@ WebInputEventResult EventHandler::HandleMousePressEvent(
     frame_->GetChromeClient().OnMouseDown(*result.InnerNode());
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  mouse_press_event_swallowed_ =
+      (event_result == WebInputEventResult::kHandledApplication);
+#endif
+
   return event_result;
 }
 
@@ -1227,6 +1236,10 @@ WebInputEventResult EventHandler::HandleMouseReleaseEvent(
   mouse_event_manager_->SetLastKnownMousePosition(mouse_event);
   mouse_event_manager_->HandleSvgPanIfNeeded(true);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  pressed_scrollbar_ = false;
+#endif
+
   if (frame_set_being_resized_) {
     WebInputEventResult result =
         mouse_event_manager_->SetMousePositionAndDispatchMouseEvent(
index 8046846..d48f4bc 100644 (file)
@@ -254,6 +254,8 @@ class CORE_EXPORT EventHandler final : public GarbageCollected<EventHandler> {
   void ClearDragState();
 
 #if BUILDFLAG(IS_TIZEN_TV)
+  bool MousePressEventSwallowed() const { return mouse_press_event_swallowed_; }
+  bool PressedScrollbar() const { return pressed_scrollbar_; }
   bool ScrollNewPosition(const ScrollOffset&, LocalFrameView*);
   bool ScrollWithMultiplier(const ScrollOffset&, Node*);
 #endif
@@ -477,6 +479,8 @@ class CORE_EXPORT EventHandler final : public GarbageCollected<EventHandler> {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   bool handled_mouse_left_button_press_event_ = false;
+  bool mouse_press_event_swallowed_ = false;
+  bool pressed_scrollbar_ = false;
 #endif
 
   // ShouldShowIBeamForNode's unit tests:
index 9386878..8525320 100644 (file)
@@ -443,6 +443,12 @@ void WidgetBaseInputHandler::HandleInputEvent(
     prevent_default = prevent_default || suppress;
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool hit_scrollbar = false;
+  if (widget_->client())
+    hit_scrollbar = widget_->client()->IsHitScrollbar();
+#endif
+
   WebInputEventResult processed = prevent_default
                                       ? WebInputEventResult::kHandledSuppressed
                                       : WebInputEventResult::kNotHandled;
@@ -543,11 +549,24 @@ void WidgetBaseInputHandler::HandleInputEvent(
 
   // Show the virtual keyboard if enabled and a user gesture triggers a focus
   // change.
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool mouse_down_event_swallowed = false;
+  if (widget_->client())
+    mouse_down_event_swallowed = widget_->client()->IsMouseDownEventSwallowed();
+
+  if (((processed != WebInputEventResult::kNotHandled &&
+        input_event.GetType() == WebInputEvent::Type::kTouchEnd) ||
+       show_virtual_keyboard_for_mouse) &&
+      !mouse_down_event_swallowed && !hit_scrollbar) {
+    widget_->ShowVirtualKeyboard();
+  }
+#else
   if ((processed != WebInputEventResult::kNotHandled &&
        input_event.GetType() == WebInputEvent::Type::kTouchEnd) ||
       show_virtual_keyboard_for_mouse) {
     widget_->ShowVirtualKeyboard();
   }
+#endif
 
   if (!prevent_default &&
       WebInputEvent::IsKeyboardEventType(input_event.GetType()))