[NextBrowser] Added conformant feature 14/322914/3
authorTarun Verma <tarun1.verma@samsung.com>
Thu, 17 Apr 2025 14:01:28 +0000 (19:31 +0530)
committerTarun Verma <tarun1.verma@samsung.com>
Mon, 21 Apr 2025 11:29:48 +0000 (16:59 +0530)
Change-Id: Ib98eb12292aa02fb0278cadaf75b1fb8cb18efbd
Signed-off-by: Tarun Verma <tarun1.verma@samsung.com>
chrome/browser/ui/samsung/input_manager.cc
chrome/browser/ui/samsung/input_manager.h
chrome/browser/ui/samsung/samsung_web_contents_controller.cc
chrome/browser/ui/samsung/samsung_web_contents_controller.h
components/samsung/input_provider/input_provider_impl.cc
components/samsung/input_provider/input_provider_impl.h
components/samsung/public/input_provider/input_provider.cc
components/samsung/public/input_provider/input_provider.h
tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc
tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc

index 03e370b86b439e8e9200a15e28cef3c85b6655ec..4fc75b869d34e3f1747117eeda2ee51869be5152 100644 (file)
@@ -104,4 +104,11 @@ void InputManager::BrowserWindowFocusOut() {
   }
 }
 
+void InputManager::OverlayBoundsChanged(gfx::Rect bounds) {
+  LOG(INFO) << "new bounds: " << bounds.ToString();
+  for (auto& observer : m_observer_list) {
+    observer.OverlayBoundsChanged(bounds);
+  }
+}
+
 }  // namespace samsung_input_manager
index 1e11ce4d340f35a7dc4c3cbf53d545edf2efd3c1..39c83062cd54b7e059caeb7b951c45c91263802e 100644 (file)
@@ -4,6 +4,7 @@
 #include "base/observer_list.h"
 #include "base/scoped_observation.h"
 #include "components/samsung/public/input_provider/input_provider.h"
+#include "ui/gfx/geometry/rect.h"
 
 namespace samsung_input_manager {
 
@@ -34,6 +35,7 @@ class InputManager : public samsung_browser_main::InputProvider::Observer {
                              int y){};
     virtual void BrowserWindowFocusIn(){};
     virtual void BrowserWindowFocusOut(){};
+    virtual void OverlayBoundsChanged(gfx::Rect bounds){};
   };
 
   void Init();
@@ -56,6 +58,7 @@ class InputManager : public samsung_browser_main::InputProvider::Observer {
                    int y) override;
   void BrowserWindowFocusIn() override;
   void BrowserWindowFocusOut() override;
+  void OverlayBoundsChanged(gfx::Rect bounds) override;
 
  private:
   base::ObserverList<Observer>::Unchecked m_observer_list;
index 8de7deaf5f00daada01eba9d8558f6ee13fe9f93..bc115c947cc7b2f13b6fdede2e71f2e2b590779b 100644 (file)
@@ -9,6 +9,7 @@
 #include "components/samsung/public/samsung_config_key.h"
 #include "content/browser/renderer_host/render_view_host_impl.h"
 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "content/public/browser/render_view_host.h"
 
 namespace samsung_browser_controller {
 
@@ -26,6 +27,10 @@ void SamsungWebContentsController::Init() {
       this);
   samsung_browser_main::SamsungBrowserCore::instance()
       ->AddLowMemoryStateObserver(this);
+  auto input_manager =
+      samsung_browser_main::SamsungBrowserCore::instance()->InputManager();
+  input_manager->AddObserver(this);
+
   Browser* browser_ = samsung_browser_main::SamsungBrowserCore::instance()
                           ->GetBrowserInstance();
   if (browser_ == nullptr) {
@@ -76,6 +81,9 @@ void SamsungWebContentsController::DeInit() {
   }
 
   tab_strip_model->RemoveObserver(this);
+  auto input_manager =
+      samsung_browser_main::SamsungBrowserCore::instance()->InputManager();
+  input_manager->RemoveObserver(this);
 }
 
 void SamsungWebContentsController::ReInit() {
@@ -405,4 +413,41 @@ void SamsungWebContentsController::OnTabStripModelChanged(
   }
 }
 
+void SamsungWebContentsController::OverlayBoundsChanged(gfx::Rect bounds) {
+  Browser* browser = samsung_browser_main::SamsungBrowserCore::instance()
+                         ->GetBrowserInstance();
+  LOG(INFO) << " bounds : " << bounds.ToString();
+  if (!browser || !browser->tab_strip_model()) {
+    LOG(INFO) << "Either browser or tab_strip mode is NULL";
+    return;
+  }
+
+  auto web_content = browser->tab_strip_model()->GetActiveWebContents();
+  if (!web_content) {
+    LOG(INFO) << " webview is null";
+    return;
+  }
+
+  if (content::RenderViewHost* render_view_host =
+          web_content->GetRenderViewHost()) {
+    if (auto& broadcast =
+            static_cast<content::RenderViewHostImpl*>(render_view_host)
+                ->GetAssociatedPageBroadcast()) {
+      LOG(INFO) << "scrolling into view port";
+      broadcast->ScrollFocusedNodeIntoView();
+    }
+  }
+  int ui_height =
+      85;  // Need to inveestigate how to get this height from chrome layer.
+  gfx::Rect newBounds = bounds;
+  newBounds.set_height(newBounds.height() - ui_height);
+  gfx::Rect currentBounds = web_content->GetNativeView()->bounds();
+  LOG(INFO) << "newBounds: " << newBounds.ToString();
+  LOG(INFO) << "currentBounds: " << currentBounds.ToString();
+  if (currentBounds == newBounds) {
+    LOG(INFO) << "webview already in right size";
+  }
+  web_content->GetNativeView()->SetBounds(newBounds);
+}
+
 }  // namespace samsung_browser_controller
index cc896cbd2d0b1f1794fb806ea7c3c694510c7954..ab17c463bb8be2552556417c0d9302c36e647802 100644 (file)
@@ -2,6 +2,7 @@
 #define CHROME_BROWSER_UI_SAMSUNG_WEB_CONTENTS_CONTROLLER_H_
 
 #include "base/logging.h"
+#include "chrome/browser/ui/samsung/input_manager.h"
 #include "chrome/browser/ui/samsung/samsung_browser_core.h"
 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
 #include "content/public/browser/web_contents.h"
@@ -11,6 +12,7 @@ namespace samsung_browser_controller {
 class SamsungWebContentsController
     : public samsung_browser_main::SamsungBrowserCore::BrowserStateObserver,
       public samsung_browser_main::SamsungBrowserCore::LowMemoryStateObserver,
+      public samsung_input_manager::InputManager::Observer,
       public TabStripModelObserver {
  public:
   explicit SamsungWebContentsController();
@@ -41,6 +43,8 @@ class SamsungWebContentsController
       const TabStripModelChange& change,
       const TabStripSelectionChange& selection) override;
 
+  void OverlayBoundsChanged(gfx::Rect bounds) override;
+
  private:
   int max_num_undiscarded_webviews_;
   int max_tabs_;
index f898ed2788ac4bca643144978b2026b86da500ce..a0164647ccd70319d05665ea842dccdbd45c4453 100644 (file)
@@ -3,6 +3,7 @@
 #include "base/logging.h"
 #include "components/samsung/public/input_provider/input_provider.h"
 #include "tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.h"
+#include "ui/gfx/geometry/rect.h"
 
 namespace samsung_browser_main {
 
@@ -15,7 +16,7 @@ InputProviderImpl::InputProviderImpl(InputProvider* input_provider)
       m_ecoreEventHandlerMouseUp(nullptr),
       input_provider_(input_provider),
       evas_window_(nullptr),
-      win_obj_(nullptr) {}
+      overlay_obj_(nullptr) {}
 
 InputProviderImpl::~InputProviderImpl() {
   DeInit();
@@ -77,6 +78,26 @@ void InputProviderImpl::UnregisterMouseEvents() {
   }
 }
 
+void InputProviderImpl::OverlayResized(void* data,
+                                       Evas* e,
+                                       Evas_Object* obj,
+                                       void* event_info) {
+  int x = 0, y = 0, w = 0, h = 0;
+  evas_object_geometry_get(obj, &x, &y, &w, &h);
+  LOG(INFO) << " Size of overlay: x[" << x << "] y[" << y << "] w[" << w
+            << "] h[" << h << "];";
+  if (h == 1079 || h == 0) {
+    LOG(INFO) << "Invalid overlay dimensions";
+    return;
+  }
+
+  InputProviderImpl* self = static_cast<InputProviderImpl*>(data);
+  gfx::Rect overlayBounds(x, y, w, h);
+  if (self) {
+    self->input_provider_->OverlayBoundsChanged(overlayBounds);
+  }
+}
+
 void InputProviderImpl::SetWindow(aura::WindowTreeHost* window_host) {
   LOG(INFO) << "";
   ui::EflWindow* window = static_cast<ui::EflWindow*>(
@@ -85,8 +106,10 @@ void InputProviderImpl::SetWindow(aura::WindowTreeHost* window_host) {
   LOG(INFO) << "Got EFL Window";
   if (window) {
     evas_window_ = window->evas();
-    win_obj_ = window->native_view();
-    // RegisterCanvasEvents();
+    overlay_obj_ = window->native_view();  // For details about overlay check
+                                           // EflWindow::CreateOverlay()
+    evas_object_event_callback_add(overlay_obj_, EVAS_CALLBACK_RESIZE,
+                                   OverlayResized, this);
   }
   if (evas_window_) {
     LOG(INFO) << "Success";
index 36abe3aa645d40e345e1d88063f35758442e590f..ab22aef94f54e4ad5adfae9a354644bde902de6d 100644 (file)
@@ -42,6 +42,11 @@ class InputProviderImpl {
   static void callbackWindowFocusIn(void* data, Evas* pEvas, void* eventInfo);
   static void callbackWindowFocusOut(void* data, Evas* pEvas, void* eventInfo);
 
+  static void OverlayResized(void* data,
+                             Evas* e,
+                             Evas_Object* obj,
+                             void* event_info);
+
   Ecore_Event_Filter* m_filter;
   Ecore_Event_Handler* m_ecoreEventHandlerMouseIn;
   Ecore_Event_Handler* m_ecoreEventHandlerMouseOut;
@@ -51,7 +56,7 @@ class InputProviderImpl {
 
   const raw_ptr<InputProvider> input_provider_;
   Evas* evas_window_;
-  Evas_Object* win_obj_;
+  Evas_Object* overlay_obj_;
 };
 }  // namespace samsung_browser_main
 #endif  // COMPONENTS_SAMSUNG_INPUT_PROVIDER_INPUT_PROVIDER_IMPL_H_
index 9b49c9c54719b394cbb43031b38548875840abfb..c417938eaec132d586f3acf6244406485bd3be92 100644 (file)
@@ -138,6 +138,13 @@ void InputProvider::BrowserWindowFocusOut() {
   NotifyBrowserWindowFocusOut();
 }
 
+void InputProvider::OverlayBoundsChanged(gfx::Rect bounds) {
+  for (auto& observer : m_observer_list) {
+    LOG(INFO) << "new bounds" << bounds.ToString();
+    observer.OverlayBoundsChanged(bounds);
+  }
+}
+
 void InputProvider::NotifyBrowserWindowFocusOut() {
   for (auto& observer : m_observer_list) {
     observer.BrowserWindowFocusOut();
index f367cee6c2521eee3aa179219df841c200d60fba..c93a5ec96585b223950eaad7fd5eb8f8c01c9387 100644 (file)
@@ -5,6 +5,7 @@
 #include "base/scoped_observation.h"
 #include "components/samsung/public/samsung_browser_enums.h"
 #include "ui/aura/window_tree_host_platform.h"
+#include "ui/gfx/geometry/rect.h"
 
 namespace samsung_browser_main {
 
@@ -37,11 +38,11 @@ class InputProvider {
     virtual void MouseButton(KeyEventType keyType, int button, int x, int y){};
     virtual void BrowserWindowFocusIn(){};
     virtual void BrowserWindowFocusOut(){};
+    virtual void OverlayBoundsChanged(gfx::Rect bounds){};
   };
 
   void AddObserver(Observer* observer);
   void RemoveObserver(Observer* observer);
-
   void SetWindow(aura::WindowTreeHost* window_host);
 
   bool CallbackFilter(std::string key,
@@ -56,6 +57,7 @@ class InputProvider {
   void MouseUp(int button, int x, int y);
   void BrowserWindowFocusIn();
   void BrowserWindowFocusOut();
+  void OverlayBoundsChanged(gfx::Rect bounds);
 
  private:
   bool NotifyCallbackFilter(std::string key,
index 40623a8bc0454cf462a53de6b40f79b730067cf2..01ee70652c91f07d83b86d534e12c6832749a52a 100644 (file)
@@ -445,7 +445,9 @@ void EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
   // Evas engine creates it's own egl window and egl surface to render.
   // Eventually additional GEM memory is created for rendering. Enable evas
   // manual rendering to prevent this symptom.
+#if !defined(SAMSUNG_NEXT_BROWSER)
   ecore_evas_manual_render_set(ee_, EINA_TRUE);
+#endif
 
 #if defined(USE_WAYLAND)
   wl_window_ = ecore_evas_wayland2_window_get(ee_);
@@ -554,6 +556,15 @@ void EflWindow::Initialize(const PlatformWindowInitProperties& properties) {
 }
 
 Evas_Object* EflWindow::CreateOverlay() {
+#if defined(SAMSUNG_NEXT_BROWSER)
+  elm_win_conformant_set(elm_win_, EINA_TRUE);
+  Evas_Object* conformant = elm_conformant_add(elm_win_);
+  evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND,
+                                   EVAS_HINT_EXPAND);
+  elm_win_resize_object_add(elm_win_, conformant);
+
+  evas_object_show(conformant);
+#endif
   Evas_Object* layout = elm_layout_add(elm_win_);
 
   base::FilePath edj_dir, main_edj;
@@ -572,6 +583,9 @@ Evas_Object* EflWindow::CreateOverlay() {
   Evas_Object* overlay = elm_bg_add(layout);
   elm_object_part_content_set(layout, "content", overlay);
   evas_object_geometry_set(overlay, 0, 0, bounds_.width(), bounds_.height());
+#if defined(SAMSUNG_NEXT_BROWSER)
+  elm_object_content_set(conformant, overlay);
+#endif
   return overlay;
 }
 
index 0ec043537fad70850a700e7fa9c2b3ae99d30e66..e99b3685eba3232dd44ab0557c43bd2096d809c9 100644 (file)
@@ -328,11 +328,13 @@ void IMContextEfl::UpdateInputMethodType(TextInputType type,
   if (ime_style_ == ImeStyle::IME_STYLE_FLOATING) {
     LOG(INFO) << "set floating_ui";
     im_data.append("&action=floating_ui");
-  } else if (ime_style_ == ImeStyle::IME_STYLE_DYNAMIC) {
+  }
+#if !defined(SAMSUNG_NEXT_BROWSER)
+  else if (ime_style_ == ImeStyle::IME_STYLE_DYNAMIC) {
     LOG(INFO) << "set dynamic_ui";
     im_data.append("&action=dynamic_ui");
   }
-
+#endif
   ecore_imf_context_input_panel_imdata_set(context_, im_data.c_str(),
                                            im_data.length());