[M108 Migration] Patches related to focusable or clickable nodes and tap highlights 59/288559/3
authorayush.k123 <ayush.k123@samsung.com>
Mon, 20 Feb 2023 03:22:28 +0000 (08:52 +0530)
committerBot Blink <blinkbot@samsung.com>
Mon, 20 Feb 2023 12:30:48 +0000 (12:30 +0000)
Patch adds below features:
  - Skip chromium default tap highlight style for HTMLElement
  - Add tap highlight to focusable or clickable node
  - Clear active and hover state before handle tap event
  - Do not show tap highlight for document node

Reference: https://review.tizen.org/gerrit/283816/

Change-Id: I8240fab2d8f34eccecbdef1c50c0fa7617d7fc23
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/input/event_handler.cc
third_party/blink/renderer/core/page/link_highlight.cc

index 8d44cb5..b88bd2e 100644 (file)
@@ -842,6 +842,16 @@ static Node* FindLinkHighlightAncestor(Node* node) {
   return nullptr;
 }
 
+#if BUILDFLAG(IS_EFL)
+static bool IsClickableOrFocusable(Node* focusable_node) {
+  return (focusable_node->IsHTMLElement() &&
+          To<HTMLElement>(focusable_node)->IsFocusable()) ||
+         focusable_node->HasEventListeners(event_type_names::kClick) ||
+         focusable_node->HasEventListeners(event_type_names::kMousedown) ||
+         focusable_node->HasEventListeners(event_type_names::kMouseup);
+}
+#endif
+
 // This is for tap (link) highlight and is tested in
 // link_highlight_impl_test.cc.
 Node* WebViewImpl::BestTapNode(
@@ -868,6 +878,28 @@ Node* WebViewImpl::BestTapNode(
   if (IsEditable(*best_touch_node))
     return nullptr;
 
+#if BUILDFLAG(IS_EFL)
+  // If we hit HTMLButtonElement, then show tap highlight on it.
+  if (RuntimeEnabledFeatures::TizenCompatibilityModeEnabled()) {
+    auto focusable = best_touch_node;
+    do {
+      if (IsClickableOrFocusable(focusable)) {
+        if (focusable->IsContainerNode() && !focusable->IsLink()) {
+          auto child =
+              static_cast<const ContainerNode*>(focusable)->firstChild();
+          while (child) {
+            if (IsClickableOrFocusable(child))
+              return nullptr;
+
+            child = NodeTraversal::Next(*child, focusable);
+          }
+        }
+        return focusable;
+      }
+    } while (focusable && (focusable = focusable->parentNode()));
+  }
+#endif
+
   Node* hand_cursor_ancestor = FindLinkHighlightAncestor(best_touch_node);
   // We show a highlight on tap only when the current node shows a hand cursor
   if (!hand_cursor_ancestor) {
index e0b10ba..904052a 100644 (file)
@@ -1924,8 +1924,12 @@ GestureEventWithHitTestResults EventHandler::TargetGestureEvent(
   bool should_keep_active_for_min_interval = false;
   if (read_only) {
     hit_type |= HitTestRequest::kReadOnly;
-  } else if (gesture_event.GetType() == WebInputEvent::Type::kGestureTap &&
-             last_show_press_timestamp_) {
+  } else if (
+#if BUILDFLAG(IS_EFL)
+      !RuntimeEnabledFeatures::TizenCompatibilityModeEnabled() &&
+#endif
+      gesture_event.GetType() == WebInputEvent::Type::kGestureTap &&
+      last_show_press_timestamp_) {
     // If the Tap is received very shortly after ShowPress, we want to
     // delay clearing of the active state so that it's visible to the user
     // for at least a couple of frames.
index 56dd7ea..6dd7831 100644 (file)
 #include "third_party/blink/renderer/core/page/page.h"
 #include "third_party/blink/renderer/core/paint/link_highlight_impl.h"
 
+#if BUILDFLAG(IS_EFL)
+#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
+#endif
+
 namespace blink {
 
 LinkHighlight::LinkHighlight(Page& owner) : page_(&owner) {}
@@ -55,6 +59,23 @@ void LinkHighlight::SetTapHighlight(Node* node) {
   DCHECK(node->GetLayoutObject());
   DCHECK(!node->IsTextNode());
 
+#if BUILDFLAG(IS_EFL)
+  // Chromium-efl shows light orange semi-transparent highlight on tap
+  // (Defined in "blink/renderer/core/layout/layout_theme_chromium_tizen.cc").
+  // For elements larger than 80% of the size of visible viewport, tap
+  // highlight resulted in undesirable visible effects. So disable the tap
+  // highlight for those elements, when compatibility mode is enabled.
+  if (RuntimeEnabledFeatures::TizenCompatibilityModeEnabled() &&
+      (node->IsHTMLElement() || node->IsDocumentNode())) {
+    gfx::Rect visible_rect =
+        MainFrame()->View()->LayoutViewport()->VisibleContentRect();
+    gfx::Rect node_rect = node->GetLayoutObject()->AbsoluteBoundingBoxRect();
+    if (node_rect.width() > (visible_rect.width() * 0.8) &&
+        node_rect.height() > (visible_rect.height() * 0.8))
+      return;
+  }
+#endif
+
   Color highlight_color =
       node->GetLayoutObject()->StyleRef().VisitedDependentColor(
           GetCSSPropertyWebkitTapHighlightColor());