From efaf9a40326d19dbac0b7651d88e8f029a44cf8c Mon Sep 17 00:00:00 2001 From: z30052106 Date: Thu, 26 Oct 2023 07:49:24 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=84=9F=E7=9F=A5w3c=20virtu?= =?UTF-8?q?alkeyboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z30052106 --- content/browser/renderer_host/page_impl.cc | 7 +++++++ content/browser/renderer_host/page_impl.h | 4 +++- ohos_nweb/include/nweb.h | 10 ++++++++++ ohos_nweb/src/cef_delegate/nweb_delegate.cc | 13 +++++++++++++ ohos_nweb/src/cef_delegate/nweb_delegate.h | 4 ++++ ohos_nweb/src/nweb_delegate_interface.h | 2 ++ ohos_nweb/src/nweb_impl.cc | 16 ++++++++++++++++ ohos_nweb/src/nweb_impl.h | 2 ++ 8 files changed, 57 insertions(+), 1 deletion(-) diff --git a/content/browser/renderer_host/page_impl.cc b/content/browser/renderer_host/page_impl.cc index fc4c3a4a85..257bceae60 100644 --- a/content/browser/renderer_host/page_impl.cc +++ b/content/browser/renderer_host/page_impl.cc @@ -258,4 +258,11 @@ void PageImpl::UpdateEncoding(const std::string& encoding_name) { base::GetCanonicalEncodingNameByAliasName(encoding_name); } +#if BUILDFLAG(IS_OHOS) +void PageImpl::NotifyVirtualKeyboardOverlayRect( + const gfx::Rect& keyboard_rect){ + GetMainDocument().GetAssociatedLocalFrame()->NotifyVirtualKeyboardOverlayRect( + keyboard_rect); +} +#endif } // namespace content diff --git a/content/browser/renderer_host/page_impl.h b/content/browser/renderer_host/page_impl.h index 6e145db0d2..8a444c9670 100644 --- a/content/browser/renderer_host/page_impl.h +++ b/content/browser/renderer_host/page_impl.h @@ -47,7 +47,9 @@ class CONTENT_EXPORT PageImpl : public Page { void WriteIntoTrace(perfetto::TracedValue context) override; base::WeakPtr GetWeakPtr() override; bool IsPageScaleFactorOne() override; - +#if BUILDFLAG(IS_OHOS) + void NotifyVirtualKeyboardOverlayRect(const gfx::Rect& keyboard_rect); +#endif void UpdateManifestUrl(const GURL& manifest_url); RenderFrameHostImpl& GetMainDocument() const; diff --git a/ohos_nweb/include/nweb.h b/ohos_nweb/include/nweb.h index 83a11aade2..1dec8c978e 100644 --- a/ohos_nweb/include/nweb.h +++ b/ohos_nweb/include/nweb.h @@ -782,6 +782,16 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { * Set enable lower the frame rate. */ virtual void SetEnableLowerFrameRate(bool enabled) const = 0; + + /** + * Set the property values for width, height, and keyboard height. + */ + virtual void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) = 0; + + /** + * Set the virtual keyboard to override the web status. + */ + virtual bool ShouldVirtualKeyboardOverlay() = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 0c0bbce229..f409fbd377 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -1889,6 +1889,19 @@ void NWebDelegate::SetShouldFrameSubmissionBeforeDraw(bool should) { } } +void NWebDelegate::SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) { + if (GetBrowser().get()) { + GetBrowser()->GetHost()->SetVirtualKeyBoardArg(width, height, keyboard); + } +} + +bool NWebDelegate::ShouldVirtualKeyboardOverlay() { + if (GetBrowser().get()) { + return GetBrowser()->GetHost()->ShouldVirtualKeyboardOverlay(); + } + return false; +} + void NWebDelegate::SetAudioResumeInterval(int32_t resumeInterval) { if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { LOG(ERROR) << "SetAudioResumeInterval can not get browser"; diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.h b/ohos_nweb/src/cef_delegate/nweb_delegate.h index 5346e2ea80..0796aa5534 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -212,6 +212,10 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void PrefetchPage( std::string& url, std::map additionalHttpHeaders) override; + void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; + bool ShouldVirtualKeyboardOverlay() override; + + #if defined (OHOS_NWEB_EX) void SetForceEnableZoom(bool forceEnableZoom) override; bool GetForceEnableZoom() override; diff --git a/ohos_nweb/src/nweb_delegate_interface.h b/ohos_nweb/src/nweb_delegate_interface.h index f77ac2981e..a181153eff 100644 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -237,6 +237,8 @@ class NWebDelegateInterface virtual void NotifyPopupWindowResult(bool result) = 0; virtual void SetWindowId(uint32_t window_id); virtual void SetToken(void* token) = 0; + virtual void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) = 0; + virtual bool ShouldVirtualKeyboardOverlay() = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 8b7e84d644..b2cc2a4e80 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -713,6 +713,22 @@ void NWebImpl::SetToken(void* token) { nweb_delegate_->SetToken(token); } +void NWebImpl::SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) { + if (nweb_delegate_ == nullptr) { + WVLOG_E("SetVirtualKeyBoardArg nweb delegate is null"); + return; + } + nweb_delegate_->SetVirtualKeyBoardArg(width, height, keyboard); +} + +bool NWebImpl::ShouldVirtualKeyboardOverlay() { + if (nweb_delegate_ == nullptr) { + WVLOG_E("ShouldVirtualKeyboardOverlay nweb delegate is null"); + return false; + } + return nweb_delegate_->ShouldVirtualKeyboardOverlay(); +} + void NWebImpl::SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) {} const std::shared_ptr NWebImpl::GetPreference() const { diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index f370a4c1aa..e90641b978 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -164,6 +164,8 @@ class NWebImpl : public NWeb { void SetWindowId(uint32_t window_id) override; void SetToken(void* token) override; void SetNestedScrollMode(const NestedScrollMode& nestedScrollMode) override; + void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; + bool ShouldVirtualKeyboardOverlay() override; // For NWebEx static NWebImpl* FromID(int32_t nweb_id); -- Gitee