[M108 Migration] Segregate RWHVAuraOffscreenHelperEfl for both rendering modes 98/289698/8
authorSurya Kumar <surya.kumar7@samsung.com>
Wed, 22 Mar 2023 09:12:26 +0000 (14:42 +0530)
committerSurya Kumar <surya.kumar7@samsung.com>
Wed, 22 Mar 2023 15:54:49 +0000 (21:24 +0530)
1. This patch segregates existing common functionalities in RWHVAuraOffscreenHelperEfl
so it can be used during both onscreen & offscreen rendering modes
2. Added safety checks before using offscreen_helper in non offscreen
rendering mode
3. Suppressed several build time warnings

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

Change-Id: I4922a60b2b9504a4c7c62b6f3a9c858cb385eafb
Signed-off-by: Surya Kumar <surya.kumar7@samsung.com>
19 files changed:
content/browser/accessibility/browser_accessibility_manager.cc
content/browser/renderer_host/render_widget_host_view_aura.cc
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/web_contents/web_contents_impl.h
tizen_src/chromium_impl/content/browser/browser_efl.gni
tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h [new file with mode: 0644]
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h
tizen_src/chromium_impl/content/browser/selection/selection_box_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_handle_efl.cc
tizen_src/chromium_impl/content/browser/selection/selection_magnifier_efl.cc
tizen_src/chromium_impl/content/public/browser/render_widget_host_helper.h
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc
tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_observer_efl.cc

index 58f9f36..2447c7d 100644 (file)
@@ -2082,7 +2082,8 @@ void BrowserAccessibilityManager::EvasToBlinkCords(int x,
   if (!view)
     return;
 
-  view->offscreen_helper()->EvasToBlinkCords(x, y, view_x, view_y);
+  if (auto offscreen_helper = view->offscreen_helper())
+    offscreen_helper->EvasToBlinkCords(x, y, view_x, view_y);
   gfx::Rect rect(*view_x, *view_y, 0, 0);
   rect.Offset(GetViewBoundsInScreenCoordinates().OffsetFromOrigin());
   *view_x = rect.x();
@@ -2093,7 +2094,7 @@ void BrowserAccessibilityManager::CheckFocusOnEwebview() {
   auto view =
       static_cast<RenderWidgetHostViewAura*>(delegate_->AccessibilityGetView());
 
-  if (!view)
+  if (!view || !view->offscreen_helper())
     return;
 
   if (!view->offscreen_helper()->HasFocus())
index 398f442..e032c12 100644 (file)
@@ -309,11 +309,10 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(
   host()->render_frame_metadata_provider()->AddObserver(this);
 
 #if BUILDFLAG(IS_EFL)
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kEnableOffscreenRendering)) {
-    offscreen_helper_ =
-        std::make_unique<RWHVAuraOffscreenHelperEfl>(this, &web_contents);
-  }
+  efl_helper_ =
+      base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOffscreenRendering)
+      ? std::make_unique<RWHVAuraOffscreenHelperEfl>(this, &web_contents)
+      : std::make_unique<RWHVAuraCommonHelperEfl>(this, &web_contents);
 #endif
 }
 
@@ -328,8 +327,7 @@ void RenderWidgetHostViewAura::InitAsChild(gfx::NativeView parent_view) {
     parent_view->AddChild(GetNativeView());
 
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->SetAuraParentWindow(parent_view);
+  efl_helper_->SetAuraParentWindow(parent_view);
 #endif
 
   device_scale_factor_ = GetDeviceScaleFactor();
@@ -543,8 +541,7 @@ void RenderWidgetHostViewAura::Focus() {
     window_->Focus();
 
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->Focus(true);
+  efl_helper_->Focus(true);
 #endif
 }
 
@@ -560,38 +557,31 @@ bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() {
 #if BUILDFLAG(IS_EFL)
 void RenderWidgetHostViewAura::BackgroundColorReceived(int callback_id,
                                                        SkColor bg_color) {
-  if (offscreen_helper_)
-    offscreen_helper_->BackgroundColorReceived(callback_id, bg_color);
+  efl_helper_->BackgroundColorReceived(callback_id, bg_color);
 }
 
 void RenderWidgetHostViewAura::DidGetContentSnapshot(const SkBitmap& bitmap,
                                                      int request_id) {
-  if (offscreen_helper_)
-    offscreen_helper_->DidGetContentSnapshot(bitmap, request_id);
+  efl_helper_->DidGetContentSnapshot(bitmap, request_id);
 }
 
 void RenderWidgetHostViewAura::DidHandleKeyEvent(
     blink::WebInputEvent::Type input_event_type,
     bool processed) {
-  if (offscreen_helper_)
-    offscreen_helper_->DidHandleKeyEvent(input_event_type, processed);
+  efl_helper_->DidHandleKeyEvent(input_event_type, processed);
 }
 
 void RenderWidgetHostViewAura::SelectionChanged(const std::u16string& text,
                                                 size_t offset,
                                                 const gfx::Range& range) {
   RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
-
-  if (offscreen_helper_)
-    offscreen_helper_->SelectionChanged(text, offset, range);
+  efl_helper_->SelectionChanged(text, offset, range);
 }
 
 void RenderWidgetHostViewAura::TextInputStateChanged(
     const ui::mojom::TextInputState& params) {
   RenderWidgetHostViewBase::TextInputStateChanged(params);
-
-  if (offscreen_helper_)
-    offscreen_helper_->TextInputStateChanged(params);
+  efl_helper_->TextInputStateChanged(params);
 }
 #endif
 
@@ -666,8 +656,7 @@ void RenderWidgetHostViewAura::HideImpl() {
          visibility_ == Visibility::OCCLUDED);
 
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->Hide();
+  efl_helper_->Hide();
 #endif
 
   if (!host()->is_hidden()) {
@@ -823,11 +812,8 @@ bool RenderWidgetHostViewAura::IsMouseLocked() {
 
 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() {
 #if BUILDFLAG(IS_EFL)
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kEnableOffscreenRendering) &&
-      offscreen_helper_) {
-    return offscreen_helper_->GetVisibleViewportSize();
-  }
+  if (efl_helper_->IsOffscreenMode())
+    return efl_helper_->GetVisibleViewportSize();
 #endif
   gfx::Rect requested_rect(GetRequestedRendererSize());
   requested_rect.Inset(insets_);
@@ -882,8 +868,7 @@ void RenderWidgetHostViewAura::ShowWithVisibility(
   UpdateScreenInfo();
 
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->Show();
+  efl_helper_->Show();
 #endif
 
   // If the viz::LocalSurfaceId is invalid, we may have been evicted,
@@ -1104,8 +1089,7 @@ void RenderWidgetHostViewAura::DidOverscroll(
   if (overscroll_controller_)
     overscroll_controller_->OnDidOverscroll(params);
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->DidOverscroll(params);
+  efl_helper_->DidOverscroll(params);
 #endif
 }
 
@@ -1189,10 +1173,10 @@ void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
 
 #if BUILDFLAG(IS_EFL)
   if (touch.event.GetType() == blink::WebInputEvent::Type::kTouchStart)
-    offscreen_helper_->SetTouchStartConsumed(result == ui::ER_HANDLED);
+    efl_helper_->SetTouchStartConsumed(result == ui::ER_HANDLED);
 
   if (touch.event.GetType() == blink::WebInputEvent::Type::kTouchEnd)
-    offscreen_helper_->SetTouchEndConsumed(result == ui::ER_HANDLED);
+    efl_helper_->SetTouchEndConsumed(result == ui::ER_HANDLED);
 #endif
 
   // Only send acks for one changed touch point.
@@ -2121,16 +2105,14 @@ void RenderWidgetHostViewAura::FocusedNodeChanged(
   has_composition_text_ = false;
 
 #if defined(USE_EFL)
-  if (offscreen_helper_) {
-    offscreen_helper_->FocusedNodeChanged(
-        editable
+  efl_helper_->FocusedNodeChanged(
+      editable
 #if BUILDFLAG(IS_TIZEN_TV)
-        ,
-        is_radio_or_checkbox, password_input_minlength, input_maxlength
+      ,
+      is_radio_or_checkbox, password_input_minlength, input_maxlength
 #endif
-        ,
-        is_content_editable);
-  }
+      ,
+      is_content_editable);
 #endif
 
 #if BUILDFLAG(IS_WIN)
@@ -2156,11 +2138,9 @@ void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
   last_pointer_type_ = event->details().primary_pointer_type();
 #if BUILDFLAG(IS_EFL)
-  // Gesture event will be processed and forwarded via offscreen helper.
-  if (offscreen_helper_) {
-    offscreen_helper_->OnGestureEvent(event);
-    return;
-  }
+  // Gesture event will be processed and forwarded via efl helper.
+  efl_helper_->OnGestureEvent(event);
+  return;
 #endif
   event_handler_->OnGestureEvent(event);
 }
@@ -2290,20 +2270,26 @@ void RenderWidgetHostViewAura::OnRenderFrameMetadataChangedAfterActivation(
 }
 
 #if BUILDFLAG(IS_EFL)
+RWHVAuraOffscreenHelperEfl* RenderWidgetHostViewAura::offscreen_helper() {
+  if (!efl_helper_->IsOffscreenMode()) {
+    DLOG(INFO) << "Onscreen rendering mode is set";
+    return nullptr;
+  }
+
+  return static_cast<RWHVAuraOffscreenHelperEfl*>(efl_helper_.get());
+}
+
 void RenderWidgetHostViewAura::DidChangeInputType(bool is_password_field) {
-  if (offscreen_helper_)
-    offscreen_helper_->DidChangeInputType(is_password_field);
+  efl_helper_->DidChangeInputType(is_password_field);
 }
 
 void RenderWidgetHostViewAura::OnGetFocusedNodeBounds(const gfx::RectF& rect) {
-  if (offscreen_helper_)
-    offscreen_helper_->OnGetFocusedNodeBounds(rect);
+  efl_helper_->OnGetFocusedNodeBounds(rect);
 }
 
 void RenderWidgetHostViewAura::OnGetMainFrameScrollbarVisible(int callback_id,
                                                               bool visible) {
-  if (offscreen_helper_)
-    offscreen_helper_->OnGetMainFrameScrollbarVisible(callback_id, visible);
+  efl_helper_->OnGetMainFrameScrollbarVisible(callback_id, visible);
 }
 #endif
 
@@ -2660,8 +2646,7 @@ void RenderWidgetHostViewAura::AddedToRootWindow() {
   DCHECK(delegated_frame_host_) << "Cannot be invoked during destruction.";
 
 #if BUILDFLAG(IS_EFL)
-  if (offscreen_helper_)
-    offscreen_helper_->AuraChildWindowAdded();
+  efl_helper_->AuraChildWindowAdded();
 #endif
 
   window_->GetHost()->AddObserver(this);
index 701f9a2..4db3ca5 100644 (file)
@@ -419,9 +419,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
 #if BUILDFLAG(IS_EFL)
   void DidChangeInputType(bool is_password_field) override;
   aura::Window* window() { return window_; }
-  RWHVAuraOffscreenHelperEfl* offscreen_helper() {
-    return offscreen_helper_.get();
-  }
+  RWHVAuraOffscreenHelperEfl* offscreen_helper();
   void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) override;
   void DidHandleKeyEvent(blink::WebInputEvent::Type input_event,
                          bool processed) override;
@@ -824,7 +822,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
   absl::optional<display::ScopedDisplayObserver> display_observer_;
 
 #if BUILDFLAG(IS_EFL)
-  std::unique_ptr<RWHVAuraOffscreenHelperEfl> offscreen_helper_;
+  std::unique_ptr<RWHVAuraCommonHelperEfl> efl_helper_;
 #endif
 
   base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_{this};
index d6ccd66..51a9893 100644 (file)
@@ -1775,7 +1775,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
 
 #if BUILDFLAG(IS_TIZEN)
   // Notifes the delegate to enter into drag state.
-  void EnterDragState(RenderViewHost* render_view_host);
+  void EnterDragState(RenderViewHost* render_view_host) override;
 #endif
 
   // Misc non-view stuff -------------------------------------------------------
index 94ca772..4a686bb 100644 (file)
@@ -88,6 +88,8 @@ external_content_browser_efl_sources = [
 
   "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.cc",
   "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.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/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc",
   "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h",
   "//tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc",
index a740b9c..6b50dfc 100644 (file)
@@ -7,6 +7,7 @@
 #include <Elementary.h>
 
 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
 #include "content/browser/web_contents/web_contents_impl.h"
 #include "content/browser/web_contents/web_contents_view_aura.h"
 #include "tizen_src/chromium_impl/tizen/system_info.h"
@@ -258,8 +259,9 @@ void ContextMenuControllerBase::ContextMenuCancelCallback(void* data,
   // But according to wcs TC(21~23) context_menu should be displayed,
   // when touchevent is consumed. So we should show context_menu again when
   // touchevent is consumed.
-  if (rwhva->offscreen_helper()->IsTouchstartConsumed() ||
-      rwhva->offscreen_helper()->IsTouchendConsumed()) {
+  if (rwhva->offscreen_helper() &&
+      (rwhva->offscreen_helper()->IsTouchstartConsumed() ||
+      rwhva->offscreen_helper()->IsTouchendConsumed())) {
     evas_object_show(menu_controller->popup_);
     return;
   }
@@ -345,8 +347,10 @@ void ContextMenuControllerBase::OnSelectionRectReceived(
       ConvertRectToPixels(gfx::Rect(selection_rect), device_scale));
 
   // Consider a webview offset.
-  selection_rect_dip.Offset(
-      rwhva()->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin());
+  if (rwhva()->offscreen_helper()) {
+    selection_rect_dip.Offset(
+        rwhva()->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin());
+  }
 
   auto visible_viewport_rect = controller->GetVisibleViewportRect();
 
@@ -627,7 +631,8 @@ SelectionControllerEfl* ContextMenuControllerBase::GetSelectionController() {
   RenderViewHost* render_view_host = web_contents_.GetRenderViewHost();
   RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
       render_view_host->GetWidget()->GetView());
-  return view ? view->offscreen_helper()->GetSelectionController() : 0;
+  return (view && view->offscreen_helper())
+      ? view->offscreen_helper()->GetSelectionController() : 0;
 }
 
 const char* ContextMenuControllerBase::GetSelectedText() {
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
new file mode 100644 (file)
index 0000000..283d714
--- /dev/null
@@ -0,0 +1,484 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
+
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/browser/web_contents/web_contents_view_aura.h"
+#include "content/common/cursors/webcursor_efl.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/render_widget_host_helper.h"
+#include "tizen/system_info.h"
+#include "ui/aura/window_tree_host_platform.h"
+#include "ui/base/clipboard/clipboard_helper_efl.h"
+#include "ui/base/ime/linux/input_method_auralinux.h"
+#include "ui/display/screen.h"
+#include "ui/ozone/platform/efl/efl_event_handler.h"
+#include "ui/ozone/platform/efl/efl_input_method_context.h"
+#include "ui/ozone/platform/efl/im_context_efl.h"
+#include "ui/platform_window/platform_window.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "ewk/efl_integration/common/application_type.h"
+#endif
+
+namespace content {
+
+namespace {
+
+blink::WebGestureEvent MakeWebGestureEventFromUIEvent(
+    const ui::GestureEvent& event) {
+  return ui::CreateWebGestureEvent(
+      event.details(), event.time_stamp(), event.location_f(),
+      event.root_location_f(), event.flags(), event.unique_touch_event_id());
+}
+
+ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
+  if (!event.TimeStamp().since_origin().InMicroseconds())
+    return ui::LatencyInfo();
+
+  // The latency number should only be added if the timestamp is valid.
+  ui::LatencyInfo latency_info;
+  const int64_t time_micros = event.TimeStamp().since_origin().InMicroseconds();
+  latency_info.AddLatencyNumberWithTimestamp(
+      ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
+      base::TimeTicks() + base::Microseconds(time_micros));
+  return latency_info;
+}
+
+class RenderWidgetHostHelperAura : public RenderWidgetHostHelper {
+ public:
+  explicit RenderWidgetHostHelperAura(RWHVAuraCommonHelperEfl* rwhv_helper)
+      : rwhv_helper_(rwhv_helper) {}
+  ~RenderWidgetHostHelperAura() override = default;
+
+  bool HasRenderWidgetHost() const override {
+    return !!rwhv_helper_->GetRenderWidgetHostImpl();
+  }
+
+  void ExtendSelectionAndDelete(int32_t before, int32_t after) override {
+    auto* handler = GetFrameWidgetInputHandler();
+    if (!handler)
+      return;
+
+    handler->ExtendSelectionAndDelete(before, after);
+  }
+
+  void SetCompositionFromExistingText(
+      int32_t start,
+      int32_t end,
+      const std::vector<ui::ImeTextSpan>& ime_text_spans) override {
+    auto* handler = GetFrameWidgetInputHandler();
+    if (!handler)
+      return;
+
+    handler->SetCompositionFromExistingText(start, end, ime_text_spans);
+  }
+
+  void ImeCommitText(const std::u16string& text,
+                     const std::vector<ui::ImeTextSpan>& ime_text_spans,
+                     const gfx::Range& replacement_range,
+                     int relative_cursor_pos) override {
+    auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+    if (!rwhi)
+      return;
+
+    rwhi->ImeCommitText(text, ime_text_spans, replacement_range,
+                        relative_cursor_pos);
+  }
+
+  void ImeFinishComposingText(bool keep_selection) override {
+    auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+    if (!rwhi)
+      return;
+
+    rwhi->ImeFinishComposingText(keep_selection);
+  }
+
+  void ImeSetComposition(const std::u16string& text,
+                         const std::vector<ui::ImeTextSpan>& ime_text_spans,
+                         const gfx::Range& replacement_range,
+                         int selection_start,
+                         int selection_end) override {
+    auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+    if (!rwhi)
+      return;
+
+    rwhi->ImeSetComposition(text, ime_text_spans, replacement_range,
+                            selection_start, selection_end);
+  }
+
+  bool ExistsSelectedText() override {
+    auto* controller = rwhv_helper_->GetSelectionController();
+    if (!controller)
+      return false;
+
+    return controller->ExistsSelectedText();
+  }
+
+  bool ImeHandleKeyEventEnabled() override { return true; }
+
+  gfx::Size GetPhysicalBackingSize() const override {
+    return rwhv_helper_->GetPhysicalBackingSize();
+  }
+
+  Evas_Object* EwkView() const override { return rwhv_helper_->ewk_view(); }
+
+  bool IsOffscreenMode() const override {
+    return rwhv_helper_->IsOffscreenMode();
+  }
+
+ private:
+  blink::mojom::FrameWidgetInputHandler* GetFrameWidgetInputHandler() const {
+    auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl();
+    if (!rwhi)
+      return nullptr;
+
+    return rwhi->GetFrameWidgetInputHandler();
+  }
+
+  RWHVAuraCommonHelperEfl* rwhv_helper_;
+};
+
+}  // namespace
+
+RWHVAuraCommonHelperEfl::RWHVAuraCommonHelperEfl(
+    RenderWidgetHostViewAura* rwhva, WebContents* web_contents)
+    : rwhv_aura_(rwhva), web_contents_(web_contents),
+      rwh_helper_(std::make_unique<RenderWidgetHostHelperAura>(this)) {
+  device_scale_factor_ =
+      display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+}
+
+RWHVAuraCommonHelperEfl::~RWHVAuraCommonHelperEfl() = default;
+
+void RWHVAuraCommonHelperEfl::DidChangeInputType(bool is_password_field) {
+  web_contents_->GetDelegate()->DidChangeInputType(is_password_field);
+}
+
+void RWHVAuraCommonHelperEfl::OnSelectionRectReceived(
+    const gfx::Rect& selection_rect) {
+  if (web_contents_) {
+    WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
+    WebContentsViewAura* wcva =
+        static_cast<WebContentsViewAura*>(wc->GetView());
+    wcva->wcva_helper()->OnSelectionRectReceived(selection_rect);
+  }
+}
+
+void RWHVAuraCommonHelperEfl::OnMouseOrTouchEvent(ui::Event* event) {
+  if (event->type() == ui::ET_MOUSE_PRESSED ||
+      event->type() == ui::ET_TOUCH_PRESSED) {
+    FocusRWHVA();
+  }
+}
+
+void RWHVAuraCommonHelperEfl::DidHandleKeyEvent(
+    blink::WebInputEvent::Type input_event_type,
+    bool processed) {
+  if (!GetIMContextEfl())
+    return;
+
+  bool is_keydown = false;
+  switch (input_event_type) {
+    case blink::WebInputEvent::Type::kRawKeyDown:
+    case blink::WebInputEvent::Type::kKeyDown:
+      is_keydown = true;
+    case blink::WebInputEvent::Type::kKeyUp:
+      GetIMContextEfl()->HandleKeyEvent(is_keydown, processed);
+  }
+}
+
+void RWHVAuraCommonHelperEfl::SelectionChanged(const std::u16string& text,
+                                               size_t offset,
+                                               const gfx::Range& range) {
+  if (range.start() == range.end() && GetIMContextEfl())
+    GetIMContextEfl()->SetCaretPosition(range.start());
+
+  if (!GetSelectionController())
+    return;
+
+  std::u16string selectedText;
+  if (!text.empty() && !range.is_empty())
+    selectedText = rwhv_aura_->GetSelectedText();
+}
+
+Evas_Object* RWHVAuraCommonHelperEfl::ewk_view() const {
+  auto wci = static_cast<WebContentsImpl*>(web_contents_);
+  if (!wci)
+    return nullptr;
+
+  return static_cast<Evas_Object*>(wci->ewk_view());
+}
+
+void RWHVAuraCommonHelperEfl::FocusRWHVA() {
+  if (!rwhv_aura_->HasFocus())
+    rwhv_aura_->Focus();
+}
+
+void RWHVAuraCommonHelperEfl::SetPageVisibility(bool visible) {
+  LOG(INFO) << __FUNCTION__ << ", visible : " << visible;
+  if (visible) {
+    // Triggers RWHVA::ShowWithVisibility followed by RWHVAHelperEfl::Show
+    web_contents_->WasShown();
+  } else {
+    // Triggers RWHVA::Hide followed by RWHVAHelperEfl::Hide
+    web_contents_->WasHidden();
+  }
+}
+
+bool RWHVAuraCommonHelperEfl::HasSelectableText() {
+  // If the last character of textarea is '\n', We can assume an extra '\n'.
+  // Actually when you insert line break by ENTER key, '\n\n' is stored in
+  // textarea. And If you press delete key, only a '\n' character will be stored
+  // although there is no visible and selectable character in textarea. That's
+  // why we should check whether selection_text contains only one line break.
+  // Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-2230
+  //
+  // Please see below commit for more information.
+  // https://codereview.chromium.org/1785603002
+  std::u16string selection_text = rwhv_aura_->GetSelectedText();
+  return !selection_text.empty() &&
+         base::UTF16ToUTF8(selection_text).compare("\n") != 0;
+}
+
+RenderWidgetHostImpl* RWHVAuraCommonHelperEfl::GetRenderWidgetHostImpl() {
+  return rwhv_aura_->host();
+}
+
+ui::EflEventHandler* RWHVAuraCommonHelperEfl::GetEventHandler() {
+  aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
+  if (!window_host)
+    return nullptr;
+
+  return static_cast<aura::WindowTreeHostPlatform*>(window_host)
+      ->platform_window()
+      ->GetEventHandler();
+}
+
+ui::IMContextEfl* RWHVAuraCommonHelperEfl::GetIMContextEfl() {
+  // im_context_efl_ is always nullptr on desktop efl.
+#if BUILDFLAG(IS_TIZEN)
+  if (!im_context_efl_) {
+    if (GetEventHandler() && GetEventHandler()->GetIMContextEfl()) {
+      im_context_efl_ = GetEventHandler()->GetIMContextEfl();
+      im_context_efl_->SetRWHHelper(rwh_helper_.get());
+      return im_context_efl_;
+    }
+    LOG(ERROR) << "im_context_efl_ is not set";
+  }
+#endif
+  return im_context_efl_;
+}
+
+gfx::NativeView RWHVAuraCommonHelperEfl::GetNativeView() {
+  return rwhv_aura_->GetNativeView();
+}
+
+void RWHVAuraCommonHelperEfl::TextInputStateChanged(
+    const ui::mojom::TextInputState& params) {
+  auto im_context = GetIMContextEfl();
+  if (!im_context) {
+    LOG(ERROR) << "im_context is nullptr";
+    return;
+  }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!rwhv_aura_->IsShowing() || !HasFocus())
+#else
+  if (!rwhv_aura_->IsShowing())
+#endif
+    return;
+
+  bool show_ime_if_needed = params.show_ime_if_needed;
+
+  if (show_ime_if_needed && !params.is_user_action)
+    show_ime_if_needed = false;
+
+  // Prevent scroll and zoom for autofocus'ed elements.
+  if (show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
+    // If webview isn't resized yet, return previous IME state.
+    bool is_ime_show = im_context->WebViewWillBeResized()
+                           ? !im_context->IsVisible()
+                           : im_context->IsVisible();
+    if (im_context && !is_ime_show)
+      is_scrolling_needed_ = true;
+  }
+
+  if (im_context) {
+    im_context->SetIsInFormTag(params.is_in_form_tag);
+#if BUILDFLAG(IS_TIZEN_TV)
+    im_context->UpdateInputMethodState(
+        params.type, params.can_compose_inline, show_ime_if_needed,
+        password_input_minlength_, input_maxlength_);
+#else
+    im_context->UpdateInputMethodState(params.type, params.can_compose_inline,
+                                       show_ime_if_needed);
+#endif
+  }
+}
+
+void RWHVAuraCommonHelperEfl::FocusedNodeChanged(
+    bool editable
+#if BUILDFLAG(IS_TIZEN_TV)
+    ,
+    bool is_radio_or_checkbox,
+    int password_input_minlength,
+    int input_maxlength
+#endif
+    ,
+    bool is_content_editable) {
+  is_content_editable_ = is_content_editable;
+#if defined(USE_WAYLAND)
+  ClipboardHelperEfl::GetInstance()->SetContentEditable(is_content_editable);
+#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  radio_or_checkbox_focused_ = is_radio_or_checkbox;
+  password_input_minlength_ = password_input_minlength;
+  input_maxlength_ = input_maxlength;
+#endif
+
+  auto im_context = GetIMContextEfl();
+  if (im_context && is_focused_node_editable_) {
+    // focus out from an editable node,
+    // need reset ime context.
+    // or else will cause previous preedit text be copied.
+    if (im_context->IsVisible()) {
+      im_context->CancelComposition();
+    } else {
+      // add ime focus out when focus out from an editable node.
+      im_context->OnFocusOut();
+    }
+  }
+  is_focused_node_editable_ = editable;
+}
+
+void RWHVAuraCommonHelperEfl::OnGetMainFrameScrollbarVisible(
+    int callback_id, bool visible) {
+  web_contents_->GetDelegate()->OnGetMainFrameScrollbarVisible(callback_id,
+                                                               visible);
+}
+
+void RWHVAuraCommonHelperEfl::OnGetFocusedNodeBounds(
+    const gfx::RectF& rect) {
+  web_contents_->GetDelegate()->OnDidChangeFocusedNodeBounds(rect);
+}
+
+void RWHVAuraCommonHelperEfl::BackgroundColorReceived(
+    int callback_id, SkColor bg_color) {
+  web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color);
+}
+
+void RWHVAuraCommonHelperEfl::SetTouchEventsEnabled(bool enabled) {
+  if (auto* event_handler = GetEventHandler())
+    event_handler->SetTouchEventsEnabled(enabled);
+}
+
+bool RWHVAuraCommonHelperEfl::TouchEventsEnabled() {
+  if (auto* event_handler = GetEventHandler())
+    return event_handler->TouchEventsEnabled();
+
+  return false;
+}
+
+void RWHVAuraCommonHelperEfl::OnGestureEvent(ui::GestureEvent* event) {
+  if (event->type() == ui::ET_GESTURE_BEGIN)
+    HandleGestureBegin();
+  else if (event->type() == ui::ET_GESTURE_END)
+    HandleGestureEnd();
+
+  blink::WebGestureEvent gesture_event = MakeWebGestureEventFromUIEvent(*event);
+  gesture_event.SetPositionInWidget(event->location_f());
+  gesture_event.SetPositionInScreen(event->root_location_f());
+  SendGestureEvent(gesture_event);
+
+  event->SetHandled();
+}
+
+void RWHVAuraCommonHelperEfl::SendGestureEvent(
+    blink::WebGestureEvent& event) {
+  HandleGesture(event);
+  blink::WebInputEvent::Type event_type = event.GetType();
+  if (magnifier_ &&
+      event_type == blink::WebInputEvent::Type::kGestureScrollUpdate) {
+    return;
+  }
+
+  // TODO: In this case, double tap should be filtered in
+  // TouchDispositionGestureFilter. (See http://goo.gl/5G8PWJ)
+  if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap &&
+      touchend_consumed_) {
+    return;
+  }
+
+  if (event_type != blink::WebInputEvent::Type::kUndefined) {
+    rwhv_aura_->host()->ForwardGestureEventWithLatencyInfo(
+        event, CreateLatencyInfo(event));
+  }
+}
+
+void RWHVAuraCommonHelperEfl::HandleGesture(blink::WebGestureEvent& event) {
+  SelectionControllerEfl* controller = GetSelectionController();
+  if (controller)
+    controller->HandleGesture(event);
+
+  blink::WebInputEvent::Type event_type = event.GetType();
+  RenderWidgetHostOwnerDelegate* owner_delegate =
+      rwhv_aura_->host()->owner_delegate();
+  if (!owner_delegate)
+    return;
+
+  if (!owner_delegate->GetWebkitPreferencesForWidget().text_zoom_enabled &&
+      (event_type == blink::WebInputEvent::Type::kGesturePinchBegin ||
+       event_type == blink::WebInputEvent::Type::kGesturePinchEnd)) {
+    return;
+  }
+
+  if (!owner_delegate->GetWebkitPreferencesForWidget()
+           .double_tap_to_zoom_enabled &&
+      event_type == blink::WebInputEvent::Type::kGestureDoubleTap) {
+    return;
+  }
+
+  if (event_type == blink::WebInputEvent::Type::kGestureTap ||
+      event_type == blink::WebInputEvent::Type::kGestureTapCancel) {
+    float size = 32.0f;  // Default value
+
+#if BUILDFLAG(IS_TIZEN)
+    if (IsMobileProfile())
+      size = elm_config_finger_size_get() / device_scale_factor_;
+#endif
+
+    event.data.tap.width = size;
+    event.data.tap.height = size;
+  }
+}
+
+void RWHVAuraCommonHelperEfl::DidOverscroll(
+    const ui::DidOverscrollParams& params) {
+  if (web_contents_) {
+    WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
+    WebContentsViewAura* wcva =
+        static_cast<WebContentsViewAura*>(wc->GetView());
+    wcva->wcva_helper()->OnOverscrolled(params.accumulated_overscroll,
+                                        params.latest_overscroll_delta);
+  }
+}
+
+}  // namespace content
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
new file mode 100644 (file)
index 0000000..4f7c79b
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
+
+#include <Evas.h>
+
+#include "base/callback.h"
+#include "content/common/cursors/webcursor.h"
+#include "third_party/blink/public/common/input/web_input_event.h"
+#include "third_party/blink/public/common/input/web_gesture_event.h"
+#include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
+#include "ui/events/event.h"
+#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/range/range.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#define DEFAULT_MAX_LENGTH std::numeric_limits<int>::max()
+#endif
+
+namespace ui {
+class EflEventHandler;
+class IMContextEfl;
+struct DidOverscrollParams;
+} // namespace ui
+
+namespace content {
+
+class RenderWidgetHostHelper;
+class RenderWidgetHostImpl;
+class RenderWidgetHostViewAura;
+class SelectionControllerEfl;
+class WebContents;
+class WebContentsDelegate;
+
+class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
+ public:
+  RWHVAuraCommonHelperEfl(
+      RenderWidgetHostViewAura* rwhva, WebContents* web_contents);
+  virtual ~RWHVAuraCommonHelperEfl();
+
+  virtual void SetAuraParentWindow(gfx::NativeView parent_view) {}
+  virtual void AuraChildWindowAdded() {}
+  virtual void NotifySwap(const size_t texture_id) {}
+  virtual void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) {}
+  virtual void Show() {}
+  virtual void Hide() {}
+  virtual void Focus(bool focus) {}
+  virtual bool HasFocus() { return false; }
+  virtual gfx::Size GetVisibleViewportSize() { return gfx::Size(); }
+  virtual gfx::Size GetPhysicalBackingSize() const { return gfx::Size(); }
+  virtual void HandleGestureBegin() {}
+  virtual void HandleGestureEnd() {}
+  virtual void HandleGesture(blink::WebGestureEvent& event);
+  virtual void DidOverscroll(const ui::DidOverscrollParams& params);
+  virtual gfx::Rect GetViewBounds() { return gfx::Rect(); }
+
+  bool IsOffscreenMode() { return is_offscreen_mode_; }
+  Evas_Object* ewk_view() const;
+  SelectionControllerEfl* GetSelectionController() const {
+    return selection_controller_.get();
+  }
+  RenderWidgetHostImpl* GetRenderWidgetHostImpl();
+  gfx::NativeView GetNativeView();
+  WebContents* GetWebContents() { return web_contents_; }
+  void SetPageVisibility(bool visible);
+
+  bool HasSelectableText();
+  void set_magnifier(bool status) { magnifier_ = status; }
+  bool IsTouchstartConsumed() const { return touchstart_consumed_; }
+  bool IsTouchendConsumed() const { return touchend_consumed_; }
+  void SetTouchStartConsumed(bool touchstart_consumed) {
+    touchstart_consumed_ = touchstart_consumed;
+  }
+  void SetTouchEndConsumed(bool touchend_consumed) {
+    touchend_consumed_ = touchend_consumed;
+  }
+  void SetTouchEventsEnabled(bool enabled);
+  bool TouchEventsEnabled();
+  bool IsFocusedNodeContentEditable() const { return is_content_editable_; }
+
+  void OnMouseOrTouchEvent(ui::Event* event);
+  void FocusedNodeChanged(bool editable,
+#if BUILDFLAG(IS_TIZEN_TV)
+      bool is_radio_or_checkbox,
+      int password_input_minlength,
+      int input_maxlength,
+#endif
+      bool is_content_editable);
+
+  void OnGestureEvent(ui::GestureEvent* event);
+  void DidChangeInputType(bool is_password_field);
+  void BackgroundColorReceived(int callback_id, SkColor bg_color);
+  void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+  void DidHandleKeyEvent(
+        blink::WebInputEvent::Type input_event_type, bool processed);
+  void SelectionChanged(
+      const std::u16string& text, size_t offset, const gfx::Range& range);
+  void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
+  void TextInputStateChanged(const ui::mojom::TextInputState& params);
+  void OnSelectionRectReceived(const gfx::Rect& selection_rect);
+
+ protected:
+  void SetOffscreenMode() { is_offscreen_mode_ = true; }
+  RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
+  ui::IMContextEfl* GetIMContextEfl();
+  void FocusRWHVA();
+  void SendGestureEvent(blink::WebGestureEvent& event);
+
+  float device_scale_factor_ = 1.0f;
+
+ private:
+  ui::EflEventHandler* GetEventHandler();
+
+  bool is_focused_node_editable_ = false;
+  bool is_scrolling_needed_ = false;
+  bool touchstart_consumed_ = false;
+  bool touchend_consumed_ = false;
+
+  ui::IMContextEfl* im_context_efl_ = nullptr;
+  RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
+  WebContents* web_contents_ = nullptr;
+  std::unique_ptr<SelectionControllerEfl> selection_controller_;
+
+  bool magnifier_ = false;
+  bool is_content_editable_ = false;
+  bool is_offscreen_mode_ = false;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool radio_or_checkbox_focused_ = false;
+  int password_input_minlength_ = -1;
+  int input_maxlength_ = DEFAULT_MAX_LENGTH;
+#endif
+
+  std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
+
+  RWHVAuraCommonHelperEfl(const RWHVAuraCommonHelperEfl&) = delete;
+  RWHVAuraCommonHelperEfl& operator=(const RWHVAuraCommonHelperEfl&) = delete;
+};
+
+} // namespace content
+
+#endif  // CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
index 1baf3ee..96feda0 100644 (file)
 #include "base/base_switches.h"
 #include "content/browser/renderer_host/edge_effect.h"
 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/browser/selection/selection_controller_efl.h"
 #include "content/browser/web_contents/web_contents_impl.h"
 #include "content/browser/web_contents/web_contents_view_aura.h"
 #include "content/public/browser/render_widget_host_helper.h"
-#include "content/public/browser/web_contents_delegate.h"
 #include "ecore_x_wayland_wrapper.h"
 #include "gpu/command_buffer/service/texture_base.h"
 #include "skia/ext/image_operations.h"
 
 namespace content {
 
-namespace {
-
-blink::WebGestureEvent MakeWebGestureEventFromUIEvent(
-    const ui::GestureEvent& event) {
-  return ui::CreateWebGestureEvent(
-      event.details(), event.time_stamp(), event.location_f(),
-      event.root_location_f(), event.flags(), event.unique_touch_event_id());
-}
-
-ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
-  if (!event.TimeStamp().since_origin().InMicroseconds())
-    return ui::LatencyInfo();
-
-  // The latency number should only be added if the timestamp is valid.
-  ui::LatencyInfo latency_info;
-  const int64_t time_micros = event.TimeStamp().since_origin().InMicroseconds();
-  latency_info.AddLatencyNumberWithTimestamp(
-      ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
-      base::TimeTicks() + base::Microseconds(time_micros));
-  return latency_info;
-}
-
-}  // namespace
-
 // If the first frame is not prepared after load is finished,
 // delay getting the snapshot by 100ms.
 static const int kSnapshotProcessDelay = 100;
@@ -182,9 +158,8 @@ class RenderWidgetHostHelperAura : public RenderWidgetHostHelper {
 RWHVAuraOffscreenHelperEfl::RWHVAuraOffscreenHelperEfl(
     RenderWidgetHostViewAura* rwhva,
     WebContents* web_contents)
-    : rwhv_aura_(rwhva),
-      web_contents_(web_contents),
-      rwh_helper_(std::make_unique<RenderWidgetHostHelperAura>(this)) {
+    : RWHVAuraCommonHelperEfl(rwhva, web_contents) {
+  SetOffscreenMode();
   Initialize();
 }
 
@@ -223,7 +198,7 @@ RWHVAuraOffscreenHelperEfl::~RWHVAuraOffscreenHelperEfl() {
 
 void RWHVAuraOffscreenHelperEfl::Initialize() {
   parent_view_ =
-      static_cast<WebContentsImpl*>(web_contents_)->GetEflNativeView();
+      static_cast<WebContentsImpl*>(GetWebContents())->GetEflNativeView();
   evas_ = evas_object_evas_get(parent_view_);
 
   InitEvasGL();
@@ -238,13 +213,8 @@ void RWHVAuraOffscreenHelperEfl::Initialize() {
   snapshot_timer_.reset(new base::OneShotTimer);
 }
 
-void RWHVAuraOffscreenHelperEfl::SetAuraParentWindow(
-    gfx::NativeView parent_window) {
-  aura_parent_window_ = parent_window;
-}
-
 void RWHVAuraOffscreenHelperEfl::AuraChildWindowAdded() {
-  aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
+  aura::WindowTreeHost* window_host = rwhva()->window()->GetHost();
   if (!window_host)
     return;
 
@@ -267,7 +237,7 @@ void RWHVAuraOffscreenHelperEfl::OnParentViewResize(void* data,
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
   gfx::Rect new_bounds(thiz->CreateNativeSurface());
-  aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+  aura::WindowTreeHost* window_host = thiz->rwhva()->window()->GetHost();
   if (window_host)
     window_host->SetBoundsInPixels(new_bounds);
 
@@ -408,20 +378,6 @@ void RWHVAuraOffscreenHelperEfl::InitializeProgram() {
   evas_gl_make_current(evas_gl_, 0, 0);
 }
 
-void RWHVAuraOffscreenHelperEfl::DidChangeInputType(bool is_password_field) {
-  web_contents_->GetDelegate()->DidChangeInputType(is_password_field);
-}
-
-void RWHVAuraOffscreenHelperEfl::OnSelectionRectReceived(
-    const gfx::Rect& selection_rect) {
-  if (web_contents_) {
-    WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
-    WebContentsViewAura* wcva =
-        static_cast<WebContentsViewAura*>(wc->GetView());
-    wcva->wcva_helper()->OnSelectionRectReceived(selection_rect);
-  }
-}
-
 void RWHVAuraOffscreenHelperEfl::PaintTextureToSurface(GLuint texture_id) {
   int x, y, width = 0, height = 0;
   evas_object_geometry_get(parent_view_, &x, &y, &width, &height);
@@ -626,7 +582,7 @@ void RWHVAuraOffscreenHelperEfl::OnFocusOut(void* data,
                                             void* event_info) {
   RWHVAuraOffscreenHelperEfl* thiz =
       static_cast<RWHVAuraOffscreenHelperEfl*>(data);
-  aura::WindowTreeHost* window_host = thiz->rwhv_aura_->window()->GetHost();
+  aura::WindowTreeHost* window_host = thiz->rwhva()->window()->GetHost();
   if (!window_host || !window_host->window())
     return;
 
@@ -660,43 +616,6 @@ void RWHVAuraOffscreenHelperEfl::OnHostFocusOut(void* data,
     thiz->GetRenderWidgetHostImpl()->Blur();
 }
 
-void RWHVAuraOffscreenHelperEfl::OnMouseOrTouchEvent(ui::Event* event) {
-  if (event->type() == ui::ET_MOUSE_PRESSED ||
-      event->type() == ui::ET_TOUCH_PRESSED) {
-    FocusRWHVA();
-  }
-}
-
-void RWHVAuraOffscreenHelperEfl::DidHandleKeyEvent(
-    blink::WebInputEvent::Type input_event_type,
-    bool processed) {
-  if (!GetIMContextEfl())
-    return;
-
-  bool is_keydown = false;
-  switch (input_event_type) {
-    case blink::WebInputEvent::Type::kRawKeyDown:
-    case blink::WebInputEvent::Type::kKeyDown:
-      is_keydown = true;
-    case blink::WebInputEvent::Type::kKeyUp:
-      GetIMContextEfl()->HandleKeyEvent(is_keydown, processed);
-  }
-}
-
-void RWHVAuraOffscreenHelperEfl::SelectionChanged(const std::u16string& text,
-                                                  size_t offset,
-                                                  const gfx::Range& range) {
-  if (range.start() == range.end() && GetIMContextEfl())
-    GetIMContextEfl()->SetCaretPosition(range.start());
-
-  if (!GetSelectionController())
-    return;
-
-  std::u16string selectedText;
-  if (!text.empty() && !range.is_empty())
-    selectedText = rwhv_aura_->GetSelectedText();
-}
-
 void RWHVAuraOffscreenHelperEfl::EvasToBlinkCords(int x,
                                                   int y,
                                                   int* view_x,
@@ -758,7 +677,7 @@ void RWHVAuraOffscreenHelperEfl::RunGetSnapshotOnMainThread(
   if (!callback)
     return;
 
-  if (rwhv_aura_->IsShowing() && evas_focus_get(evas_))
+  if (rwhva()->IsShowing() && evas_focus_get(evas_))
     callback->Run(GetSnapshot(snapshot_area, scale_factor));
   screen_capture_cb_map_.Remove(request_id);
 }
@@ -784,7 +703,7 @@ Evas_Object* RWHVAuraOffscreenHelperEfl::GetSnapshot(
   }
 
   const gfx::Rect window_rect = gfx::ToEnclosingRect(gfx::ConvertRectToPixels(
-      rwhv_aura_->GetBoundsInRootWindow(), device_scale_factor_));
+      rwhva()->GetBoundsInRootWindow(), device_scale_factor_));
   // |view_rect| is absolute coordinate of webview.
   gfx::Rect view_rect = GetViewBoundsInPix();
 
@@ -949,7 +868,7 @@ void RWHVAuraOffscreenHelperEfl::RequestSnapshotAsync(
 
   int request_id = screen_capture_cb_map_.Add(base::WrapUnique(cb));
 
-  if (rwhv_aura_->IsShowing() && evas_focus_get(evas_)) {
+  if (rwhva()->IsShowing() && evas_focus_get(evas_)) {
     // Create a snapshot task that will be executed after frame
     // is generated and drawn to surface.
     snapshot_task_list_.push_back(base::BindOnce(
@@ -970,7 +889,7 @@ void RWHVAuraOffscreenHelperEfl::RequestSnapshotAsync(
                        base::Unretained(this)));
   } else {
     // Sends message to renderer to capture the content snapshot of the view.
-    rwhv_aura_->host()->RequestContentSnapshot(snapshot_area, scale_factor,
+    rwhva()->host()->RequestContentSnapshot(snapshot_area, scale_factor,
                                                request_id);
   }
 }
@@ -992,19 +911,6 @@ void RWHVAuraOffscreenHelperEfl::DidGetContentSnapshot(const SkBitmap& bitmap,
   screen_capture_cb_map_.Remove(request_id);
 }
 
-Evas_Object* RWHVAuraOffscreenHelperEfl::ewk_view() const {
-  auto wci = static_cast<WebContentsImpl*>(web_contents_);
-  if (!wci)
-    return nullptr;
-
-  return static_cast<Evas_Object*>(wci->ewk_view());
-}
-
-void RWHVAuraOffscreenHelperEfl::FocusRWHVA() {
-  if (!rwhv_aura_->HasFocus())
-    rwhv_aura_->Focus();
-}
-
 void RWHVAuraOffscreenHelperEfl::Show() {
   evas_object_show(content_image_elm_host_);
 }
@@ -1017,7 +923,7 @@ void RWHVAuraOffscreenHelperEfl::SetCustomViewportSize(const gfx::Size& size) {
   if (custom_viewport_size_ != size) {
     custom_viewport_size_ = size;
     // Take the view port change into account.
-    rwhv_aura_->host()->SynchronizeVisualProperties();
+    rwhva()->host()->SynchronizeVisualProperties();
   }
 }
 
@@ -1032,100 +938,13 @@ gfx::Rect RWHVAuraOffscreenHelperEfl::GetViewBounds() {
       gfx::ConvertRectToDips(GetViewBoundsInPix(), device_scale_factor_));
 }
 
-void RWHVAuraOffscreenHelperEfl::SetPageVisibility(bool visible) {
-  LOG(INFO) << __FUNCTION__ << ", visible : " << visible;
-  if (visible) {
-    // Triggers RWHVA::ShowWithVisibility followed by RWHVAHelperEfl::Show
-    web_contents_->WasShown();
-  } else {
-    // Triggers RWHVA::Hide followed by RWHVAHelperEfl::Hide
-    web_contents_->WasHidden();
-  }
-}
-
-RenderWidgetHostImpl* RWHVAuraOffscreenHelperEfl::GetRenderWidgetHostImpl() {
-  return rwhv_aura_->host();
-}
-
-ui::EflEventHandler* RWHVAuraOffscreenHelperEfl::GetEventHandler() {
-  aura::WindowTreeHost* window_host = rwhv_aura_->window()->GetHost();
-  if (!window_host)
-    return nullptr;
-
-  return static_cast<aura::WindowTreeHostPlatform*>(window_host)
-      ->platform_window()
-      ->GetEventHandler();
-}
-
-ui::IMContextEfl* RWHVAuraOffscreenHelperEfl::GetIMContextEfl() {
-  // im_context_efl_ is always nullptr on desktop efl.
-#if BUILDFLAG(IS_TIZEN)
-  if (!im_context_efl_) {
-    im_context_efl_ =
-        GetEventHandler() ? GetEventHandler()->GetIMContextEfl() : nullptr;
-    if (im_context_efl_)
-      im_context_efl_->SetRWHHelper(rwh_helper_.get());
-    else
-      LOG(ERROR) << "im_context_efl_ is not set";
-  }
-#endif
-  return im_context_efl_;
-}
-
-gfx::NativeView RWHVAuraOffscreenHelperEfl::GetNativeView() {
-  return rwhv_aura_->GetNativeView();
-}
-
 gfx::Point RWHVAuraOffscreenHelperEfl::ConvertPointInViewPix(gfx::Point point) {
   return gfx::ToFlooredPoint(
       gfx::ScalePoint(gfx::PointF(point), device_scale_factor_));
 }
 
-void RWHVAuraOffscreenHelperEfl::TextInputStateChanged(
-    const ui::mojom::TextInputState& params) {
-  auto im_context = GetIMContextEfl();
-  if (!im_context) {
-    LOG(ERROR) << "im_context is nullptr";
-    return;
-  }
-
-#if BUILDFLAG(IS_TIZEN_TV)
-  if (!rwhv_aura_->IsShowing() || !HasFocus())
-#else
-  if (!rwhv_aura_->IsShowing())
-#endif
-    return;
-
-  bool show_ime_if_needed = params.show_ime_if_needed;
-
-  if (show_ime_if_needed && !params.is_user_action)
-    show_ime_if_needed = false;
-
-  // Prevent scroll and zoom for autofocus'ed elements.
-  if (show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
-    // If webview isn't resized yet, return previous IME state.
-    bool is_ime_show = im_context->WebViewWillBeResized()
-                           ? !im_context->IsVisible()
-                           : im_context->IsVisible();
-    if (im_context && !is_ime_show)
-      is_scrolling_needed_ = true;
-  }
-
-  if (im_context) {
-    im_context->SetIsInFormTag(params.is_in_form_tag);
-#if BUILDFLAG(IS_TIZEN_TV)
-    im_context->UpdateInputMethodState(
-        params.type, params.can_compose_inline, show_ime_if_needed,
-        password_input_minlength_, input_maxlength_);
-#else
-    im_context->UpdateInputMethodState(params.type, params.can_compose_inline,
-                                       show_ime_if_needed);
-#endif
-  }
-}
-
 void RWHVAuraOffscreenHelperEfl::MoveCaret(const gfx::Point& point) {
-  if (auto* delegate = rwhv_aura_->host()->delegate()) {
+  if (auto* delegate = rwhva()->host()->delegate()) {
     delegate->MoveCaret(gfx::Point(point.x() / device_scale_factor_,
                                    point.y() / device_scale_factor_));
   }
@@ -1136,58 +955,7 @@ void RWHVAuraOffscreenHelperEfl::SelectClosestWord(
   int view_x, view_y;
   EvasToBlinkCords(touch_point.x(), touch_point.y(), &view_x, &view_y);
 
-  rwhv_aura_->host()->SelectClosestWord(view_x, view_y);
-}
-
-bool RWHVAuraOffscreenHelperEfl::HasSelectableText() {
-  // If the last character of textarea is '\n', We can assume an extra '\n'.
-  // Actually when you insert line break by ENTER key, '\n\n' is stored in
-  // textarea. And If you press delete key, only a '\n' character will be stored
-  // although there is no visible and selectable character in textarea. That's
-  // why we should check whether selection_text contains only one line break.
-  // Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-2230
-  //
-  // Please see below commit for more information.
-  // https://codereview.chromium.org/1785603002
-  std::u16string selection_text = rwhv_aura_->GetSelectedText();
-  return !selection_text.empty() &&
-         base::UTF16ToUTF8(selection_text).compare("\n") != 0;
-}
-
-void RWHVAuraOffscreenHelperEfl::FocusedNodeChanged(
-    bool editable
-#if BUILDFLAG(IS_TIZEN_TV)
-    ,
-    bool is_radio_or_checkbox,
-    int password_input_minlength,
-    int input_maxlength
-#endif
-    ,
-    bool is_content_editable) {
-  is_content_editable_ = is_content_editable;
-#if defined(USE_WAYLAND)
-  ClipboardHelperEfl::GetInstance()->SetContentEditable(is_content_editable);
-#endif
-
-#if BUILDFLAG(IS_TIZEN_TV)
-  radio_or_checkbox_focused_ = is_radio_or_checkbox;
-  password_input_minlength_ = password_input_minlength;
-  input_maxlength_ = input_maxlength;
-#endif
-
-  auto im_context = GetIMContextEfl();
-  if (im_context && is_focused_node_editable_) {
-    // focus out from an editable node,
-    // need reset ime context.
-    // or else will cause previous preedit text be copied.
-    if (im_context->IsVisible()) {
-      im_context->CancelComposition();
-    } else {
-      // add ime focus out when focus out from an editable node.
-      im_context->OnFocusOut();
-    }
-  }
-  is_focused_node_editable_ = editable;
+  rwhva()->host()->SelectClosestWord(view_x, view_y);
 }
 
 gfx::Size RWHVAuraOffscreenHelperEfl::GetPhysicalBackingSize() const {
@@ -1254,34 +1022,6 @@ void RWHVAuraOffscreenHelperEfl::ClearLabels() {
 }
 #endif
 
-void RWHVAuraOffscreenHelperEfl::OnGetMainFrameScrollbarVisible(int callback_id,
-                                                                bool visible) {
-  web_contents_->GetDelegate()->OnGetMainFrameScrollbarVisible(callback_id,
-                                                               visible);
-}
-
-void RWHVAuraOffscreenHelperEfl::OnGetFocusedNodeBounds(
-    const gfx::RectF& rect) {
-  web_contents_->GetDelegate()->OnDidChangeFocusedNodeBounds(rect);
-}
-
-void RWHVAuraOffscreenHelperEfl::BackgroundColorReceived(int callback_id,
-                                                         SkColor bg_color) {
-  web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color);
-}
-
-void RWHVAuraOffscreenHelperEfl::SetTouchEventsEnabled(bool enabled) {
-  if (auto* event_handler = GetEventHandler())
-    event_handler->SetTouchEventsEnabled(enabled);
-}
-
-bool RWHVAuraOffscreenHelperEfl::TouchEventsEnabled() {
-  if (auto* event_handler = GetEventHandler())
-    return event_handler->TouchEventsEnabled();
-
-  return false;
-}
-
 EdgeEffect& RWHVAuraOffscreenHelperEfl::EnsureEdgeEffect() {
   if (!edge_effect_) {
     edge_effect_ = base::WrapUnique(new EdgeEffect(content_image_));
@@ -1301,46 +1041,6 @@ void RWHVAuraOffscreenHelperEfl::HandleGestureEnd() {
   EnsureEdgeEffect().Disable();
 }
 
-void RWHVAuraOffscreenHelperEfl::OnGestureEvent(ui::GestureEvent* event) {
-  if (event->type() == ui::ET_GESTURE_BEGIN)
-    HandleGestureBegin();
-  else if (event->type() == ui::ET_GESTURE_END)
-    HandleGestureEnd();
-
-  blink::WebGestureEvent gesture_event = MakeWebGestureEventFromUIEvent(*event);
-  gesture_event.SetPositionInWidget(event->location_f());
-  gesture_event.SetPositionInScreen(event->root_location_f());
-  SendGestureEvent(gesture_event);
-
-  event->SetHandled();
-}
-
-void RWHVAuraOffscreenHelperEfl::SendGestureEvent(
-    blink::WebGestureEvent& event) {
-  HandleGesture(event);
-  blink::WebInputEvent::Type event_type = event.GetType();
-  if (magnifier_ &&
-      event_type == blink::WebInputEvent::Type::kGestureScrollUpdate) {
-    return;
-  }
-
-  // TODO: In this case, double tap should be filtered in
-  // TouchDispositionGestureFilter. (See http://goo.gl/5G8PWJ)
-  if (event_type == blink::WebInputEvent::Type::kGestureDoubleTap &&
-      touchend_consumed_) {
-    return;
-  }
-
-  if (event_type != blink::WebInputEvent::Type::kUndefined) {
-    rwhv_aura_->host()->ForwardGestureEventWithLatencyInfo(
-        event, CreateLatencyInfo(event));
-  }
-}
-
-void RWHVAuraOffscreenHelperEfl::set_magnifier(bool status) {
-  magnifier_ = status;
-}
-
 void RWHVAuraOffscreenHelperEfl::GetMagnifierSnapshot(
     gfx::Rect snapshot_area,
     float scale_factor,
@@ -1367,7 +1067,8 @@ void RWHVAuraOffscreenHelperEfl::RequestMagnifierSnapshotAsync(
   gfx::Rect view_rect = GetViewBoundsInPix();
 
   // Adjust snapshot rect for email app
-  auto visible_viewport_rect = selection_controller_->GetVisibleViewportRect();
+  auto visible_viewport_rect =
+      GetSelectionController()->GetVisibleViewportRect();
   int hidden_view_width = visible_viewport_rect.x() - view_rect.x();
   int hidden_view_height = visible_viewport_rect.y() - view_rect.y();
   if (hidden_view_height || hidden_view_width) {
@@ -1383,40 +1084,9 @@ void RWHVAuraOffscreenHelperEfl::RequestMagnifierSnapshotAsync(
 }
 
 void RWHVAuraOffscreenHelperEfl::HandleGesture(blink::WebGestureEvent& event) {
-  SelectionControllerEfl* controller = GetSelectionController();
-  if (controller)
-    controller->HandleGesture(event);
+  RWHVAuraCommonHelperEfl::HandleGesture(event);
 
   blink::WebInputEvent::Type event_type = event.GetType();
-  RenderWidgetHostOwnerDelegate* owner_delegate =
-      rwhv_aura_->host()->owner_delegate();
-  if (!owner_delegate)
-    return;
-
-  if (!owner_delegate->GetWebkitPreferencesForWidget().text_zoom_enabled &&
-      (event_type == blink::WebInputEvent::Type::kGesturePinchBegin ||
-       event_type == blink::WebInputEvent::Type::kGesturePinchEnd)) {
-    return;
-  }
-
-  if (!owner_delegate->GetWebkitPreferencesForWidget()
-           .double_tap_to_zoom_enabled &&
-      event_type == blink::WebInputEvent::Type::kGestureDoubleTap) {
-    return;
-  }
-
-  if (event_type == blink::WebInputEvent::Type::kGestureTap ||
-      event_type == blink::WebInputEvent::Type::kGestureTapCancel) {
-    float size = 32.0f;  // Default value
-
-#if BUILDFLAG(IS_TIZEN)
-    if (IsMobileProfile())
-      size = elm_config_finger_size_get() / device_scale_factor_;
-#endif
-
-    event.data.tap.width = size;
-    event.data.tap.height = size;
-  }
 
   if (event_type == blink::WebInputEvent::Type::kGestureTapDown) {
     // Webkit does not stop a fling-scroll on tap-down. So explicitly send an
@@ -1464,13 +1134,7 @@ void RWHVAuraOffscreenHelperEfl::OnEdgeEffectForUIF(bool top,
 
 void RWHVAuraOffscreenHelperEfl::DidOverscroll(
     const ui::DidOverscrollParams& params) {
-  if (web_contents_) {
-    WebContentsImpl* wc = static_cast<WebContentsImpl*>(web_contents_);
-    WebContentsViewAura* wcva =
-        static_cast<WebContentsViewAura*>(wc->GetView());
-    wcva->wcva_helper()->OnOverscrolled(params.accumulated_overscroll,
-                                        params.latest_overscroll_delta);
-  }
+  RWHVAuraCommonHelperEfl::DidOverscroll(params);
 
   const gfx::Vector2dF& accumulated_overscroll = params.accumulated_overscroll;
   const gfx::Vector2dF& latest_overscroll_delta =
@@ -1497,11 +1161,4 @@ void RWHVAuraOffscreenHelperEfl::UpdateEdgeEffect() {
   EnsureEdgeEffect().UpdateRect();
 }
 
-void RWHVAuraOffscreenHelperEfl::SetTouchStartConsumed(
-    bool touchstart_consumed) {
-  touchstart_consumed_ = touchstart_consumed;
-}
-void RWHVAuraOffscreenHelperEfl::SetTouchEndConsumed(bool touchend_consumed) {
-  touchend_consumed_ = touchend_consumed;
-}
 }  // namespace content
index 97d43d6..d4e4018 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <list>
 
-#include <Evas.h>
 #include <Evas_GL.h>
 
 #include <Ecore.h>
 #include <Ecore_Input.h>
 #include <Elementary.h>
 
-#include "base/callback.h"
 #include "base/containers/id_map.h"
 #include "base/timer/timer.h"
-#include "content/browser/selection/selection_controller_efl.h"
-#include "content/common/cursors/webcursor.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-#include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
-#include "ui/events/event.h"
-#include "ui/gfx/geometry/size_f.h"
+#include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
 #include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/range/range.h"
-
-#if BUILDFLAG(IS_TIZEN_TV)
-#define DEFAULT_MAX_LENGTH std::numeric_limits<int>::max()
-#endif
-
-namespace ui {
-class EflEventHandler;
-class IMContextEfl;
-struct DidOverscrollParams;
-}  // namespace ui
 
 namespace content {
 
@@ -43,53 +25,44 @@ typedef void (*Screenshot_Captured_Callback)(Evas_Object* image,
                                              void* user_data);
 typedef base::OnceCallback<void()> SnapshotTask;
 
-class RenderWidgetHostHelper;
-class RenderWidgetHostImpl;
-class RenderWidgetHostViewAura;
 class ScreenshotCapturedCallback;
-class WebContents;
-class WebContentsDelegate;
 class EdgeEffect;
 
-class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
+class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl
+    : public RWHVAuraCommonHelperEfl {
  public:
 
   using OnFocusCallback = base::RepeatingCallback<void(void)>;
 
   RWHVAuraOffscreenHelperEfl(RenderWidgetHostViewAura* rwhva,
                              WebContents* web_contents);
-  ~RWHVAuraOffscreenHelperEfl();
-
-  void SetAuraParentWindow(gfx::NativeView parent_window);
-  void AuraChildWindowAdded();
-  void NotifySwap(const size_t texture_id);
-  void BackgroundColorReceived(int callback_id, SkColor bg_color);
-  void Show();
-  void Hide();
-  void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
-
-  gfx::Size GetVisibleViewportSize();
-  gfx::Rect GetViewBounds();
-  void SetCustomViewportSize(const gfx::Size& size);
-  gfx::Size GetPhysicalBackingSize() const;
-  void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+  ~RWHVAuraOffscreenHelperEfl() override;
 
-  void SetTouchStartConsumed(bool touchstart_consumed);
-  void SetTouchEndConsumed(bool touchend_consumed);
-  bool IsTouchstartConsumed() const { return touchstart_consumed_; }
-  bool IsTouchendConsumed() const { return touchend_consumed_; }
-
-  void SetTouchEventsEnabled(bool enabled);
-  bool TouchEventsEnabled();
+  // RWHVAuraCommonHelperEfl overrides
+  void SetAuraParentWindow(gfx::NativeView parent_window) override {
+    aura_parent_window_ = parent_window;
+  }
+  void AuraChildWindowAdded() override;
+  void NotifySwap(const size_t texture_id) override;
+  void Show() override;
+  void Hide() override;
+  gfx::Size GetVisibleViewportSize() override;
+  gfx::Rect GetViewBounds() override;
+  gfx::Size GetPhysicalBackingSize() const override;
+  void HandleGestureBegin() override;
+  void HandleGestureEnd() override;
+  void HandleGesture(blink::WebGestureEvent& event) override;
+  void DidOverscroll(const ui::DidOverscrollParams& params) override;
+  void Focus(bool focus) override;
+  bool HasFocus() override;
+  void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) override;
 
+  void SetCustomViewportSize(const gfx::Size& size);
   bool GetHorizontalPanningHold() const { return horizontal_panning_hold_; }
   void SetHorizontalPanningHold(bool hold) { horizontal_panning_hold_ = hold; }
   bool GetVerticalPanningHold() const { return vertical_panning_hold_; }
   void SetVerticalPanningHold(bool hold) { vertical_panning_hold_ = hold; }
 
-  void DidChangeInputType(bool is_password_field);
-  void OnSelectionRectReceived(const gfx::Rect& selection_rect);
-
 #if BUILDFLAG(IS_TIZEN_TV)
   void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
   void ClearLabels();
@@ -102,25 +75,10 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   }
   int GetTopControlsHeight();
 
-  void DidOverscroll(const ui::DidOverscrollParams& params);
 #if BUILDFLAG(IS_TIZEN)
   void OnEdgeEffectForUIF(bool, bool, bool, bool);
 #endif
 
-  void Focus(bool focus);
-  bool HasFocus();
-  void SetPageVisibility(bool visible);
-  void TextInputStateChanged(const ui::mojom::TextInputState& params);
-  void FocusedNodeChanged(bool editable
-#if BUILDFLAG(IS_TIZEN_TV)
-                          ,
-                          bool is_radio_or_checkbox,
-                          int password_input_minlength,
-                          int input_maxlength
-#endif
-                          ,
-                          bool is_content_editable);
-
   // |snapshot_area| is relative coordinate system based on Webview.
   // (0,0) is top left corner.
   Evas_Object* GetSnapshot(const gfx::Rect& snapshot_area,
@@ -130,46 +88,21 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
                             Screenshot_Captured_Callback callback,
                             void* user_data,
                             float scale_factor = 1.0);
-  void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id);
 
-  RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
-  void OnGestureEvent(ui::GestureEvent* event);
   EdgeEffect& EnsureEdgeEffect();
   void UpdateEdgeEffect();
-  void HandleGestureBegin();
-  void HandleGestureEnd();
-  void SendGestureEvent(blink::WebGestureEvent& event);
-  void HandleGesture(blink::WebGestureEvent& event);
-  void OnMouseOrTouchEvent(ui::Event* event);
-  void DidHandleKeyEvent(blink::WebInputEvent::Type input_event_type,
-                         bool processed);
-  void SelectionChanged(const std::u16string& text,
-                        size_t offset,
-                        const gfx::Range& range);
-  SelectionControllerEfl* GetSelectionController() const {
-    return selection_controller_.get();
-  }
   void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
 
-  Evas_Object* ewk_view() const;
   Evas_Object* content_image() const { return content_image_; }
   Evas_Object* content_image_elm_host() const {
     return content_image_elm_host_;
   }
   gfx::Point ConvertPointInViewPix(gfx::Point point);
-  RenderWidgetHostImpl* GetRenderWidgetHostImpl();
-  gfx::NativeView GetNativeView();
-  WebContents* GetWebContents() { return web_contents_; }
 
   void SetFocusInOutCallbacks(const OnFocusCallback& on_focus_in,
                               const OnFocusCallback& on_focus_out);
-
-  bool IsFocusedNodeContentEditable() const { return is_content_editable_; }
-
   void MoveCaret(const gfx::Point& point);
   void SelectClosestWord(const gfx::Point& touch_point);
-  bool HasSelectableText();
-  void set_magnifier(bool status);
   void RequestMagnifierSnapshotAsync(const Eina_Rectangle rect,
                                      Screenshot_Captured_Callback callback,
                                      void* user_data,
@@ -187,7 +120,6 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   void Initialize();
   void InitializeProgram();
   void PaintTextureToSurface(GLuint texture_id);
-  void FocusRWHVA();
 
   void InitEvasGL();
   gfx::Size CreateNativeSurface();
@@ -204,9 +136,6 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
                             float scale_factor,
                             std::unique_ptr<ScreenshotCapturedCallback> cb);
 
-  ui::EflEventHandler* GetEventHandler();
-  ui::IMContextEfl* GetIMContextEfl();
-
   Evas* evas_ = nullptr;
   Evas_GL* evas_gl_ = nullptr;
   Evas_GL_API* evas_gl_api_ = nullptr;
@@ -228,7 +157,6 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   gfx::NativeView aura_parent_window_ = nullptr;
 
   int rotation_ = 0;
-  float device_scale_factor_ = 1.0f;
   gfx::SizeF scaled_contents_size_;
   gfx::Size custom_viewport_size_;
 
@@ -238,13 +166,6 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   int input_maxlength_ = DEFAULT_MAX_LENGTH;
   std::vector<Evas_Object*> voice_manager_labels_;
 #endif
-  bool is_focused_node_editable_ = false;
-  bool is_scrolling_needed_ = false;
-
-  ui::IMContextEfl* im_context_efl_ = nullptr;
-  RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
-  WebContents* web_contents_ = nullptr;
-  std::unique_ptr<SelectionControllerEfl> selection_controller_;
 
   std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
 
@@ -257,15 +178,9 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   bool horizontal_panning_hold_ = false;
   bool vertical_panning_hold_ = false;
 
-  bool magnifier_ = false;
-
-  bool touchstart_consumed_ = false;
-  bool touchend_consumed_ = false;
-
   OnFocusCallback on_focus_in_callback_;
   OnFocusCallback on_focus_out_callback_;
 
-  bool is_content_editable_ = false;
   std::unique_ptr<EdgeEffect> edge_effect_;
   // Magnifier snapshot requests are not added to snapshot_task_list_, because
   // we only care about the last one if they piled up - we can only display
index c5a5eed..bd69109 100644 (file)
@@ -40,7 +40,10 @@ bool SelectionBoxEfl::UpdateRectData(const gfx::Rect& left_rect, const gfx::Rect
   left_rect_ = left_rect;
   right_rect_ = right_rect;
 
-  //context params suppose to be global - related to evas not the web view
+  if (!rwhva_->offscreen_helper())
+    return ret;
+
+  // Context params suppose to be global - related to evas not the web view
   gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
   ret |= (context_params_->x != (left_rect_.x() + (view_bounds.x())));
   ret |= (context_params_->y != (left_rect_.y() + view_bounds.y()));
@@ -59,9 +62,11 @@ void SelectionBoxEfl::SetStatus(bool enable) {
   status_ = enable;
 
   // invoke CB only if mode actually changed
-  if (invoke_cb_at_end && rwhva_->offscreen_helper()->ewk_view())
+  if (invoke_cb_at_end && rwhva_->offscreen_helper() &&
+      rwhva_->offscreen_helper()->ewk_view()) {
     evas_object_smart_callback_call(rwhva_->offscreen_helper()->ewk_view(),
                                     "textselection,mode", &status_);
+  }
 }
 
 }
index 225550c..038f5ea 100644 (file)
@@ -64,7 +64,9 @@ gfx::Vector2dF ComputeLineOffsetFromBottom(const gfx::SelectionBound& bound) {
 }
 
 content::WebContents* SelectionControllerEfl::web_contents() const {
-  return rwhva_->offscreen_helper()->GetWebContents();
+  return rwhva_->offscreen_helper()
+      ? rwhva_->offscreen_helper()->GetWebContents()
+      : nullptr;
 }
 
 SelectionControllerEfl::SelectionControllerEfl(RenderWidgetHostViewAura* rwhva)
@@ -77,9 +79,11 @@ SelectionControllerEfl::SelectionControllerEfl(RenderWidgetHostViewAura* rwhva)
       input_handle_(
           new SelectionHandleEfl(*this, SelectionHandleEfl::HANDLE_TYPE_INPUT)),
       magnifier_(new SelectionMagnifierEfl(this)) {
-  evas_object_event_callback_add(rwhva_->offscreen_helper()->content_image(),
-                                 EVAS_CALLBACK_MOVE,
-                                 &EvasParentViewMoveCallback, this);
+  if (rwhva_->offscreen_helper()) {
+    evas_object_event_callback_add(rwhva_->offscreen_helper()->content_image(),
+                                   EVAS_CALLBACK_MOVE,
+                                   &EvasParentViewMoveCallback, this);
+  }
 #if BUILDFLAG(IS_TIZEN)
   vconf_notify_key_changed(VCONFKEY_LANGSET, PlatformLanguageChanged, this);
 #endif
@@ -92,9 +96,11 @@ SelectionControllerEfl::~SelectionControllerEfl() {
     ClearSelectionViaEWebView();
   HideHandleAndContextMenu();
 
-  evas_object_event_callback_del(rwhva_->offscreen_helper()->content_image(),
-                                 EVAS_CALLBACK_MOVE,
-                                 &EvasParentViewMoveCallback);
+  if (rwhva_->offscreen_helper()) {
+    evas_object_event_callback_del(rwhva_->offscreen_helper()->content_image(),
+                                   EVAS_CALLBACK_MOVE,
+                                   &EvasParentViewMoveCallback);
+  }
 }
 
 void SelectionControllerEfl::SetSelectionStatus(bool enable) {
@@ -208,7 +214,7 @@ void SelectionControllerEfl::OnSelectionChanged(
   // In case of the selected text contains only line break and no other
   // characters, we should use caret selection mode.
   if (GetSelectionEditable() && !handle_being_dragged_ && rwhva_ &&
-      rwhva_->GetSelectedText() == (u"\n")) {
+      rwhva_->GetSelectedText() == (u"\n") && rwhva_->offscreen_helper()) {
     rwhva_->offscreen_helper()->MoveCaret(
         selection_data_->GetLeftRect().origin());
     is_caret_mode_forced_ = true;
@@ -272,7 +278,8 @@ void SelectionControllerEfl::SetSelectionMode(enum SelectionMode mode) {
 }
 
 void SelectionControllerEfl::ToggleCaretAfterSelection() {
-  if (!GetCaretSelectionStatus() && GetSelectionEditable()) {
+  if (!GetCaretSelectionStatus() && GetSelectionEditable() &&
+      rwhva_->offscreen_helper()) {
     rwhva_->offscreen_helper()->MoveCaret(
         selection_data_->GetRightRect().origin());
     ClearSelection();
@@ -358,7 +365,8 @@ void SelectionControllerEfl::ShowHandleAndContextMenuIfRequired(
   // the visible part contains selection rects.
   auto visible_viewport_rect = GetVisibleViewportRect();
   if (!visible_viewport_rect.IsEmpty() ||
-      rwhva_->offscreen_helper()->GetTopControlsHeight() > 0) {
+      (rwhva_->offscreen_helper() &&
+       rwhva_->offscreen_helper()->GetTopControlsHeight() > 0)) {
     auto view_offset =
         rwhva_->offscreen_helper()->GetViewBoundsInPix().OffsetFromOrigin();
     is_start_selection_visible =
@@ -450,11 +458,13 @@ void SelectionControllerEfl::ShowContextMenu() {
   content::ContextMenuParams convertedParams =
       *(selection_data_->GetContextMenuParams());
 
-  int blinkX, blinkY;
-  rwhva_->offscreen_helper()->EvasToBlinkCords(
-      convertedParams.x, convertedParams.y, &blinkX, &blinkY);
-  convertedParams.x = blinkX;
-  convertedParams.y = blinkY;
+  if (rwhva_->offscreen_helper()) {
+    int blinkX, blinkY;
+    rwhva_->offscreen_helper()->EvasToBlinkCords(
+        convertedParams.x, convertedParams.y, &blinkX, &blinkY);
+    convertedParams.x = blinkX;
+    convertedParams.y = blinkY;
+  }
 
   // TODO(a1.gomes): In case of EWK apps, the call below end up calling
   // EWebView::ShowContextMenu. We have to make sure parameters
@@ -599,12 +609,15 @@ void SelectionControllerEfl::HandleDragUpdateNotification(SelectionHandleEfl* ha
     return;
 
   // FIXME : Check the text Direction later
-  gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
+  gfx::Rect view_bounds = rwhva_->offscreen_helper()
+      ? rwhva_->offscreen_helper()->GetViewBoundsInPix()
+      : gfx::Rect();
   selection_change_reason_ = Reason::HandleDragged;
 
   switch (handle->Type()) {
     case SelectionHandleEfl::HANDLE_TYPE_INPUT: {
-      rwhva_->offscreen_helper()->MoveCaret(handle->GetBasePosition());
+      if (rwhva_->offscreen_helper())
+        rwhva_->offscreen_helper()->MoveCaret(handle->GetBasePosition());
       return;
     }
     case SelectionHandleEfl::HANDLE_TYPE_LEFT:
@@ -694,7 +707,7 @@ void SelectionControllerEfl::HandlePostponedGesture(int x,
       web_contents()->GetRenderWidgetHostView());
 
   gfx::Point point = gfx::Point(x, y);
-  if (rwhva)
+  if (rwhva && rwhva_->offscreen_helper())
     point = rwhva->offscreen_helper()->ConvertPointInViewPix(point);
   switch (type) {
     case ui::ET_GESTURE_LONG_PRESS: {
@@ -722,7 +735,8 @@ bool SelectionControllerEfl::HandleLongPressEvent(
     // If one long press on an empty form, do not enter selection mode.
     // Instead, context menu will be shown if needed for clipboard actions.
     if (params.selection_text.empty() &&
-        !(rwhva_ && !rwhva_->offscreen_helper()->HasSelectableText()) &&
+        !(rwhva_ && rwhva_->offscreen_helper() &&
+          !rwhva_->offscreen_helper()->HasSelectableText()) &&
         !ClipboardHelperEfl::GetInstance()->CanPasteFromSystemClipboard()) {
       long_mouse_press_ = false;
       selection_change_reason_ = Reason::Irrelevant;
@@ -767,14 +781,16 @@ void SelectionControllerEfl::HandleLongPressEventPrivate(
     const gfx::Point& touch_point) {
   Clear();
 
-  gfx::Rect view_bounds = rwhva_->offscreen_helper()->GetViewBoundsInPix();
+  gfx::Rect view_bounds = rwhva_->offscreen_helper()
+      ? rwhva_->offscreen_helper()->GetViewBoundsInPix()
+      : gfx::Rect();
   magnifier_->HandleLongPress(gfx::Point(touch_point.x() + view_bounds.x(),
                                          touch_point.y() + view_bounds.y()),
                               selection_data_->IsInEditField());
 }
 
 void SelectionControllerEfl::HandleLongPressMoveEvent(const gfx::Point& touch_point) {
-  if (rwhva_)
+  if (rwhva_ && rwhva_->offscreen_helper())
     rwhva_->offscreen_helper()->SelectClosestWord(touch_point);
 }
 
@@ -900,6 +916,9 @@ gfx::Rect SelectionControllerEfl::GetForbiddenRegionRect(
 }
 
 gfx::Rect SelectionControllerEfl::GetVisibleViewportRect() const {
+  if (!rwhva_->offscreen_helper())
+    return gfx::Rect();
+
   if (custom_visible_view_rect_.IsEmpty())
     return rwhva_->offscreen_helper()->GetViewBoundsInPix();
 
index d095ff3..778b634 100644 (file)
@@ -43,6 +43,9 @@ SelectionHandleEfl::SelectionHandleEfl(SelectionControllerEfl& controller,
       pressed_(false),
       is_top_(false),
       handle_type_(type) {
+  if (!controller_.rwhva()->offscreen_helper())
+    return;
+
   Evas* evas = evas_object_evas_get(
       controller_.rwhva()->offscreen_helper()->content_image());
   handle_ = edje_object_add(evas);
@@ -208,6 +211,9 @@ SelectionHandleEfl::HandleDirection SelectionHandleEfl::CalculateDirection(
 }
 
 void SelectionHandleEfl::ChangeObjectDirection(HandleDirection direction) {
+  if (!controller_.rwhva()->offscreen_helper())
+    return;
+
   TRACE_EVENT2("selection,efl", __PRETTY_FUNCTION__,
                "handle type", handle_type_, "direction", direction);
 
@@ -276,6 +282,9 @@ gfx::Rect SelectionHandleEfl::GetSelectionRect() const {
 }
 
 void SelectionHandleEfl::MoveObject(const gfx::Point& point, bool ignore_parent_view_offset) {
+  if (!controller_.rwhva()->offscreen_helper())
+    return;
+
   gfx::Rect view_bounds =
       controller_.rwhva()->offscreen_helper()->GetViewBoundsInPix();
   int handle_x = point.x() + view_bounds.x();
index 3e863e6..45bdc60 100644 (file)
@@ -24,6 +24,9 @@ const float kZoomScale = 0.66;
 SelectionMagnifierEfl::SelectionMagnifierEfl(
     content::SelectionControllerEfl* controller)
     : controller_(controller), content_image_(0), shown_(false) {
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   base::FilePath edj_dir;
   base::FilePath magnifier_edj;
   base::PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
@@ -47,6 +50,9 @@ SelectionMagnifierEfl::~SelectionMagnifierEfl() {
 
 void SelectionMagnifierEfl::HandleLongPress(const gfx::Point& touch_point,
                                             bool is_in_edit_field) {
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   evas_object_event_callback_add(
       controller_->rwhva()->offscreen_helper()->content_image(),
       EVAS_CALLBACK_MOUSE_MOVE, OnAnimatorMove, this);
@@ -63,6 +69,9 @@ void SelectionMagnifierEfl::HandleLongPress(const gfx::Point& touch_point,
 }
 
 void SelectionMagnifierEfl::DisconnectCallbacks() {
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   evas_object_event_callback_del(
       controller_->rwhva()->offscreen_helper()->content_image(),
       EVAS_CALLBACK_MOUSE_MOVE, OnAnimatorMove);
@@ -83,6 +92,9 @@ void SelectionMagnifierEfl::OnAnimatorMove(void* data,
 }
 
 void SelectionMagnifierEfl::OnAnimatorMove() {
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   Evas_Coord_Point point;
   evas_pointer_canvas_xy_get(
       evas_object_evas_get(
@@ -181,8 +193,10 @@ void SelectionMagnifierEfl::UpdateLocation(const gfx::Point& location) {
   rect.w = content_rect.width();
   rect.h = content_rect.height();
 
-  controller_->rwhva()->offscreen_helper()->RequestMagnifierSnapshotAsync(
-      rect, MagnifierGetSnapshotCb, this);
+  if (controller_->rwhva()->offscreen_helper()) {
+    controller_->rwhva()->offscreen_helper()->RequestMagnifierSnapshotAsync(
+        rect, MagnifierGetSnapshotCb, this);
+  }
 }
 
 void SelectionMagnifierEfl::Move(const gfx::Point& location) {
@@ -223,6 +237,10 @@ void SelectionMagnifierEfl::Show() {
 
   shown_ = true;
   evas_object_show(container_);
+
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   controller_->rwhva()->offscreen_helper()->set_magnifier(true);
   if (controller_->rwhva()->offscreen_helper()->ewk_view()) {
     evas_object_smart_callback_call(
@@ -238,6 +256,10 @@ void SelectionMagnifierEfl::Hide() {
   shown_ = false;
   evas_object_hide(content_image_);
   evas_object_hide(container_);
+
+  if (!controller_->rwhva()->offscreen_helper())
+    return;
+
   controller_->rwhva()->offscreen_helper()->set_magnifier(false);
   if (controller_->rwhva()->offscreen_helper()->ewk_view()) {
     evas_object_smart_callback_call(
index 743a4c0..7032103 100644 (file)
@@ -48,10 +48,12 @@ class CONTENT_EXPORT RenderWidgetHostHelper {
   // API defined `SelectionControllerEfl`
   virtual bool ExistsSelectedText() = 0;
 
-  // APIs defined in `RenderWidgetHostViewAuraHelperEfl`
+  // APIs defined in `RWHVAuraCommonHelperEfl`
   virtual bool ImeHandleKeyEventEnabled() = 0;
   virtual gfx::Size GetPhysicalBackingSize() const = 0;
   virtual Evas_Object* EwkView() const = 0;
+
+  virtual bool IsOffscreenMode() const = 0;
 };
 
 }  // namespace content
index 1fb583b..3f6b6a7 100644 (file)
@@ -730,7 +730,7 @@ bool IMContextEfl::IsFocused() const {
 }
 
 bool IMContextEfl::WebViewWillBeResized() {
-  if (!context_ || !rwh_helper_)
+  if (!context_ || !rwh_helper_ || !rwh_helper_->IsOffscreenMode())
     return false;
 
   return IsVisible()
index 9829a8f..2b7103d 100644 (file)
@@ -367,6 +367,9 @@ gfx::RectF AutofillClientEfl::GetElementBoundsInScreen(
         display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
   }
 
+  if (!rwhva->offscreen_helper())
+    return element_bounds;
+
   gfx::Vector2d view_offset =
       gfx::ToEnclosingRect(
           gfx::ConvertRectToDips(
index cf71a9c..fd2eae8 100644 (file)
@@ -234,11 +234,11 @@ void WebContentsDelegateEfl::NavigationStateChanged(
     web_view_->ResetContextMenuController();
     auto rwhva = static_cast<RenderWidgetHostViewAura*>(
         web_contents_.GetRenderWidgetHostView());
-    if (rwhva) {
+    if (rwhva && rwhva->offscreen_helper() &&
+        rwhva->offscreen_helper()->GetSelectionController()) {
       auto selection_controller =
           rwhva->offscreen_helper()->GetSelectionController();
-      if (selection_controller)
-        selection_controller->ClearSelection();
+      selection_controller->ClearSelection();
     }
   }
 }
index f510534..e22fefa 100644 (file)
@@ -328,7 +328,7 @@ void WebContentsObserverEfl::OnEdgeEffectForUIF(bool top,
                                                 bool left) {
   auto* rwhva = static_cast<RenderWidgetHostViewAura*>(
       web_contents_.GetRenderWidgetHostView());
-  if (rwhva)
+  if (rwhva && rwhva->offscreen_helper())
     rwhva->offscreen_helper()->OnEdgeEffectForUIF(top, bottom, right, left);
 }
 #endif