From 3e410c3e782292ac22eaec82778610f860f72d4c Mon Sep 17 00:00:00 2001 From: Chandan Padhi Date: Wed, 1 Feb 2023 18:16:51 +0530 Subject: [PATCH] Implement WebViewObserver for EFL This commit 1. adds WebViewObserverEfl 2. removes upstream code changes related to RenderFrame(Impl|Observer) 3. removes EWK_BRINGUP for related code Change-Id: I39ec8e55378cb6936a5cefbcdb99e4a4d395c56a Signed-off-by: Chandan Padhi --- content/public/renderer/render_frame_observer.h | 3 -- content/renderer/render_frame_impl.cc | 7 ---- content/renderer/render_frame_impl.h | 3 -- .../blink/public/web/web_local_frame_client.h | 4 -- .../blink/renderer/core/exported/web_view_impl.cc | 5 --- tizen_src/ewk/efl_integration/BUILD.gn | 2 + .../renderer/content_renderer_client_efl.cc | 17 ++++----- .../renderer/content_renderer_client_efl.h | 13 ++++--- .../renderer/render_frame_observer_efl.cc | 25 ------------ .../renderer/render_frame_observer_efl.h | 3 -- .../renderer/web_view_observer_efl.cc | 44 ++++++++++++++++++++++ .../renderer/web_view_observer_efl.h | 28 ++++++++++++++ 12 files changed, 90 insertions(+), 64 deletions(-) create mode 100644 tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.cc create mode 100644 tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.h diff --git a/content/public/renderer/render_frame_observer.h b/content/public/renderer/render_frame_observer.h index 99e8ad2..0af40eb 100644 --- a/content/public/renderer/render_frame_observer.h +++ b/content/public/renderer/render_frame_observer.h @@ -125,9 +125,6 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, // being created occurs). virtual void DidCreateNewDocument() {} virtual void DidCreateDocumentElement() {} -#if BUILDFLAG(IS_EFL) - virtual void DidUpdateMainFrameLayout() {} -#endif // TODO(dgozman): replace next two methods with DidFinishNavigation. // DidCommitProvisionalLoad is only called for new-document navigations. // Use DidFinishSameDocumentNavigation for same-document navigations. diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index efba244..e8d27f6 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -3893,13 +3893,6 @@ void RenderFrameImpl::DidDispatchDOMContentLoadedEvent() { UpdateEncoding(frame_, frame_->View()->PageEncoding().Utf8()); } -#if BUILDFLAG(IS_EFL) -void RenderFrameImpl::DidUpdateMainFrameLayout() { - for (auto& observer : observers_) - observer.DidUpdateMainFrameLayout(); -} -#endif - void RenderFrameImpl::RunScriptsAtDocumentReady() { DCHECK(initialized_); GetContentClient()->renderer()->RunScriptsAtDocumentEnd(this); diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 8e056c3..0e1296d 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -540,9 +540,6 @@ class CONTENT_EXPORT RenderFrameImpl blink::WebDocumentLoader* document_loader) override; void DidClearWindowObject() override; void DidCreateDocumentElement() override; -#if BUILDFLAG(IS_EFL) - void DidUpdateMainFrameLayout() override; -#endif void RunScriptsAtDocumentElementAvailable() override; void DidReceiveTitle(const blink::WebString& title) override; void DidDispatchDOMContentLoadedEvent() override; diff --git a/third_party/blink/public/web/web_local_frame_client.h b/third_party/blink/public/web/web_local_frame_client.h index 05ddf22..149ca59 100644 --- a/third_party/blink/public/web/web_local_frame_client.h +++ b/third_party/blink/public/web/web_local_frame_client.h @@ -377,10 +377,6 @@ class BLINK_EXPORT WebLocalFrameClient { // This method may not invalidate the frame, nor execute JavaScript code. virtual void DidCreateDocumentElement() {} -#if BUILDFLAG(IS_EFL) - virtual void DidUpdateMainFrameLayout() {} -#endif - // Like |didCreateDocumentElement|, except this method may run JavaScript // code (and possibly invalidate the frame). virtual void RunScriptsAtDocumentElementAvailable() {} diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index 4a19946..5fc7eb1 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -3566,11 +3566,6 @@ void WebViewImpl::MainFrameLayoutUpdated() { if (!web_view_client_) return; -#if BUILDFLAG(IS_EFL) - if (MainFrameImpl() && MainFrameImpl()->Client()) - MainFrameImpl()->Client()->DidUpdateMainFrameLayout(); -#endif - for (auto& observer : observers_) observer.DidUpdateMainFrameLayout(); needs_preferred_size_update_ = true; diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index 56e33c0..768c872 100755 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -578,6 +578,8 @@ shared_library("chromium-ewk") { "renderer/render_thread_observer_efl.h", "renderer/tizen_extensible.cc", "renderer/tizen_extensible.h", + "renderer/web_view_observer_efl.cc", + "renderer/web_view_observer_efl.h", "web_contents_observer_efl.cc", "web_contents_observer_efl.h", "wrt/dynamicplugin.cc", diff --git a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc index aebd674..a4cfaae 100644 --- a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc +++ b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc @@ -29,6 +29,7 @@ #include "renderer/gin_native_bridge_dispatcher.h" #include "renderer/plugins/plugin_placeholder_efl.h" #include "renderer/render_frame_observer_efl.h" +#include "renderer/web_view_observer_efl.h" #include "third_party/blink/public/platform/url_conversion.h" #include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/public/platform/web_url_request_extra_data.h" @@ -170,21 +171,19 @@ void ContentRendererClientEfl::RenderFrameCreated(content::RenderFrame* render_f #endif } -#if !defined(EWK_BRINGUP) // FIXME: m108 bringup -void ContentRendererClientEfl::RenderViewCreated(content::RenderView* render_view) { - ApplyCustomMobileSettings(render_view->GetWebView()); +void ContentRendererClientEfl::WebViewCreated( + blink::WebView* web_view, + bool was_created_by_renderer, + const url::Origin* outermost_origin) { + ApplyCustomMobileSettings(web_view); + + new WebViewObserverEfl(web_view); #if !defined(EWK_BRINGUP) // FIXME: m94 bringup - // Deletes itself when render_view is destroyed. - new RenderViewObserverEfl(render_view, this); new editing::EditorClientAgent(render_view); -#endif - -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup render_view->SetWrtUrlParser(wrt_url_parser_.get()); #endif } -#endif bool ContentRendererClientEfl::OverrideCreatePlugin( content::RenderFrame* render_frame, diff --git a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h index 16c8c7d..3d5a537 100644 --- a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h +++ b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h @@ -31,14 +31,17 @@ class WrtUrlParseImpl; class ContentRendererClientEfl : public content::ContentRendererClient { public: ContentRendererClientEfl(); + + ContentRendererClientEfl(const ContentRendererClientEfl&) = delete; + ContentRendererClientEfl& operator=(const ContentRendererClientEfl&) = delete; + ~ContentRendererClientEfl() override; void RenderThreadStarted() override; - void RenderFrameCreated(content::RenderFrame* render_frame) override; -#if !defined(EWK_BRINGUP) // FIXME: m108 bringup - void RenderViewCreated(content::RenderView* render_view); -#endif + void WebViewCreated(blink::WebView* web_view, + bool was_created_by_renderer, + const url::Origin* outermost_origin) override; bool OverrideCreatePlugin( content::RenderFrame* render_frame, const blink::WebPluginParams& params, @@ -107,4 +110,4 @@ class ContentRendererClientEfl : public content::ContentRendererClient { bool shutting_down_ = false; }; -#endif +#endif // CONTENT_RENDERER_CLIENT_EFL_H diff --git a/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.cc b/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.cc index 860b3b6..4c79681 100644 --- a/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.cc +++ b/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.cc @@ -202,31 +202,6 @@ void RenderFrameObserverEfl::DidChangeScrollOffset() { #endif } -void RenderFrameObserverEfl::DidUpdateMainFrameLayout() { - blink::WebView* view = render_frame()->GetWebView(); - if (!view || !view->MainFrame() || !view->MainFrame()->IsWebLocalFrame()) - return; - - gfx::Size contents_size = - view->MainFrame()->ToWebLocalFrame()->DocumentSize(); - - // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a - // 0x0 size (this happens during initial load). - if (contents_size.IsEmpty()) { - contents_size = render_frame() - ->GetWebView() - ->ContentsPreferredMinimumSize(); - } - - if (contents_size == last_sent_contents_size_) - return; - - last_sent_contents_size_ = contents_size; - Send(new EwkHostMsg_DidChangeContentsSize(render_frame()->GetRoutingID(), - contents_size.width(), - contents_size.height())); -} - void RenderFrameObserverEfl::WillSubmitForm( const blink::WebFormElement& form) { GURL url(blink::WebStringToGURL(form.Action())); diff --git a/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.h b/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.h index 6a4c564..d9cb6b9 100644 --- a/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.h +++ b/tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.h @@ -52,8 +52,6 @@ class RenderFrameObserverEfl : public RenderFrameObserver { int world_id) override; void WillReleaseScriptContext(v8::Handle context, int world_id) override; - void DidUpdateMainFrameLayout() override; - void DidCreateDocumentElement() override; private: @@ -67,7 +65,6 @@ class RenderFrameObserverEfl : public RenderFrameObserver { gfx::Size max_scroll_offset_; gfx::Size last_scroll_offset_; - gfx::Size last_sent_contents_size_; service_manager::BinderRegistry registry_; blink::AssociatedInterfaceRegistry associated_interfaces_; }; diff --git a/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.cc b/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.cc new file mode 100644 index 0000000..ef54c77 --- /dev/null +++ b/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.cc @@ -0,0 +1,44 @@ +// Copyright 2022 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "renderer/web_view_observer_efl.h" + +#include "common/render_messages_ewk.h" +#include "content/public/renderer/render_frame.h" +#include "third_party/blink/public/web/web_local_frame.h" +#include "third_party/blink/public/web/web_view.h" + +WebViewObserverEfl::WebViewObserverEfl(blink::WebView* web_view) + : blink::WebViewObserver(web_view) {} + +WebViewObserverEfl::~WebViewObserverEfl() = default; + +void WebViewObserverEfl::OnDestruct() { + delete this; +} + +void WebViewObserverEfl::DidUpdateMainFrameLayout() { + blink::WebView* webview = GetWebView(); + blink::WebFrame* main_frame = webview->MainFrame(); + if (!main_frame || !main_frame->IsWebLocalFrame()) + return; + + gfx::Size contents_size = main_frame->ToWebLocalFrame()->DocumentSize(); + + // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a + // 0x0 size (this happens during initial load). + if (contents_size.IsEmpty()) + contents_size = GetWebView()->ContentsPreferredMinimumSize(); + + if (contents_size == last_sent_contents_size_) + return; + + last_sent_contents_size_ = contents_size; + + content::RenderFrame* render_frame = + content::RenderFrame::FromWebFrame(main_frame->ToWebLocalFrame()); + render_frame->Send(new EwkHostMsg_DidChangeContentsSize( + render_frame->GetRoutingID(), contents_size.width(), + contents_size.height())); +} diff --git a/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.h b/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.h new file mode 100644 index 0000000..4f28022 --- /dev/null +++ b/tizen_src/ewk/efl_integration/renderer/web_view_observer_efl.h @@ -0,0 +1,28 @@ +// Copyright 2022 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEB_VIEW_OBSERVER_EFL_H_ +#define WEB_VIEW_OBSERVER_EFL_H_ + +#include "third_party/blink/public/web/web_view_observer.h" +#include "ui/gfx/geometry/size.h" + +class WebViewObserverEfl : public blink::WebViewObserver { + public: + WebViewObserverEfl(blink::WebView* web_view); + + WebViewObserverEfl(const WebViewObserverEfl&) = delete; + WebViewObserverEfl& operator=(const WebViewObserverEfl&) = delete; + + // blink::WebViewObserver implementation. + void OnDestruct() override; + void DidUpdateMainFrameLayout() override; + + private: + ~WebViewObserverEfl() override; + + gfx::Size last_sent_contents_size_; +}; + +#endif // WEB_VIEW_OBSERVER_EFL_H_ -- 2.7.4